OSDN Git Service

Change the editor button bar from a QHBoxLayout to a QToolBar. This will allow the...
[neighbornote/NeighborNote.git] / src / cx / fbn / nevernote / dialog / ConfigIndexPage.java
1 /*\r
2  * This file is part of NeverNote \r
3  * Copyright 2009 Randy Baumgarte\r
4  * \r
5  * This file may be licensed under the terms of of the\r
6  * GNU General Public License Version 2 (the ``GPL'').\r
7  *\r
8  * Software distributed under the License is distributed\r
9  * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either\r
10  * express or implied. See the GPL for the specific language\r
11  * governing rights and limitations.\r
12  *\r
13  * You should have received a copy of the GPL along with this\r
14  * program. If not, go to http://www.gnu.org/licenses/gpl.html\r
15  * or write to the Free Software Foundation, Inc.,\r
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\r
17  *\r
18 */\r
19 \r
20 package cx.fbn.nevernote.dialog;\r
21 \r
22 import com.trolltech.qt.gui.QGroupBox;\r
23 import com.trolltech.qt.gui.QHBoxLayout;\r
24 import com.trolltech.qt.gui.QLabel;\r
25 import com.trolltech.qt.gui.QLineEdit;\r
26 import com.trolltech.qt.gui.QSpinBox;\r
27 import com.trolltech.qt.gui.QVBoxLayout;\r
28 import com.trolltech.qt.gui.QWidget;\r
29 \r
30 import cx.fbn.nevernote.Global;\r
31 \r
32 public class ConfigIndexPage extends QWidget {\r
33 \r
34         private final QSpinBox  indexThreadSpinner;\r
35         private final QSpinBox lengthSpinner;\r
36         private final QSpinBox weightSpinner;\r
37         private final QLineEdit regexEdit;\r
38         \r
39         public ConfigIndexPage(QWidget parent) {\r
40 //              super(parent);\r
41                 \r
42                 indexThreadSpinner = new QSpinBox(this);\r
43                 indexThreadSpinner.setMaximum(5);\r
44                 indexThreadSpinner.setMinimum(1);\r
45                         \r
46                 // Index threads layout\r
47                 QLabel threadLabel = new QLabel(tr("Maximum Threads"));\r
48                 QHBoxLayout threadsLayout = new QHBoxLayout();\r
49                 threadsLayout.addWidget(threadLabel);\r
50                 threadsLayout.addWidget(indexThreadSpinner);\r
51                 QGroupBox threadsGroup = new QGroupBox(tr("Indexing Threads (Requires Restart)"));\r
52                 threadsGroup.setLayout(threadsLayout);\r
53                 \r
54                 threadsGroup.setVisible(false);\r
55                 \r
56                 \r
57                 // Minimum word length\r
58                 QGroupBox wordLengthGroup = new QGroupBox(tr("Word Length"));\r
59                 QLabel wordLengthLabel = new QLabel(tr("Minimum Word Length"));\r
60                 lengthSpinner = new QSpinBox();\r
61                 lengthSpinner.setRange(3,10);\r
62                 lengthSpinner.setSingleStep(1);\r
63                 lengthSpinner.setValue(Global.minimumWordCount);\r
64                 \r
65                 QHBoxLayout wordLengthLayout = new QHBoxLayout();\r
66                 wordLengthLayout.addWidget(wordLengthLabel);\r
67                 wordLengthLayout.addWidget(lengthSpinner);\r
68                 wordLengthGroup.setLayout(wordLengthLayout);\r
69                 \r
70 \r
71                 // Minimum word length\r
72                 QGroupBox weightGroup = new QGroupBox(tr("Recognition"));\r
73                 QLabel weightLabel = new QLabel(tr("Minimum Recognition Weight"));\r
74                 weightSpinner = new QSpinBox();\r
75                 weightSpinner.setRange(1,100);\r
76                 weightSpinner.setSingleStep(1);\r
77                 weightSpinner.setValue(Global.getRecognitionWeight());\r
78 \r
79                 QHBoxLayout weightLayout = new QHBoxLayout();\r
80                 weightLayout.addWidget(weightLabel);\r
81                 weightLayout.addWidget(weightSpinner);\r
82                 weightGroup.setLayout(weightLayout);\r
83                 \r
84         \r
85                 // Regular Expressions for word parsing\r
86                 QGroupBox regexGroup = new QGroupBox(tr("Word Parse"));\r
87                 QLabel regexLabel = new QLabel(tr("Regular Expression"));\r
88                 regexEdit = new QLineEdit();\r
89                 regexEdit.setText(Global.getWordRegex());\r
90 \r
91                 QHBoxLayout regexLayout = new QHBoxLayout();\r
92                 regexLayout.addWidget(regexLabel);\r
93                 regexLayout.addWidget(regexEdit);               \r
94                 regexGroup.setLayout(regexLayout);\r
95                 \r
96                 \r
97                 QVBoxLayout mainLayout = new QVBoxLayout();\r
98                 mainLayout.addWidget(threadsGroup);\r
99                 mainLayout.addWidget(wordLengthGroup);\r
100                 mainLayout.addWidget(weightGroup);\r
101                 mainLayout.addWidget(regexGroup);\r
102                 mainLayout.addStretch(1);\r
103                 setLayout(mainLayout);\r
104 \r
105 \r
106         }\r
107         \r
108         //*****************************************\r
109         //* Word length get/set methods \r
110         //*****************************************\r
111         public void setWordLength(int len) {\r
112                 lengthSpinner.setValue(len);\r
113         }\r
114         public int getWordLength() {\r
115                 return lengthSpinner.value();\r
116         }\r
117 \r
118         \r
119         //*****************************************\r
120         //* Recognition Weight \r
121         //*****************************************\r
122         public void setRecognitionWeight(int len) {\r
123                 weightSpinner.setValue(len);\r
124         }\r
125         public int getRecognitionWeight() {\r
126                 return weightSpinner.value();\r
127         }\r
128         \r
129         //*****************************************\r
130         //* Index Threads get/set methods\r
131         //*****************************************\r
132         public void setIndexThreads(int value) {\r
133                 indexThreadSpinner.setValue(value);\r
134         }\r
135         public int getIndexThreads() {\r
136                 return indexThreadSpinner.value();\r
137         }\r
138 \r
139         \r
140         \r
141         //*****************************************\r
142         //* Regex get/set methods \r
143         //*****************************************\r
144         public void setRegex(String s) {\r
145                 regexEdit.setText(s);\r
146         }\r
147         public String getRegex() {\r
148                 return regexEdit.text();\r
149         }\r
150 \r
151 }\r