1 | /*
|
---|
2 | * QtQuery.hpp
|
---|
3 | *
|
---|
4 | * Created on: Nov 8, 2010
|
---|
5 | * Author: heber
|
---|
6 | */
|
---|
7 |
|
---|
8 | #ifndef QTQUERY_HPP_
|
---|
9 | #define QTQUERY_HPP_
|
---|
10 |
|
---|
11 | // include config.h
|
---|
12 | #ifdef HAVE_CONFIG_H
|
---|
13 | #include <config.h>
|
---|
14 | #endif
|
---|
15 |
|
---|
16 |
|
---|
17 | #include <Qt/qwidget.h>
|
---|
18 | #include "Qt4/QtDialog.hpp"
|
---|
19 | #include "QtQueryList.hpp"
|
---|
20 |
|
---|
21 | #include "Parameters/Parameter.hpp"
|
---|
22 |
|
---|
23 | class QHBoxLayout;
|
---|
24 | class QBoxLayout;
|
---|
25 | class QDialogButtonBox;
|
---|
26 | class QLabel;
|
---|
27 | class QSpinBox;
|
---|
28 | class QDoubleSpinBox;
|
---|
29 | class QLineEdit;
|
---|
30 | class QListWidget;
|
---|
31 | class QPushButton;
|
---|
32 | class QTableWidget;
|
---|
33 | class QTextEdit;
|
---|
34 | class QComboBox;
|
---|
35 | class QCheckBox;
|
---|
36 | class QFileDialog;
|
---|
37 |
|
---|
38 | template<class T>
|
---|
39 | class QtQuery : public Dialog::TQuery<T>
|
---|
40 | {
|
---|
41 | public:
|
---|
42 | QtQuery(Parameter<T> &_param, const std::string &_title, const std::string &_description = "") :
|
---|
43 | Dialog::TQuery<T>(_param, _title, _description) {}
|
---|
44 | // QtQueries are interactive - no need for handle().
|
---|
45 | virtual bool handle(){ return true; }
|
---|
46 | };
|
---|
47 |
|
---|
48 | class QtDialog::AtomQtQuery : public QWidget, public QtQuery<const atom *> {
|
---|
49 | Q_OBJECT
|
---|
50 | public:
|
---|
51 | AtomQtQuery(Parameter<const atom *> &, const std::string &_title, const std::string &description, QBoxLayout *_parent,Dialog *_dialog);
|
---|
52 | virtual ~AtomQtQuery();
|
---|
53 |
|
---|
54 | public slots:
|
---|
55 | void onUpdate(int);
|
---|
56 |
|
---|
57 | private:
|
---|
58 | QBoxLayout *parent;
|
---|
59 | QBoxLayout *thisLayout;
|
---|
60 | QLabel *titleLabel;
|
---|
61 | QComboBox *inputBox;
|
---|
62 | Dialog *dialog;
|
---|
63 | };
|
---|
64 |
|
---|
65 | class QtDialog::AtomsQtQuery : public QWidget, public QtQuery<std::vector<const atom *> >, public QtQueryList<const atom *> {
|
---|
66 | Q_OBJECT
|
---|
67 | public:
|
---|
68 | AtomsQtQuery(Parameter<std::vector<const atom *> > &, const std::string &_title, const std::string &description, QBoxLayout *_parent,Dialog *_dialog);
|
---|
69 | virtual ~AtomsQtQuery();
|
---|
70 |
|
---|
71 | virtual void onSubUpdate();
|
---|
72 |
|
---|
73 | public slots:
|
---|
74 | void onAddElement();
|
---|
75 | void onRemoveElement();
|
---|
76 | void onElementSelected();
|
---|
77 |
|
---|
78 | private:
|
---|
79 | AtomQtQuery *subQuery;
|
---|
80 | };
|
---|
81 |
|
---|
82 | class QtDialog::BooleanQtQuery : public QWidget, public QtQuery<bool> {
|
---|
83 | Q_OBJECT
|
---|
84 | public:
|
---|
85 | BooleanQtQuery(Parameter<bool> &, const std::string &_title, const std::string &description, QBoxLayout *_parent, Dialog *_dialog);
|
---|
86 | virtual ~BooleanQtQuery();
|
---|
87 |
|
---|
88 | public slots:
|
---|
89 | void onUpdate(int);
|
---|
90 |
|
---|
91 | private:
|
---|
92 | QBoxLayout *parent;
|
---|
93 | QBoxLayout *thisLayout;
|
---|
94 | QLabel *titleLabel;
|
---|
95 | QCheckBox *booleanCheckBox;
|
---|
96 | Dialog *dialog;
|
---|
97 | };
|
---|
98 |
|
---|
99 | class QtDialog::RealSpaceMatrixQtQuery : public QWidget, public QtQuery<RealSpaceMatrix> {
|
---|
100 | Q_OBJECT
|
---|
101 | public:
|
---|
102 | RealSpaceMatrixQtQuery(Parameter<RealSpaceMatrix> &, const std::string &_title, const std::string &description, QBoxLayout *_parent,Dialog *_dialog);
|
---|
103 | virtual ~RealSpaceMatrixQtQuery();
|
---|
104 |
|
---|
105 | public slots:
|
---|
106 | void onUpdate(int, int);
|
---|
107 |
|
---|
108 | private:
|
---|
109 | QBoxLayout *parent;
|
---|
110 | QBoxLayout *thisLayout;
|
---|
111 | QLabel *titleLabel;
|
---|
112 | QTableWidget *inputTable;
|
---|
113 | Dialog *dialog;
|
---|
114 | };
|
---|
115 |
|
---|
116 | class QtDialog::DoubleQtQuery : public QWidget, public QtQuery<double> {
|
---|
117 | Q_OBJECT
|
---|
118 | public:
|
---|
119 | DoubleQtQuery(Parameter<double> &, const std::string &_title, const std::string &_description,QBoxLayout *_parent,Dialog *_dialog);
|
---|
120 | virtual ~DoubleQtQuery();
|
---|
121 |
|
---|
122 | public slots:
|
---|
123 | void onUpdate(double);
|
---|
124 |
|
---|
125 | private:
|
---|
126 | QBoxLayout *parent;
|
---|
127 | QBoxLayout *thisLayout;
|
---|
128 | QLabel *titleLabel;
|
---|
129 | QDoubleSpinBox *inputBox;
|
---|
130 | Dialog *dialog;
|
---|
131 | };
|
---|
132 |
|
---|
133 | class QtDialog::DoublesQtQuery : public QWidget, public QtQuery<std::vector<double> >, public QtQueryList<double> {
|
---|
134 | Q_OBJECT
|
---|
135 | public:
|
---|
136 | DoublesQtQuery(Parameter<std::vector<double> > &, const std::string &_title, const std::string &description, QBoxLayout *_parent,Dialog *_dialog);
|
---|
137 | virtual ~DoublesQtQuery();
|
---|
138 |
|
---|
139 | virtual void onSubUpdate();
|
---|
140 |
|
---|
141 | public slots:
|
---|
142 | void onAddElement();
|
---|
143 | void onRemoveElement();
|
---|
144 | void onElementSelected();
|
---|
145 |
|
---|
146 | private:
|
---|
147 | DoubleQtQuery *subQuery;
|
---|
148 | };
|
---|
149 |
|
---|
150 | class QtDialog::ElementQtQuery : public QWidget, public QtQuery<const element *> {
|
---|
151 | Q_OBJECT
|
---|
152 | public:
|
---|
153 | ElementQtQuery(Parameter<const element *> &, const std::string &_title, const std::string &description, QBoxLayout *_parent, Dialog *_dialog);
|
---|
154 | virtual ~ElementQtQuery();
|
---|
155 |
|
---|
156 | public slots:
|
---|
157 | void onUpdate(int);
|
---|
158 |
|
---|
159 | private:
|
---|
160 | QBoxLayout *parent;
|
---|
161 | QBoxLayout *thisLayout;
|
---|
162 | QLabel *titleLabel;
|
---|
163 | QComboBox *inputBox;
|
---|
164 | Dialog *dialog;
|
---|
165 | };
|
---|
166 |
|
---|
167 | class QtDialog::ElementsQtQuery : public QWidget, public QtQuery<std::vector<const element *> >, public QtQueryList<const element *> {
|
---|
168 | Q_OBJECT
|
---|
169 | public:
|
---|
170 | ElementsQtQuery(Parameter<std::vector<const element *> > &, const std::string &_title, const std::string &description, QBoxLayout *_parent,Dialog *_dialog);
|
---|
171 | virtual ~ElementsQtQuery();
|
---|
172 |
|
---|
173 | virtual void onSubUpdate();
|
---|
174 |
|
---|
175 | public slots:
|
---|
176 | void onAddElement();
|
---|
177 | void onRemoveElement();
|
---|
178 | void onElementSelected();
|
---|
179 |
|
---|
180 | private:
|
---|
181 | ElementQtQuery *subQuery;
|
---|
182 | };
|
---|
183 |
|
---|
184 | class QtDialog::EmptyQtQuery : public Dialog::EmptyQuery {
|
---|
185 | public:
|
---|
186 | EmptyQtQuery(const std::string &_title, const std::string &description, QBoxLayout *_parent, Dialog *_dialog);
|
---|
187 | virtual ~EmptyQtQuery();
|
---|
188 | virtual bool handle();
|
---|
189 | private:
|
---|
190 | QBoxLayout *parent;
|
---|
191 | QBoxLayout *thisLayout;
|
---|
192 | QLabel *titleLabel;
|
---|
193 | Dialog *dialog;
|
---|
194 | };
|
---|
195 |
|
---|
196 | class QtDialog::FileQtQuery : public QWidget, public QtQuery<boost::filesystem::path> {
|
---|
197 | Q_OBJECT
|
---|
198 | public:
|
---|
199 | FileQtQuery(Parameter<boost::filesystem::path> &, const std::string &_title, const std::string &description, QBoxLayout *_parent, Dialog *_dialog);
|
---|
200 | virtual ~FileQtQuery();
|
---|
201 |
|
---|
202 | public slots:
|
---|
203 | void onUpdate();
|
---|
204 | void showFileDialog();
|
---|
205 |
|
---|
206 | private:
|
---|
207 | QBoxLayout *parent;
|
---|
208 | QBoxLayout *thisLayout;
|
---|
209 | QLabel *filenameLabel;
|
---|
210 | QLineEdit *filenameLineEdit;
|
---|
211 | QPushButton *filedialogButton;
|
---|
212 | QFileDialog *theFileDialog;
|
---|
213 | Dialog *dialog;
|
---|
214 | std::vector<std::string> suffixes;
|
---|
215 | bool mustBePresent;
|
---|
216 | };
|
---|
217 |
|
---|
218 | class QtDialog::FilesQtQuery : public QWidget, public QtQuery<std::vector<boost::filesystem::path> >, public QtQueryList<boost::filesystem::path> {
|
---|
219 | Q_OBJECT
|
---|
220 | public:
|
---|
221 | FilesQtQuery(Parameter<std::vector<boost::filesystem::path> > &, const std::string &_title, const std::string &description, QBoxLayout *_parent,Dialog *_dialog);
|
---|
222 | virtual ~FilesQtQuery();
|
---|
223 |
|
---|
224 | virtual void onSubUpdate();
|
---|
225 |
|
---|
226 | public slots:
|
---|
227 | void onAddElement();
|
---|
228 | void onRemoveElement();
|
---|
229 | void onElementSelected();
|
---|
230 |
|
---|
231 | private:
|
---|
232 | FileQtQuery *subQuery;
|
---|
233 | };
|
---|
234 |
|
---|
235 | class QtDialog::IntQtQuery : public QWidget, public QtQuery<int> {
|
---|
236 | Q_OBJECT
|
---|
237 | public:
|
---|
238 | IntQtQuery(Parameter<int> &, const std::string &_title, const std::string &description,QBoxLayout *_parent,Dialog *_dialog);
|
---|
239 | virtual ~IntQtQuery();
|
---|
240 |
|
---|
241 | public slots:
|
---|
242 | void onUpdate(int);
|
---|
243 |
|
---|
244 | private:
|
---|
245 | QBoxLayout *parent;
|
---|
246 | QBoxLayout *thisLayout;
|
---|
247 | QLabel *titleLabel;
|
---|
248 | QSpinBox *inputBox;
|
---|
249 | Dialog *dialog;
|
---|
250 | };
|
---|
251 |
|
---|
252 | class QtDialog::IntsQtQuery : public QWidget, public QtQuery<std::vector<int> >, public QtQueryList<int> {
|
---|
253 | Q_OBJECT
|
---|
254 | public:
|
---|
255 | IntsQtQuery(Parameter<std::vector<int> > &, const std::string &_title, const std::string &description, QBoxLayout *_parent,Dialog *_dialog);
|
---|
256 | virtual ~IntsQtQuery();
|
---|
257 |
|
---|
258 | virtual void onSubUpdate();
|
---|
259 |
|
---|
260 | public slots:
|
---|
261 | void onAddElement();
|
---|
262 | void onRemoveElement();
|
---|
263 | void onElementSelected();
|
---|
264 |
|
---|
265 | private:
|
---|
266 | IntQtQuery *subQuery;
|
---|
267 | };
|
---|
268 |
|
---|
269 | class QtDialog::MoleculeQtQuery : public QWidget, public QtQuery<const molecule *> {
|
---|
270 | Q_OBJECT
|
---|
271 | public:
|
---|
272 | MoleculeQtQuery(Parameter<const molecule *> &, const std::string &_title, const std::string &description, QBoxLayout *_parent,Dialog *_dialog);
|
---|
273 | virtual ~MoleculeQtQuery();
|
---|
274 |
|
---|
275 | public slots:
|
---|
276 | void onUpdate(int);
|
---|
277 |
|
---|
278 | private:
|
---|
279 | QBoxLayout *parent;
|
---|
280 | QBoxLayout *thisLayout;
|
---|
281 | QLabel *titleLabel;
|
---|
282 | QComboBox *inputBox;
|
---|
283 | Dialog *dialog;
|
---|
284 | };
|
---|
285 |
|
---|
286 | class QtDialog::MoleculesQtQuery : public QWidget, public QtQuery<std::vector<const molecule *> >, public QtQueryList<const molecule *> {
|
---|
287 | Q_OBJECT
|
---|
288 | public:
|
---|
289 | MoleculesQtQuery(Parameter<std::vector<const molecule *> > &, const std::string &_title, const std::string &description, QBoxLayout *_parent,Dialog *_dialog);
|
---|
290 | virtual ~MoleculesQtQuery();
|
---|
291 |
|
---|
292 | virtual void onSubUpdate();
|
---|
293 |
|
---|
294 | public slots:
|
---|
295 | void onAddElement();
|
---|
296 | void onRemoveElement();
|
---|
297 | void onElementSelected();
|
---|
298 |
|
---|
299 | private:
|
---|
300 | MoleculeQtQuery *subQuery;
|
---|
301 | };
|
---|
302 |
|
---|
303 | class QtDialog::KeyValuePairQtQuery : public QWidget, public QtQuery<KeyValuePair> {
|
---|
304 | Q_OBJECT
|
---|
305 | public:
|
---|
306 | KeyValuePairQtQuery(Parameter<KeyValuePair> &, const std::string &_title, const std::string &description, QBoxLayout *_parent,Dialog *_dialog);
|
---|
307 | virtual ~KeyValuePairQtQuery();
|
---|
308 |
|
---|
309 | public slots:
|
---|
310 | void onUpdate(const QString&);
|
---|
311 | void onUpdateCombo(int index);
|
---|
312 |
|
---|
313 | private:
|
---|
314 | QBoxLayout *parent;
|
---|
315 | QBoxLayout *thisLayout;
|
---|
316 | QLabel *titleLabel;
|
---|
317 | QLineEdit *inputBox;
|
---|
318 | QComboBox *comboBox;
|
---|
319 | Dialog *dialog;
|
---|
320 | };
|
---|
321 |
|
---|
322 | class QtDialog::KeyValuePairsQtQuery : public QWidget, public QtQuery<std::vector<KeyValuePair> >, public QtQueryList<KeyValuePair> {
|
---|
323 | Q_OBJECT
|
---|
324 | public:
|
---|
325 | KeyValuePairsQtQuery(Parameter<std::vector<KeyValuePair> > &, const std::string &_title, const std::string &description, QBoxLayout *_parent,Dialog *_dialog);
|
---|
326 | virtual ~KeyValuePairsQtQuery();
|
---|
327 |
|
---|
328 | virtual void onSubUpdate();
|
---|
329 |
|
---|
330 | public slots:
|
---|
331 | void onAddElement();
|
---|
332 | void onRemoveElement();
|
---|
333 | void onElementSelected();
|
---|
334 |
|
---|
335 | private:
|
---|
336 | KeyValuePairQtQuery *subQuery;
|
---|
337 | };
|
---|
338 |
|
---|
339 | class QtDialog::StringQtQuery : public QWidget, public QtQuery<std::string> {
|
---|
340 | Q_OBJECT
|
---|
341 | public:
|
---|
342 | StringQtQuery(Parameter<std::string> &, const std::string &_title, const std::string &description, QBoxLayout *_parent,Dialog *_dialog);
|
---|
343 | virtual ~StringQtQuery();
|
---|
344 |
|
---|
345 | public slots:
|
---|
346 | void onUpdate(const QString&);
|
---|
347 | void onUpdateCombo(int index);
|
---|
348 |
|
---|
349 | private:
|
---|
350 | QBoxLayout *parent;
|
---|
351 | QBoxLayout *thisLayout;
|
---|
352 | QLabel *titleLabel;
|
---|
353 | QLineEdit *inputBox;
|
---|
354 | QComboBox *comboBox;
|
---|
355 | Dialog *dialog;
|
---|
356 | };
|
---|
357 |
|
---|
358 | class QtDialog::StringsQtQuery : public QWidget, public QtQuery<std::vector<std::string> >, public QtQueryList<std::string> {
|
---|
359 | Q_OBJECT
|
---|
360 | public:
|
---|
361 | StringsQtQuery(Parameter<std::vector<std::string> > &, const std::string &_title, const std::string &description, QBoxLayout *_parent,Dialog *_dialog);
|
---|
362 | virtual ~StringsQtQuery();
|
---|
363 |
|
---|
364 | virtual void onSubUpdate();
|
---|
365 |
|
---|
366 | public slots:
|
---|
367 | void onAddElement();
|
---|
368 | void onRemoveElement();
|
---|
369 | void onElementSelected();
|
---|
370 |
|
---|
371 | private:
|
---|
372 | StringQtQuery *subQuery;
|
---|
373 | };
|
---|
374 |
|
---|
375 | class QtDialog::UnsignedIntQtQuery : public QWidget, public QtQuery<unsigned int> {
|
---|
376 | Q_OBJECT
|
---|
377 | public:
|
---|
378 | UnsignedIntQtQuery(Parameter<unsigned int> &, const std::string &_title, const std::string &description,QBoxLayout *_parent,Dialog *_dialog);
|
---|
379 | virtual ~UnsignedIntQtQuery();
|
---|
380 |
|
---|
381 | public slots:
|
---|
382 | void onUpdate(int);
|
---|
383 |
|
---|
384 | private:
|
---|
385 | QBoxLayout *parent;
|
---|
386 | QBoxLayout *thisLayout;
|
---|
387 | QLabel *titleLabel;
|
---|
388 | QSpinBox *inputBox;
|
---|
389 | Dialog *dialog;
|
---|
390 | };
|
---|
391 |
|
---|
392 | class QtDialog::UnsignedIntsQtQuery : public QWidget, public QtQuery<std::vector<unsigned int> >, public QtQueryList<unsigned int> {
|
---|
393 | Q_OBJECT
|
---|
394 | public:
|
---|
395 | UnsignedIntsQtQuery(Parameter<std::vector<unsigned int> > &, const std::string &_title, const std::string &description, QBoxLayout *_parent,Dialog *_dialog);
|
---|
396 | virtual ~UnsignedIntsQtQuery();
|
---|
397 |
|
---|
398 | virtual void onSubUpdate();
|
---|
399 |
|
---|
400 | public slots:
|
---|
401 | void onAddElement();
|
---|
402 | void onRemoveElement();
|
---|
403 | void onElementSelected();
|
---|
404 |
|
---|
405 | private:
|
---|
406 | UnsignedIntQtQuery *subQuery;
|
---|
407 | };
|
---|
408 |
|
---|
409 | class QtDialog::VectorQtQuery : public QWidget, public QtQuery<Vector> {
|
---|
410 | Q_OBJECT
|
---|
411 | public:
|
---|
412 | VectorQtQuery(Parameter<Vector> &, const std::string &_title, const std::string &_description,QBoxLayout *,Dialog *);
|
---|
413 | virtual ~VectorQtQuery();
|
---|
414 |
|
---|
415 | public slots:
|
---|
416 | void onUpdateX(double);
|
---|
417 | void onUpdateY(double);
|
---|
418 | void onUpdateZ(double);
|
---|
419 |
|
---|
420 | private:
|
---|
421 | QBoxLayout *parent;
|
---|
422 | QBoxLayout *mainLayout;
|
---|
423 | QLabel *titleLabel;
|
---|
424 | QBoxLayout *subLayout;
|
---|
425 | QBoxLayout *coordLayout;
|
---|
426 | QLabel *coordLabel;
|
---|
427 | QDoubleSpinBox *coordInputX;
|
---|
428 | QDoubleSpinBox *coordInputY;
|
---|
429 | QDoubleSpinBox *coordInputZ;
|
---|
430 | Dialog *dialog;
|
---|
431 | };
|
---|
432 |
|
---|
433 | class QtDialog::VectorsQtQuery : public QWidget, public QtQuery<std::vector<Vector> >, public QtQueryList<Vector> {
|
---|
434 | Q_OBJECT
|
---|
435 | public:
|
---|
436 | VectorsQtQuery(Parameter<std::vector<Vector> > &, const std::string &_title, const std::string &description, QBoxLayout *_parent,Dialog *_dialog);
|
---|
437 | virtual ~VectorsQtQuery();
|
---|
438 |
|
---|
439 | virtual void onSubUpdate();
|
---|
440 |
|
---|
441 | public slots:
|
---|
442 | void onAddElement();
|
---|
443 | void onRemoveElement();
|
---|
444 | void onElementSelected();
|
---|
445 |
|
---|
446 | private:
|
---|
447 | VectorQtQuery *subQuery;
|
---|
448 | };
|
---|
449 |
|
---|
450 | #endif /* QTQUERY_HPP_ */
|
---|