2 * This file is part of NixNote/NeighborNote
\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 QCheckBox indexImageRecognition;
\r
46 private final QCheckBox indexTitle;
\r
47 // private final QCheckBox automaticWildcard;
\r
48 // private final QLineEdit specialStrip;
\r
49 private final QCheckBox indexBody;
\r
50 // private final QLineEdit regexEdit;
\r
52 public ConfigIndexPage(QWidget parent) {
\r
55 // Recognition weight
\r
56 QGroupBox weightGroup = new QGroupBox(tr("Recognition"));
\r
57 QLabel weightLabel = new QLabel(tr("Minimum Recognition Weight"));
\r
58 weightSpinner = new QSpinBox();
\r
59 weightSpinner.setRange(1,100);
\r
60 weightSpinner.setSingleStep(1);
\r
61 weightSpinner.setValue(Global.getRecognitionWeight());
\r
63 QHBoxLayout weightLayout = new QHBoxLayout();
\r
64 weightLayout.addWidget(weightLabel);
\r
65 weightLayout.addWidget(weightSpinner);
\r
66 weightGroup.setLayout(weightLayout);
\r
68 // Local attachment indexing
\r
69 QGroupBox attachmentGroup = new QGroupBox(tr("Content"));
\r
70 indexBody = new QCheckBox(tr("Index Note Body"));
\r
71 indexBody.setChecked(Global.indexNoteBody());
\r
72 indexTitle = new QCheckBox(tr("Index Note Title"));
\r
73 indexTitle.setChecked(Global.indexNoteTitle());
\r
74 indexAttachmentsLocally = new QCheckBox(tr("Index Attachments Locally"));
\r
75 indexAttachmentsLocally.setChecked(Global.indexAttachmentsLocally());
\r
76 indexImageRecognition = new QCheckBox(tr("Index Image Recognition"));
\r
77 indexImageRecognition.setChecked(Global.indexImageRecognition());
\r
79 // automaticWildcard = new QCheckBox(tr("Automatically Wildcard All Searches"));
\r
80 // automaticWildcard.setChecked(Global.automaticWildcardSearches());
\r
82 // specialStrip = new QLineEdit();
\r
83 // specialStrip.setText(Global.getSpecialIndexCharacters());
\r
85 QVBoxLayout attachmentLayout = new QVBoxLayout();
\r
86 attachmentLayout.addWidget(indexBody);
\r
87 attachmentLayout.addWidget(indexTitle);
\r
88 attachmentLayout.addWidget(indexAttachmentsLocally);
\r
89 attachmentLayout.addWidget(indexImageRecognition);
\r
90 // attachmentLayout.addWidget(automaticWildcard);
\r
92 // QHBoxLayout specialCharLayout = new QHBoxLayout();
\r
93 // specialCharLayout.addWidget(new QLabel(tr("Special Word Characters")));
\r
94 // specialCharLayout.addWidget(specialStrip);
\r
95 // attachmentLayout.addLayout(specialCharLayout);
\r
96 attachmentGroup.setLayout(attachmentLayout);
\r
98 // Index sleep interval
\r
99 QGroupBox sleepGroup = new QGroupBox(tr("Index Interval"));
\r
100 QLabel sleepLabel = new QLabel(tr("Seconds between looking for unindexed notes"));
\r
101 sleepSpinner = new QSpinBox();
\r
102 sleepSpinner.setRange(30,600);
\r
103 sleepSpinner.setSingleStep(1);
\r
104 sleepSpinner.setValue(Global.getIndexThreadSleepInterval());
\r
106 QHBoxLayout sleepLayout = new QHBoxLayout();
\r
107 sleepLayout.addWidget(sleepLabel);
\r
108 sleepLayout.addWidget(sleepSpinner);
\r
109 sleepGroup.setLayout(sleepLayout);
\r
111 // Regular Expressions for word parsing
\r
112 // QGroupBox regexGroup = new QGroupBox(tr("Word Parse"));
\r
113 // QLabel regexLabel = new QLabel(tr("Regular Expression"));
\r
114 // regexEdit = new QLineEdit();
\r
115 // regexEdit.setText(Global.getWordRegex());
\r
117 // QHBoxLayout regexLayout = new QHBoxLayout();
\r
118 // regexLayout.addWidget(regexLabel);
\r
119 // regexLayout.addWidget(regexEdit);
\r
120 // regexGroup.setLayout(regexLayout);
\r
123 QVBoxLayout mainLayout = new QVBoxLayout();
\r
124 mainLayout.addWidget(sleepGroup);
\r
125 mainLayout.addWidget(weightGroup);
\r
126 mainLayout.addWidget(attachmentGroup);
\r
127 // mainLayout.addWidget(regexGroup);
\r
128 mainLayout.addStretch(1);
\r
129 setLayout(mainLayout);
\r
135 //*****************************************
\r
136 //* Get for flag to index attachments
\r
137 //*****************************************
\r
138 public boolean getIndexAttachmentsLocally() {
\r
139 return indexAttachmentsLocally.isChecked();
\r
141 public boolean getIndexNoteBody() {
\r
142 return indexBody.isChecked();
\r
144 public boolean getIndexNoteTitle() {
\r
145 return indexTitle.isChecked();
\r
147 // public String getSpecialCharacters() {
\r
148 // return specialStrip.text();
\r
150 public boolean getIndexImageRecognition() {
\r
151 return indexImageRecognition.isChecked();
\r
153 // public boolean getAutomaticWildcardSearches() {
\r
154 // return automaticWildcard.isChecked();
\r
157 //*****************************************
\r
158 //* Word length get/set methods
\r
159 //*****************************************
\r
160 public void setSleepInterval(int len) {
\r
161 sleepSpinner.setValue(len);
\r
163 public int getSleepInterval() {
\r
164 return sleepSpinner.value();
\r
169 //*****************************************
\r
170 //* Recognition Weight
\r
171 //*****************************************
\r
172 public void setRecognitionWeight(int len) {
\r
173 weightSpinner.setValue(len);
\r
175 public int getRecognitionWeight() {
\r
176 return weightSpinner.value();
\r
181 //*****************************************
\r
182 //* Regex get/set methods
\r
183 //*****************************************
\r
184 // public void setRegex(String s) {
\r
185 // regexEdit.setText(s);
\r
187 // public String getRegex() {
\r
188 // return regexEdit.text();
\r