source: src/UIElements/Qt4/Query/QtQuery.hpp@ 2c97ad

Candidate_v1.6.1 ChemicalSpaceEvaluator Gui_displays_atomic_force_velocity PythonUI_with_named_parameters TremoloParser_IncreasedPrecision
Last change on this file since 2c97ad was f4b6bc9, checked in by Frederik Heber <frederik.heber@…>, 7 years ago

Query::handle() no longer returns bool but has internal result flag.

  • we use this flag conditionally in setResult(), i.e. if the handle() has failed, then we should not set its result which might overwrite a present default value in the parameter.
  • this fixes the problem with StepWorldTime which has a default value of 1 but which was overwritten with 0 because of the non-conditionally calling of setResult().
  • this required change of "output-types" default parameter to an empty vector. So far, we were just lucky that this actually worked.
  • also StoreSaturatedFragmentAction needed the same change as default values have to be consistent over the specific token.
  • Property mode set to 100644
File size: 11.7 KB
RevLine 
[308aa4]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
[56f73b]11// include config.h
12#ifdef HAVE_CONFIG_H
13#include <config.h>
14#endif
15
16
[7c9921]17#include <Qt/qwidget.h>
[308aa4]18#include "Qt4/QtDialog.hpp"
[7b8a8e]19#include "QtQueryList.hpp"
[308aa4]20
[33e801]21#include "Parameters/Parameter.hpp"
22
[0275ad]23class QHBoxLayout;
[a5ddf0]24class QBoxLayout;
25class QDialogButtonBox;
26class QLabel;
27class QSpinBox;
28class QDoubleSpinBox;
29class QLineEdit;
30class QListWidget;
[0275ad]31class QPushButton;
[a5ddf0]32class QTableWidget;
[0275ad]33class QTextEdit;
[a5ddf0]34class QComboBox;
[85b112]35class QCheckBox;
[7c9921]36class QFileDialog;
[a5ddf0]37
[852ea3]38template<class T>
39class QtQuery : public Dialog::TQuery<T>
40{
41public:
[f130d4]42 QtQuery(Parameter<T> &_param, const std::string &_title, const std::string &_description = "") :
43 Dialog::TQuery<T>(_param, _title, _description) {}
[852ea3]44 // QtQueries are interactive - no need for handle().
[f4b6bc9]45 virtual ~QtQuery() {}
46 virtual void handle(){ Dialog::TQuery<T>::handleSuccess = true; }
[852ea3]47};
48
49class QtDialog::AtomQtQuery : public QWidget, public QtQuery<const atom *> {
[7c9921]50 Q_OBJECT
[308aa4]51public:
[f130d4]52 AtomQtQuery(Parameter<const atom *> &, const std::string &_title, const std::string &description, QBoxLayout *_parent,Dialog *_dialog);
[308aa4]53 virtual ~AtomQtQuery();
[7c9921]54
55public slots:
56 void onUpdate(int);
57
[308aa4]58private:
59 QBoxLayout *parent;
60 QBoxLayout *thisLayout;
61 QLabel *titleLabel;
62 QComboBox *inputBox;
[7dfd07]63 Dialog *dialog;
[308aa4]64};
65
[852ea3]66class QtDialog::AtomsQtQuery : public QWidget, public QtQuery<std::vector<const atom *> >, public QtQueryList<const atom *> {
[7c9921]67 Q_OBJECT
[308aa4]68public:
[f130d4]69 AtomsQtQuery(Parameter<std::vector<const atom *> > &, const std::string &_title, const std::string &description, QBoxLayout *_parent,Dialog *_dialog);
[308aa4]70 virtual ~AtomsQtQuery();
[7c9921]71
[2f4e81]72 virtual void onSubUpdate();
73
[7c9921]74public slots:
[2f4e81]75 void onAddElement();
76 void onRemoveElement();
77 void onElementSelected();
[7c9921]78
[308aa4]79private:
[2f4e81]80 AtomQtQuery *subQuery;
[308aa4]81};
82
[852ea3]83class QtDialog::BooleanQtQuery : public QWidget, public QtQuery<bool> {
[7c9921]84 Q_OBJECT
[308aa4]85public:
[f130d4]86 BooleanQtQuery(Parameter<bool> &, const std::string &_title, const std::string &description, QBoxLayout *_parent, Dialog *_dialog);
[308aa4]87 virtual ~BooleanQtQuery();
[7c9921]88
89public slots:
90 void onUpdate(int);
91
[308aa4]92private:
93 QBoxLayout *parent;
94 QBoxLayout *thisLayout;
95 QLabel *titleLabel;
[85b112]96 QCheckBox *booleanCheckBox;
[7dfd07]97 Dialog *dialog;
[308aa4]98};
99
[852ea3]100class QtDialog::RealSpaceMatrixQtQuery : public QWidget, public QtQuery<RealSpaceMatrix> {
[7c9921]101 Q_OBJECT
[308aa4]102public:
[f130d4]103 RealSpaceMatrixQtQuery(Parameter<RealSpaceMatrix> &, const std::string &_title, const std::string &description, QBoxLayout *_parent,Dialog *_dialog);
[7d9416]104 virtual ~RealSpaceMatrixQtQuery();
[7c9921]105
106public slots:
107 void onUpdate(int, int);
108
[308aa4]109private:
110 QBoxLayout *parent;
111 QBoxLayout *thisLayout;
112 QLabel *titleLabel;
113 QTableWidget *inputTable;
[7dfd07]114 Dialog *dialog;
[308aa4]115};
116
[852ea3]117class QtDialog::DoubleQtQuery : public QWidget, public QtQuery<double> {
[7c9921]118 Q_OBJECT
[308aa4]119public:
[f130d4]120 DoubleQtQuery(Parameter<double> &, const std::string &_title, const std::string &_description,QBoxLayout *_parent,Dialog *_dialog);
[308aa4]121 virtual ~DoubleQtQuery();
[7c9921]122
123public slots:
124 void onUpdate(double);
125
[308aa4]126private:
127 QBoxLayout *parent;
128 QBoxLayout *thisLayout;
129 QLabel *titleLabel;
130 QDoubleSpinBox *inputBox;
[7dfd07]131 Dialog *dialog;
[308aa4]132};
133
[852ea3]134class QtDialog::DoublesQtQuery : public QWidget, public QtQuery<std::vector<double> >, public QtQueryList<double> {
[7c9921]135 Q_OBJECT
[308aa4]136public:
[f130d4]137 DoublesQtQuery(Parameter<std::vector<double> > &, const std::string &_title, const std::string &description, QBoxLayout *_parent,Dialog *_dialog);
[308aa4]138 virtual ~DoublesQtQuery();
[7c9921]139
[7e8e79]140 virtual void onSubUpdate();
141
[7c9921]142public slots:
[7e8e79]143 void onAddElement();
144 void onRemoveElement();
145 void onElementSelected();
[7c9921]146
[308aa4]147private:
[7e8e79]148 DoubleQtQuery *subQuery;
[308aa4]149};
150
[852ea3]151class QtDialog::ElementQtQuery : public QWidget, public QtQuery<const element *> {
[7c9921]152 Q_OBJECT
[308aa4]153public:
[f130d4]154 ElementQtQuery(Parameter<const element *> &, const std::string &_title, const std::string &description, QBoxLayout *_parent, Dialog *_dialog);
[308aa4]155 virtual ~ElementQtQuery();
[7c9921]156
157public slots:
158 void onUpdate(int);
159
[308aa4]160private:
161 QBoxLayout *parent;
162 QBoxLayout *thisLayout;
163 QLabel *titleLabel;
164 QComboBox *inputBox;
[7dfd07]165 Dialog *dialog;
[308aa4]166};
167
[852ea3]168class QtDialog::ElementsQtQuery : public QWidget, public QtQuery<std::vector<const element *> >, public QtQueryList<const element *> {
[7c9921]169 Q_OBJECT
[308aa4]170public:
[f130d4]171 ElementsQtQuery(Parameter<std::vector<const element *> > &, const std::string &_title, const std::string &description, QBoxLayout *_parent,Dialog *_dialog);
[308aa4]172 virtual ~ElementsQtQuery();
[7c9921]173
[572701]174 virtual void onSubUpdate();
175
[7c9921]176public slots:
[572701]177 void onAddElement();
178 void onRemoveElement();
179 void onElementSelected();
[7c9921]180
[308aa4]181private:
[572701]182 ElementQtQuery *subQuery;
[308aa4]183};
184
185class QtDialog::EmptyQtQuery : public Dialog::EmptyQuery {
186public:
[f130d4]187 EmptyQtQuery(const std::string &_title, const std::string &description, QBoxLayout *_parent, Dialog *_dialog);
[308aa4]188 virtual ~EmptyQtQuery();
[f4b6bc9]189 virtual void handle();
[308aa4]190private:
191 QBoxLayout *parent;
192 QBoxLayout *thisLayout;
193 QLabel *titleLabel;
[7dfd07]194 Dialog *dialog;
[308aa4]195};
196
[852ea3]197class QtDialog::FileQtQuery : public QWidget, public QtQuery<boost::filesystem::path> {
[7c9921]198 Q_OBJECT
[308aa4]199public:
[f130d4]200 FileQtQuery(Parameter<boost::filesystem::path> &, const std::string &_title, const std::string &description, QBoxLayout *_parent, Dialog *_dialog);
[308aa4]201 virtual ~FileQtQuery();
[7c9921]202
203public slots:
204 void onUpdate();
205 void showFileDialog();
206
[308aa4]207private:
208 QBoxLayout *parent;
209 QBoxLayout *thisLayout;
210 QLabel *filenameLabel;
211 QLineEdit *filenameLineEdit;
212 QPushButton *filedialogButton;
[7c9921]213 QFileDialog *theFileDialog;
[7dfd07]214 Dialog *dialog;
[dae158]215 std::vector<std::string> suffixes;
216 bool mustBePresent;
[308aa4]217};
218
[852ea3]219class QtDialog::FilesQtQuery : public QWidget, public QtQuery<std::vector<boost::filesystem::path> >, public QtQueryList<boost::filesystem::path> {
[7c9921]220 Q_OBJECT
[2c5765]221public:
[f130d4]222 FilesQtQuery(Parameter<std::vector<boost::filesystem::path> > &, const std::string &_title, const std::string &description, QBoxLayout *_parent,Dialog *_dialog);
[2c5765]223 virtual ~FilesQtQuery();
[324403]224
225 virtual void onSubUpdate();
[7c9921]226
227public slots:
[324403]228 void onAddElement();
229 void onRemoveElement();
230 void onElementSelected();
[7c9921]231
[2c5765]232private:
[324403]233 FileQtQuery *subQuery;
[2c5765]234};
235
[852ea3]236class QtDialog::IntQtQuery : public QWidget, public QtQuery<int> {
[7c9921]237 Q_OBJECT
[308aa4]238public:
[f130d4]239 IntQtQuery(Parameter<int> &, const std::string &_title, const std::string &description,QBoxLayout *_parent,Dialog *_dialog);
[308aa4]240 virtual ~IntQtQuery();
[7c9921]241
242public slots:
243 void onUpdate(int);
244
[308aa4]245private:
246 QBoxLayout *parent;
247 QBoxLayout *thisLayout;
248 QLabel *titleLabel;
249 QSpinBox *inputBox;
[7dfd07]250 Dialog *dialog;
[308aa4]251};
252
[852ea3]253class QtDialog::IntsQtQuery : public QWidget, public QtQuery<std::vector<int> >, public QtQueryList<int> {
[7c9921]254 Q_OBJECT
[308aa4]255public:
[f130d4]256 IntsQtQuery(Parameter<std::vector<int> > &, const std::string &_title, const std::string &description, QBoxLayout *_parent,Dialog *_dialog);
[308aa4]257 virtual ~IntsQtQuery();
[26ac2d]258
259 virtual void onSubUpdate();
[7c9921]260
261public slots:
[26ac2d]262 void onAddElement();
263 void onRemoveElement();
264 void onElementSelected();
[7c9921]265
[308aa4]266private:
[26ac2d]267 IntQtQuery *subQuery;
[308aa4]268};
269
[852ea3]270class QtDialog::MoleculeQtQuery : public QWidget, public QtQuery<const molecule *> {
[7c9921]271 Q_OBJECT
[308aa4]272public:
[f130d4]273 MoleculeQtQuery(Parameter<const molecule *> &, const std::string &_title, const std::string &description, QBoxLayout *_parent,Dialog *_dialog);
[308aa4]274 virtual ~MoleculeQtQuery();
[7c9921]275
276public slots:
277 void onUpdate(int);
278
[308aa4]279private:
280 QBoxLayout *parent;
281 QBoxLayout *thisLayout;
282 QLabel *titleLabel;
283 QComboBox *inputBox;
[7dfd07]284 Dialog *dialog;
[308aa4]285};
286
[852ea3]287class QtDialog::MoleculesQtQuery : public QWidget, public QtQuery<std::vector<const molecule *> >, public QtQueryList<const molecule *> {
[7c9921]288 Q_OBJECT
[308aa4]289public:
[f130d4]290 MoleculesQtQuery(Parameter<std::vector<const molecule *> > &, const std::string &_title, const std::string &description, QBoxLayout *_parent,Dialog *_dialog);
[308aa4]291 virtual ~MoleculesQtQuery();
[7c9921]292
[1ae820]293 virtual void onSubUpdate();
294
[7c9921]295public slots:
[1ae820]296 void onAddElement();
297 void onRemoveElement();
298 void onElementSelected();
[7c9921]299
[308aa4]300private:
[1ae820]301 MoleculeQtQuery *subQuery;
[308aa4]302};
303
[33e801]304class QtDialog::KeyValuePairQtQuery : public QWidget, public QtQuery<KeyValuePair> {
305 Q_OBJECT
306public:
307 KeyValuePairQtQuery(Parameter<KeyValuePair> &, const std::string &_title, const std::string &description, QBoxLayout *_parent,Dialog *_dialog);
308 virtual ~KeyValuePairQtQuery();
309
310public slots:
311 void onUpdate(const QString&);
312 void onUpdateCombo(int index);
313
314private:
315 QBoxLayout *parent;
316 QBoxLayout *thisLayout;
317 QLabel *titleLabel;
318 QLineEdit *inputBox;
319 QComboBox *comboBox;
320 Dialog *dialog;
321};
322
323class QtDialog::KeyValuePairsQtQuery : public QWidget, public QtQuery<std::vector<KeyValuePair> >, public QtQueryList<KeyValuePair> {
324 Q_OBJECT
325public:
326 KeyValuePairsQtQuery(Parameter<std::vector<KeyValuePair> > &, const std::string &_title, const std::string &description, QBoxLayout *_parent,Dialog *_dialog);
327 virtual ~KeyValuePairsQtQuery();
328
329 virtual void onSubUpdate();
330
331public slots:
332 void onAddElement();
333 void onRemoveElement();
334 void onElementSelected();
335
336private:
337 KeyValuePairQtQuery *subQuery;
338};
339
[852ea3]340class QtDialog::StringQtQuery : public QWidget, public QtQuery<std::string> {
[7c9921]341 Q_OBJECT
[308aa4]342public:
[f130d4]343 StringQtQuery(Parameter<std::string> &, const std::string &_title, const std::string &description, QBoxLayout *_parent,Dialog *_dialog);
[308aa4]344 virtual ~StringQtQuery();
[7c9921]345
346public slots:
347 void onUpdate(const QString&);
[dbf6c7]348 void onUpdateCombo(int index);
[7c9921]349
[308aa4]350private:
351 QBoxLayout *parent;
352 QBoxLayout *thisLayout;
353 QLabel *titleLabel;
354 QLineEdit *inputBox;
[dbf6c7]355 QComboBox *comboBox;
[7dfd07]356 Dialog *dialog;
[308aa4]357};
358
[852ea3]359class QtDialog::StringsQtQuery : public QWidget, public QtQuery<std::vector<std::string> >, public QtQueryList<std::string> {
[7c9921]360 Q_OBJECT
[308aa4]361public:
[f130d4]362 StringsQtQuery(Parameter<std::vector<std::string> > &, const std::string &_title, const std::string &description, QBoxLayout *_parent,Dialog *_dialog);
[308aa4]363 virtual ~StringsQtQuery();
[7c9921]364
[7b8a8e]365 virtual void onSubUpdate();
366
[7c9921]367public slots:
[7b8a8e]368 void onAddElement();
369 void onRemoveElement();
370 void onElementSelected();
[7c9921]371
[308aa4]372private:
[7b8a8e]373 StringQtQuery *subQuery;
[308aa4]374};
375
[852ea3]376class QtDialog::UnsignedIntQtQuery : public QWidget, public QtQuery<unsigned int> {
[7c9921]377 Q_OBJECT
[838cd0]378public:
[f130d4]379 UnsignedIntQtQuery(Parameter<unsigned int> &, const std::string &_title, const std::string &description,QBoxLayout *_parent,Dialog *_dialog);
[838cd0]380 virtual ~UnsignedIntQtQuery();
[7c9921]381
382public slots:
[a2aa2f]383 void onUpdate(int);
[7c9921]384
[838cd0]385private:
386 QBoxLayout *parent;
387 QBoxLayout *thisLayout;
388 QLabel *titleLabel;
389 QSpinBox *inputBox;
[7dfd07]390 Dialog *dialog;
[838cd0]391};
392
[852ea3]393class QtDialog::UnsignedIntsQtQuery : public QWidget, public QtQuery<std::vector<unsigned int> >, public QtQueryList<unsigned int> {
[7c9921]394 Q_OBJECT
[12948c]395public:
[f130d4]396 UnsignedIntsQtQuery(Parameter<std::vector<unsigned int> > &, const std::string &_title, const std::string &description, QBoxLayout *_parent,Dialog *_dialog);
[12948c]397 virtual ~UnsignedIntsQtQuery();
[a2aa2f]398
399 virtual void onSubUpdate();
[7c9921]400
401public slots:
[a2aa2f]402 void onAddElement();
403 void onRemoveElement();
404 void onElementSelected();
[7c9921]405
[12948c]406private:
[a2aa2f]407 UnsignedIntQtQuery *subQuery;
[12948c]408};
409
[852ea3]410class QtDialog::VectorQtQuery : public QWidget, public QtQuery<Vector> {
[7c9921]411 Q_OBJECT
[308aa4]412public:
[f130d4]413 VectorQtQuery(Parameter<Vector> &, const std::string &_title, const std::string &_description,QBoxLayout *,Dialog *);
[308aa4]414 virtual ~VectorQtQuery();
[7c9921]415
416public slots:
[f79d65]417 void pageChanged(int);
418 void onUpdateName(int);
[7c9921]419 void onUpdateX(double);
420 void onUpdateY(double);
421 void onUpdateZ(double);
422
[308aa4]423private:
424 QBoxLayout *parent;
425 QBoxLayout *mainLayout;
426 QLabel *titleLabel;
427 QBoxLayout *subLayout;
428 QBoxLayout *coordLayout;
[a14fe3]429 QDoubleSpinBox *coordInputX;
430 QDoubleSpinBox *coordInputY;
431 QDoubleSpinBox *coordInputZ;
[7dfd07]432 Dialog *dialog;
[f79d65]433 QBoxLayout *nameLayout;
434 QComboBox *nameComboBox;
[308aa4]435};
436
[f79d65]437class QtDialog::VectorsQtQuery :
438 public QWidget,
439 public QtQuery<std::vector<Vector> >,
440 public QtQueryList<Vector> {
[7c9921]441 Q_OBJECT
[308aa4]442public:
[f130d4]443 VectorsQtQuery(Parameter<std::vector<Vector> > &, const std::string &_title, const std::string &description, QBoxLayout *_parent,Dialog *_dialog);
[308aa4]444 virtual ~VectorsQtQuery();
[7c9921]445
[f84992]446 virtual void onSubUpdate();
447
[7c9921]448public slots:
[f84992]449 void onAddElement();
450 void onRemoveElement();
451 void onElementSelected();
[7c9921]452
[308aa4]453private:
[f84992]454 VectorQtQuery *subQuery;
[308aa4]455};
456
457#endif /* QTQUERY_HPP_ */
Note: See TracBrowser for help on using the repository browser.