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