| [d3a5ea] | 1 | /* | 
|---|
|  | 2 | * QTDialog.cpp | 
|---|
|  | 3 | * | 
|---|
|  | 4 | *  Created on: Jan 18, 2010 | 
|---|
|  | 5 | *      Author: crueger | 
|---|
|  | 6 | */ | 
|---|
|  | 7 |  | 
|---|
|  | 8 | #include "UIElements/QT4/QTDialog.hpp" | 
|---|
|  | 9 |  | 
|---|
|  | 10 | #include <string> | 
|---|
|  | 11 | #include <sstream> | 
|---|
| [b8d1aeb] | 12 | #include <limits> | 
|---|
| [d3a5ea] | 13 |  | 
|---|
|  | 14 | #include <Qt/qboxlayout.h> | 
|---|
|  | 15 | #include <Qt/qlabel.h> | 
|---|
|  | 16 | #include <Qt/qspinbox.h> | 
|---|
| [b8d1aeb] | 17 | #include <QtGui/QDoubleSpinBox> | 
|---|
| [d3a5ea] | 18 | #include <Qt/qlineedit.h> | 
|---|
| [7cd6e7] | 19 | #include <Qt/qlistwidget.h> | 
|---|
| [d3a5ea] | 20 | #include <Qt/qdialogbuttonbox.h> | 
|---|
|  | 21 | #include <Qt/qpushbutton.h> | 
|---|
|  | 22 | #include <Qt/qcombobox.h> | 
|---|
|  | 23 |  | 
|---|
| [4c9a97] | 24 | #include <boost/lexical_cast.hpp> | 
|---|
|  | 25 |  | 
|---|
| [257c77] | 26 | #include "Helpers/MemDebug.hpp" | 
|---|
|  | 27 |  | 
|---|
| [cbf01e] | 28 | #include "World.hpp" | 
|---|
|  | 29 | #include "periodentafel.hpp" | 
|---|
| [d3a5ea] | 30 | #include "atom.hpp" | 
|---|
| [cbf01e] | 31 | #include "element.hpp" | 
|---|
| [d3a5ea] | 32 | #include "molecule.hpp" | 
|---|
| [7cd6e7] | 33 | #include "Descriptors/AtomIdDescriptor.hpp" | 
|---|
| [257c77] | 34 | #include "Descriptors/MoleculeIdDescriptor.hpp" | 
|---|
| [5ec8e3] | 35 | #include "Matrix.hpp" | 
|---|
|  | 36 | #include "Box.hpp" | 
|---|
| [d3a5ea] | 37 |  | 
|---|
|  | 38 |  | 
|---|
|  | 39 | using namespace std; | 
|---|
|  | 40 |  | 
|---|
|  | 41 | QTDialog::QTDialog() : | 
|---|
|  | 42 | QDialog(0) | 
|---|
|  | 43 | { | 
|---|
|  | 44 | // creating and filling of the Dialog window | 
|---|
|  | 45 | mainLayout = new QVBoxLayout(); | 
|---|
|  | 46 | inputLayout = new QVBoxLayout(); | 
|---|
|  | 47 | buttonLayout = new QVBoxLayout(); | 
|---|
|  | 48 | setLayout(mainLayout); | 
|---|
|  | 49 | mainLayout->addLayout(inputLayout); | 
|---|
|  | 50 | mainLayout->addLayout(buttonLayout); | 
|---|
|  | 51 | buttons = new QDialogButtonBox(QDialogButtonBox::Ok| QDialogButtonBox::Cancel); | 
|---|
|  | 52 | buttonLayout->addWidget(buttons); | 
|---|
|  | 53 |  | 
|---|
|  | 54 | // Disable the ok button until something was entered | 
|---|
|  | 55 | buttons->button(QDialogButtonBox::Ok)->setEnabled(false); | 
|---|
|  | 56 |  | 
|---|
|  | 57 | // connect the buttons to their appropriate slots | 
|---|
|  | 58 | connect(buttons, SIGNAL(accepted()), this, SLOT(accept())); | 
|---|
|  | 59 | connect(buttons, SIGNAL(rejected()), this, SLOT(reject())); | 
|---|
|  | 60 | } | 
|---|
|  | 61 |  | 
|---|
|  | 62 | QTDialog::~QTDialog() | 
|---|
|  | 63 | { | 
|---|
|  | 64 | } | 
|---|
|  | 65 |  | 
|---|
|  | 66 | bool QTDialog::display(){ | 
|---|
|  | 67 | // Button state might have changed by some update that | 
|---|
|  | 68 | // was done during query construction. To make sure | 
|---|
|  | 69 | // the state is correct, we just call update one more time. | 
|---|
|  | 70 | update(); | 
|---|
|  | 71 | if(exec()) { | 
|---|
|  | 72 | setAll(); | 
|---|
|  | 73 | return true; | 
|---|
|  | 74 | } | 
|---|
|  | 75 | else { | 
|---|
|  | 76 | return false; | 
|---|
|  | 77 | } | 
|---|
|  | 78 | } | 
|---|
|  | 79 |  | 
|---|
|  | 80 | void QTDialog::update(){ | 
|---|
|  | 81 | buttons->button(QDialogButtonBox::Ok)->setEnabled(checkAll()); | 
|---|
|  | 82 | } | 
|---|
|  | 83 |  | 
|---|
|  | 84 | /************************** Query Infrastructure ************************/ | 
|---|
|  | 85 |  | 
|---|
| [257c77] | 86 | void QTDialog::queryEmpty(char const*, string){ | 
|---|
|  | 87 | // TODO | 
|---|
|  | 88 | ASSERT(false, "Not implemented yet"); | 
|---|
|  | 89 | } | 
|---|
|  | 90 |  | 
|---|
| [3731b4] | 91 | void QTDialog::queryBoolean(char const*,string){ | 
|---|
| [257c77] | 92 | // TODO | 
|---|
|  | 93 | ASSERT(false, "Not implemented yet"); | 
|---|
|  | 94 | } | 
|---|
|  | 95 |  | 
|---|
| [3731b4] | 96 | void QTDialog::queryAtom(char const*, string){ | 
|---|
| [257c77] | 97 | // TODO | 
|---|
|  | 98 | ASSERT(false, "Not implemented yet"); | 
|---|
|  | 99 | } | 
|---|
|  | 100 |  | 
|---|
| [7cd6e7] | 101 | void QTDialog::queryAtoms(char const*, string){ | 
|---|
|  | 102 | // TODO | 
|---|
|  | 103 | ASSERT(false, "Not implemented yet"); | 
|---|
|  | 104 | } | 
|---|
|  | 105 |  | 
|---|
| [3731b4] | 106 | void QTDialog::queryBox(char const*, string){ | 
|---|
| [257c77] | 107 | // TODO | 
|---|
|  | 108 | ASSERT(false, "Not implemented yet"); | 
|---|
|  | 109 | } | 
|---|
|  | 110 |  | 
|---|
|  | 111 |  | 
|---|
| [3731b4] | 112 | void QTDialog::queryInt(const char *title,string) | 
|---|
| [d3a5ea] | 113 | { | 
|---|
| [3731b4] | 114 | registerQuery(new IntQTQuery(title,inputLayout,this)); | 
|---|
| [d3a5ea] | 115 | } | 
|---|
|  | 116 |  | 
|---|
| [7cd6e7] | 117 | void QTDialog::queryInts(const char *title,string) | 
|---|
|  | 118 | { | 
|---|
|  | 119 | registerQuery(new IntsQTQuery(title,inputLayout,this)); | 
|---|
|  | 120 | } | 
|---|
|  | 121 |  | 
|---|
| [3731b4] | 122 | void QTDialog::queryDouble(const char* title,string){ | 
|---|
|  | 123 | registerQuery(new DoubleQTQuery(title,inputLayout,this)); | 
|---|
| [b8d1aeb] | 124 | } | 
|---|
|  | 125 |  | 
|---|
| [7cd6e7] | 126 | void QTDialog::queryDoubles(const char* title,string){ | 
|---|
|  | 127 | registerQuery(new DoublesQTQuery(title,inputLayout,this)); | 
|---|
|  | 128 | } | 
|---|
|  | 129 |  | 
|---|
| [3731b4] | 130 | void QTDialog::queryString(const char* title,string) | 
|---|
| [d3a5ea] | 131 | { | 
|---|
| [3731b4] | 132 | registerQuery(new StringQTQuery(title,inputLayout,this)); | 
|---|
| [d3a5ea] | 133 | } | 
|---|
|  | 134 |  | 
|---|
| [3731b4] | 135 | void QTDialog::queryStrings(const char* title,string) | 
|---|
| [cd8e55] | 136 | { | 
|---|
| [3731b4] | 137 | registerQuery(new StringsQTQuery(title,inputLayout,this)); | 
|---|
| [cd8e55] | 138 | } | 
|---|
|  | 139 |  | 
|---|
| [3731b4] | 140 | void QTDialog::queryMolecule(const char *title,string) | 
|---|
| [d3a5ea] | 141 | { | 
|---|
| [3731b4] | 142 | registerQuery(new MoleculeQTQuery(title,inputLayout,this)); | 
|---|
| [d3a5ea] | 143 | } | 
|---|
|  | 144 |  | 
|---|
| [7cd6e7] | 145 | void QTDialog::queryMolecules(const char *title,string) | 
|---|
|  | 146 | { | 
|---|
|  | 147 | // TODO | 
|---|
|  | 148 | ASSERT(false, "Not implemented yet"); | 
|---|
|  | 149 | } | 
|---|
|  | 150 |  | 
|---|
| [3731b4] | 151 | void QTDialog::queryVector(const char* title, bool check,string) { | 
|---|
|  | 152 | registerQuery(new VectorQTQuery(title,check,inputLayout,this)); | 
|---|
| [b8d1aeb] | 153 | } | 
|---|
|  | 154 |  | 
|---|
| [7cd6e7] | 155 | void QTDialog::queryVectors(const char* title, bool check,string) { | 
|---|
|  | 156 | // TODO | 
|---|
|  | 157 | ASSERT(false, "Not implemented yet"); | 
|---|
|  | 158 | } | 
|---|
|  | 159 |  | 
|---|
| [3731b4] | 160 | void QTDialog::queryElement(const char* title, string){ | 
|---|
|  | 161 | registerQuery(new ElementQTQuery(title,inputLayout,this)); | 
|---|
| [cbf01e] | 162 | } | 
|---|
|  | 163 |  | 
|---|
| [7cd6e7] | 164 | void QTDialog::queryElements(const char* title, string){ | 
|---|
|  | 165 | // TODO | 
|---|
|  | 166 | ASSERT(false, "Not implemented yet"); | 
|---|
|  | 167 | } | 
|---|
|  | 168 |  | 
|---|
| [b8d1aeb] | 169 | /************************** Query Objects *******************************/ | 
|---|
|  | 170 |  | 
|---|
| [3731b4] | 171 | QTDialog::IntQTQuery::IntQTQuery(string _title,QBoxLayout *_parent,QTDialog *_dialog) : | 
|---|
|  | 172 | Dialog::IntQuery(_title), | 
|---|
| [d3a5ea] | 173 | parent(_parent) | 
|---|
|  | 174 | { | 
|---|
|  | 175 | thisLayout = new QHBoxLayout(); | 
|---|
|  | 176 | titleLabel = new QLabel(QString(getTitle().c_str())); | 
|---|
|  | 177 | inputBox = new QSpinBox(); | 
|---|
|  | 178 | inputBox->setValue(0); | 
|---|
|  | 179 | parent->addLayout(thisLayout); | 
|---|
|  | 180 | thisLayout->addWidget(titleLabel); | 
|---|
|  | 181 | thisLayout->addWidget(inputBox); | 
|---|
|  | 182 |  | 
|---|
|  | 183 | pipe = new IntQTQueryPipe(&tmp,_dialog); | 
|---|
|  | 184 | pipe->update(inputBox->value()); | 
|---|
|  | 185 | connect(inputBox,SIGNAL(valueChanged(int)),pipe,SLOT(update(int))); | 
|---|
|  | 186 | } | 
|---|
|  | 187 |  | 
|---|
|  | 188 | QTDialog::IntQTQuery::~IntQTQuery() | 
|---|
|  | 189 | { | 
|---|
|  | 190 | delete pipe; | 
|---|
|  | 191 | } | 
|---|
|  | 192 |  | 
|---|
| [7cd6e7] | 193 | bool QTDialog::IntQTQuery::handle() { | 
|---|
|  | 194 | return true; | 
|---|
|  | 195 | } | 
|---|
|  | 196 |  | 
|---|
|  | 197 |  | 
|---|
|  | 198 | QTDialog::IntsQTQuery::IntsQTQuery(string _title,QBoxLayout *_parent,QTDialog *_dialog) : | 
|---|
|  | 199 | Dialog::IntsQuery(_title), | 
|---|
|  | 200 | parent(_parent) | 
|---|
|  | 201 | { | 
|---|
|  | 202 | QHBoxLayout * thisHLayout = new QHBoxLayout(); | 
|---|
|  | 203 | QVBoxLayout * thisV1Layout = new QVBoxLayout(); | 
|---|
|  | 204 | QVBoxLayout * thisV2Layout = new QVBoxLayout(); | 
|---|
|  | 205 |  | 
|---|
|  | 206 | QLabel *titleLabel = new QLabel(QString(getTitle().c_str())); | 
|---|
|  | 207 | QLabel *inputLabel = new QLabel("Enter to add"); | 
|---|
|  | 208 | QListWidget* inputList = new QListWidget(); | 
|---|
|  | 209 | inputList->setSelectionMode(QAbstractItemView::ExtendedSelection); | 
|---|
|  | 210 | QLineEdit* inputBox = new QLineEdit(); | 
|---|
|  | 211 | inputLabel->setBuddy(inputBox); | 
|---|
|  | 212 | titleLabel->setBuddy(inputList); | 
|---|
|  | 213 | QPushButton* AddButton = new QPushButton("Add"); | 
|---|
|  | 214 | AddButton->setEnabled(false); | 
|---|
|  | 215 | QPushButton* RemoveButton = new QPushButton("Remove"); | 
|---|
|  | 216 | RemoveButton->setEnabled(false); | 
|---|
|  | 217 |  | 
|---|
|  | 218 | thisV1Layout->addWidget(titleLabel); | 
|---|
|  | 219 | thisV1Layout->addWidget(inputList); | 
|---|
|  | 220 | thisV2Layout->addWidget(inputLabel); | 
|---|
|  | 221 | thisV2Layout->addWidget(inputBox); | 
|---|
|  | 222 | thisV2Layout->addWidget(AddButton); | 
|---|
|  | 223 | thisV2Layout->addWidget(RemoveButton); | 
|---|
|  | 224 | parent->addLayout(thisHLayout); | 
|---|
|  | 225 | thisHLayout->addLayout(thisV1Layout); | 
|---|
|  | 226 | thisHLayout->addLayout(thisV2Layout); | 
|---|
|  | 227 |  | 
|---|
|  | 228 | pipe = new QTQueryListPipe<int>(&tmp,_dialog,inputBox,inputList,AddButton,RemoveButton); | 
|---|
|  | 229 | connect(inputBox,SIGNAL(textChanged(const QString&)),pipe,SLOT(IntegerEntered(const QString&))); | 
|---|
|  | 230 | connect(inputList,SIGNAL(itemSelectionChanged()),pipe,SLOT(IntegerSelected())); | 
|---|
|  | 231 | connect(AddButton,SIGNAL(Clicked()),pipe,SLOT(AddValue())); | 
|---|
|  | 232 | connect(RemoveButton,SIGNAL(Clicked()),pipe,SLOT(RemoveRow())); | 
|---|
|  | 233 | } | 
|---|
|  | 234 |  | 
|---|
|  | 235 | QTDialog::IntsQTQuery::~IntsQTQuery() | 
|---|
| [d3a5ea] | 236 | { | 
|---|
| [7cd6e7] | 237 | delete pipe; | 
|---|
|  | 238 | } | 
|---|
|  | 239 |  | 
|---|
|  | 240 | bool QTDialog::IntsQTQuery::handle() { | 
|---|
| [d3a5ea] | 241 | return true; | 
|---|
|  | 242 | } | 
|---|
|  | 243 |  | 
|---|
| [7cd6e7] | 244 |  | 
|---|
| [3731b4] | 245 | QTDialog::DoubleQTQuery::DoubleQTQuery(string title,QBoxLayout *_parent,QTDialog *_dialog) : | 
|---|
|  | 246 | Dialog::DoubleQuery(title), | 
|---|
| [b8d1aeb] | 247 | parent(_parent) | 
|---|
|  | 248 | { | 
|---|
|  | 249 | thisLayout = new QHBoxLayout(); | 
|---|
|  | 250 | titleLabel = new QLabel(QString(getTitle().c_str())); | 
|---|
|  | 251 | inputBox = new QDoubleSpinBox(); | 
|---|
|  | 252 | inputBox->setValue(0); | 
|---|
|  | 253 | inputBox->setRange(-numeric_limits<double>::max(),numeric_limits<double>::max()); | 
|---|
|  | 254 | inputBox->setDecimals(3); | 
|---|
|  | 255 | parent->addLayout(thisLayout); | 
|---|
|  | 256 | thisLayout->addWidget(titleLabel); | 
|---|
|  | 257 | thisLayout->addWidget(inputBox); | 
|---|
|  | 258 |  | 
|---|
|  | 259 | pipe = new DoubleQTQueryPipe(&tmp,_dialog); | 
|---|
|  | 260 | pipe->update(inputBox->value()); | 
|---|
|  | 261 | connect(inputBox,SIGNAL(valueChanged(double)),pipe,SLOT(update(double))); | 
|---|
|  | 262 | } | 
|---|
|  | 263 |  | 
|---|
|  | 264 | QTDialog::DoubleQTQuery::~DoubleQTQuery() | 
|---|
|  | 265 | { | 
|---|
|  | 266 | delete pipe; | 
|---|
|  | 267 | } | 
|---|
|  | 268 |  | 
|---|
|  | 269 | bool QTDialog::DoubleQTQuery::handle() { | 
|---|
|  | 270 | return true; | 
|---|
|  | 271 | } | 
|---|
|  | 272 |  | 
|---|
| [d3a5ea] | 273 |  | 
|---|
| [7cd6e7] | 274 | QTDialog::DoublesQTQuery::DoublesQTQuery(string title,QBoxLayout *_parent,QTDialog *_dialog) : | 
|---|
|  | 275 | Dialog::DoublesQuery(title), | 
|---|
|  | 276 | parent(_parent) | 
|---|
|  | 277 | { | 
|---|
|  | 278 | QHBoxLayout * thisHLayout = new QHBoxLayout(); | 
|---|
|  | 279 | QVBoxLayout * thisV1Layout = new QVBoxLayout(); | 
|---|
|  | 280 | QVBoxLayout * thisV2Layout = new QVBoxLayout(); | 
|---|
|  | 281 |  | 
|---|
|  | 282 | QLabel *titleLabel = new QLabel(QString(getTitle().c_str())); | 
|---|
|  | 283 | QLabel *inputLabel = new QLabel("Enter to add"); | 
|---|
|  | 284 | QListWidget* inputList = new QListWidget(); | 
|---|
|  | 285 | inputList->setSelectionMode(QAbstractItemView::ExtendedSelection); | 
|---|
|  | 286 | QLineEdit* inputBox = new QLineEdit(); | 
|---|
|  | 287 | inputLabel->setBuddy(inputBox); | 
|---|
|  | 288 | titleLabel->setBuddy(inputList); | 
|---|
|  | 289 | QPushButton* AddButton = new QPushButton("Add"); | 
|---|
|  | 290 | AddButton->setEnabled(false); | 
|---|
|  | 291 | QPushButton* RemoveButton = new QPushButton("Remove"); | 
|---|
|  | 292 | RemoveButton->setEnabled(false); | 
|---|
|  | 293 |  | 
|---|
|  | 294 | thisV1Layout->addWidget(titleLabel); | 
|---|
|  | 295 | thisV1Layout->addWidget(inputList); | 
|---|
|  | 296 | thisV2Layout->addWidget(inputLabel); | 
|---|
|  | 297 | thisV2Layout->addWidget(inputBox); | 
|---|
|  | 298 | thisV2Layout->addWidget(AddButton); | 
|---|
|  | 299 | thisV2Layout->addWidget(RemoveButton); | 
|---|
|  | 300 | parent->addLayout(thisHLayout); | 
|---|
|  | 301 | thisHLayout->addLayout(thisV1Layout); | 
|---|
|  | 302 | thisHLayout->addLayout(thisV2Layout); | 
|---|
|  | 303 |  | 
|---|
|  | 304 | pipe = new QTQueryListPipe<double>(&tmp,_dialog,inputBox,inputList,AddButton,RemoveButton); | 
|---|
|  | 305 | connect(inputBox,SIGNAL(textChanged(const QString&)),pipe,SLOT(IntegerEntered(const QString&))); | 
|---|
|  | 306 | connect(inputList,SIGNAL(itemSelectionChanged()),pipe,SLOT(IntegerSelected())); | 
|---|
|  | 307 | connect(AddButton,SIGNAL(Clicked()),pipe,SLOT(AddValue())); | 
|---|
|  | 308 | connect(RemoveButton,SIGNAL(Clicked()),pipe,SLOT(RemoveRow()));} | 
|---|
|  | 309 |  | 
|---|
|  | 310 | QTDialog::DoublesQTQuery::~DoublesQTQuery() | 
|---|
|  | 311 | { | 
|---|
|  | 312 | delete pipe; | 
|---|
|  | 313 | } | 
|---|
|  | 314 |  | 
|---|
|  | 315 | bool QTDialog::DoublesQTQuery::handle() { | 
|---|
|  | 316 | return true; | 
|---|
|  | 317 | } | 
|---|
|  | 318 |  | 
|---|
|  | 319 |  | 
|---|
| [3731b4] | 320 | QTDialog::StringQTQuery::StringQTQuery(string _title,QBoxLayout *_parent,QTDialog *_dialog) : | 
|---|
|  | 321 | Dialog::StringQuery(_title), | 
|---|
| [d3a5ea] | 322 | parent(_parent) | 
|---|
|  | 323 | { | 
|---|
|  | 324 | thisLayout = new QHBoxLayout(); | 
|---|
|  | 325 | titleLabel = new QLabel(QString(getTitle().c_str())); | 
|---|
|  | 326 | inputBox = new QLineEdit(); | 
|---|
|  | 327 | parent->addLayout(thisLayout); | 
|---|
|  | 328 | thisLayout->addWidget(titleLabel); | 
|---|
|  | 329 | thisLayout->addWidget(inputBox); | 
|---|
|  | 330 |  | 
|---|
|  | 331 | pipe = new StringQTQueryPipe(&tmp,_dialog); | 
|---|
|  | 332 | pipe->update(inputBox->text()); | 
|---|
|  | 333 | connect(inputBox,SIGNAL(textChanged(const QString&)),pipe,SLOT(update(const QString&))); | 
|---|
|  | 334 | } | 
|---|
|  | 335 |  | 
|---|
|  | 336 | QTDialog::StringQTQuery::~StringQTQuery() | 
|---|
|  | 337 | { | 
|---|
|  | 338 | delete pipe; | 
|---|
|  | 339 | } | 
|---|
|  | 340 |  | 
|---|
|  | 341 | // All values besides the empty string are valid | 
|---|
|  | 342 | bool QTDialog::StringQTQuery::handle() | 
|---|
|  | 343 | { | 
|---|
|  | 344 | return tmp!=""; | 
|---|
|  | 345 | } | 
|---|
|  | 346 |  | 
|---|
| [3731b4] | 347 | QTDialog::StringsQTQuery::StringsQTQuery(string _title,QBoxLayout *_parent,QTDialog *_dialog) : | 
|---|
|  | 348 | Dialog::StringsQuery(_title), | 
|---|
| [cd8e55] | 349 | parent(_parent) | 
|---|
|  | 350 | { | 
|---|
| [7cd6e7] | 351 | QHBoxLayout * thisHLayout = new QHBoxLayout(); | 
|---|
|  | 352 | QVBoxLayout * thisV1Layout = new QVBoxLayout(); | 
|---|
|  | 353 | QVBoxLayout * thisV2Layout = new QVBoxLayout(); | 
|---|
|  | 354 |  | 
|---|
|  | 355 | QLabel *titleLabel = new QLabel(QString(getTitle().c_str())); | 
|---|
|  | 356 | QLabel *inputLabel = new QLabel("Enter to add"); | 
|---|
|  | 357 | QListWidget* inputList = new QListWidget(); | 
|---|
|  | 358 | inputList->setSelectionMode(QAbstractItemView::ExtendedSelection); | 
|---|
|  | 359 | QLineEdit* inputBox = new QLineEdit(); | 
|---|
|  | 360 | inputLabel->setBuddy(inputBox); | 
|---|
|  | 361 | titleLabel->setBuddy(inputList); | 
|---|
|  | 362 | QPushButton* AddButton = new QPushButton("Add"); | 
|---|
|  | 363 | AddButton->setEnabled(false); | 
|---|
|  | 364 | QPushButton* RemoveButton = new QPushButton("Remove"); | 
|---|
|  | 365 | RemoveButton->setEnabled(false); | 
|---|
|  | 366 |  | 
|---|
|  | 367 | thisV1Layout->addWidget(titleLabel); | 
|---|
|  | 368 | thisV1Layout->addWidget(inputList); | 
|---|
|  | 369 | thisV2Layout->addWidget(inputLabel); | 
|---|
|  | 370 | thisV2Layout->addWidget(inputBox); | 
|---|
|  | 371 | thisV2Layout->addWidget(AddButton); | 
|---|
|  | 372 | thisV2Layout->addWidget(RemoveButton); | 
|---|
|  | 373 | parent->addLayout(thisHLayout); | 
|---|
|  | 374 | thisHLayout->addLayout(thisV1Layout); | 
|---|
|  | 375 | thisHLayout->addLayout(thisV2Layout); | 
|---|
|  | 376 |  | 
|---|
|  | 377 | pipe = new QTQueryListPipe<std::string>(&tmp,_dialog,inputBox,inputList,AddButton,RemoveButton); | 
|---|
|  | 378 | connect(inputBox,SIGNAL(textChanged(const QString&)),pipe,SLOT(IntegerEntered(const QString&))); | 
|---|
|  | 379 | connect(inputList,SIGNAL(itemSelectionChanged()),pipe,SLOT(IntegerSelected())); | 
|---|
|  | 380 | connect(AddButton,SIGNAL(Clicked()),pipe,SLOT(AddValue())); | 
|---|
|  | 381 | connect(RemoveButton,SIGNAL(Clicked()),pipe,SLOT(RemoveRow()));} | 
|---|
| [cd8e55] | 382 |  | 
|---|
|  | 383 | QTDialog::StringsQTQuery::~StringsQTQuery() | 
|---|
|  | 384 | { | 
|---|
|  | 385 | delete pipe; | 
|---|
|  | 386 | } | 
|---|
|  | 387 |  | 
|---|
|  | 388 | // All values besides the empty string are valid | 
|---|
|  | 389 | bool QTDialog::StringsQTQuery::handle() | 
|---|
|  | 390 | { | 
|---|
|  | 391 | // dissect by "," | 
|---|
|  | 392 | string::iterator olditer = temp.begin(); | 
|---|
|  | 393 | for(string::iterator iter = temp.begin(); iter != temp.end(); ++iter) { | 
|---|
|  | 394 | if (*iter == ' ') { | 
|---|
|  | 395 | tmp.push_back(string(iter, olditer)); | 
|---|
|  | 396 | olditer = iter; | 
|---|
|  | 397 | } | 
|---|
|  | 398 | } | 
|---|
|  | 399 | if (olditer != temp.begin())  // insert last part also | 
|---|
|  | 400 | tmp.push_back(string(olditer, temp.end())); | 
|---|
|  | 401 |  | 
|---|
|  | 402 | return temp!=""; | 
|---|
|  | 403 | } | 
|---|
|  | 404 |  | 
|---|
| [3731b4] | 405 | QTDialog::MoleculeQTQuery::MoleculeQTQuery(string _title, QBoxLayout *_parent,QTDialog *_dialog) : | 
|---|
|  | 406 | Dialog::MoleculeQuery(_title), | 
|---|
| [d3a5ea] | 407 | parent(_parent) | 
|---|
|  | 408 | { | 
|---|
|  | 409 | thisLayout = new QHBoxLayout(); | 
|---|
|  | 410 | titleLabel = new QLabel(QString(getTitle().c_str())); | 
|---|
|  | 411 | inputBox = new QComboBox(); | 
|---|
|  | 412 | // add all molecules to the combo box | 
|---|
| [257c77] | 413 | vector<molecule*> molecules = World::getInstance().getAllMolecules(); | 
|---|
|  | 414 | for(vector<molecule*>::iterator iter  = molecules.begin(); | 
|---|
|  | 415 | iter != molecules.end(); | 
|---|
| [cbf01e] | 416 | ++iter) { | 
|---|
| [d3a5ea] | 417 | stringstream sstr; | 
|---|
| [6adb96] | 418 | sstr << (*iter)->IndexNr << "\t" << (*iter)->getName(); | 
|---|
| [d3a5ea] | 419 | inputBox->addItem(QString(sstr.str().c_str()),QVariant((*iter)->IndexNr)); | 
|---|
|  | 420 | } | 
|---|
|  | 421 | parent->addLayout(thisLayout); | 
|---|
|  | 422 | thisLayout->addWidget(titleLabel); | 
|---|
|  | 423 | thisLayout->addWidget(inputBox); | 
|---|
|  | 424 |  | 
|---|
| [257c77] | 425 | pipe = new MoleculeQTQueryPipe(&tmp,_dialog,inputBox); | 
|---|
| [d3a5ea] | 426 | pipe->update(inputBox->currentIndex()); | 
|---|
|  | 427 | connect(inputBox,SIGNAL(currentIndexChanged(int)),pipe,SLOT(update(int))); | 
|---|
|  | 428 | } | 
|---|
|  | 429 |  | 
|---|
|  | 430 | QTDialog::MoleculeQTQuery::~MoleculeQTQuery() | 
|---|
|  | 431 | { | 
|---|
|  | 432 | delete pipe; | 
|---|
|  | 433 | } | 
|---|
|  | 434 |  | 
|---|
|  | 435 | // Handling is easy, since the GUI makes it impossible to select invalid values | 
|---|
|  | 436 | bool QTDialog::MoleculeQTQuery::handle() | 
|---|
|  | 437 | { | 
|---|
|  | 438 | return true; | 
|---|
|  | 439 | } | 
|---|
|  | 440 |  | 
|---|
| [7cd6e7] | 441 | QTDialog::MoleculesQTQuery::MoleculesQTQuery(string _title, QBoxLayout *_parent,QTDialog *_dialog) : | 
|---|
|  | 442 | Dialog::MoleculesQuery(_title), | 
|---|
|  | 443 | parent(_parent) | 
|---|
|  | 444 | { | 
|---|
|  | 445 | thisLayout = new QHBoxLayout(); | 
|---|
|  | 446 | titleLabel = new QLabel(QString(getTitle().c_str())); | 
|---|
|  | 447 | inputBox = new QComboBox(); | 
|---|
|  | 448 | // add all molecules to the combo box | 
|---|
|  | 449 | vector<molecule*> molecules = World::getInstance().getAllMolecules(); | 
|---|
|  | 450 | for(vector<molecule*>::iterator iter  = molecules.begin(); | 
|---|
|  | 451 | iter != molecules.end(); | 
|---|
|  | 452 | ++iter) { | 
|---|
|  | 453 | stringstream sstr; | 
|---|
|  | 454 | sstr << (*iter)->IndexNr << "\t" << (*iter)->getName(); | 
|---|
|  | 455 | inputBox->addItem(QString(sstr.str().c_str()),QVariant((*iter)->IndexNr)); | 
|---|
|  | 456 | } | 
|---|
|  | 457 | parent->addLayout(thisLayout); | 
|---|
|  | 458 | thisLayout->addWidget(titleLabel); | 
|---|
|  | 459 | thisLayout->addWidget(inputBox); | 
|---|
|  | 460 |  | 
|---|
|  | 461 | pipe = new MoleculesQTQueryPipe(&tmp,_dialog,inputBox); | 
|---|
|  | 462 | pipe->update(inputBox->currentIndex()); | 
|---|
|  | 463 | connect(inputBox,SIGNAL(currentIndexChanged(int)),pipe,SLOT(update(int))); | 
|---|
|  | 464 | } | 
|---|
|  | 465 |  | 
|---|
|  | 466 | QTDialog::MoleculesQTQuery::~MoleculesQTQuery() | 
|---|
|  | 467 | { | 
|---|
|  | 468 | delete pipe; | 
|---|
|  | 469 | } | 
|---|
|  | 470 |  | 
|---|
|  | 471 | // Handling is easy, since the GUI makes it impossible to select invalid values | 
|---|
|  | 472 | bool QTDialog::MoleculesQTQuery::handle() | 
|---|
|  | 473 | { | 
|---|
|  | 474 | return true; | 
|---|
|  | 475 | } | 
|---|
|  | 476 |  | 
|---|
| [3731b4] | 477 | QTDialog::VectorQTQuery::VectorQTQuery(std::string title, bool _check,QBoxLayout *_parent,QTDialog *_dialog) : | 
|---|
|  | 478 | Dialog::VectorQuery(title,_check), | 
|---|
| [b8d1aeb] | 479 | parent(_parent) | 
|---|
|  | 480 | { | 
|---|
| [5ec8e3] | 481 | const Matrix& M = World::getInstance().getDomain().getM(); | 
|---|
| [b8d1aeb] | 482 | const char *coords[3] = {"x:","y:","z:"}; | 
|---|
|  | 483 | mainLayout= new QHBoxLayout(); | 
|---|
|  | 484 | titleLabel = new QLabel(QString(getTitle().c_str())); | 
|---|
|  | 485 | mainLayout->addWidget(titleLabel); | 
|---|
|  | 486 | subLayout = new QVBoxLayout(); | 
|---|
|  | 487 | mainLayout->addLayout(subLayout); | 
|---|
| [7cd6e7] | 488 | QComboBox* inputBox = new QComboBox(); | 
|---|
|  | 489 | coordLayout = new QHBoxLayout(); | 
|---|
|  | 490 | subLayout->addLayout(coordLayout); | 
|---|
|  | 491 | coordLabel = new QLabel(QString("x,y,z")); | 
|---|
|  | 492 | coordLayout->addWidget(coordLabel); | 
|---|
|  | 493 | coordInput = new QDoubleSpinBox(); | 
|---|
|  | 494 | //  coordInput->setRange(0,M.at(i,i)); | 
|---|
|  | 495 | coordInput->setDecimals(3); | 
|---|
|  | 496 | coordLayout->addWidget(coordInput); | 
|---|
|  | 497 | pipe = new VectorQTQueryPipe(&(tmp),_dialog,inputBox); | 
|---|
|  | 498 | //pipe->update(coordInput->value()); | 
|---|
|  | 499 | connect(coordInput,SIGNAL(valueChanged(double)),pipe,SLOT(update(double))); | 
|---|
| [b8d1aeb] | 500 | parent->addLayout(mainLayout); | 
|---|
|  | 501 | } | 
|---|
|  | 502 |  | 
|---|
|  | 503 | QTDialog::VectorQTQuery::~VectorQTQuery() | 
|---|
|  | 504 | {} | 
|---|
|  | 505 |  | 
|---|
|  | 506 | bool QTDialog::VectorQTQuery::handle() { | 
|---|
|  | 507 | return true; | 
|---|
|  | 508 | } | 
|---|
|  | 509 |  | 
|---|
| [d3a5ea] | 510 |  | 
|---|
| [7cd6e7] | 511 | QTDialog::VectorsQTQuery::VectorsQTQuery(std::string title, bool _check,QBoxLayout *_parent,QTDialog *_dialog) : | 
|---|
|  | 512 | Dialog::VectorsQuery(title,_check), | 
|---|
|  | 513 | parent(_parent) | 
|---|
|  | 514 | { | 
|---|
|  | 515 | const Matrix& M = World::getInstance().getDomain().getM(); | 
|---|
|  | 516 | const char *coords[3] = {"x:","y:","z:"}; | 
|---|
|  | 517 | mainLayout= new QHBoxLayout(); | 
|---|
|  | 518 | titleLabel = new QLabel(QString(getTitle().c_str())); | 
|---|
|  | 519 | mainLayout->addWidget(titleLabel); | 
|---|
|  | 520 | subLayout = new QVBoxLayout(); | 
|---|
|  | 521 | mainLayout->addLayout(subLayout); | 
|---|
|  | 522 | QComboBox* inputBox = new QComboBox(); | 
|---|
|  | 523 | coordLayout = new QHBoxLayout(); | 
|---|
|  | 524 | subLayout->addLayout(coordLayout); | 
|---|
|  | 525 | coordLabel = new QLabel(QString("x,y,z")); | 
|---|
|  | 526 | coordLayout->addWidget(coordLabel); | 
|---|
|  | 527 | coordInput = new QDoubleSpinBox(); | 
|---|
|  | 528 | //  coordInput->setRange(0,M.at(i,i)); | 
|---|
|  | 529 | coordInput->setDecimals(3); | 
|---|
|  | 530 | coordLayout->addWidget(coordInput); | 
|---|
|  | 531 | pipe = new VectorsQTQueryPipe(&(tmp),_dialog,inputBox); | 
|---|
|  | 532 | //pipe->update(coordInput->value()); | 
|---|
|  | 533 | connect(coordInput,SIGNAL(valueChanged(double)),pipe,SLOT(update(double))); | 
|---|
|  | 534 | parent->addLayout(mainLayout); | 
|---|
|  | 535 | } | 
|---|
|  | 536 |  | 
|---|
|  | 537 | QTDialog::VectorsQTQuery::~VectorsQTQuery() | 
|---|
|  | 538 | {} | 
|---|
|  | 539 |  | 
|---|
|  | 540 | bool QTDialog::VectorsQTQuery::handle() { | 
|---|
|  | 541 | return true; | 
|---|
|  | 542 | } | 
|---|
|  | 543 |  | 
|---|
|  | 544 |  | 
|---|
| [3731b4] | 545 | QTDialog::ElementQTQuery::ElementQTQuery(std::string _title, QBoxLayout *_parent, QTDialog *_dialog) : | 
|---|
|  | 546 | Dialog::ElementQuery(_title), | 
|---|
| [cbf01e] | 547 | parent(_parent) | 
|---|
|  | 548 | { | 
|---|
| [cd032d] | 549 | periodentafel *periode = World::getInstance().getPeriode(); | 
|---|
| [cbf01e] | 550 | thisLayout = new QHBoxLayout(); | 
|---|
|  | 551 | titleLabel = new QLabel(QString(getTitle().c_str())); | 
|---|
|  | 552 | inputBox = new QComboBox(); | 
|---|
| [68d781] | 553 | for(periodentafel::const_iterator iter = periode->begin(); | 
|---|
|  | 554 | iter!=periode->end(); | 
|---|
|  | 555 | ++iter) | 
|---|
| [cbf01e] | 556 | { | 
|---|
|  | 557 | stringstream sstr; | 
|---|
| [68d781] | 558 | sstr << (*iter).first << "\t" << (*iter).second->name; | 
|---|
|  | 559 | inputBox->addItem(QString(sstr.str().c_str()),QVariant((*iter).first)); | 
|---|
| [cbf01e] | 560 | } | 
|---|
|  | 561 | parent->addLayout(thisLayout); | 
|---|
|  | 562 | thisLayout->addWidget(titleLabel); | 
|---|
|  | 563 | thisLayout->addWidget(inputBox); | 
|---|
|  | 564 |  | 
|---|
| [3731b4] | 565 | pipe = new ElementQTQueryPipe(&tmp,_dialog,inputBox); | 
|---|
| [cbf01e] | 566 | pipe->update(inputBox->currentIndex()); | 
|---|
|  | 567 | connect(inputBox,SIGNAL(currentIndexChanged(int)),pipe,SLOT(update(int))); | 
|---|
|  | 568 | } | 
|---|
|  | 569 |  | 
|---|
|  | 570 | QTDialog::ElementQTQuery::~ElementQTQuery() | 
|---|
|  | 571 | { | 
|---|
|  | 572 | delete pipe; | 
|---|
|  | 573 | } | 
|---|
|  | 574 |  | 
|---|
|  | 575 | bool QTDialog::ElementQTQuery::handle(){ | 
|---|
|  | 576 | return true; | 
|---|
|  | 577 | } | 
|---|
|  | 578 |  | 
|---|
| [7cd6e7] | 579 |  | 
|---|
|  | 580 | QTDialog::ElementsQTQuery::ElementsQTQuery(std::string _title, QBoxLayout *_parent, QTDialog *_dialog) : | 
|---|
|  | 581 | Dialog::ElementsQuery(_title), | 
|---|
|  | 582 | parent(_parent) | 
|---|
|  | 583 | { | 
|---|
|  | 584 | periodentafel *periode = World::getInstance().getPeriode(); | 
|---|
|  | 585 | thisLayout = new QHBoxLayout(); | 
|---|
|  | 586 | titleLabel = new QLabel(QString(getTitle().c_str())); | 
|---|
|  | 587 | inputBox = new QComboBox(); | 
|---|
|  | 588 | for(periodentafel::const_iterator iter = periode->begin(); | 
|---|
|  | 589 | iter!=periode->end(); | 
|---|
|  | 590 | ++iter) | 
|---|
|  | 591 | { | 
|---|
|  | 592 | stringstream sstr; | 
|---|
|  | 593 | sstr << (*iter).first << "\t" << (*iter).second->name; | 
|---|
|  | 594 | inputBox->addItem(QString(sstr.str().c_str()),QVariant((*iter).first)); | 
|---|
|  | 595 | } | 
|---|
|  | 596 | parent->addLayout(thisLayout); | 
|---|
|  | 597 | thisLayout->addWidget(titleLabel); | 
|---|
|  | 598 | thisLayout->addWidget(inputBox); | 
|---|
|  | 599 |  | 
|---|
|  | 600 | pipe = new ElementsQTQueryPipe(&tmp,_dialog,inputBox); | 
|---|
|  | 601 | pipe->update(inputBox->currentIndex()); | 
|---|
|  | 602 | connect(inputBox,SIGNAL(currentIndexChanged(int)),pipe,SLOT(update(int))); | 
|---|
|  | 603 | } | 
|---|
|  | 604 |  | 
|---|
|  | 605 | QTDialog::ElementsQTQuery::~ElementsQTQuery() | 
|---|
|  | 606 | { | 
|---|
|  | 607 | delete pipe; | 
|---|
|  | 608 | } | 
|---|
|  | 609 |  | 
|---|
|  | 610 | bool QTDialog::ElementsQTQuery::handle(){ | 
|---|
|  | 611 | return true; | 
|---|
|  | 612 | } | 
|---|
|  | 613 |  | 
|---|
| [d3a5ea] | 614 | /*************************** Plumbing *******************************/ | 
|---|
|  | 615 |  | 
|---|
| [7cd6e7] | 616 |  | 
|---|
|  | 617 | template<typename T> QTQueryListPipe<T>::QTQueryListPipe(std::vector<T> *_content, QTDialog *_dialog, QLineEdit *_inputBox, QListWidget *_inputList, QPushButton *_AddButton, QPushButton *_RemoveButton) : | 
|---|
|  | 618 | content(_content), | 
|---|
|  | 619 | dialog(_dialog), | 
|---|
|  | 620 | inputBox(_inputBox), | 
|---|
|  | 621 | inputList(_inputList), | 
|---|
|  | 622 | AddButton(_AddButton), | 
|---|
|  | 623 | RemoveButton(_RemoveButton) | 
|---|
|  | 624 | {} | 
|---|
|  | 625 |  | 
|---|
|  | 626 | template<typename T> QTQueryListPipe<T>::~QTQueryListPipe() | 
|---|
|  | 627 | {} | 
|---|
|  | 628 |  | 
|---|
|  | 629 | template<typename T> void QTQueryListPipe<T>::IntegerEntered(const QString&) | 
|---|
|  | 630 | { | 
|---|
|  | 631 | AddButton->setEnabled(true); | 
|---|
|  | 632 | } | 
|---|
|  | 633 |  | 
|---|
|  | 634 | template<typename T> void QTQueryListPipe<T>::IntegerSelected() | 
|---|
|  | 635 | { | 
|---|
|  | 636 | if (inputList->selectedItems().empty()) | 
|---|
|  | 637 | RemoveButton->setEnabled(false); | 
|---|
|  | 638 | else | 
|---|
|  | 639 | RemoveButton->setEnabled(true); | 
|---|
|  | 640 | } | 
|---|
|  | 641 |  | 
|---|
|  | 642 | template<typename T> void QTQueryListPipe<T>::AddInteger() { | 
|---|
|  | 643 | // type-check | 
|---|
|  | 644 | std::string text = inputBox->text().toStdString(); | 
|---|
|  | 645 | int number = 0; | 
|---|
|  | 646 | try { | 
|---|
|  | 647 | number = boost::lexical_cast<int>(text); | 
|---|
|  | 648 | } catch (boost::bad_lexical_cast&) { | 
|---|
|  | 649 | return; | 
|---|
|  | 650 | }; | 
|---|
|  | 651 | // add item to both | 
|---|
|  | 652 | inputList->addItem(QString(number)); | 
|---|
|  | 653 | AddValue(number); | 
|---|
|  | 654 | } | 
|---|
|  | 655 |  | 
|---|
|  | 656 | template<typename T> void QTQueryListPipe<T>::AddValue(T item) { | 
|---|
|  | 657 | content->push_back(item); | 
|---|
|  | 658 |  | 
|---|
|  | 659 | dialog->update(); | 
|---|
|  | 660 | } | 
|---|
|  | 661 |  | 
|---|
|  | 662 | template<typename T> void QTQueryListPipe<T>::RemoveInteger() { | 
|---|
|  | 663 | QList<QListWidgetItem *> items = inputList->selectedItems(); | 
|---|
|  | 664 | for (QList<QListWidgetItem *>::iterator iter = items.begin(); !items.empty(); iter = items.begin()) { | 
|---|
|  | 665 | // obtain which position item has (by making it current item) | 
|---|
|  | 666 | inputList->setCurrentItem(*iter); | 
|---|
|  | 667 | // remove | 
|---|
|  | 668 | QTQueryListPipe<T>::RemoteRow(inputList->currentRow()); // template parameters needs to be known, such that compiler knows which to call | 
|---|
|  | 669 | inputList->removeItemWidget(*iter); | 
|---|
|  | 670 | } | 
|---|
|  | 671 | } | 
|---|
|  | 672 |  | 
|---|
|  | 673 | template<typename T> void QTQueryListPipe<T>::RemoveRow(int row) { | 
|---|
|  | 674 | int counter = 0; | 
|---|
|  | 675 | typename std::vector<T>::iterator iter = content->begin(); | 
|---|
|  | 676 | for (; iter != content->end(); ++iter) | 
|---|
|  | 677 | if (counter++ == row) | 
|---|
|  | 678 | break; | 
|---|
|  | 679 | if (iter != content->end()) | 
|---|
|  | 680 | content->erase(iter); | 
|---|
|  | 681 | } | 
|---|
|  | 682 |  | 
|---|
|  | 683 |  | 
|---|
| [d3a5ea] | 684 | StringQTQueryPipe::StringQTQueryPipe(string *_content, QTDialog *_dialog) : | 
|---|
|  | 685 | content(_content), | 
|---|
|  | 686 | dialog(_dialog) | 
|---|
|  | 687 | {} | 
|---|
|  | 688 |  | 
|---|
|  | 689 | StringQTQueryPipe::~StringQTQueryPipe() | 
|---|
|  | 690 | {} | 
|---|
|  | 691 |  | 
|---|
|  | 692 | void StringQTQueryPipe::update(const QString& newText) { | 
|---|
|  | 693 | content->assign(newText.toStdString()); | 
|---|
|  | 694 | dialog->update(); | 
|---|
|  | 695 | } | 
|---|
|  | 696 |  | 
|---|
|  | 697 | IntQTQueryPipe::IntQTQueryPipe(int *_content, QTDialog *_dialog) : | 
|---|
|  | 698 | content(_content), | 
|---|
|  | 699 | dialog(_dialog) | 
|---|
|  | 700 | {} | 
|---|
|  | 701 |  | 
|---|
|  | 702 | IntQTQueryPipe::~IntQTQueryPipe() | 
|---|
|  | 703 | {} | 
|---|
|  | 704 |  | 
|---|
|  | 705 | void IntQTQueryPipe::update(int newInt) { | 
|---|
|  | 706 | (*content) = newInt; | 
|---|
|  | 707 | dialog->update(); | 
|---|
|  | 708 | } | 
|---|
|  | 709 |  | 
|---|
| [b8d1aeb] | 710 | DoubleQTQueryPipe::DoubleQTQueryPipe(double *_content, QTDialog *_dialog) : | 
|---|
|  | 711 | content(_content), | 
|---|
|  | 712 | dialog(_dialog) | 
|---|
|  | 713 | {} | 
|---|
|  | 714 |  | 
|---|
|  | 715 | DoubleQTQueryPipe::~DoubleQTQueryPipe() | 
|---|
|  | 716 | {} | 
|---|
|  | 717 |  | 
|---|
|  | 718 | void DoubleQTQueryPipe::update(double newDbl) { | 
|---|
|  | 719 | (*content) = newDbl; | 
|---|
|  | 720 | dialog->update(); | 
|---|
|  | 721 | } | 
|---|
|  | 722 |  | 
|---|
| [7cd6e7] | 723 | VectorQTQueryPipe::VectorQTQueryPipe(Vector *_content, QTDialog *_dialog, QComboBox *_theBox) : | 
|---|
|  | 724 | content(_content), | 
|---|
|  | 725 | dialog(_dialog), | 
|---|
|  | 726 | theBox(_theBox) | 
|---|
|  | 727 | {} | 
|---|
|  | 728 |  | 
|---|
|  | 729 | VectorQTQueryPipe::~VectorQTQueryPipe() | 
|---|
|  | 730 | {} | 
|---|
|  | 731 |  | 
|---|
|  | 732 | void VectorQTQueryPipe::update() { | 
|---|
|  | 733 | dialog->update(); | 
|---|
|  | 734 | } | 
|---|
|  | 735 |  | 
|---|
|  | 736 | VectorsQTQueryPipe::VectorsQTQueryPipe(std::vector<Vector> *_content, QTDialog *_dialog, QComboBox *_theBox) : | 
|---|
|  | 737 | content(_content), | 
|---|
|  | 738 | dialog(_dialog), | 
|---|
|  | 739 | theBox(_theBox) | 
|---|
|  | 740 | {} | 
|---|
|  | 741 |  | 
|---|
|  | 742 | VectorsQTQueryPipe::~VectorsQTQueryPipe() | 
|---|
|  | 743 | {} | 
|---|
|  | 744 |  | 
|---|
|  | 745 | void VectorsQTQueryPipe::update() { | 
|---|
|  | 746 | dialog->update(); | 
|---|
|  | 747 | } | 
|---|
|  | 748 |  | 
|---|
|  | 749 | AtomQTQueryPipe::AtomQTQueryPipe(atom **_content, QTDialog *_dialog, QComboBox *_theBox) : | 
|---|
|  | 750 | content(_content), | 
|---|
|  | 751 | dialog(_dialog), | 
|---|
|  | 752 | theBox(_theBox) | 
|---|
|  | 753 | {} | 
|---|
|  | 754 |  | 
|---|
|  | 755 | AtomQTQueryPipe::~AtomQTQueryPipe() | 
|---|
|  | 756 | {} | 
|---|
|  | 757 |  | 
|---|
|  | 758 | void AtomQTQueryPipe::update(int newIndex) { | 
|---|
|  | 759 | QVariant data = theBox->itemData(newIndex); | 
|---|
|  | 760 | int idx = data.toInt(); | 
|---|
|  | 761 | (*content) = World::getInstance().getAtom(AtomById(idx)); | 
|---|
|  | 762 | dialog->update(); | 
|---|
|  | 763 | } | 
|---|
|  | 764 |  | 
|---|
|  | 765 |  | 
|---|
|  | 766 | AtomsQTQueryPipe::AtomsQTQueryPipe(std::vector<atom *>*_content, QTDialog *_dialog, QComboBox *_theBox) : | 
|---|
|  | 767 | content(_content), | 
|---|
|  | 768 | dialog(_dialog), | 
|---|
|  | 769 | theBox(_theBox) | 
|---|
|  | 770 | {} | 
|---|
|  | 771 |  | 
|---|
|  | 772 | AtomsQTQueryPipe::~AtomsQTQueryPipe() | 
|---|
|  | 773 | {} | 
|---|
|  | 774 |  | 
|---|
|  | 775 | void AtomsQTQueryPipe::update(int newIndex) { | 
|---|
|  | 776 | QVariant data = theBox->itemData(newIndex); | 
|---|
|  | 777 | int idx = data.toInt(); | 
|---|
|  | 778 | atom *Walker = World::getInstance().getAtom(AtomById(idx)); | 
|---|
|  | 779 | if (Walker) | 
|---|
|  | 780 | (*content).push_back(Walker) ; | 
|---|
|  | 781 | dialog->update(); | 
|---|
|  | 782 | } | 
|---|
|  | 783 |  | 
|---|
|  | 784 |  | 
|---|
| [257c77] | 785 | MoleculeQTQueryPipe::MoleculeQTQueryPipe(molecule **_content, QTDialog *_dialog, QComboBox *_theBox) : | 
|---|
| [d3a5ea] | 786 | content(_content), | 
|---|
|  | 787 | dialog(_dialog), | 
|---|
| [257c77] | 788 | theBox(_theBox) | 
|---|
| [d3a5ea] | 789 | {} | 
|---|
|  | 790 |  | 
|---|
|  | 791 | MoleculeQTQueryPipe::~MoleculeQTQueryPipe() | 
|---|
|  | 792 | {} | 
|---|
|  | 793 |  | 
|---|
|  | 794 | void MoleculeQTQueryPipe::update(int newIndex) { | 
|---|
|  | 795 | QVariant data = theBox->itemData(newIndex); | 
|---|
|  | 796 | int idx = data.toInt(); | 
|---|
| [257c77] | 797 | (*content) = World::getInstance().getMolecule(MoleculeById(idx)); | 
|---|
| [d3a5ea] | 798 | dialog->update(); | 
|---|
|  | 799 | } | 
|---|
|  | 800 |  | 
|---|
| [7cd6e7] | 801 |  | 
|---|
|  | 802 | MoleculesQTQueryPipe::MoleculesQTQueryPipe(std::vector<molecule *>*_content, QTDialog *_dialog, QComboBox *_theBox) : | 
|---|
| [cbf01e] | 803 | content(_content), | 
|---|
|  | 804 | dialog(_dialog), | 
|---|
|  | 805 | theBox(_theBox) | 
|---|
| [7cd6e7] | 806 | {} | 
|---|
|  | 807 |  | 
|---|
|  | 808 | MoleculesQTQueryPipe::~MoleculesQTQueryPipe() | 
|---|
|  | 809 | {} | 
|---|
|  | 810 |  | 
|---|
|  | 811 | void MoleculesQTQueryPipe::update(int newIndex) { | 
|---|
|  | 812 | QVariant data = theBox->itemData(newIndex); | 
|---|
|  | 813 | int idx = data.toInt(); | 
|---|
|  | 814 | molecule *mol = World::getInstance().getMolecule(MoleculeById(idx)); | 
|---|
|  | 815 | if (mol) | 
|---|
|  | 816 | (*content).push_back(mol); | 
|---|
|  | 817 | dialog->update(); | 
|---|
| [257c77] | 818 | } | 
|---|
| [cbf01e] | 819 |  | 
|---|
| [7cd6e7] | 820 | ElementQTQueryPipe::ElementQTQueryPipe(element **_content, QTDialog *_dialog, QComboBox *_theBox) : | 
|---|
|  | 821 | content(_content), | 
|---|
|  | 822 | dialog(_dialog), | 
|---|
|  | 823 | theBox(_theBox) | 
|---|
|  | 824 | {} | 
|---|
|  | 825 |  | 
|---|
| [cbf01e] | 826 | ElementQTQueryPipe::~ElementQTQueryPipe() | 
|---|
|  | 827 | {} | 
|---|
|  | 828 |  | 
|---|
|  | 829 | void ElementQTQueryPipe::update(int newIndex) { | 
|---|
|  | 830 | QVariant data = theBox->itemData(newIndex); | 
|---|
|  | 831 | int idx = data.toInt(); | 
|---|
| [7cd6e7] | 832 | *content = World::getInstance().getPeriode()->FindElement(idx); | 
|---|
|  | 833 | dialog->update(); | 
|---|
|  | 834 | } | 
|---|
|  | 835 |  | 
|---|
|  | 836 | ElementsQTQueryPipe::ElementsQTQueryPipe(std::vector<element *>*_content, QTDialog *_dialog, QComboBox *_theBox) : | 
|---|
|  | 837 | content(_content), | 
|---|
|  | 838 | dialog(_dialog), | 
|---|
|  | 839 | theBox(_theBox) | 
|---|
|  | 840 | {} | 
|---|
|  | 841 |  | 
|---|
|  | 842 | ElementsQTQueryPipe::~ElementsQTQueryPipe() | 
|---|
|  | 843 | {} | 
|---|
|  | 844 |  | 
|---|
|  | 845 | void ElementsQTQueryPipe::update(int newIndex) { | 
|---|
|  | 846 | QVariant data = theBox->itemData(newIndex); | 
|---|
|  | 847 | int idx = data.toInt(); | 
|---|
|  | 848 | element *elemental = World::getInstance().getPeriode()->FindElement(idx); | 
|---|
|  | 849 | if(elemental) | 
|---|
|  | 850 | (*content).push_back(elemental); | 
|---|
| [cbf01e] | 851 | dialog->update(); | 
|---|
|  | 852 | } | 
|---|
|  | 853 |  | 
|---|
| [7cd6e7] | 854 |  | 
|---|