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