OSDN Git Service

Add logic to display stacks in notebook tree
[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 QSpinBox sleepSpinner;\r
38         private final QLineEdit regexEdit;\r
39         \r
40         public ConfigIndexPage(QWidget parent) {\r
41 //              super(parent);\r
42                 \r
43                 indexThreadSpinner = new QSpinBox(this);\r
44                 indexThreadSpinner.setMaximum(5);\r
45                 indexThreadSpinner.setMinimum(1);\r
46                         \r
47                 // Index threads layout\r
48                 QLabel threadLabel = new QLabel(tr("Maximum Threads"));\r
49                 QHBoxLayout threadsLayout = new QHBoxLayout();\r
50                 threadsLayout.addWidget(threadLabel);\r
51                 threadsLayout.addWidget(indexThreadSpinner);\r
52                 QGroupBox threadsGroup = new QGroupBox(tr("Indexing Threads (Requires Restart)"));\r
53                 threadsGroup.setLayout(threadsLayout);\r
54                 \r
55                 threadsGroup.setVisible(false);\r
56                 \r
57                 \r
58                 // Minimum word length\r
59                 QGroupBox wordLengthGroup = new QGroupBox(tr("Word Length"));\r
60                 QLabel wordLengthLabel = new QLabel(tr("Minimum Word Length"));\r
61                 lengthSpinner = new QSpinBox();\r
62                 lengthSpinner.setRange(1,10);\r
63                 lengthSpinner.setSingleStep(1);\r
64                 lengthSpinner.setValue(Global.minimumWordCount);\r
65                 \r
66                 QHBoxLayout wordLengthLayout = new QHBoxLayout();\r
67                 wordLengthLayout.addWidget(wordLengthLabel);\r
68                 wordLengthLayout.addWidget(lengthSpinner);\r
69                 wordLengthGroup.setLayout(wordLengthLayout);\r
70                 \r
71 \r
72                 // Minimum word length\r
73                 QGroupBox weightGroup = new QGroupBox(tr("Recognition"));\r
74                 QLabel weightLabel = new QLabel(tr("Minimum Recognition Weight"));\r
75                 weightSpinner = new QSpinBox();\r
76                 weightSpinner.setRange(1,100);\r
77                 weightSpinner.setSingleStep(1);\r
78                 weightSpinner.setValue(Global.getRecognitionWeight());\r
79 \r
80                 QHBoxLayout weightLayout = new QHBoxLayout();\r
81                 weightLayout.addWidget(weightLabel);\r
82                 weightLayout.addWidget(weightSpinner);\r
83                 weightGroup.setLayout(weightLayout);\r
84                 \r
85 \r
86                 // Index sleep interval\r
87                 QGroupBox sleepGroup = new QGroupBox(tr("Index Interval"));\r
88                 QLabel sleepLabel = new QLabel(tr("Seconds between looking for unindexed notes"));\r
89                 sleepSpinner = new QSpinBox();\r
90                 sleepSpinner.setRange(30,600);\r
91                 sleepSpinner.setSingleStep(1);\r
92                 sleepSpinner.setValue(Global.getIndexThreadSleepInterval());\r
93 \r
94                 QHBoxLayout sleepLayout = new QHBoxLayout();\r
95                 sleepLayout.addWidget(sleepLabel);\r
96                 sleepLayout.addWidget(sleepSpinner);\r
97                 sleepGroup.setLayout(sleepLayout);\r
98 \r
99                 \r
100                 \r
101                 // Regular Expressions for word parsing\r
102                 QGroupBox regexGroup = new QGroupBox(tr("Word Parse"));\r
103                 QLabel regexLabel = new QLabel(tr("Regular Expression"));\r
104                 regexEdit = new QLineEdit();\r
105                 regexEdit.setText(Global.getWordRegex());\r
106 \r
107                 QHBoxLayout regexLayout = new QHBoxLayout();\r
108                 regexLayout.addWidget(regexLabel);\r
109                 regexLayout.addWidget(regexEdit);               \r
110                 regexGroup.setLayout(regexLayout);\r
111                 \r
112                 \r
113                 QVBoxLayout mainLayout = new QVBoxLayout();\r
114                 mainLayout.addWidget(threadsGroup);\r
115                 mainLayout.addWidget(wordLengthGroup);\r
116                 mainLayout.addWidget(sleepGroup);\r
117                 mainLayout.addWidget(weightGroup);\r
118                 mainLayout.addWidget(regexGroup);\r
119                 mainLayout.addStretch(1);\r
120                 setLayout(mainLayout);\r
121 \r
122 \r
123         }\r
124         \r
125         //*****************************************\r
126         //* Word length get/set methods \r
127         //*****************************************\r
128         public void setWordLength(int len) {\r
129                 lengthSpinner.setValue(len);\r
130         }\r
131         public int getWordLength() {\r
132                 return lengthSpinner.value();\r
133         }\r
134         \r
135         \r
136         //*****************************************\r
137         //* Word length get/set methods \r
138         //*****************************************\r
139         public void setSleepInterval(int len) {\r
140                 sleepSpinner.setValue(len);\r
141         }\r
142         public int getSleepInterval() {\r
143                 return sleepSpinner.value();\r
144         }\r
145 \r
146 \r
147         \r
148         //*****************************************\r
149         //* Recognition Weight \r
150         //*****************************************\r
151         public void setRecognitionWeight(int len) {\r
152                 weightSpinner.setValue(len);\r
153         }\r
154         public int getRecognitionWeight() {\r
155                 return weightSpinner.value();\r
156         }\r
157         \r
158         //*****************************************\r
159         //* Index Threads get/set methods\r
160         //*****************************************\r
161         public void setIndexThreads(int value) {\r
162                 indexThreadSpinner.setValue(value);\r
163         }\r
164         public int getIndexThreads() {\r
165                 return indexThreadSpinner.value();\r
166         }\r
167 \r
168         \r
169         \r
170         //*****************************************\r
171         //* Regex get/set methods \r
172         //*****************************************\r
173         public void setRegex(String s) {\r
174                 regexEdit.setText(s);\r
175         }\r
176         public String getRegex() {\r
177                 return regexEdit.text();\r
178         }\r
179 \r
180 }\r