OSDN Git Service

- Added the ability to do special refreshes for debugging. - Added the ability to...
[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 \r
21 //**********************************************\r
22 //**********************************************\r
23 //* Index settings in Edit/Preferences\r
24 //**********************************************\r
25 //**********************************************\r
26 \r
27 package cx.fbn.nevernote.dialog;\r
28 \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
37 \r
38 import cx.fbn.nevernote.Global;\r
39 \r
40 public class ConfigIndexPage extends QWidget {\r
41 \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 QLineEdit specialStrip;\r
48         private final QCheckBox indexBody;\r
49         private final QLineEdit regexEdit;\r
50         \r
51         public ConfigIndexPage(QWidget parent) {\r
52 //              super(parent);\r
53                                                         \r
54                 // Recognition weight\r
55                 QGroupBox weightGroup = new QGroupBox(tr("Recognition"));\r
56                 QLabel weightLabel = new QLabel(tr("Minimum Recognition Weight"));\r
57                 weightSpinner = new QSpinBox();\r
58                 weightSpinner.setRange(1,100);\r
59                 weightSpinner.setSingleStep(1);\r
60                 weightSpinner.setValue(Global.getRecognitionWeight());\r
61                 \r
62                 QHBoxLayout weightLayout = new QHBoxLayout();\r
63                 weightLayout.addWidget(weightLabel);\r
64                 weightLayout.addWidget(weightSpinner);\r
65                 weightGroup.setLayout(weightLayout);\r
66                 \r
67                 // Local attachment indexing\r
68                 QGroupBox attachmentGroup = new QGroupBox(tr("Content"));\r
69                 indexBody = new QCheckBox(tr("Index Note Body"));\r
70                 indexBody.setChecked(Global.indexNoteBody());\r
71                 indexTitle = new QCheckBox(tr("Index Note Title"));\r
72                 indexTitle.setChecked(Global.indexNoteTitle());\r
73                 indexAttachmentsLocally = new QCheckBox(tr("Index Attachments Locally"));\r
74                 indexAttachmentsLocally.setChecked(Global.indexAttachmentsLocally());\r
75                 indexImageRecognition = new QCheckBox(tr("Index Image Recognition"));\r
76                 indexImageRecognition.setChecked(Global.indexImageRecognition());\r
77                 \r
78                 specialStrip = new QLineEdit();\r
79                 specialStrip.setText(Global.getSpecialIndexCharacters());\r
80                 \r
81                 QVBoxLayout attachmentLayout = new QVBoxLayout();\r
82                 attachmentLayout.addWidget(indexBody);\r
83                 attachmentLayout.addWidget(indexTitle);\r
84                 attachmentLayout.addWidget(indexAttachmentsLocally);\r
85                 attachmentLayout.addWidget(indexImageRecognition);\r
86                 \r
87                 QHBoxLayout specialCharLayout = new QHBoxLayout();\r
88                 specialCharLayout.addWidget(new QLabel(tr("Special Word Characters")));\r
89                 specialCharLayout.addWidget(specialStrip);\r
90                 attachmentLayout.addLayout(specialCharLayout);\r
91                 attachmentGroup.setLayout(attachmentLayout);\r
92 \r
93                 // Index sleep interval\r
94                 QGroupBox sleepGroup = new QGroupBox(tr("Index Interval"));\r
95                 QLabel sleepLabel = new QLabel(tr("Seconds between looking for unindexed notes"));\r
96                 sleepSpinner = new QSpinBox();\r
97                 sleepSpinner.setRange(30,600);\r
98                 sleepSpinner.setSingleStep(1);\r
99                 sleepSpinner.setValue(Global.getIndexThreadSleepInterval());\r
100 \r
101                 QHBoxLayout sleepLayout = new QHBoxLayout();\r
102                 sleepLayout.addWidget(sleepLabel);\r
103                 sleepLayout.addWidget(sleepSpinner);\r
104                 sleepGroup.setLayout(sleepLayout);\r
105                 \r
106                 // Regular Expressions for word parsing\r
107                 QGroupBox regexGroup = new QGroupBox(tr("Word Parse"));\r
108                 QLabel regexLabel = new QLabel(tr("Regular Expression"));\r
109                 regexEdit = new QLineEdit();\r
110                 regexEdit.setText(Global.getWordRegex());\r
111 \r
112                 QHBoxLayout regexLayout = new QHBoxLayout();\r
113                 regexLayout.addWidget(regexLabel);\r
114                 regexLayout.addWidget(regexEdit);               \r
115                 regexGroup.setLayout(regexLayout);\r
116                 \r
117                 \r
118                 QVBoxLayout mainLayout = new QVBoxLayout();\r
119                 mainLayout.addWidget(sleepGroup);\r
120                 mainLayout.addWidget(weightGroup);\r
121                 mainLayout.addWidget(attachmentGroup);\r
122                 mainLayout.addWidget(regexGroup);\r
123                 mainLayout.addStretch(1);\r
124                 setLayout(mainLayout);\r
125 \r
126 \r
127         }\r
128         \r
129         \r
130         //*****************************************\r
131         //* Get for flag to index attachments \r
132         //*****************************************\r
133         public boolean getIndexAttachmentsLocally() {\r
134                 return indexAttachmentsLocally.isChecked();\r
135         }\r
136         public boolean getIndexNoteBody() {\r
137                 return indexBody.isChecked();\r
138         }\r
139         public boolean getIndexNoteTitle() {\r
140                 return indexTitle.isChecked();\r
141         }\r
142         public String getSpecialCharacters() {\r
143                 return specialStrip.text();\r
144         }\r
145         public boolean getIndexImageRecognition() {\r
146                 return indexImageRecognition.isChecked();\r
147         }\r
148         \r
149         //*****************************************\r
150         //* Word length get/set methods \r
151         //*****************************************\r
152         public void setSleepInterval(int len) {\r
153                 sleepSpinner.setValue(len);\r
154         }\r
155         public int getSleepInterval() {\r
156                 return sleepSpinner.value();\r
157         }\r
158 \r
159 \r
160         \r
161         //*****************************************\r
162         //* Recognition Weight \r
163         //*****************************************\r
164         public void setRecognitionWeight(int len) {\r
165                 weightSpinner.setValue(len);\r
166         }\r
167         public int getRecognitionWeight() {\r
168                 return weightSpinner.value();\r
169         }\r
170         \r
171         \r
172         \r
173         //*****************************************\r
174         //* Regex get/set methods \r
175         //*****************************************\r
176         public void setRegex(String s) {\r
177                 regexEdit.setText(s);\r
178         }\r
179         public String getRegex() {\r
180                 return regexEdit.text();\r
181         }\r
182 \r
183 }\r