OSDN Git Service

44c4a429c038957574abb82a4030e084baa7622d
[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 QLineEdit regexEdit;\r
46         \r
47         public ConfigIndexPage(QWidget parent) {\r
48 //              super(parent);\r
49                                                         \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
57                 \r
58                 QHBoxLayout weightLayout = new QHBoxLayout();\r
59                 weightLayout.addWidget(weightLabel);\r
60                 weightLayout.addWidget(weightSpinner);\r
61                 weightGroup.setLayout(weightLayout);\r
62                 \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
67                 \r
68                 QHBoxLayout attachmentLayout = new QHBoxLayout();\r
69                 attachmentLayout.addWidget(indexAttachmentsLocally);\r
70                 attachmentGroup.setLayout(attachmentLayout);\r
71 \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
79 \r
80                 QHBoxLayout sleepLayout = new QHBoxLayout();\r
81                 sleepLayout.addWidget(sleepLabel);\r
82                 sleepLayout.addWidget(sleepSpinner);\r
83                 sleepGroup.setLayout(sleepLayout);\r
84                 \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
90 \r
91                 QHBoxLayout regexLayout = new QHBoxLayout();\r
92                 regexLayout.addWidget(regexLabel);\r
93                 regexLayout.addWidget(regexEdit);               \r
94                 regexGroup.setLayout(regexLayout);\r
95                 \r
96                 \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
104 \r
105 \r
106         }\r
107         \r
108         \r
109         //*****************************************\r
110         //* Get for flag to index attachments \r
111         //*****************************************\r
112         public boolean getIndexAttachmentsLocally() {\r
113                 return indexAttachmentsLocally.isChecked();\r
114         }\r
115         \r
116         //*****************************************\r
117         //* Word length get/set methods \r
118         //*****************************************\r
119         public void setSleepInterval(int len) {\r
120                 sleepSpinner.setValue(len);\r
121         }\r
122         public int getSleepInterval() {\r
123                 return sleepSpinner.value();\r
124         }\r
125 \r
126 \r
127         \r
128         //*****************************************\r
129         //* Recognition Weight \r
130         //*****************************************\r
131         public void setRecognitionWeight(int len) {\r
132                 weightSpinner.setValue(len);\r
133         }\r
134         public int getRecognitionWeight() {\r
135                 return weightSpinner.value();\r
136         }\r
137         \r
138         \r
139         \r
140         //*****************************************\r
141         //* Regex get/set methods \r
142         //*****************************************\r
143         public void setRegex(String s) {\r
144                 regexEdit.setText(s);\r
145         }\r
146         public String getRegex() {\r
147                 return regexEdit.text();\r
148         }\r
149 \r
150 }\r