1 | /*
|
---|
2 | * QTDialog.hpp
|
---|
3 | *
|
---|
4 | * Created on: Jan 18, 2010
|
---|
5 | * Author: crueger
|
---|
6 | */
|
---|
7 |
|
---|
8 | #ifndef QTDIALOG_HPP_
|
---|
9 | #define QTDIALOG_HPP_
|
---|
10 |
|
---|
11 | #include "UIElements/Dialog.hpp"
|
---|
12 | #include <QtGui/QDialog>
|
---|
13 | #include <QtGui/QFileDialog>
|
---|
14 |
|
---|
15 | #include <boost/filesystem.hpp>
|
---|
16 |
|
---|
17 | class QBoxLayout;
|
---|
18 | class QLabel;
|
---|
19 | class QSpinBox;
|
---|
20 | class QDoubleSpinBox;
|
---|
21 | class QLineEdit;
|
---|
22 | class QListWidget;
|
---|
23 | class QComboBox;
|
---|
24 | class QDialogButtonBox;
|
---|
25 |
|
---|
26 |
|
---|
27 | // Forward declarations for plumbing
|
---|
28 | template<typename T> class QTQueryListPipe;
|
---|
29 | class StringQTQueryPipe;
|
---|
30 | class StringsQTQueryPipe;
|
---|
31 | class IntQTQueryPipe;
|
---|
32 | class DoubleQTQueryPipe;
|
---|
33 | class DoublesQTQueryPipe;
|
---|
34 | class AtomQTQueryPipe;
|
---|
35 | class AtomsQTQueryPipe;
|
---|
36 | class MoleculeQTQueryPipe;
|
---|
37 | class MoleculesQTQueryPipe;
|
---|
38 | class ElementQTQueryPipe;
|
---|
39 | class ElementsQTQueryPipe;
|
---|
40 | class VectorQTQueryPipe;
|
---|
41 | class VectorsQTQueryPipe;
|
---|
42 | class FileQTQueryPipe;
|
---|
43 |
|
---|
44 | class QTDialog : public QDialog, public Dialog
|
---|
45 | {
|
---|
46 | Q_OBJECT
|
---|
47 | public:
|
---|
48 | QTDialog();
|
---|
49 | virtual ~QTDialog();
|
---|
50 |
|
---|
51 | virtual void queryEmpty(const char*, std::string);
|
---|
52 | virtual void queryBoolean(const char *, std::string = "");
|
---|
53 | virtual void queryInt(const char *,std::string = "");
|
---|
54 | virtual void queryInts(const char *,std::string = "");
|
---|
55 | virtual void queryDouble(const char*,std::string = "");
|
---|
56 | virtual void queryDoubles(const char*,std::string = "");
|
---|
57 | virtual void queryString(const char*,std::string = "");
|
---|
58 | virtual void queryStrings(const char*,std::string = "");
|
---|
59 | virtual void queryAtom(const char*,std::string = "");
|
---|
60 | virtual void queryAtoms(const char*,std::string = "");
|
---|
61 | virtual void queryMolecule(const char*,std::string = "");
|
---|
62 | virtual void queryMolecules(const char*,std::string = "");
|
---|
63 | virtual void queryVector(const char*,bool,std::string = "");
|
---|
64 | virtual void queryVectors(const char*,bool,std::string = "");
|
---|
65 | virtual void queryBox(const char*, std::string = "");
|
---|
66 | virtual void queryElement(const char*,std::string = "");
|
---|
67 | virtual void queryElements(const char*,std::string = "");
|
---|
68 | virtual void queryFile(const char*,std::string = "");
|
---|
69 |
|
---|
70 | virtual bool display();
|
---|
71 |
|
---|
72 | virtual void update();
|
---|
73 |
|
---|
74 | protected:
|
---|
75 | class IntQTQuery : public Dialog::IntQuery {
|
---|
76 | public:
|
---|
77 | IntQTQuery(std::string _title,QBoxLayout *_parent,QTDialog *_dialog);
|
---|
78 | virtual ~IntQTQuery();
|
---|
79 | virtual bool handle();
|
---|
80 | private:
|
---|
81 | QBoxLayout *parent;
|
---|
82 | QBoxLayout *thisLayout;
|
---|
83 | QLabel *titleLabel;
|
---|
84 | QSpinBox *inputBox;
|
---|
85 |
|
---|
86 | IntQTQueryPipe *pipe;
|
---|
87 | };
|
---|
88 |
|
---|
89 | class IntsQTQuery : public Dialog::IntsQuery {
|
---|
90 | public:
|
---|
91 | IntsQTQuery(std::string _title,QBoxLayout *_parent,QTDialog *_dialog);
|
---|
92 | virtual ~IntsQTQuery();
|
---|
93 | virtual bool handle();
|
---|
94 | void IntegerEntered(const QString&);
|
---|
95 | void IntegerSelected();
|
---|
96 | void AddInteger();
|
---|
97 | void RemoveInteger();
|
---|
98 | private:
|
---|
99 | QBoxLayout *parent;
|
---|
100 | QBoxLayout *thisLayout;
|
---|
101 | QLabel *titleLabel;
|
---|
102 |
|
---|
103 | QTQueryListPipe<int> *pipe;
|
---|
104 | };
|
---|
105 |
|
---|
106 | class DoubleQTQuery : public Dialog::DoubleQuery {
|
---|
107 | public:
|
---|
108 | DoubleQTQuery(std::string title,QBoxLayout *_parent,QTDialog *_dialog);
|
---|
109 | virtual ~DoubleQTQuery();
|
---|
110 | virtual bool handle();
|
---|
111 | private:
|
---|
112 | QBoxLayout *parent;
|
---|
113 | QBoxLayout *thisLayout;
|
---|
114 | QLabel *titleLabel;
|
---|
115 | QDoubleSpinBox *inputBox;
|
---|
116 |
|
---|
117 | DoubleQTQueryPipe *pipe;
|
---|
118 | };
|
---|
119 |
|
---|
120 | class DoublesQTQuery : public Dialog::DoublesQuery {
|
---|
121 | public:
|
---|
122 | DoublesQTQuery(std::string title,QBoxLayout *_parent,QTDialog *_dialog);
|
---|
123 | virtual ~DoublesQTQuery();
|
---|
124 | virtual bool handle();
|
---|
125 | private:
|
---|
126 | QBoxLayout *parent;
|
---|
127 | QBoxLayout *thisLayout;
|
---|
128 | QLabel *titleLabel;
|
---|
129 | QDoubleSpinBox *inputBox;
|
---|
130 |
|
---|
131 | QTQueryListPipe<double> *pipe;
|
---|
132 | };
|
---|
133 |
|
---|
134 | class StringQTQuery : public Dialog::StringQuery {
|
---|
135 | public:
|
---|
136 | StringQTQuery(std::string _title, QBoxLayout *_parent,QTDialog *_dialog);
|
---|
137 | virtual ~StringQTQuery();
|
---|
138 | virtual bool handle();
|
---|
139 | private:
|
---|
140 | QBoxLayout *parent;
|
---|
141 | QBoxLayout *thisLayout;
|
---|
142 | QLabel *titleLabel;
|
---|
143 | QLineEdit *inputBox;
|
---|
144 |
|
---|
145 | StringQTQueryPipe *pipe;
|
---|
146 | };
|
---|
147 |
|
---|
148 | class StringsQTQuery : public Dialog::StringsQuery {
|
---|
149 | public:
|
---|
150 | StringsQTQuery(std::string _title, QBoxLayout *_parent,QTDialog *_dialog);
|
---|
151 | virtual ~StringsQTQuery();
|
---|
152 | virtual bool handle();
|
---|
153 | private:
|
---|
154 | QBoxLayout *parent;
|
---|
155 | QBoxLayout *thisLayout;
|
---|
156 | QLabel *titleLabel;
|
---|
157 | QLineEdit *inputBox;
|
---|
158 |
|
---|
159 | QTQueryListPipe<std::string> *pipe;
|
---|
160 | };
|
---|
161 |
|
---|
162 | class AtomQTQuery : public Dialog::AtomQuery {
|
---|
163 | public:
|
---|
164 | AtomQTQuery(std::string _title, QBoxLayout *_parent,QTDialog *_dialog);
|
---|
165 | virtual ~AtomQTQuery();
|
---|
166 | virtual bool handle();
|
---|
167 | private:
|
---|
168 | QBoxLayout *parent;
|
---|
169 | QBoxLayout *thisLayout;
|
---|
170 | QLabel *titleLabel;
|
---|
171 | QComboBox *inputBox;
|
---|
172 |
|
---|
173 | AtomQTQueryPipe *pipe;
|
---|
174 | };
|
---|
175 |
|
---|
176 | class AtomsQTQuery : public Dialog::AtomsQuery {
|
---|
177 | public:
|
---|
178 | AtomsQTQuery(std::string _title, QBoxLayout *_parent,QTDialog *_dialog);
|
---|
179 | virtual ~AtomsQTQuery();
|
---|
180 | virtual bool handle();
|
---|
181 | private:
|
---|
182 | QBoxLayout *parent;
|
---|
183 | QBoxLayout *thisLayout;
|
---|
184 | QLabel *titleLabel;
|
---|
185 | QComboBox *inputBox;
|
---|
186 |
|
---|
187 | AtomsQTQueryPipe *pipe;
|
---|
188 | };
|
---|
189 |
|
---|
190 | class MoleculeQTQuery : public Dialog::MoleculeQuery {
|
---|
191 | public:
|
---|
192 | MoleculeQTQuery(std::string _title, QBoxLayout *_parent,QTDialog *_dialog);
|
---|
193 | virtual ~MoleculeQTQuery();
|
---|
194 | virtual bool handle();
|
---|
195 | private:
|
---|
196 | QBoxLayout *parent;
|
---|
197 | QBoxLayout *thisLayout;
|
---|
198 | QLabel *titleLabel;
|
---|
199 | QComboBox *inputBox;
|
---|
200 |
|
---|
201 | MoleculeQTQueryPipe *pipe;
|
---|
202 | };
|
---|
203 |
|
---|
204 | class MoleculesQTQuery : public Dialog::MoleculesQuery {
|
---|
205 | public:
|
---|
206 | MoleculesQTQuery(std::string _title, QBoxLayout *_parent,QTDialog *_dialog);
|
---|
207 | virtual ~MoleculesQTQuery();
|
---|
208 | virtual bool handle();
|
---|
209 | private:
|
---|
210 | QBoxLayout *parent;
|
---|
211 | QBoxLayout *thisLayout;
|
---|
212 | QLabel *titleLabel;
|
---|
213 | QComboBox *inputBox;
|
---|
214 |
|
---|
215 | MoleculesQTQueryPipe *pipe;
|
---|
216 | };
|
---|
217 |
|
---|
218 | class VectorQTQuery : public Dialog::VectorQuery {
|
---|
219 | public:
|
---|
220 | VectorQTQuery(std::string title,bool _check,QBoxLayout *,QTDialog *);
|
---|
221 | virtual ~VectorQTQuery();
|
---|
222 | virtual bool handle();
|
---|
223 | private:
|
---|
224 | QBoxLayout *parent;
|
---|
225 | QBoxLayout *mainLayout;
|
---|
226 | QLabel *titleLabel;
|
---|
227 | QBoxLayout *subLayout;
|
---|
228 | QBoxLayout *coordLayout;
|
---|
229 | QLabel *coordLabel;
|
---|
230 | QDoubleSpinBox *coordInput;
|
---|
231 |
|
---|
232 | VectorQTQueryPipe *pipe;
|
---|
233 | };
|
---|
234 |
|
---|
235 | class VectorsQTQuery : public Dialog::VectorsQuery {
|
---|
236 | public:
|
---|
237 | VectorsQTQuery(std::string title,bool _check,QBoxLayout *,QTDialog *);
|
---|
238 | virtual ~VectorsQTQuery();
|
---|
239 | virtual bool handle();
|
---|
240 | private:
|
---|
241 | QBoxLayout *parent;
|
---|
242 | QBoxLayout *mainLayout;
|
---|
243 | QLabel *titleLabel;
|
---|
244 | QBoxLayout *subLayout;
|
---|
245 | QBoxLayout *coordLayout;
|
---|
246 | QLabel *coordLabel;
|
---|
247 | QDoubleSpinBox *coordInput;
|
---|
248 |
|
---|
249 | VectorsQTQueryPipe *pipe;
|
---|
250 | };
|
---|
251 |
|
---|
252 | class ElementQTQuery : public Dialog::ElementQuery {
|
---|
253 | public:
|
---|
254 | ElementQTQuery(std::string _title, QBoxLayout *_parent, QTDialog *_dialog);
|
---|
255 | virtual ~ElementQTQuery();
|
---|
256 | virtual bool handle();
|
---|
257 | private:
|
---|
258 | QBoxLayout *parent;
|
---|
259 | QBoxLayout *thisLayout;
|
---|
260 | QLabel *titleLabel;
|
---|
261 | QComboBox *inputBox;
|
---|
262 |
|
---|
263 | ElementQTQueryPipe *pipe;
|
---|
264 | };
|
---|
265 |
|
---|
266 | class ElementsQTQuery : public Dialog::ElementsQuery {
|
---|
267 | public:
|
---|
268 | ElementsQTQuery(std::string _title, QBoxLayout *_parent, QTDialog *_dialog);
|
---|
269 | virtual ~ElementsQTQuery();
|
---|
270 | virtual bool handle();
|
---|
271 | private:
|
---|
272 | QBoxLayout *parent;
|
---|
273 | QBoxLayout *thisLayout;
|
---|
274 | QLabel *titleLabel;
|
---|
275 | QComboBox *inputBox;
|
---|
276 |
|
---|
277 | ElementsQTQueryPipe *pipe;
|
---|
278 | };
|
---|
279 |
|
---|
280 | class FileQTQuery : public Dialog::FileQuery {
|
---|
281 | public:
|
---|
282 | FileQTQuery(std::string _title, QBoxLayout *_parent, QTDialog *_dialog);
|
---|
283 | virtual ~FileQTQuery();
|
---|
284 | virtual bool handle();
|
---|
285 | private:
|
---|
286 | QBoxLayout *parent;
|
---|
287 | QBoxLayout *thisLayout;
|
---|
288 | QLineEdit *filenameLineEdit;
|
---|
289 | QPushButton *filedialogButton;
|
---|
290 |
|
---|
291 | FileQTQueryPipe *pipe;
|
---|
292 | };
|
---|
293 |
|
---|
294 | private:
|
---|
295 | QBoxLayout *mainLayout;
|
---|
296 | QBoxLayout *inputLayout;
|
---|
297 | QBoxLayout *buttonLayout;
|
---|
298 | QDialogButtonBox *buttons;
|
---|
299 | };
|
---|
300 |
|
---|
301 | // All kinds of plumbing for Queries
|
---|
302 | // Plumbing needs to be outside of the class where it is needed,
|
---|
303 | // since MOC doesn't like nested classes
|
---|
304 |
|
---|
305 |
|
---|
306 | template<typename T> class QTQueryListPipe : public QWidget {
|
---|
307 | public:
|
---|
308 | QTQueryListPipe(std::vector<T> *_content, QTDialog *_dialog, QLineEdit *_inputBox, QListWidget *_inputList, QPushButton *_AddButton, QPushButton *_RemoveButton);
|
---|
309 | virtual ~QTQueryListPipe();
|
---|
310 | void AddInteger();
|
---|
311 | void RemoveInteger();
|
---|
312 | void IntegerSelected();
|
---|
313 | void IntegerEntered(const QString&);
|
---|
314 |
|
---|
315 | private:
|
---|
316 | void AddValue(T item);
|
---|
317 | void RemoveRow(int row);
|
---|
318 |
|
---|
319 | std::vector<T> *content;
|
---|
320 | QTDialog *dialog;
|
---|
321 | QLineEdit *inputBox;
|
---|
322 | QListWidget *inputList;
|
---|
323 | QPushButton *AddButton;
|
---|
324 | QPushButton *RemoveButton;
|
---|
325 | };
|
---|
326 |
|
---|
327 |
|
---|
328 | class StringQTQueryPipe : public QWidget {
|
---|
329 | Q_OBJECT
|
---|
330 | public:
|
---|
331 | StringQTQueryPipe(std::string *_content, QTDialog *_dialog);
|
---|
332 | virtual ~StringQTQueryPipe();
|
---|
333 |
|
---|
334 | public slots:
|
---|
335 | void update(const QString&);
|
---|
336 |
|
---|
337 | private:
|
---|
338 | std::string *content;
|
---|
339 | QTDialog *dialog;
|
---|
340 |
|
---|
341 | };
|
---|
342 |
|
---|
343 | class IntQTQueryPipe : public QWidget {
|
---|
344 | Q_OBJECT
|
---|
345 | public:
|
---|
346 | IntQTQueryPipe(int *_content, QTDialog *_dialog);
|
---|
347 | virtual ~IntQTQueryPipe();
|
---|
348 |
|
---|
349 | public slots:
|
---|
350 | void update(int);
|
---|
351 |
|
---|
352 | private:
|
---|
353 | int *content;
|
---|
354 | QTDialog *dialog;
|
---|
355 |
|
---|
356 | };
|
---|
357 |
|
---|
358 |
|
---|
359 | class DoubleQTQueryPipe : public QWidget {
|
---|
360 | Q_OBJECT
|
---|
361 | public:
|
---|
362 | DoubleQTQueryPipe(double *_content, QTDialog *_dialog);
|
---|
363 | virtual ~DoubleQTQueryPipe();
|
---|
364 |
|
---|
365 | public slots:
|
---|
366 | void update(double);
|
---|
367 |
|
---|
368 | private:
|
---|
369 | double *content;
|
---|
370 | QTDialog *dialog;
|
---|
371 |
|
---|
372 | };
|
---|
373 |
|
---|
374 | class AtomQTQueryPipe : public QWidget {
|
---|
375 | Q_OBJECT
|
---|
376 | public:
|
---|
377 | AtomQTQueryPipe(atom **_content, QTDialog *_dialog, QComboBox *_theBox);
|
---|
378 | virtual ~AtomQTQueryPipe();
|
---|
379 |
|
---|
380 | public slots:
|
---|
381 | void update(int);
|
---|
382 |
|
---|
383 | private:
|
---|
384 | atom **content;
|
---|
385 | QTDialog *dialog;
|
---|
386 | QComboBox *theBox;
|
---|
387 |
|
---|
388 | };
|
---|
389 |
|
---|
390 |
|
---|
391 | class AtomsQTQueryPipe : public QWidget {
|
---|
392 | Q_OBJECT
|
---|
393 | public:
|
---|
394 | AtomsQTQueryPipe(std::vector<atom *>*_content, QTDialog *_dialog, QComboBox *_theBox);
|
---|
395 | virtual ~AtomsQTQueryPipe();
|
---|
396 |
|
---|
397 | public slots:
|
---|
398 | void update(int);
|
---|
399 |
|
---|
400 | private:
|
---|
401 | std::vector<atom *>*content;
|
---|
402 | QTDialog *dialog;
|
---|
403 | QComboBox *theBox;
|
---|
404 |
|
---|
405 | };
|
---|
406 |
|
---|
407 | class MoleculeQTQueryPipe : public QWidget {
|
---|
408 | Q_OBJECT
|
---|
409 | public:
|
---|
410 | MoleculeQTQueryPipe(molecule **_content, QTDialog *_dialog, QComboBox *_theBox);
|
---|
411 | virtual ~MoleculeQTQueryPipe();
|
---|
412 |
|
---|
413 | public slots:
|
---|
414 | void update(int);
|
---|
415 |
|
---|
416 | private:
|
---|
417 | molecule **content;
|
---|
418 | QTDialog *dialog;
|
---|
419 | QComboBox *theBox;
|
---|
420 |
|
---|
421 | };
|
---|
422 |
|
---|
423 | class MoleculesQTQueryPipe : public QWidget {
|
---|
424 | Q_OBJECT
|
---|
425 | public:
|
---|
426 | MoleculesQTQueryPipe(std::vector<molecule *>*_content, QTDialog *_dialog, QComboBox *_theBox);
|
---|
427 | virtual ~MoleculesQTQueryPipe();
|
---|
428 |
|
---|
429 | public slots:
|
---|
430 | void update(int);
|
---|
431 |
|
---|
432 | private:
|
---|
433 | std::vector<molecule *>*content;
|
---|
434 | QTDialog *dialog;
|
---|
435 | QComboBox *theBox;
|
---|
436 |
|
---|
437 | };
|
---|
438 |
|
---|
439 | class VectorQTQueryPipe : public QWidget {
|
---|
440 | Q_OBJECT
|
---|
441 | public:
|
---|
442 | VectorQTQueryPipe(Vector *_content, QTDialog *_dialog, QComboBox *_theBox);
|
---|
443 | virtual ~VectorQTQueryPipe();
|
---|
444 |
|
---|
445 | public slots:
|
---|
446 | void update();
|
---|
447 |
|
---|
448 | private:
|
---|
449 | Vector *content;
|
---|
450 | QTDialog *dialog;
|
---|
451 | QComboBox *theBox;
|
---|
452 | };
|
---|
453 |
|
---|
454 | class VectorsQTQueryPipe : public QWidget {
|
---|
455 | Q_OBJECT
|
---|
456 | public:
|
---|
457 | VectorsQTQueryPipe(std::vector<Vector>*_content, QTDialog *_dialog, QComboBox *_theBox);
|
---|
458 | virtual ~VectorsQTQueryPipe();
|
---|
459 |
|
---|
460 | public slots:
|
---|
461 | void update();
|
---|
462 |
|
---|
463 | private:
|
---|
464 | std::vector<Vector> *content;
|
---|
465 | QTDialog *dialog;
|
---|
466 | QComboBox *theBox;
|
---|
467 | };
|
---|
468 |
|
---|
469 | class ElementQTQueryPipe : public QWidget {
|
---|
470 | Q_OBJECT
|
---|
471 | public:
|
---|
472 | ElementQTQueryPipe(const element **_content, QTDialog *_dialog, QComboBox *_theBox);
|
---|
473 | virtual ~ElementQTQueryPipe();
|
---|
474 |
|
---|
475 | public slots:
|
---|
476 | void update(int);
|
---|
477 |
|
---|
478 | private:
|
---|
479 | const element **content;
|
---|
480 | QTDialog *dialog;
|
---|
481 | QComboBox *theBox;
|
---|
482 | };
|
---|
483 |
|
---|
484 | class ElementsQTQueryPipe : public QWidget {
|
---|
485 | Q_OBJECT
|
---|
486 | public:
|
---|
487 | ElementsQTQueryPipe(std::vector<const element *>*_content, QTDialog *_dialog, QComboBox *_theBox);
|
---|
488 | virtual ~ElementsQTQueryPipe();
|
---|
489 |
|
---|
490 | public slots:
|
---|
491 | void update(int);
|
---|
492 |
|
---|
493 | private:
|
---|
494 | std::vector<const element *>*content;
|
---|
495 | QTDialog *dialog;
|
---|
496 | QComboBox *theBox;
|
---|
497 | };
|
---|
498 |
|
---|
499 | class FileQTQueryPipe : public QWidget {
|
---|
500 | Q_OBJECT
|
---|
501 | public:
|
---|
502 | FileQTQueryPipe(const boost::filesystem::path &_content, QTDialog *_dialog, QLineEdit *_filenameLineEdit, QPushButton *_filedialogButton);
|
---|
503 | virtual ~FileQTQueryPipe();
|
---|
504 |
|
---|
505 | public slots:
|
---|
506 | void update();
|
---|
507 | void showFileDialog();
|
---|
508 |
|
---|
509 | private:
|
---|
510 | boost::filesystem::path content;
|
---|
511 | QTDialog *dialog;
|
---|
512 | QLineEdit *filenameLineEdit;
|
---|
513 | QPushButton *filedialogButton;
|
---|
514 | QFileDialog *theFileDialog;
|
---|
515 | };
|
---|
516 |
|
---|
517 | #endif /* QTDIALOG_HPP_ */
|
---|