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