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
21 //**********************************************
\r
22 //**********************************************
\r
23 //* Index settings in Edit/Preferences
\r
24 //**********************************************
\r
25 //**********************************************
\r
27 package cx.fbn.nevernote.dialog;
\r
29 import com.trolltech.qt.gui.QCheckBox;
\r
30 import com.trolltech.qt.gui.QGroupBox;
\r
31 import com.trolltech.qt.gui.QHBoxLayout;
\r
32 import com.trolltech.qt.gui.QLabel;
\r
33 import com.trolltech.qt.gui.QLineEdit;
\r
34 import com.trolltech.qt.gui.QSpinBox;
\r
35 import com.trolltech.qt.gui.QVBoxLayout;
\r
36 import com.trolltech.qt.gui.QWidget;
\r
38 import cx.fbn.nevernote.Global;
\r
40 public class ConfigIndexPage extends QWidget {
\r
42 private final QSpinBox weightSpinner;
\r
43 private final QSpinBox sleepSpinner;
\r
44 private final QCheckBox indexAttachmentsLocally;
\r
45 private final QLineEdit regexEdit;
\r
47 public ConfigIndexPage(QWidget parent) {
\r
50 // Recognition weight
\r
51 QGroupBox weightGroup = new QGroupBox(tr("Recognition"));
\r
52 QLabel weightLabel = new QLabel(tr("Minimum Recognition Weight"));
\r
53 weightSpinner = new QSpinBox();
\r
54 weightSpinner.setRange(1,100);
\r
55 weightSpinner.setSingleStep(1);
\r
56 weightSpinner.setValue(Global.getRecognitionWeight());
\r
58 QHBoxLayout weightLayout = new QHBoxLayout();
\r
59 weightLayout.addWidget(weightLabel);
\r
60 weightLayout.addWidget(weightSpinner);
\r
61 weightGroup.setLayout(weightLayout);
\r
63 // Local attachment indexing
\r
64 QGroupBox attachmentGroup = new QGroupBox(tr("Attachments"));
\r
65 indexAttachmentsLocally = new QCheckBox(tr("Index Attachments Locally"));
\r
66 indexAttachmentsLocally.setChecked(Global.indexAttachmentsLocally());
\r
68 QHBoxLayout attachmentLayout = new QHBoxLayout();
\r
69 attachmentLayout.addWidget(indexAttachmentsLocally);
\r
70 attachmentGroup.setLayout(attachmentLayout);
\r
72 // Index sleep interval
\r
73 QGroupBox sleepGroup = new QGroupBox(tr("Index Interval"));
\r
74 QLabel sleepLabel = new QLabel(tr("Seconds between looking for unindexed notes"));
\r
75 sleepSpinner = new QSpinBox();
\r
76 sleepSpinner.setRange(30,600);
\r
77 sleepSpinner.setSingleStep(1);
\r
78 sleepSpinner.setValue(Global.getIndexThreadSleepInterval());
\r
80 QHBoxLayout sleepLayout = new QHBoxLayout();
\r
81 sleepLayout.addWidget(sleepLabel);
\r
82 sleepLayout.addWidget(sleepSpinner);
\r
83 sleepGroup.setLayout(sleepLayout);
\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
91 QHBoxLayout regexLayout = new QHBoxLayout();
\r
92 regexLayout.addWidget(regexLabel);
\r
93 regexLayout.addWidget(regexEdit);
\r
94 regexGroup.setLayout(regexLayout);
\r
97 QVBoxLayout mainLayout = new QVBoxLayout();
\r
98 mainLayout.addWidget(sleepGroup);
\r
99 mainLayout.addWidget(weightGroup);
\r
100 mainLayout.addWidget(attachmentGroup);
\r
101 mainLayout.addWidget(regexGroup);
\r
102 mainLayout.addStretch(1);
\r
103 setLayout(mainLayout);
\r
109 //*****************************************
\r
110 //* Get for flag to index attachments
\r
111 //*****************************************
\r
112 public boolean getIndexAttachmentsLocally() {
\r
113 return indexAttachmentsLocally.isChecked();
\r
116 //*****************************************
\r
117 //* Word length get/set methods
\r
118 //*****************************************
\r
119 public void setSleepInterval(int len) {
\r
120 sleepSpinner.setValue(len);
\r
122 public int getSleepInterval() {
\r
123 return sleepSpinner.value();
\r
128 //*****************************************
\r
129 //* Recognition Weight
\r
130 //*****************************************
\r
131 public void setRecognitionWeight(int len) {
\r
132 weightSpinner.setValue(len);
\r
134 public int getRecognitionWeight() {
\r
135 return weightSpinner.value();
\r
140 //*****************************************
\r
141 //* Regex get/set methods
\r
142 //*****************************************
\r
143 public void setRegex(String s) {
\r
144 regexEdit.setText(s);
\r
146 public String getRegex() {
\r
147 return regexEdit.text();
\r