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