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.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
31 import cx.fbn.nevernote.Global;
\r
33 public class ConfigIndexPage extends QWidget {
\r
35 private final QSpinBox weightSpinner;
\r
36 private final QSpinBox sleepSpinner;
\r
37 private final QCheckBox indexAttachmentsLocally;
\r
38 private final QLineEdit regexEdit;
\r
40 public ConfigIndexPage(QWidget parent) {
\r
43 // Recognition weight
\r
44 QGroupBox weightGroup = new QGroupBox(tr("Recognition"));
\r
45 QLabel weightLabel = new QLabel(tr("Minimum Recognition Weight"));
\r
46 weightSpinner = new QSpinBox();
\r
47 weightSpinner.setRange(1,100);
\r
48 weightSpinner.setSingleStep(1);
\r
49 weightSpinner.setValue(Global.getRecognitionWeight());
\r
51 QHBoxLayout weightLayout = new QHBoxLayout();
\r
52 weightLayout.addWidget(weightLabel);
\r
53 weightLayout.addWidget(weightSpinner);
\r
54 weightGroup.setLayout(weightLayout);
\r
56 // Local attachment indexing
\r
57 QGroupBox attachmentGroup = new QGroupBox(tr("Attachments"));
\r
58 indexAttachmentsLocally = new QCheckBox(tr("Index Attachments Locally"));
\r
59 indexAttachmentsLocally.setChecked(Global.indexAttachmentsLocally());
\r
61 QHBoxLayout attachmentLayout = new QHBoxLayout();
\r
62 attachmentLayout.addWidget(indexAttachmentsLocally);
\r
63 attachmentGroup.setLayout(attachmentLayout);
\r
65 // Index sleep interval
\r
66 QGroupBox sleepGroup = new QGroupBox(tr("Index Interval"));
\r
67 QLabel sleepLabel = new QLabel(tr("Seconds between looking for unindexed notes"));
\r
68 sleepSpinner = new QSpinBox();
\r
69 sleepSpinner.setRange(30,600);
\r
70 sleepSpinner.setSingleStep(1);
\r
71 sleepSpinner.setValue(Global.getIndexThreadSleepInterval());
\r
73 QHBoxLayout sleepLayout = new QHBoxLayout();
\r
74 sleepLayout.addWidget(sleepLabel);
\r
75 sleepLayout.addWidget(sleepSpinner);
\r
76 sleepGroup.setLayout(sleepLayout);
\r
78 // Regular Expressions for word parsing
\r
79 QGroupBox regexGroup = new QGroupBox(tr("Word Parse"));
\r
80 QLabel regexLabel = new QLabel(tr("Regular Expression"));
\r
81 regexEdit = new QLineEdit();
\r
82 regexEdit.setText(Global.getWordRegex());
\r
84 QHBoxLayout regexLayout = new QHBoxLayout();
\r
85 regexLayout.addWidget(regexLabel);
\r
86 regexLayout.addWidget(regexEdit);
\r
87 regexGroup.setLayout(regexLayout);
\r
90 QVBoxLayout mainLayout = new QVBoxLayout();
\r
91 mainLayout.addWidget(sleepGroup);
\r
92 mainLayout.addWidget(weightGroup);
\r
93 mainLayout.addWidget(attachmentGroup);
\r
94 mainLayout.addWidget(regexGroup);
\r
95 mainLayout.addStretch(1);
\r
96 setLayout(mainLayout);
\r
102 //*****************************************
\r
103 //* Get for flag to index attachments
\r
104 //*****************************************
\r
105 public boolean getIndexAttachmentsLocally() {
\r
106 return indexAttachmentsLocally.isChecked();
\r
109 //*****************************************
\r
110 //* Word length get/set methods
\r
111 //*****************************************
\r
112 public void setSleepInterval(int len) {
\r
113 sleepSpinner.setValue(len);
\r
115 public int getSleepInterval() {
\r
116 return sleepSpinner.value();
\r
121 //*****************************************
\r
122 //* Recognition Weight
\r
123 //*****************************************
\r
124 public void setRecognitionWeight(int len) {
\r
125 weightSpinner.setValue(len);
\r
127 public int getRecognitionWeight() {
\r
128 return weightSpinner.value();
\r
133 //*****************************************
\r
134 //* Regex get/set methods
\r
135 //*****************************************
\r
136 public void setRegex(String s) {
\r
137 regexEdit.setText(s);
\r
139 public String getRegex() {
\r
140 return regexEdit.text();
\r