OSDN Git Service

c8553a66b180d7fcf4a03bd9d9975c52a7b493fb
[neighbornote/NeighborNote.git] / src / cx / fbn / nevernote / gui / SearchPanel.java
1 package cx.fbn.nevernote.gui;\r
2 \r
3 import com.trolltech.qt.gui.QComboBox;\r
4 import com.trolltech.qt.gui.QHBoxLayout;\r
5 import com.trolltech.qt.gui.QLabel;\r
6 import com.trolltech.qt.gui.QSpinBox;\r
7 import com.trolltech.qt.gui.QVBoxLayout;\r
8 import com.trolltech.qt.gui.QWidget;\r
9 \r
10 import cx.fbn.nevernote.gui.controls.QuotaProgressBar;\r
11 \r
12 public class SearchPanel extends QWidget {\r
13         private final QLabel zoomLabel;\r
14         private final QSpinBox zoomSpinner;\r
15         private final NotebookTreeWidget notebook;\r
16         private final QComboBox search;\r
17         private final QuotaProgressBar bar;\r
18         \r
19         public SearchPanel(QComboBox search, QuotaProgressBar bar, NotebookTreeWidget notebook, QSpinBox zoom) {\r
20                 QVBoxLayout mainLayout = new QVBoxLayout();\r
21                 QVBoxLayout subLayout = new QVBoxLayout();\r
22                 zoomSpinner = zoom;\r
23                 this.bar = bar;\r
24                 this.search = search;\r
25                 this.notebook = notebook;\r
26                 \r
27                 setLayout(mainLayout);\r
28                 subLayout.addWidget(search);\r
29                 subLayout.addWidget(bar);\r
30                 QHBoxLayout zoomLayout = new QHBoxLayout();\r
31                 zoomLabel = new QLabel(tr("Zoom:"));\r
32                 zoomLayout.addWidget(zoomLabel);\r
33                 zoomLayout.addWidget(zoom);\r
34                 zoomLayout.setStretch(1, 100);\r
35                 subLayout.addLayout(zoomLayout);\r
36                 mainLayout.addLayout(subLayout);\r
37                 mainLayout.addWidget(notebook);\r
38                 //setStyleSheet("QTreeView {border: 0.0em;}");\r
39                 mainLayout.setContentsMargins(0, 0, 0, 0);\r
40         }\r
41         \r
42         public void hideZoom() {\r
43                 zoomLabel.hide();\r
44                 zoomSpinner.hide();\r
45         }\r
46         public void showZoom() {\r
47                 zoomLabel.show();\r
48                 zoomSpinner.show();\r
49         }\r
50         \r
51         public void toggleNotebook() {\r
52                 show();\r
53                 if (notebook.isVisible())\r
54                         notebook.hide();\r
55                 else\r
56                         notebook.show();\r
57                 \r
58                 checkVisibility();\r
59         }\r
60         \r
61         public void toggleSearchField() {\r
62                 show();\r
63                 if (search.isVisible())\r
64                         search.hide();\r
65                 else\r
66                         search.show();\r
67                 checkVisibility();\r
68         }\r
69         \r
70         private void checkVisibility() {\r
71                 if (notebook.isHidden() && bar.isHidden() && search.isHidden() && zoomSpinner.isHidden()) {\r
72                         hide();\r
73                 }\r
74         }\r
75         \r
76         public void toggleQuotaBar() {\r
77                 show();\r
78                 if (bar.isVisible())\r
79                         bar.hide();\r
80                 else\r
81                         bar.show();\r
82                 checkVisibility();\r
83         }\r
84         \r
85         public void toggleZoom() {\r
86                 show();\r
87                 if (zoomSpinner.isVisible()) {\r
88                         zoomSpinner.hide();\r
89                         zoomLabel.hide();\r
90                 } else {\r
91                         zoomSpinner.show();\r
92                         zoomLabel.show();\r
93                 }\r
94                 checkVisibility();\r
95         }\r
96 }\r