2 * This file is part of NeverNote
\r
3 * Copyright 2009 Randy Baumgarte
\r
5 * This file may be licensed under the terms of of the
\r
6 * GNU General Public License Version 2 (the ``GPL'').
\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
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
20 package cx.fbn.nevernote.dialog;
\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
30 import cx.fbn.nevernote.Global;
\r
32 public class ConfigIndexPage extends QWidget {
\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
40 public ConfigIndexPage(QWidget parent) {
\r
43 indexThreadSpinner = new QSpinBox(this);
\r
44 indexThreadSpinner.setMaximum(5);
\r
45 indexThreadSpinner.setMinimum(1);
\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
55 threadsGroup.setVisible(false);
\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
66 QHBoxLayout wordLengthLayout = new QHBoxLayout();
\r
67 wordLengthLayout.addWidget(wordLengthLabel);
\r
68 wordLengthLayout.addWidget(lengthSpinner);
\r
69 wordLengthGroup.setLayout(wordLengthLayout);
\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
80 QHBoxLayout weightLayout = new QHBoxLayout();
\r
81 weightLayout.addWidget(weightLabel);
\r
82 weightLayout.addWidget(weightSpinner);
\r
83 weightGroup.setLayout(weightLayout);
\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
94 QHBoxLayout sleepLayout = new QHBoxLayout();
\r
95 sleepLayout.addWidget(sleepLabel);
\r
96 sleepLayout.addWidget(sleepSpinner);
\r
97 sleepGroup.setLayout(sleepLayout);
\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
107 QHBoxLayout regexLayout = new QHBoxLayout();
\r
108 regexLayout.addWidget(regexLabel);
\r
109 regexLayout.addWidget(regexEdit);
\r
110 regexGroup.setLayout(regexLayout);
\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
125 //*****************************************
\r
126 //* Word length get/set methods
\r
127 //*****************************************
\r
128 public void setWordLength(int len) {
\r
129 lengthSpinner.setValue(len);
\r
131 public int getWordLength() {
\r
132 return lengthSpinner.value();
\r
136 //*****************************************
\r
137 //* Word length get/set methods
\r
138 //*****************************************
\r
139 public void setSleepInterval(int len) {
\r
140 sleepSpinner.setValue(len);
\r
142 public int getSleepInterval() {
\r
143 return sleepSpinner.value();
\r
148 //*****************************************
\r
149 //* Recognition Weight
\r
150 //*****************************************
\r
151 public void setRecognitionWeight(int len) {
\r
152 weightSpinner.setValue(len);
\r
154 public int getRecognitionWeight() {
\r
155 return weightSpinner.value();
\r
158 //*****************************************
\r
159 //* Index Threads get/set methods
\r
160 //*****************************************
\r
161 public void setIndexThreads(int value) {
\r
162 indexThreadSpinner.setValue(value);
\r
164 public int getIndexThreads() {
\r
165 return indexThreadSpinner.value();
\r
170 //*****************************************
\r
171 //* Regex get/set methods
\r
172 //*****************************************
\r
173 public void setRegex(String s) {
\r
174 regexEdit.setText(s);
\r
176 public String getRegex() {
\r
177 return regexEdit.text();
\r