OSDN Git Service

連想ノートリストの重み付けにプリセットモードを導入した
[neighbornote/NeighborNote.git] / src / cx / fbn / nevernote / dialog / ConfigRensoNoteListPage.java
1 /*
2  * This file is part of NeighborNote
3  * Copyright 2013 Yuki Takahashi
4  * 
5  * This file may be licensed under the terms of of the
6  * GNU General Public License Version 2 (the ``GPL'').
7  *
8  * Software distributed under the License is distributed
9  * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
10  * express or implied. See the GPL for the specific language
11  * governing rights and limitations.
12  *
13  * You should have received a copy of the GPL along with this
14  * program. If not, go to http://www.gnu.org/licenses/gpl.html
15  * or write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18 */
19
20 // ICHANGED
21 package cx.fbn.nevernote.dialog;
22
23 import com.trolltech.qt.core.Qt;
24 import com.trolltech.qt.gui.QCheckBox;
25 import com.trolltech.qt.gui.QFormLayout;
26 import com.trolltech.qt.gui.QGroupBox;
27 import com.trolltech.qt.gui.QHBoxLayout;
28 import com.trolltech.qt.gui.QLabel;
29 import com.trolltech.qt.gui.QSlider;
30 import com.trolltech.qt.gui.QSpinBox;
31 import com.trolltech.qt.gui.QVBoxLayout;
32 import com.trolltech.qt.gui.QWidget;
33
34 import cx.fbn.nevernote.Global;
35
36 public class ConfigRensoNoteListPage extends QWidget {
37         private final QSlider browseSlider;
38         private final QSlider copyPasteSlider;
39         private final QSlider addNewNoteSlider;
40         private final QSlider rensoItemClickSlider;
41         private final QSlider sameTagSlider;
42         private final QSlider sameNotebookSlider;
43         private final QSlider enRelatedNotesSlider;
44         
45         private final QSpinBox browseSpinner;
46         private final QSpinBox copyPasteSpinner;
47         private final QSpinBox addNewNoteSpinner;
48         private final QSpinBox rensoItemClickSpinner;
49         private final QSpinBox sameTagSpinner;
50         private final QSpinBox sameNotebookSpinner;
51         private final QSpinBox rensoListItemMaximumSpinner;
52         private final QSpinBox enRelatedNotesSpinner;
53         
54         private final QCheckBox mergeCheck;
55         private final QCheckBox duplicateCheck;
56         private final QCheckBox verifyExclude;
57         
58         public ConfigRensoNoteListPage(QWidget parent) {
59                 // 操作履歴への重み付け
60                 // browseHistory
61                 browseSlider = new QSlider();
62                 browseSlider.setOrientation(Qt.Orientation.Horizontal);
63                 browseSlider.setRange(0, 10);
64                 browseSlider.setSingleStep(1);
65                 browseSlider.setTickPosition(QSlider.TickPosition.TicksAbove);
66                 browseSlider.setTickInterval(1);
67                 browseSlider.setFocusPolicy(Qt.FocusPolicy.StrongFocus);
68
69                 browseSpinner = new QSpinBox();
70                 browseSpinner.setRange(0,10);
71                 browseSpinner.setSingleStep(1);
72                 
73                 browseSlider.valueChanged.connect(browseSpinner, "setValue(int)");
74                 browseSpinner.valueChanged.connect(browseSlider, "setValue(int)");
75                 browseSlider.setValue(Global.getBrowseWeight());
76                 
77                 QHBoxLayout browseLayout = new QHBoxLayout();
78                 browseLayout.addWidget(browseSlider);
79                 browseLayout.addWidget(browseSpinner);
80                 
81                 
82                 // copyPasteHistory
83                 copyPasteSlider = new QSlider();
84                 copyPasteSlider.setOrientation(Qt.Orientation.Horizontal);
85                 copyPasteSlider.setRange(0, 10);
86                 copyPasteSlider.setSingleStep(1);
87                 copyPasteSlider.setTickPosition(QSlider.TickPosition.TicksAbove);
88                 copyPasteSlider.setTickInterval(1);
89                 copyPasteSlider.setFocusPolicy(Qt.FocusPolicy.StrongFocus);
90                 
91                 copyPasteSpinner = new QSpinBox();
92                 copyPasteSpinner.setRange(0,10);
93                 copyPasteSpinner.setSingleStep(1);
94                 
95                 copyPasteSlider.valueChanged.connect(copyPasteSpinner, "setValue(int)");
96                 copyPasteSpinner.valueChanged.connect(copyPasteSlider, "setValue(int)");
97                 copyPasteSlider.setValue(Global.getCopyPasteWeight());
98
99                 
100                 QHBoxLayout copyPasteLayout = new QHBoxLayout();
101                 copyPasteLayout.addWidget(copyPasteSlider);
102                 copyPasteLayout.addWidget(copyPasteSpinner);
103                 
104                 
105                 // addNewNoteHistory
106                 addNewNoteSlider = new QSlider();
107                 addNewNoteSlider.setOrientation(Qt.Orientation.Horizontal);
108                 addNewNoteSlider.setRange(0, 10);
109                 addNewNoteSlider.setSingleStep(1);
110                 addNewNoteSlider.setTickPosition(QSlider.TickPosition.TicksAbove);
111                 addNewNoteSlider.setTickInterval(1);
112                 addNewNoteSlider.setFocusPolicy(Qt.FocusPolicy.StrongFocus);
113
114                 addNewNoteSpinner = new QSpinBox();
115                 addNewNoteSpinner.setRange(0,10);
116                 addNewNoteSpinner.setSingleStep(1);
117                 
118                 addNewNoteSlider.valueChanged.connect(addNewNoteSpinner, "setValue(int)");
119                 addNewNoteSpinner.valueChanged.connect(addNewNoteSlider, "setValue(int)");
120                 addNewNoteSlider.setValue(Global.getAddNewNoteWeight());
121                 
122                 QHBoxLayout addNewNoteLayout = new QHBoxLayout();
123                 addNewNoteLayout.addWidget(addNewNoteSlider);
124                 addNewNoteLayout.addWidget(addNewNoteSpinner);
125                 
126                 
127                 // rensoItemClickHistory
128                 rensoItemClickSlider = new QSlider();
129                 rensoItemClickSlider.setOrientation(Qt.Orientation.Horizontal);
130                 rensoItemClickSlider.setRange(0, 10);
131                 rensoItemClickSlider.setSingleStep(1);
132                 rensoItemClickSlider.setTickPosition(QSlider.TickPosition.TicksAbove);
133                 rensoItemClickSlider.setTickInterval(1);
134                 rensoItemClickSlider.setFocusPolicy(Qt.FocusPolicy.StrongFocus);
135
136                 rensoItemClickSpinner = new QSpinBox();
137                 rensoItemClickSpinner.setRange(0,10);
138                 rensoItemClickSpinner.setSingleStep(1);
139                 
140                 rensoItemClickSlider.valueChanged.connect(rensoItemClickSpinner, "setValue(int)");
141                 rensoItemClickSpinner.valueChanged.connect(rensoItemClickSlider, "setValue(int)");
142                 rensoItemClickSlider.setValue(Global.getRensoItemClickWeight());
143                 
144                 QHBoxLayout rensoItemClickLayout = new QHBoxLayout();
145                 rensoItemClickLayout.addWidget(rensoItemClickSlider);
146                 rensoItemClickLayout.addWidget(rensoItemClickSpinner);
147                 
148                 // sameTagHistory
149                 sameTagSlider = new QSlider();
150                 sameTagSlider.setOrientation(Qt.Orientation.Horizontal);
151                 sameTagSlider.setRange(0, 10);
152                 sameTagSlider.setSingleStep(1);
153                 sameTagSlider.setTickPosition(QSlider.TickPosition.TicksAbove);
154                 sameTagSlider.setTickInterval(1);
155                 sameTagSlider.setFocusPolicy(Qt.FocusPolicy.StrongFocus);
156
157                 sameTagSpinner = new QSpinBox();
158                 sameTagSpinner.setRange(0,10);
159                 sameTagSpinner.setSingleStep(1);
160                 
161                 sameTagSlider.valueChanged.connect(sameTagSpinner, "setValue(int)");
162                 sameTagSpinner.valueChanged.connect(sameTagSlider, "setValue(int)");
163                 sameTagSlider.setValue(Global.getSameTagWeight());
164                 
165                 QHBoxLayout sameTagLayout = new QHBoxLayout();
166                 sameTagLayout.addWidget(sameTagSlider);
167                 sameTagLayout.addWidget(sameTagSpinner);
168                 
169                 // sameNotebookHistory
170                 sameNotebookSlider = new QSlider();
171                 sameNotebookSlider.setOrientation(Qt.Orientation.Horizontal);
172                 sameNotebookSlider.setRange(0, 10);
173                 sameNotebookSlider.setSingleStep(1);
174                 sameNotebookSlider.setTickPosition(QSlider.TickPosition.TicksAbove);
175                 sameNotebookSlider.setTickInterval(1);
176                 sameNotebookSlider.setFocusPolicy(Qt.FocusPolicy.StrongFocus);
177
178                 sameNotebookSpinner = new QSpinBox();
179                 sameNotebookSpinner.setRange(0,10);
180                 sameNotebookSpinner.setSingleStep(1);
181                 
182                 sameNotebookSlider.valueChanged.connect(sameNotebookSpinner, "setValue(int)");
183                 sameNotebookSpinner.valueChanged.connect(sameNotebookSlider, "setValue(int)");
184                 sameNotebookSlider.setValue(Global.getSameNotebookWeight());
185                 
186                 QHBoxLayout sameNotebookLayout = new QHBoxLayout();
187                 sameNotebookLayout.addWidget(sameNotebookSlider);
188                 sameNotebookLayout.addWidget(sameNotebookSpinner);
189                 
190                 // enRelatedNotes
191                 enRelatedNotesSlider = new QSlider();
192                 enRelatedNotesSlider.setOrientation(Qt.Orientation.Horizontal);
193                 enRelatedNotesSlider.setRange(0, 10);
194                 enRelatedNotesSlider.setSingleStep(1);
195                 enRelatedNotesSlider.setTickPosition(QSlider.TickPosition.TicksAbove);
196                 enRelatedNotesSlider.setTickInterval(1);
197                 enRelatedNotesSlider.setFocusPolicy(Qt.FocusPolicy.StrongFocus);
198                 
199                 enRelatedNotesSpinner = new QSpinBox();
200                 enRelatedNotesSpinner.setRange(0, 10);
201                 enRelatedNotesSpinner.setSingleStep(1);
202                 
203                 enRelatedNotesSlider.valueChanged.connect(enRelatedNotesSpinner, "setValue(int)");
204                 enRelatedNotesSpinner.valueChanged.connect(enRelatedNotesSlider, "setValue(int)");
205                 enRelatedNotesSpinner.setValue(Global.getENRelatedNotesWeight());
206                 
207                 QHBoxLayout enRelatedNotesLayout = new QHBoxLayout();
208                 enRelatedNotesLayout.addWidget(enRelatedNotesSlider);
209                 enRelatedNotesLayout.addWidget(enRelatedNotesSpinner);
210                 
211                 // 重み付け設定部分のレイアウト
212                 QVBoxLayout vLayout = new QVBoxLayout();
213                 QFormLayout styleLayout = new QFormLayout();
214                 styleLayout.setHorizontalSpacing(10);
215                 styleLayout.setVerticalSpacing(30);
216                 styleLayout.addRow(tr("Concurrent Browse Weight"), browseLayout);
217                 styleLayout.addRow(tr("Copy&Paste Weight"), copyPasteLayout);
218                 styleLayout.addRow(tr("Add New Note Weight"), addNewNoteLayout);
219                 styleLayout.addRow(tr("Renso Item Click Weight"), rensoItemClickLayout);
220                 styleLayout.addRow(tr("Same Tag Weight"), sameTagLayout);
221                 styleLayout.addRow(tr("Same Notebook Weight"), sameNotebookLayout);
222                 styleLayout.addRow(tr("Evernote Related Notes Weight"), enRelatedNotesLayout);
223                 vLayout.addLayout(styleLayout);
224
225                 QGroupBox weightingGroup = new QGroupBox(tr("Weighting"));
226                 weightingGroup.setLayout(vLayout);
227                 
228                 // プリセットモードがカスタム以外ならば設定不可能にする
229                 String mode = new String(Global.rensoWeightingSelect());
230                 if (!mode.equals("Custom")) {
231                         QLabel attention = new QLabel(tr("You can change these settings if you select \"Custom\" Mode."));
232                         attention.setStyleSheet("color : red");
233                         vLayout.insertWidget(0, attention);
234                         vLayout.insertSpacing(1, 20);
235                         
236                         browseSlider.setEnabled(false);
237                         browseSpinner.setEnabled(false);
238                         copyPasteSlider.setEnabled(false);
239                         copyPasteSpinner.setEnabled(false);
240                         addNewNoteSlider.setEnabled(false);
241                         addNewNoteSpinner.setEnabled(false);
242                         rensoItemClickSlider.setEnabled(false);
243                         rensoItemClickSpinner.setEnabled(false);
244                         sameTagSlider.setEnabled(false);
245                         sameTagSpinner.setEnabled(false);
246                         sameNotebookSlider.setEnabled(false);
247                         sameNotebookSpinner.setEnabled(false);
248                         enRelatedNotesSlider.setEnabled(false);
249                         enRelatedNotesSpinner.setEnabled(false);
250                 }
251                 
252                 // ノートのマージ・複製の関連ノートリストへの適用
253                 mergeCheck = new QCheckBox(tr("When you merge the notes, also merge RensoNoteList"));
254                 mergeCheck.setChecked(Global.getMergeRensoNote());
255                 duplicateCheck = new QCheckBox(tr("When you duplicate the notes, also duplicate RensoNoteList"));
256                 duplicateCheck.setChecked(Global.getDuplicateRensoNote());
257                 verifyExclude = new QCheckBox(tr("Verify when you exclude the note"));
258                 verifyExclude.setChecked(Global.verifyExclude());
259                 
260                 // 連想ノートリスト最大アイテム表示数
261                 rensoListItemMaximumSpinner = new QSpinBox();
262                 rensoListItemMaximumSpinner.setRange(1,100);
263                 rensoListItemMaximumSpinner.setSingleStep(1);
264                 rensoListItemMaximumSpinner.setValue(Global.getRensoListItemMaximum());
265                 QFormLayout fLayout = new QFormLayout();
266                 fLayout.setHorizontalSpacing(100);
267                 fLayout.addRow(tr("Renso Note List Item Maximum"), rensoListItemMaximumSpinner);
268                 
269                 // その他のレイアウト
270                 QVBoxLayout othersLayout = new QVBoxLayout();
271                 othersLayout.addWidget(mergeCheck);
272                 othersLayout.addWidget(duplicateCheck);
273                 othersLayout.addWidget(verifyExclude);
274                 othersLayout.addLayout(fLayout);
275                 
276                 QGroupBox othersGroup = new QGroupBox(tr("Others"));
277                 othersGroup.setLayout(othersLayout);
278                 
279                 QVBoxLayout mainLayout = new QVBoxLayout();
280                 mainLayout.addWidget(weightingGroup);
281                 mainLayout.addWidget(othersGroup);
282                 mainLayout.addStretch(1);
283                 setLayout(mainLayout);
284                 
285         }
286         
287         //*****************************************
288         //* Browse Weight 
289         //*****************************************
290         public int getBrowseWeight() {
291                 return browseSpinner.value();
292         }
293         
294         //*****************************************
295         //* Copy & Paste Weight 
296         //*****************************************
297         public int getCopyPasteWeight() {
298                 return copyPasteSpinner.value();
299         }
300         
301         //*****************************************
302         //* Add New Note Weight 
303         //*****************************************
304         public int getAddNewNoteWeight() {
305                 return addNewNoteSpinner.value();
306         }
307         
308         //*****************************************
309         //* Renso Item Click Weight
310         //*****************************************
311         public int getRensoItemClickWeight() {
312                 return rensoItemClickSpinner.value();
313         }
314         
315         //*****************************************
316         //* Same Tag Weight
317         //*****************************************
318         public int getSameTagWeight() {
319                 return sameTagSpinner.value();
320         }
321         
322         //*****************************************
323         //* Same Notebook Weight
324         //*****************************************
325         public int getSameNotebookWeight() {
326                 return sameNotebookSpinner.value();
327         }
328         
329         //*****************************************
330         //* Evernote Related Notes Integration Weight
331         //*****************************************
332         public int getENRelatedNotesWeight() {
333                 return enRelatedNotesSpinner.value();
334         }
335
336         //*****************************************
337         //* Merge Check
338         //*****************************************
339         public boolean getMergeChecked() {
340                 return mergeCheck.isChecked();
341         }
342
343         //*****************************************
344         //* DuplicateCheck
345         //*****************************************
346         public boolean getDuplicateChecked() {
347                 return duplicateCheck.isChecked();
348         }
349         
350         //*****************************************
351         //* VerifyExcludeCheck
352         //*****************************************
353         public boolean getVerifyExcludeChecked() {
354                 return verifyExclude.isChecked();
355         }
356
357         //*****************************************
358         //* RensoNoteListItemMaximum
359         //*****************************************
360         public int getRensoListItemMaximum() {
361                 return rensoListItemMaximumSpinner.value();
362         }
363 }