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 QComboBox;
|
---|
20 | class QDialogButtonBox;
|
---|
21 |
|
---|
22 |
|
---|
23 | // Forward declarations for plumbing
|
---|
24 | class StringQTQueryPipe;
|
---|
25 | class IntQTQueryPipe;
|
---|
26 | class DoubleQTQueryPipe;
|
---|
27 | class MoleculeQTQueryPipe;
|
---|
28 | class ElementQTQueryPipe;
|
---|
29 |
|
---|
30 | class QTDialog : public QDialog, public Dialog
|
---|
31 | {
|
---|
32 | Q_OBJECT
|
---|
33 | public:
|
---|
34 | QTDialog();
|
---|
35 | virtual ~QTDialog();
|
---|
36 |
|
---|
37 | virtual void queryEmpty(const char*, std::string);
|
---|
38 | virtual void queryBoolean(const char *, bool *, std::string = "");
|
---|
39 | virtual void queryInt(const char *, int *,std::string = "");
|
---|
40 | virtual void queryDouble(const char*,double *,std::string = "");
|
---|
41 | virtual void queryString(const char*, std::string *,std::string = "");
|
---|
42 | virtual void queryStrings(const char*, std::vector<std::string> *,std::string = "");
|
---|
43 | virtual void queryAtom(const char*,atom**,std::string = "");
|
---|
44 | virtual void queryMolecule(const char*,molecule**,std::string = "");
|
---|
45 | virtual void queryVector(const char*,Vector *,bool,std::string = "");
|
---|
46 | virtual void queryBox(const char*,Box*, std::string = "");
|
---|
47 | virtual void queryElement(const char*,std::vector<element *> *_target,std::string = "");
|
---|
48 |
|
---|
49 | virtual bool display();
|
---|
50 |
|
---|
51 | virtual void update();
|
---|
52 |
|
---|
53 | protected:
|
---|
54 | class IntQTQuery : public Dialog::IntQuery {
|
---|
55 | public:
|
---|
56 | IntQTQuery(std::string _title, int *_target,QBoxLayout *_parent,QTDialog *_dialog);
|
---|
57 | virtual ~IntQTQuery();
|
---|
58 | virtual bool handle();
|
---|
59 | private:
|
---|
60 | QBoxLayout *parent;
|
---|
61 | QBoxLayout *thisLayout;
|
---|
62 | QLabel *titleLabel;
|
---|
63 | QSpinBox *inputBox;
|
---|
64 |
|
---|
65 | IntQTQueryPipe *pipe;
|
---|
66 | };
|
---|
67 |
|
---|
68 | class DoubleQTQuery : public Dialog::DoubleQuery {
|
---|
69 | public:
|
---|
70 | DoubleQTQuery(std::string title, double *_target,QBoxLayout *_parent,QTDialog *_dialog);
|
---|
71 | virtual ~DoubleQTQuery();
|
---|
72 | virtual bool handle();
|
---|
73 | private:
|
---|
74 | QBoxLayout *parent;
|
---|
75 | QBoxLayout *thisLayout;
|
---|
76 | QLabel *titleLabel;
|
---|
77 | QDoubleSpinBox *inputBox;
|
---|
78 |
|
---|
79 | DoubleQTQueryPipe *pipe;
|
---|
80 | };
|
---|
81 |
|
---|
82 | class StringQTQuery : public Dialog::StringQuery {
|
---|
83 | public:
|
---|
84 | StringQTQuery(std::string _title, std::string *_target, QBoxLayout *_parent,QTDialog *_dialog);
|
---|
85 | virtual ~StringQTQuery();
|
---|
86 | virtual bool handle();
|
---|
87 | private:
|
---|
88 | QBoxLayout *parent;
|
---|
89 | QBoxLayout *thisLayout;
|
---|
90 | QLabel *titleLabel;
|
---|
91 | QLineEdit *inputBox;
|
---|
92 |
|
---|
93 | StringQTQueryPipe *pipe;
|
---|
94 | };
|
---|
95 |
|
---|
96 | class StringsQTQuery : public Dialog::StringsQuery {
|
---|
97 | public:
|
---|
98 | StringsQTQuery(std::string _title, std::vector<std::string> *_target, QBoxLayout *_parent,QTDialog *_dialog);
|
---|
99 | virtual ~StringsQTQuery();
|
---|
100 | virtual bool handle();
|
---|
101 | private:
|
---|
102 | QBoxLayout *parent;
|
---|
103 | QBoxLayout *thisLayout;
|
---|
104 | QLabel *titleLabel;
|
---|
105 | QLineEdit *inputBox;
|
---|
106 |
|
---|
107 | StringQTQueryPipe *pipe;
|
---|
108 | };
|
---|
109 |
|
---|
110 | class MoleculeQTQuery : public Dialog::MoleculeQuery {
|
---|
111 | public:
|
---|
112 | MoleculeQTQuery(std::string _title, molecule **_target, QBoxLayout *_parent,QTDialog *_dialog);
|
---|
113 | virtual ~MoleculeQTQuery();
|
---|
114 | virtual bool handle();
|
---|
115 | private:
|
---|
116 | QBoxLayout *parent;
|
---|
117 | QBoxLayout *thisLayout;
|
---|
118 | QLabel *titleLabel;
|
---|
119 | QComboBox *inputBox;
|
---|
120 |
|
---|
121 | MoleculeQTQueryPipe *pipe;
|
---|
122 | };
|
---|
123 |
|
---|
124 | class VectorQTQuery : public Dialog::VectorQuery {
|
---|
125 | public:
|
---|
126 | VectorQTQuery(std::string title,Vector *_target,bool _check,QBoxLayout *,QTDialog *);
|
---|
127 | virtual ~VectorQTQuery();
|
---|
128 | virtual bool handle();
|
---|
129 | private:
|
---|
130 | QBoxLayout *parent;
|
---|
131 | QBoxLayout *mainLayout;
|
---|
132 | QLabel *titleLabel;
|
---|
133 | QBoxLayout *subLayout;
|
---|
134 | QBoxLayout *coordLayout[3];
|
---|
135 | QLabel *coordLabel[3];
|
---|
136 | QDoubleSpinBox *coordInput[3];
|
---|
137 |
|
---|
138 | DoubleQTQueryPipe *pipe[3];
|
---|
139 | };
|
---|
140 |
|
---|
141 | class ElementQTQuery : public Dialog::ElementQuery {
|
---|
142 | public:
|
---|
143 | ElementQTQuery(std::string _title, std::vector<element *> *_target, QBoxLayout *_parent, QTDialog *_dialog);
|
---|
144 | virtual ~ElementQTQuery();
|
---|
145 | virtual bool handle();
|
---|
146 | private:
|
---|
147 | QBoxLayout *parent;
|
---|
148 | QBoxLayout *thisLayout;
|
---|
149 | QLabel *titleLabel;
|
---|
150 | QComboBox *inputBox;
|
---|
151 |
|
---|
152 | ElementQTQueryPipe *pipe;
|
---|
153 | };
|
---|
154 |
|
---|
155 | private:
|
---|
156 | QBoxLayout *mainLayout;
|
---|
157 | QBoxLayout *inputLayout;
|
---|
158 | QBoxLayout *buttonLayout;
|
---|
159 | QDialogButtonBox *buttons;
|
---|
160 | };
|
---|
161 |
|
---|
162 | // All kinds of plumbing for Queries
|
---|
163 | // Plumbing needs to be outside of the class where it is needed,
|
---|
164 | // since MOC doesn't like nested classes
|
---|
165 |
|
---|
166 | class StringQTQueryPipe : public QWidget {
|
---|
167 | Q_OBJECT
|
---|
168 | public:
|
---|
169 | StringQTQueryPipe(std::string *_content, QTDialog *_dialog);
|
---|
170 | virtual ~StringQTQueryPipe();
|
---|
171 |
|
---|
172 | public slots:
|
---|
173 | void update(const QString&);
|
---|
174 |
|
---|
175 | private:
|
---|
176 | std::string *content;
|
---|
177 | QTDialog *dialog;
|
---|
178 |
|
---|
179 | };
|
---|
180 |
|
---|
181 | class IntQTQueryPipe : public QWidget {
|
---|
182 | Q_OBJECT
|
---|
183 | public:
|
---|
184 | IntQTQueryPipe(int *_content, QTDialog *_dialog);
|
---|
185 | virtual ~IntQTQueryPipe();
|
---|
186 |
|
---|
187 | public slots:
|
---|
188 | void update(int);
|
---|
189 |
|
---|
190 | private:
|
---|
191 | int *content;
|
---|
192 | QTDialog *dialog;
|
---|
193 |
|
---|
194 | };
|
---|
195 |
|
---|
196 | class DoubleQTQueryPipe : public QWidget {
|
---|
197 | Q_OBJECT
|
---|
198 | public:
|
---|
199 | DoubleQTQueryPipe(double *_content, QTDialog *_dialog);
|
---|
200 | virtual ~DoubleQTQueryPipe();
|
---|
201 |
|
---|
202 | public slots:
|
---|
203 | void update(double);
|
---|
204 |
|
---|
205 | private:
|
---|
206 | double *content;
|
---|
207 | QTDialog *dialog;
|
---|
208 |
|
---|
209 | };
|
---|
210 |
|
---|
211 | class MoleculeQTQueryPipe : public QWidget {
|
---|
212 | Q_OBJECT
|
---|
213 | public:
|
---|
214 | MoleculeQTQueryPipe(molecule **_content, QTDialog *_dialog, QComboBox *_theBox);
|
---|
215 | virtual ~MoleculeQTQueryPipe();
|
---|
216 |
|
---|
217 | public slots:
|
---|
218 | void update(int);
|
---|
219 |
|
---|
220 | private:
|
---|
221 | molecule **content;
|
---|
222 | QTDialog *dialog;
|
---|
223 | QComboBox *theBox;
|
---|
224 |
|
---|
225 | };
|
---|
226 |
|
---|
227 | class ElementQTQueryPipe : public QWidget {
|
---|
228 | Q_OBJECT
|
---|
229 | public:
|
---|
230 | ElementQTQueryPipe(std::vector<element *> *_content, QTDialog *_dialog, QComboBox *_theBox);
|
---|
231 | virtual ~ElementQTQueryPipe();
|
---|
232 |
|
---|
233 | public slots:
|
---|
234 | void update(int);
|
---|
235 |
|
---|
236 | private:
|
---|
237 | std::vector<element *> *content;
|
---|
238 | QTDialog *dialog;
|
---|
239 | QComboBox *theBox;
|
---|
240 | };
|
---|
241 | #endif /* QTDIALOG_HPP_ */
|
---|