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