OSDN Git Service

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