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, std::string title, 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 *> &, std::string _title, 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 *> > &, std::string _title, 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> &, std::string _title, 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> &, std::string _title, 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> &, std::string title,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> > &, std::string _title, 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 *> &, std::string _title, 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 *> > &, std::string _title, 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(std::string _title, 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> &, std::string _title, 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 | };
|
---|
214 |
|
---|
215 | class QtDialog::FilesQtQuery : public QWidget, public QtQuery<std::vector<boost::filesystem::path> >, public QtQueryList<boost::filesystem::path> {
|
---|
216 | Q_OBJECT
|
---|
217 | public:
|
---|
218 | FilesQtQuery(Parameter<std::vector<boost::filesystem::path> > &, std::string _title, QBoxLayout *_parent,Dialog *_dialog);
|
---|
219 | virtual ~FilesQtQuery();
|
---|
220 |
|
---|
221 | virtual void onSubUpdate();
|
---|
222 |
|
---|
223 | public slots:
|
---|
224 | void onAddElement();
|
---|
225 | void onRemoveElement();
|
---|
226 | void onElementSelected();
|
---|
227 |
|
---|
228 | private:
|
---|
229 | FileQtQuery *subQuery;
|
---|
230 | };
|
---|
231 |
|
---|
232 | class QtDialog::IntQtQuery : public QWidget, public QtQuery<int> {
|
---|
233 | Q_OBJECT
|
---|
234 | public:
|
---|
235 | IntQtQuery(Parameter<int> &, std::string _title,QBoxLayout *_parent,Dialog *_dialog);
|
---|
236 | virtual ~IntQtQuery();
|
---|
237 |
|
---|
238 | public slots:
|
---|
239 | void onUpdate(int);
|
---|
240 |
|
---|
241 | private:
|
---|
242 | QBoxLayout *parent;
|
---|
243 | QBoxLayout *thisLayout;
|
---|
244 | QLabel *titleLabel;
|
---|
245 | QSpinBox *inputBox;
|
---|
246 | Dialog *dialog;
|
---|
247 | };
|
---|
248 |
|
---|
249 | class QtDialog::IntsQtQuery : public QWidget, public QtQuery<std::vector<int> >, public QtQueryList<int> {
|
---|
250 | Q_OBJECT
|
---|
251 | public:
|
---|
252 | IntsQtQuery(Parameter<std::vector<int> > &, std::string _title, QBoxLayout *_parent,Dialog *_dialog);
|
---|
253 | virtual ~IntsQtQuery();
|
---|
254 |
|
---|
255 | virtual void onSubUpdate();
|
---|
256 |
|
---|
257 | public slots:
|
---|
258 | void onAddElement();
|
---|
259 | void onRemoveElement();
|
---|
260 | void onElementSelected();
|
---|
261 |
|
---|
262 | private:
|
---|
263 | IntQtQuery *subQuery;
|
---|
264 | };
|
---|
265 |
|
---|
266 | class QtDialog::MoleculeQtQuery : public QWidget, public QtQuery<const molecule *> {
|
---|
267 | Q_OBJECT
|
---|
268 | public:
|
---|
269 | MoleculeQtQuery(Parameter<const molecule *> &, std::string _title, QBoxLayout *_parent,Dialog *_dialog);
|
---|
270 | virtual ~MoleculeQtQuery();
|
---|
271 |
|
---|
272 | public slots:
|
---|
273 | void onUpdate(int);
|
---|
274 |
|
---|
275 | private:
|
---|
276 | QBoxLayout *parent;
|
---|
277 | QBoxLayout *thisLayout;
|
---|
278 | QLabel *titleLabel;
|
---|
279 | QComboBox *inputBox;
|
---|
280 | Dialog *dialog;
|
---|
281 | };
|
---|
282 |
|
---|
283 | class QtDialog::MoleculesQtQuery : public QWidget, public QtQuery<std::vector<const molecule *> >, public QtQueryList<const molecule *> {
|
---|
284 | Q_OBJECT
|
---|
285 | public:
|
---|
286 | MoleculesQtQuery(Parameter<std::vector<const molecule *> > &, std::string _title, QBoxLayout *_parent,Dialog *_dialog);
|
---|
287 | virtual ~MoleculesQtQuery();
|
---|
288 |
|
---|
289 | virtual void onSubUpdate();
|
---|
290 |
|
---|
291 | public slots:
|
---|
292 | void onAddElement();
|
---|
293 | void onRemoveElement();
|
---|
294 | void onElementSelected();
|
---|
295 |
|
---|
296 | private:
|
---|
297 | MoleculeQtQuery *subQuery;
|
---|
298 | };
|
---|
299 |
|
---|
300 | class QtDialog::StringQtQuery : public QWidget, public QtQuery<std::string> {
|
---|
301 | Q_OBJECT
|
---|
302 | public:
|
---|
303 | StringQtQuery(Parameter<std::string> &, std::string _title, QBoxLayout *_parent,Dialog *_dialog);
|
---|
304 | virtual ~StringQtQuery();
|
---|
305 |
|
---|
306 | public slots:
|
---|
307 | void onUpdate(const QString&);
|
---|
308 |
|
---|
309 | private:
|
---|
310 | QBoxLayout *parent;
|
---|
311 | QBoxLayout *thisLayout;
|
---|
312 | QLabel *titleLabel;
|
---|
313 | QLineEdit *inputBox;
|
---|
314 | Dialog *dialog;
|
---|
315 | };
|
---|
316 |
|
---|
317 | class QtDialog::StringsQtQuery : public QWidget, public QtQuery<std::vector<std::string> >, public QtQueryList<std::string> {
|
---|
318 | Q_OBJECT
|
---|
319 | public:
|
---|
320 | StringsQtQuery(Parameter<std::vector<std::string> > &, std::string _title, QBoxLayout *_parent,Dialog *_dialog);
|
---|
321 | virtual ~StringsQtQuery();
|
---|
322 |
|
---|
323 | virtual void onSubUpdate();
|
---|
324 |
|
---|
325 | public slots:
|
---|
326 | void onAddElement();
|
---|
327 | void onRemoveElement();
|
---|
328 | void onElementSelected();
|
---|
329 |
|
---|
330 | private:
|
---|
331 | StringQtQuery *subQuery;
|
---|
332 | };
|
---|
333 |
|
---|
334 | class QtDialog::UnsignedIntQtQuery : public QWidget, public QtQuery<unsigned int> {
|
---|
335 | Q_OBJECT
|
---|
336 | public:
|
---|
337 | UnsignedIntQtQuery(Parameter<unsigned int> &, std::string _title,QBoxLayout *_parent,Dialog *_dialog);
|
---|
338 | virtual ~UnsignedIntQtQuery();
|
---|
339 |
|
---|
340 | public slots:
|
---|
341 | void onUpdate(int);
|
---|
342 |
|
---|
343 | private:
|
---|
344 | QBoxLayout *parent;
|
---|
345 | QBoxLayout *thisLayout;
|
---|
346 | QLabel *titleLabel;
|
---|
347 | QSpinBox *inputBox;
|
---|
348 | Dialog *dialog;
|
---|
349 | };
|
---|
350 |
|
---|
351 | class QtDialog::UnsignedIntsQtQuery : public QWidget, public QtQuery<std::vector<unsigned int> >, public QtQueryList<unsigned int> {
|
---|
352 | Q_OBJECT
|
---|
353 | public:
|
---|
354 | UnsignedIntsQtQuery(Parameter<std::vector<unsigned int> > &, std::string _title, QBoxLayout *_parent,Dialog *_dialog);
|
---|
355 | virtual ~UnsignedIntsQtQuery();
|
---|
356 |
|
---|
357 | virtual void onSubUpdate();
|
---|
358 |
|
---|
359 | public slots:
|
---|
360 | void onAddElement();
|
---|
361 | void onRemoveElement();
|
---|
362 | void onElementSelected();
|
---|
363 |
|
---|
364 | private:
|
---|
365 | UnsignedIntQtQuery *subQuery;
|
---|
366 | };
|
---|
367 |
|
---|
368 | class QtDialog::VectorQtQuery : public QWidget, public QtQuery<Vector> {
|
---|
369 | Q_OBJECT
|
---|
370 | public:
|
---|
371 | VectorQtQuery(Parameter<Vector> &, std::string title,QBoxLayout *,Dialog *);
|
---|
372 | virtual ~VectorQtQuery();
|
---|
373 |
|
---|
374 | public slots:
|
---|
375 | void onUpdateX(double);
|
---|
376 | void onUpdateY(double);
|
---|
377 | void onUpdateZ(double);
|
---|
378 |
|
---|
379 | private:
|
---|
380 | QBoxLayout *parent;
|
---|
381 | QBoxLayout *mainLayout;
|
---|
382 | QLabel *titleLabel;
|
---|
383 | QBoxLayout *subLayout;
|
---|
384 | QBoxLayout *coordLayout;
|
---|
385 | QLabel *coordLabel;
|
---|
386 | QDoubleSpinBox *coordInputX;
|
---|
387 | QDoubleSpinBox *coordInputY;
|
---|
388 | QDoubleSpinBox *coordInputZ;
|
---|
389 | Dialog *dialog;
|
---|
390 | };
|
---|
391 |
|
---|
392 | class QtDialog::VectorsQtQuery : public QWidget, public QtQuery<std::vector<Vector> >, public QtQueryList<Vector> {
|
---|
393 | Q_OBJECT
|
---|
394 | public:
|
---|
395 | VectorsQtQuery(Parameter<std::vector<Vector> > &, std::string _title, QBoxLayout *_parent,Dialog *_dialog);
|
---|
396 | virtual ~VectorsQtQuery();
|
---|
397 |
|
---|
398 | virtual void onSubUpdate();
|
---|
399 |
|
---|
400 | public slots:
|
---|
401 | void onAddElement();
|
---|
402 | void onRemoveElement();
|
---|
403 | void onElementSelected();
|
---|
404 |
|
---|
405 | private:
|
---|
406 | VectorQtQuery *subQuery;
|
---|
407 | };
|
---|
408 |
|
---|
409 | class QtDialog::RandomNumberDistribution_ParametersQtQuery : public QWidget, public QtQuery<RandomNumberDistribution_Parameters> {
|
---|
410 | Q_OBJECT
|
---|
411 | public:
|
---|
412 | RandomNumberDistribution_ParametersQtQuery(Parameter<RandomNumberDistribution_Parameters> &, std::string title,QBoxLayout *,Dialog *);
|
---|
413 | virtual ~RandomNumberDistribution_ParametersQtQuery();
|
---|
414 |
|
---|
415 | public slots:
|
---|
416 | void onUpdate();
|
---|
417 |
|
---|
418 | private:
|
---|
419 | QBoxLayout *parent;
|
---|
420 | QHBoxLayout *thisLayout;
|
---|
421 | QLabel *titleLabel;
|
---|
422 | QTextEdit *inputBox;
|
---|
423 | QPushButton *okButton;
|
---|
424 | Dialog *dialog;
|
---|
425 | };
|
---|
426 |
|
---|
427 | #endif /* QTQUERY_HPP_ */
|
---|