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 | #include <map>
|
---|
18 | #include <set>
|
---|
19 | #include <vector>
|
---|
20 |
|
---|
21 | class QBoxLayout;
|
---|
22 | class QLabel;
|
---|
23 | class QSpinBox;
|
---|
24 | class QDoubleSpinBox;
|
---|
25 | class QLineEdit;
|
---|
26 | class QListWidget;
|
---|
27 | class QTableWidget;
|
---|
28 | class QComboBox;
|
---|
29 | class QDialogButtonBox;
|
---|
30 |
|
---|
31 | class Matrix;
|
---|
32 |
|
---|
33 |
|
---|
34 | class QtDialog : public QDialog, public Dialog
|
---|
35 | {
|
---|
36 | Q_OBJECT
|
---|
37 | public:
|
---|
38 | QtDialog();
|
---|
39 | virtual ~QtDialog();
|
---|
40 |
|
---|
41 | virtual void queryEmpty(const char*, std::string);
|
---|
42 | virtual void queryBoolean(const char *, std::string = "");
|
---|
43 | virtual void queryInt(const char *,std::string = "");
|
---|
44 | virtual void queryInts(const char *,std::string = "");
|
---|
45 | virtual void queryDouble(const char*,std::string = "");
|
---|
46 | virtual void queryDoubles(const char*,std::string = "");
|
---|
47 | virtual void queryString(const char*,std::string = "");
|
---|
48 | virtual void queryStrings(const char*,std::string = "");
|
---|
49 | virtual void queryAtom(const char*,std::string = "");
|
---|
50 | virtual void queryAtoms(const char*,std::string = "");
|
---|
51 | virtual void queryMolecule(const char*,std::string = "");
|
---|
52 | virtual void queryMolecules(const char*,std::string = "");
|
---|
53 | virtual void queryVector(const char*,bool,std::string = "");
|
---|
54 | virtual void queryVectors(const char*,bool,std::string = "");
|
---|
55 | virtual void queryBox(const char*, std::string = "");
|
---|
56 | virtual void queryElement(const char*,std::string = "");
|
---|
57 | virtual void queryElements(const char*,std::string = "");
|
---|
58 | virtual void queryFile(const char*,std::string = "");
|
---|
59 |
|
---|
60 | virtual bool display();
|
---|
61 |
|
---|
62 | virtual void update();
|
---|
63 |
|
---|
64 | protected:
|
---|
65 | class AtomQtQuery;
|
---|
66 | class AtomsQtQuery;
|
---|
67 | class BooleanQtQuery;
|
---|
68 | class BoxQtQuery;
|
---|
69 | class DoubleQtQuery;
|
---|
70 | class DoublesQtQuery;
|
---|
71 | class ElementQtQuery;
|
---|
72 | class ElementsQtQuery;
|
---|
73 | class EmptyQtQuery;
|
---|
74 | class FileQtQuery;
|
---|
75 | class IntQtQuery;
|
---|
76 | class IntsQtQuery;
|
---|
77 | class MoleculeQtQuery;
|
---|
78 | class MoleculesQtQuery;
|
---|
79 | class StringQtQuery;
|
---|
80 | class StringsQtQuery;
|
---|
81 | class VectorQtQuery;
|
---|
82 | class VectorsQtQuery;
|
---|
83 |
|
---|
84 | private:
|
---|
85 | QBoxLayout *mainLayout;
|
---|
86 | QBoxLayout *inputLayout;
|
---|
87 | QBoxLayout *buttonLayout;
|
---|
88 | QDialogButtonBox *buttons;
|
---|
89 | };
|
---|
90 |
|
---|
91 | // All kinds of plumbing for Queries
|
---|
92 | // Plumbing needs to be outside of the class where it is needed,
|
---|
93 | // since MOC doesn't like nested classes
|
---|
94 |
|
---|
95 |
|
---|
96 | template<typename T> class QtQueryListPipe : public QWidget {
|
---|
97 | public:
|
---|
98 | QtQueryListPipe(std::vector<T> *_content, QtDialog *_dialog, QLineEdit *_inputBox, QListWidget *_inputList, QPushButton *_AddButton, QPushButton *_RemoveButton);
|
---|
99 | virtual ~QtQueryListPipe();
|
---|
100 | void AddInteger();
|
---|
101 | void RemoveInteger();
|
---|
102 | void IntegerSelected();
|
---|
103 | void IntegerEntered(const QString&);
|
---|
104 |
|
---|
105 | private:
|
---|
106 | void AddValue(T item);
|
---|
107 | void RemoveRow(int row);
|
---|
108 |
|
---|
109 | std::vector<T> *content;
|
---|
110 | QtDialog *dialog;
|
---|
111 | QLineEdit *inputBox;
|
---|
112 | QListWidget *inputList;
|
---|
113 | QPushButton *AddButton;
|
---|
114 | QPushButton *RemoveButton;
|
---|
115 | };
|
---|
116 |
|
---|
117 |
|
---|
118 | class StringQtQueryPipe : public QWidget {
|
---|
119 | Q_OBJECT
|
---|
120 | public:
|
---|
121 | StringQtQueryPipe(std::string *_content, QtDialog *_dialog);
|
---|
122 | virtual ~StringQtQueryPipe();
|
---|
123 |
|
---|
124 | public slots:
|
---|
125 | void update(const QString&);
|
---|
126 |
|
---|
127 | private:
|
---|
128 | std::string *content;
|
---|
129 | QtDialog *dialog;
|
---|
130 |
|
---|
131 | };
|
---|
132 |
|
---|
133 | class IntQtQueryPipe : public QWidget {
|
---|
134 | Q_OBJECT
|
---|
135 | public:
|
---|
136 | IntQtQueryPipe(int *_content, QtDialog *_dialog);
|
---|
137 | virtual ~IntQtQueryPipe();
|
---|
138 |
|
---|
139 | public slots:
|
---|
140 | void update(int);
|
---|
141 |
|
---|
142 | private:
|
---|
143 | int *content;
|
---|
144 | QtDialog *dialog;
|
---|
145 |
|
---|
146 | };
|
---|
147 |
|
---|
148 |
|
---|
149 | class DoubleQtQueryPipe : public QWidget {
|
---|
150 | Q_OBJECT
|
---|
151 | public:
|
---|
152 | DoubleQtQueryPipe(double *_content, QtDialog *_dialog);
|
---|
153 | virtual ~DoubleQtQueryPipe();
|
---|
154 |
|
---|
155 | public slots:
|
---|
156 | void update(double);
|
---|
157 |
|
---|
158 | private:
|
---|
159 | double *content;
|
---|
160 | QtDialog *dialog;
|
---|
161 |
|
---|
162 | };
|
---|
163 |
|
---|
164 | class BoxQtQueryPipe : public QWidget {
|
---|
165 | Q_OBJECT
|
---|
166 | public:
|
---|
167 | BoxQtQueryPipe(Box &_content, QtDialog *_dialog, QTableWidget *_inputTable);
|
---|
168 | virtual ~BoxQtQueryPipe();
|
---|
169 |
|
---|
170 | public slots:
|
---|
171 | void update(int,int);
|
---|
172 |
|
---|
173 | private:
|
---|
174 | Box &content;
|
---|
175 | QtDialog *dialog;
|
---|
176 | QTableWidget *inputTable;
|
---|
177 |
|
---|
178 | Matrix *tmpM;
|
---|
179 | };
|
---|
180 |
|
---|
181 |
|
---|
182 | class AtomQtQueryPipe : public QWidget {
|
---|
183 | Q_OBJECT
|
---|
184 | public:
|
---|
185 | AtomQtQueryPipe(const atom **_content, QtDialog *_dialog, QComboBox *_theBox);
|
---|
186 | virtual ~AtomQtQueryPipe();
|
---|
187 |
|
---|
188 | public slots:
|
---|
189 | void update(int);
|
---|
190 |
|
---|
191 | private:
|
---|
192 | const atom **content;
|
---|
193 | QtDialog *dialog;
|
---|
194 | QComboBox *theBox;
|
---|
195 |
|
---|
196 | };
|
---|
197 |
|
---|
198 |
|
---|
199 | class AtomsQtQueryPipe : public QWidget {
|
---|
200 | Q_OBJECT
|
---|
201 | public:
|
---|
202 | AtomsQtQueryPipe(std::vector<const atom *>*_content, QtDialog *_dialog, QListWidget *_theList);
|
---|
203 | virtual ~AtomsQtQueryPipe();
|
---|
204 |
|
---|
205 | public slots:
|
---|
206 | void update();
|
---|
207 | void add();
|
---|
208 | void remove();
|
---|
209 |
|
---|
210 | private:
|
---|
211 | std::vector<const atom *>*content;
|
---|
212 | std::map<int, const atom *> lookup;
|
---|
213 | std::set<const atom *> currentList;
|
---|
214 | QtDialog *dialog;
|
---|
215 | QListWidget *theList;
|
---|
216 |
|
---|
217 | };
|
---|
218 |
|
---|
219 | class MoleculeQtQueryPipe : public QWidget {
|
---|
220 | Q_OBJECT
|
---|
221 | public:
|
---|
222 | MoleculeQtQueryPipe(const molecule **_content, QtDialog *_dialog, QComboBox *_theBox);
|
---|
223 | virtual ~MoleculeQtQueryPipe();
|
---|
224 |
|
---|
225 | public slots:
|
---|
226 | void update(int);
|
---|
227 |
|
---|
228 | private:
|
---|
229 | const molecule **content;
|
---|
230 | QtDialog *dialog;
|
---|
231 | QComboBox *theBox;
|
---|
232 |
|
---|
233 | };
|
---|
234 |
|
---|
235 | class MoleculesQtQueryPipe : public QWidget {
|
---|
236 | Q_OBJECT
|
---|
237 | public:
|
---|
238 | MoleculesQtQueryPipe(std::vector<const molecule *>*_content, QtDialog *_dialog, QComboBox *_theBox);
|
---|
239 | virtual ~MoleculesQtQueryPipe();
|
---|
240 |
|
---|
241 | public slots:
|
---|
242 | void update(int);
|
---|
243 |
|
---|
244 | private:
|
---|
245 | std::vector<const molecule *>*content;
|
---|
246 | QtDialog *dialog;
|
---|
247 | QComboBox *theBox;
|
---|
248 |
|
---|
249 | };
|
---|
250 |
|
---|
251 | class VectorQtQueryPipe : public QWidget {
|
---|
252 | Q_OBJECT
|
---|
253 | public:
|
---|
254 | VectorQtQueryPipe(Vector *_content, QtDialog *_dialog, QComboBox *_theBox);
|
---|
255 | virtual ~VectorQtQueryPipe();
|
---|
256 |
|
---|
257 | public slots:
|
---|
258 | void update();
|
---|
259 |
|
---|
260 | private:
|
---|
261 | Vector *content;
|
---|
262 | QtDialog *dialog;
|
---|
263 | QComboBox *theBox;
|
---|
264 | };
|
---|
265 |
|
---|
266 | class VectorsQtQueryPipe : public QWidget {
|
---|
267 | Q_OBJECT
|
---|
268 | public:
|
---|
269 | VectorsQtQueryPipe(std::vector<Vector>*_content, QtDialog *_dialog, QComboBox *_theBox);
|
---|
270 | virtual ~VectorsQtQueryPipe();
|
---|
271 |
|
---|
272 | public slots:
|
---|
273 | void update();
|
---|
274 |
|
---|
275 | private:
|
---|
276 | std::vector<Vector> *content;
|
---|
277 | QtDialog *dialog;
|
---|
278 | QComboBox *theBox;
|
---|
279 | };
|
---|
280 |
|
---|
281 | class EmptyQtQueryPipe : public QWidget {
|
---|
282 | Q_OBJECT
|
---|
283 | public:
|
---|
284 | EmptyQtQueryPipe(QtDialog *_dialog, QLabel *_textLabel);
|
---|
285 | virtual ~EmptyQtQueryPipe();
|
---|
286 |
|
---|
287 | public slots:
|
---|
288 | void update();
|
---|
289 |
|
---|
290 | private:
|
---|
291 | QtDialog *dialog;
|
---|
292 | QLabel *textLabel;
|
---|
293 | };
|
---|
294 |
|
---|
295 | class BooleanQtQueryPipe : public QWidget {
|
---|
296 | Q_OBJECT
|
---|
297 | public:
|
---|
298 | BooleanQtQueryPipe(const bool *_content, QtDialog *_dialog, QComboBox *_booleanComboBox);
|
---|
299 | virtual ~BooleanQtQueryPipe();
|
---|
300 |
|
---|
301 | public slots:
|
---|
302 | void update();
|
---|
303 |
|
---|
304 | private:
|
---|
305 | const bool *content;
|
---|
306 | QtDialog *dialog;
|
---|
307 | QComboBox *booleanComboBox;
|
---|
308 | };
|
---|
309 |
|
---|
310 | class ElementQtQueryPipe : public QWidget {
|
---|
311 | Q_OBJECT
|
---|
312 | public:
|
---|
313 | ElementQtQueryPipe(const element **_content, QtDialog *_dialog, QComboBox *_theBox);
|
---|
314 | virtual ~ElementQtQueryPipe();
|
---|
315 |
|
---|
316 | public slots:
|
---|
317 | void update(int);
|
---|
318 |
|
---|
319 | private:
|
---|
320 | const element **content;
|
---|
321 | QtDialog *dialog;
|
---|
322 | QComboBox *theBox;
|
---|
323 | };
|
---|
324 |
|
---|
325 | class ElementsQtQueryPipe : public QWidget {
|
---|
326 | Q_OBJECT
|
---|
327 | public:
|
---|
328 | ElementsQtQueryPipe(std::vector<const element *>*_content, QtDialog *_dialog, QComboBox *_theBox);
|
---|
329 | virtual ~ElementsQtQueryPipe();
|
---|
330 |
|
---|
331 | public slots:
|
---|
332 | void update(int);
|
---|
333 |
|
---|
334 | private:
|
---|
335 | std::vector<const element *>*content;
|
---|
336 | QtDialog *dialog;
|
---|
337 | QComboBox *theBox;
|
---|
338 | };
|
---|
339 |
|
---|
340 | class FileQtQueryPipe : public QWidget {
|
---|
341 | Q_OBJECT
|
---|
342 | public:
|
---|
343 | FileQtQueryPipe(boost::filesystem::path *_content, QtDialog *_dialog, QLineEdit *_filenameLineEdit, QPushButton *_filedialogButton);
|
---|
344 | virtual ~FileQtQueryPipe();
|
---|
345 |
|
---|
346 | public slots:
|
---|
347 | void update();
|
---|
348 | void showFileDialog();
|
---|
349 |
|
---|
350 | private:
|
---|
351 | boost::filesystem::path *content;
|
---|
352 | QtDialog *dialog;
|
---|
353 | QLineEdit *filenameLineEdit;
|
---|
354 | QPushButton *filedialogButton;
|
---|
355 | QFileDialog *theFileDialog;
|
---|
356 | };
|
---|
357 |
|
---|
358 | #endif /* QTDIALOG_HPP_ */
|
---|