[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 |
|
---|
[257c77] | 24 | #include "Helpers/MemDebug.hpp"
|
---|
| 25 |
|
---|
[cbf01e] | 26 | #include "World.hpp"
|
---|
| 27 | #include "periodentafel.hpp"
|
---|
[d3a5ea] | 28 | #include "atom.hpp"
|
---|
[cbf01e] | 29 | #include "element.hpp"
|
---|
[d3a5ea] | 30 | #include "molecule.hpp"
|
---|
[7cd6e7] | 31 | #include "Descriptors/AtomIdDescriptor.hpp"
|
---|
[257c77] | 32 | #include "Descriptors/MoleculeIdDescriptor.hpp"
|
---|
[5ec8e3] | 33 | #include "Matrix.hpp"
|
---|
| 34 | #include "Box.hpp"
|
---|
[d3a5ea] | 35 |
|
---|
| 36 |
|
---|
| 37 | using namespace std;
|
---|
| 38 |
|
---|
| 39 | QTDialog::QTDialog() :
|
---|
| 40 | QDialog(0)
|
---|
| 41 | {
|
---|
| 42 | // creating and filling of the Dialog window
|
---|
| 43 | mainLayout = new QVBoxLayout();
|
---|
| 44 | inputLayout = new QVBoxLayout();
|
---|
| 45 | buttonLayout = new QVBoxLayout();
|
---|
| 46 | setLayout(mainLayout);
|
---|
| 47 | mainLayout->addLayout(inputLayout);
|
---|
| 48 | mainLayout->addLayout(buttonLayout);
|
---|
| 49 | buttons = new QDialogButtonBox(QDialogButtonBox::Ok| QDialogButtonBox::Cancel);
|
---|
| 50 | buttonLayout->addWidget(buttons);
|
---|
| 51 |
|
---|
| 52 | // Disable the ok button until something was entered
|
---|
| 53 | buttons->button(QDialogButtonBox::Ok)->setEnabled(false);
|
---|
| 54 |
|
---|
| 55 | // connect the buttons to their appropriate slots
|
---|
| 56 | connect(buttons, SIGNAL(accepted()), this, SLOT(accept()));
|
---|
| 57 | connect(buttons, SIGNAL(rejected()), this, SLOT(reject()));
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 | QTDialog::~QTDialog()
|
---|
| 61 | {
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 64 | bool QTDialog::display(){
|
---|
| 65 | // Button state might have changed by some update that
|
---|
| 66 | // was done during query construction. To make sure
|
---|
| 67 | // the state is correct, we just call update one more time.
|
---|
| 68 | update();
|
---|
| 69 | if(exec()) {
|
---|
| 70 | setAll();
|
---|
| 71 | return true;
|
---|
| 72 | }
|
---|
| 73 | else {
|
---|
| 74 | return false;
|
---|
| 75 | }
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | void QTDialog::update(){
|
---|
| 79 | buttons->button(QDialogButtonBox::Ok)->setEnabled(checkAll());
|
---|
| 80 | }
|
---|
| 81 |
|
---|
| 82 | /************************** Query Infrastructure ************************/
|
---|
| 83 |
|
---|
[257c77] | 84 | void QTDialog::queryEmpty(char const*, string){
|
---|
| 85 | // TODO
|
---|
| 86 | ASSERT(false, "Not implemented yet");
|
---|
| 87 | }
|
---|
| 88 |
|
---|
[3731b4] | 89 | void QTDialog::queryBoolean(char const*,string){
|
---|
[257c77] | 90 | // TODO
|
---|
| 91 | ASSERT(false, "Not implemented yet");
|
---|
| 92 | }
|
---|
| 93 |
|
---|
[3731b4] | 94 | void QTDialog::queryAtom(char const*, string){
|
---|
[257c77] | 95 | // TODO
|
---|
| 96 | ASSERT(false, "Not implemented yet");
|
---|
| 97 | }
|
---|
| 98 |
|
---|
[7cd6e7] | 99 | void QTDialog::queryAtoms(char const*, string){
|
---|
| 100 | // TODO
|
---|
| 101 | ASSERT(false, "Not implemented yet");
|
---|
| 102 | }
|
---|
| 103 |
|
---|
[3731b4] | 104 | void QTDialog::queryBox(char const*, string){
|
---|
[257c77] | 105 | // TODO
|
---|
| 106 | ASSERT(false, "Not implemented yet");
|
---|
| 107 | }
|
---|
| 108 |
|
---|
| 109 |
|
---|
[3731b4] | 110 | void QTDialog::queryInt(const char *title,string)
|
---|
[d3a5ea] | 111 | {
|
---|
[3731b4] | 112 | registerQuery(new IntQTQuery(title,inputLayout,this));
|
---|
[d3a5ea] | 113 | }
|
---|
| 114 |
|
---|
[7cd6e7] | 115 | void QTDialog::queryInts(const char *title,string)
|
---|
| 116 | {
|
---|
| 117 | registerQuery(new IntsQTQuery(title,inputLayout,this));
|
---|
| 118 | }
|
---|
| 119 |
|
---|
[3731b4] | 120 | void QTDialog::queryDouble(const char* title,string){
|
---|
| 121 | registerQuery(new DoubleQTQuery(title,inputLayout,this));
|
---|
[b8d1aeb] | 122 | }
|
---|
| 123 |
|
---|
[7cd6e7] | 124 | void QTDialog::queryDoubles(const char* title,string){
|
---|
| 125 | registerQuery(new DoublesQTQuery(title,inputLayout,this));
|
---|
| 126 | }
|
---|
| 127 |
|
---|
[3731b4] | 128 | void QTDialog::queryString(const char* title,string)
|
---|
[d3a5ea] | 129 | {
|
---|
[3731b4] | 130 | registerQuery(new StringQTQuery(title,inputLayout,this));
|
---|
[d3a5ea] | 131 | }
|
---|
| 132 |
|
---|
[3731b4] | 133 | void QTDialog::queryStrings(const char* title,string)
|
---|
[cd8e55] | 134 | {
|
---|
[3731b4] | 135 | registerQuery(new StringsQTQuery(title,inputLayout,this));
|
---|
[cd8e55] | 136 | }
|
---|
| 137 |
|
---|
[3731b4] | 138 | void QTDialog::queryMolecule(const char *title,string)
|
---|
[d3a5ea] | 139 | {
|
---|
[3731b4] | 140 | registerQuery(new MoleculeQTQuery(title,inputLayout,this));
|
---|
[d3a5ea] | 141 | }
|
---|
| 142 |
|
---|
[7cd6e7] | 143 | void QTDialog::queryMolecules(const char *title,string)
|
---|
| 144 | {
|
---|
| 145 | // TODO
|
---|
| 146 | ASSERT(false, "Not implemented yet");
|
---|
| 147 | }
|
---|
| 148 |
|
---|
[3731b4] | 149 | void QTDialog::queryVector(const char* title, bool check,string) {
|
---|
| 150 | registerQuery(new VectorQTQuery(title,check,inputLayout,this));
|
---|
[b8d1aeb] | 151 | }
|
---|
| 152 |
|
---|
[7cd6e7] | 153 | void QTDialog::queryVectors(const char* title, bool check,string) {
|
---|
| 154 | // TODO
|
---|
| 155 | ASSERT(false, "Not implemented yet");
|
---|
| 156 | }
|
---|
| 157 |
|
---|
[3731b4] | 158 | void QTDialog::queryElement(const char* title, string){
|
---|
| 159 | registerQuery(new ElementQTQuery(title,inputLayout,this));
|
---|
[cbf01e] | 160 | }
|
---|
| 161 |
|
---|
[7cd6e7] | 162 | void QTDialog::queryElements(const char* title, string){
|
---|
| 163 | // TODO
|
---|
| 164 | ASSERT(false, "Not implemented yet");
|
---|
| 165 | }
|
---|
| 166 |
|
---|
[b8d1aeb] | 167 | /************************** Query Objects *******************************/
|
---|
| 168 |
|
---|
[3731b4] | 169 | QTDialog::IntQTQuery::IntQTQuery(string _title,QBoxLayout *_parent,QTDialog *_dialog) :
|
---|
| 170 | Dialog::IntQuery(_title),
|
---|
[d3a5ea] | 171 | parent(_parent)
|
---|
| 172 | {
|
---|
| 173 | thisLayout = new QHBoxLayout();
|
---|
| 174 | titleLabel = new QLabel(QString(getTitle().c_str()));
|
---|
| 175 | inputBox = new QSpinBox();
|
---|
| 176 | inputBox->setValue(0);
|
---|
| 177 | parent->addLayout(thisLayout);
|
---|
| 178 | thisLayout->addWidget(titleLabel);
|
---|
| 179 | thisLayout->addWidget(inputBox);
|
---|
| 180 |
|
---|
| 181 | pipe = new IntQTQueryPipe(&tmp,_dialog);
|
---|
| 182 | pipe->update(inputBox->value());
|
---|
| 183 | connect(inputBox,SIGNAL(valueChanged(int)),pipe,SLOT(update(int)));
|
---|
| 184 | }
|
---|
| 185 |
|
---|
| 186 | QTDialog::IntQTQuery::~IntQTQuery()
|
---|
| 187 | {
|
---|
| 188 | delete pipe;
|
---|
| 189 | }
|
---|
| 190 |
|
---|
[7cd6e7] | 191 | bool QTDialog::IntQTQuery::handle() {
|
---|
| 192 | return true;
|
---|
| 193 | }
|
---|
| 194 |
|
---|
| 195 |
|
---|
| 196 | QTDialog::IntsQTQuery::IntsQTQuery(string _title,QBoxLayout *_parent,QTDialog *_dialog) :
|
---|
| 197 | Dialog::IntsQuery(_title),
|
---|
| 198 | parent(_parent)
|
---|
| 199 | {
|
---|
| 200 | QHBoxLayout * thisHLayout = new QHBoxLayout();
|
---|
| 201 | QVBoxLayout * thisV1Layout = new QVBoxLayout();
|
---|
| 202 | QVBoxLayout * thisV2Layout = new QVBoxLayout();
|
---|
| 203 |
|
---|
| 204 | QLabel *titleLabel = new QLabel(QString(getTitle().c_str()));
|
---|
| 205 | QLabel *inputLabel = new QLabel("Enter to add");
|
---|
| 206 | QListWidget* inputList = new QListWidget();
|
---|
| 207 | inputList->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
---|
| 208 | QLineEdit* inputBox = new QLineEdit();
|
---|
| 209 | inputLabel->setBuddy(inputBox);
|
---|
| 210 | titleLabel->setBuddy(inputList);
|
---|
| 211 | QPushButton* AddButton = new QPushButton("Add");
|
---|
| 212 | AddButton->setEnabled(false);
|
---|
| 213 | QPushButton* RemoveButton = new QPushButton("Remove");
|
---|
| 214 | RemoveButton->setEnabled(false);
|
---|
| 215 |
|
---|
| 216 | thisV1Layout->addWidget(titleLabel);
|
---|
| 217 | thisV1Layout->addWidget(inputList);
|
---|
| 218 | thisV2Layout->addWidget(inputLabel);
|
---|
| 219 | thisV2Layout->addWidget(inputBox);
|
---|
| 220 | thisV2Layout->addWidget(AddButton);
|
---|
| 221 | thisV2Layout->addWidget(RemoveButton);
|
---|
| 222 | parent->addLayout(thisHLayout);
|
---|
| 223 | thisHLayout->addLayout(thisV1Layout);
|
---|
| 224 | thisHLayout->addLayout(thisV2Layout);
|
---|
| 225 |
|
---|
| 226 | pipe = new QTQueryListPipe<int>(&tmp,_dialog,inputBox,inputList,AddButton,RemoveButton);
|
---|
| 227 | connect(inputBox,SIGNAL(textChanged(const QString&)),pipe,SLOT(IntegerEntered(const QString&)));
|
---|
| 228 | connect(inputList,SIGNAL(itemSelectionChanged()),pipe,SLOT(IntegerSelected()));
|
---|
| 229 | connect(AddButton,SIGNAL(Clicked()),pipe,SLOT(AddValue()));
|
---|
| 230 | connect(RemoveButton,SIGNAL(Clicked()),pipe,SLOT(RemoveRow()));
|
---|
| 231 | }
|
---|
| 232 |
|
---|
| 233 | QTDialog::IntsQTQuery::~IntsQTQuery()
|
---|
[d3a5ea] | 234 | {
|
---|
[7cd6e7] | 235 | delete pipe;
|
---|
| 236 | }
|
---|
| 237 |
|
---|
| 238 | bool QTDialog::IntsQTQuery::handle() {
|
---|
[d3a5ea] | 239 | return true;
|
---|
| 240 | }
|
---|
| 241 |
|
---|
[7cd6e7] | 242 |
|
---|
[3731b4] | 243 | QTDialog::DoubleQTQuery::DoubleQTQuery(string title,QBoxLayout *_parent,QTDialog *_dialog) :
|
---|
| 244 | Dialog::DoubleQuery(title),
|
---|
[b8d1aeb] | 245 | parent(_parent)
|
---|
| 246 | {
|
---|
| 247 | thisLayout = new QHBoxLayout();
|
---|
| 248 | titleLabel = new QLabel(QString(getTitle().c_str()));
|
---|
| 249 | inputBox = new QDoubleSpinBox();
|
---|
| 250 | inputBox->setValue(0);
|
---|
| 251 | inputBox->setRange(-numeric_limits<double>::max(),numeric_limits<double>::max());
|
---|
| 252 | inputBox->setDecimals(3);
|
---|
| 253 | parent->addLayout(thisLayout);
|
---|
| 254 | thisLayout->addWidget(titleLabel);
|
---|
| 255 | thisLayout->addWidget(inputBox);
|
---|
| 256 |
|
---|
| 257 | pipe = new DoubleQTQueryPipe(&tmp,_dialog);
|
---|
| 258 | pipe->update(inputBox->value());
|
---|
| 259 | connect(inputBox,SIGNAL(valueChanged(double)),pipe,SLOT(update(double)));
|
---|
| 260 | }
|
---|
| 261 |
|
---|
| 262 | QTDialog::DoubleQTQuery::~DoubleQTQuery()
|
---|
| 263 | {
|
---|
| 264 | delete pipe;
|
---|
| 265 | }
|
---|
| 266 |
|
---|
| 267 | bool QTDialog::DoubleQTQuery::handle() {
|
---|
| 268 | return true;
|
---|
| 269 | }
|
---|
| 270 |
|
---|
[d3a5ea] | 271 |
|
---|
[7cd6e7] | 272 | QTDialog::DoublesQTQuery::DoublesQTQuery(string title,QBoxLayout *_parent,QTDialog *_dialog) :
|
---|
| 273 | Dialog::DoublesQuery(title),
|
---|
| 274 | parent(_parent)
|
---|
| 275 | {
|
---|
| 276 | QHBoxLayout * thisHLayout = new QHBoxLayout();
|
---|
| 277 | QVBoxLayout * thisV1Layout = new QVBoxLayout();
|
---|
| 278 | QVBoxLayout * thisV2Layout = new QVBoxLayout();
|
---|
| 279 |
|
---|
| 280 | QLabel *titleLabel = new QLabel(QString(getTitle().c_str()));
|
---|
| 281 | QLabel *inputLabel = new QLabel("Enter to add");
|
---|
| 282 | QListWidget* inputList = new QListWidget();
|
---|
| 283 | inputList->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
---|
| 284 | QLineEdit* inputBox = new QLineEdit();
|
---|
| 285 | inputLabel->setBuddy(inputBox);
|
---|
| 286 | titleLabel->setBuddy(inputList);
|
---|
| 287 | QPushButton* AddButton = new QPushButton("Add");
|
---|
| 288 | AddButton->setEnabled(false);
|
---|
| 289 | QPushButton* RemoveButton = new QPushButton("Remove");
|
---|
| 290 | RemoveButton->setEnabled(false);
|
---|
| 291 |
|
---|
| 292 | thisV1Layout->addWidget(titleLabel);
|
---|
| 293 | thisV1Layout->addWidget(inputList);
|
---|
| 294 | thisV2Layout->addWidget(inputLabel);
|
---|
| 295 | thisV2Layout->addWidget(inputBox);
|
---|
| 296 | thisV2Layout->addWidget(AddButton);
|
---|
| 297 | thisV2Layout->addWidget(RemoveButton);
|
---|
| 298 | parent->addLayout(thisHLayout);
|
---|
| 299 | thisHLayout->addLayout(thisV1Layout);
|
---|
| 300 | thisHLayout->addLayout(thisV2Layout);
|
---|
| 301 |
|
---|
| 302 | pipe = new QTQueryListPipe<double>(&tmp,_dialog,inputBox,inputList,AddButton,RemoveButton);
|
---|
| 303 | connect(inputBox,SIGNAL(textChanged(const QString&)),pipe,SLOT(IntegerEntered(const QString&)));
|
---|
| 304 | connect(inputList,SIGNAL(itemSelectionChanged()),pipe,SLOT(IntegerSelected()));
|
---|
| 305 | connect(AddButton,SIGNAL(Clicked()),pipe,SLOT(AddValue()));
|
---|
| 306 | connect(RemoveButton,SIGNAL(Clicked()),pipe,SLOT(RemoveRow()));}
|
---|
| 307 |
|
---|
| 308 | QTDialog::DoublesQTQuery::~DoublesQTQuery()
|
---|
| 309 | {
|
---|
| 310 | delete pipe;
|
---|
| 311 | }
|
---|
| 312 |
|
---|
| 313 | bool QTDialog::DoublesQTQuery::handle() {
|
---|
| 314 | return true;
|
---|
| 315 | }
|
---|
| 316 |
|
---|
| 317 |
|
---|
[3731b4] | 318 | QTDialog::StringQTQuery::StringQTQuery(string _title,QBoxLayout *_parent,QTDialog *_dialog) :
|
---|
| 319 | Dialog::StringQuery(_title),
|
---|
[d3a5ea] | 320 | parent(_parent)
|
---|
| 321 | {
|
---|
| 322 | thisLayout = new QHBoxLayout();
|
---|
| 323 | titleLabel = new QLabel(QString(getTitle().c_str()));
|
---|
| 324 | inputBox = new QLineEdit();
|
---|
| 325 | parent->addLayout(thisLayout);
|
---|
| 326 | thisLayout->addWidget(titleLabel);
|
---|
| 327 | thisLayout->addWidget(inputBox);
|
---|
| 328 |
|
---|
| 329 | pipe = new StringQTQueryPipe(&tmp,_dialog);
|
---|
| 330 | pipe->update(inputBox->text());
|
---|
| 331 | connect(inputBox,SIGNAL(textChanged(const QString&)),pipe,SLOT(update(const QString&)));
|
---|
| 332 | }
|
---|
| 333 |
|
---|
| 334 | QTDialog::StringQTQuery::~StringQTQuery()
|
---|
| 335 | {
|
---|
| 336 | delete pipe;
|
---|
| 337 | }
|
---|
| 338 |
|
---|
| 339 | // All values besides the empty string are valid
|
---|
| 340 | bool QTDialog::StringQTQuery::handle()
|
---|
| 341 | {
|
---|
| 342 | return tmp!="";
|
---|
| 343 | }
|
---|
| 344 |
|
---|
[3731b4] | 345 | QTDialog::StringsQTQuery::StringsQTQuery(string _title,QBoxLayout *_parent,QTDialog *_dialog) :
|
---|
| 346 | Dialog::StringsQuery(_title),
|
---|
[cd8e55] | 347 | parent(_parent)
|
---|
| 348 | {
|
---|
[7cd6e7] | 349 | QHBoxLayout * thisHLayout = new QHBoxLayout();
|
---|
| 350 | QVBoxLayout * thisV1Layout = new QVBoxLayout();
|
---|
| 351 | QVBoxLayout * thisV2Layout = new QVBoxLayout();
|
---|
| 352 |
|
---|
| 353 | QLabel *titleLabel = new QLabel(QString(getTitle().c_str()));
|
---|
| 354 | QLabel *inputLabel = new QLabel("Enter to add");
|
---|
| 355 | QListWidget* inputList = new QListWidget();
|
---|
| 356 | inputList->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
---|
| 357 | QLineEdit* inputBox = new QLineEdit();
|
---|
| 358 | inputLabel->setBuddy(inputBox);
|
---|
| 359 | titleLabel->setBuddy(inputList);
|
---|
| 360 | QPushButton* AddButton = new QPushButton("Add");
|
---|
| 361 | AddButton->setEnabled(false);
|
---|
| 362 | QPushButton* RemoveButton = new QPushButton("Remove");
|
---|
| 363 | RemoveButton->setEnabled(false);
|
---|
| 364 |
|
---|
| 365 | thisV1Layout->addWidget(titleLabel);
|
---|
| 366 | thisV1Layout->addWidget(inputList);
|
---|
| 367 | thisV2Layout->addWidget(inputLabel);
|
---|
| 368 | thisV2Layout->addWidget(inputBox);
|
---|
| 369 | thisV2Layout->addWidget(AddButton);
|
---|
| 370 | thisV2Layout->addWidget(RemoveButton);
|
---|
| 371 | parent->addLayout(thisHLayout);
|
---|
| 372 | thisHLayout->addLayout(thisV1Layout);
|
---|
| 373 | thisHLayout->addLayout(thisV2Layout);
|
---|
| 374 |
|
---|
| 375 | pipe = new QTQueryListPipe<std::string>(&tmp,_dialog,inputBox,inputList,AddButton,RemoveButton);
|
---|
| 376 | connect(inputBox,SIGNAL(textChanged(const QString&)),pipe,SLOT(IntegerEntered(const QString&)));
|
---|
| 377 | connect(inputList,SIGNAL(itemSelectionChanged()),pipe,SLOT(IntegerSelected()));
|
---|
| 378 | connect(AddButton,SIGNAL(Clicked()),pipe,SLOT(AddValue()));
|
---|
| 379 | connect(RemoveButton,SIGNAL(Clicked()),pipe,SLOT(RemoveRow()));}
|
---|
[cd8e55] | 380 |
|
---|
| 381 | QTDialog::StringsQTQuery::~StringsQTQuery()
|
---|
| 382 | {
|
---|
| 383 | delete pipe;
|
---|
| 384 | }
|
---|
| 385 |
|
---|
| 386 | // All values besides the empty string are valid
|
---|
| 387 | bool QTDialog::StringsQTQuery::handle()
|
---|
| 388 | {
|
---|
| 389 | // dissect by ","
|
---|
| 390 | string::iterator olditer = temp.begin();
|
---|
| 391 | for(string::iterator iter = temp.begin(); iter != temp.end(); ++iter) {
|
---|
| 392 | if (*iter == ' ') {
|
---|
| 393 | tmp.push_back(string(iter, olditer));
|
---|
| 394 | olditer = iter;
|
---|
| 395 | }
|
---|
| 396 | }
|
---|
| 397 | if (olditer != temp.begin()) // insert last part also
|
---|
| 398 | tmp.push_back(string(olditer, temp.end()));
|
---|
| 399 |
|
---|
| 400 | return temp!="";
|
---|
| 401 | }
|
---|
| 402 |
|
---|
[3731b4] | 403 | QTDialog::MoleculeQTQuery::MoleculeQTQuery(string _title, QBoxLayout *_parent,QTDialog *_dialog) :
|
---|
| 404 | Dialog::MoleculeQuery(_title),
|
---|
[d3a5ea] | 405 | parent(_parent)
|
---|
| 406 | {
|
---|
| 407 | thisLayout = new QHBoxLayout();
|
---|
| 408 | titleLabel = new QLabel(QString(getTitle().c_str()));
|
---|
| 409 | inputBox = new QComboBox();
|
---|
| 410 | // add all molecules to the combo box
|
---|
[257c77] | 411 | vector<molecule*> molecules = World::getInstance().getAllMolecules();
|
---|
| 412 | for(vector<molecule*>::iterator iter = molecules.begin();
|
---|
| 413 | iter != molecules.end();
|
---|
[cbf01e] | 414 | ++iter) {
|
---|
[d3a5ea] | 415 | stringstream sstr;
|
---|
[6adb96] | 416 | sstr << (*iter)->IndexNr << "\t" << (*iter)->getName();
|
---|
[d3a5ea] | 417 | inputBox->addItem(QString(sstr.str().c_str()),QVariant((*iter)->IndexNr));
|
---|
| 418 | }
|
---|
| 419 | parent->addLayout(thisLayout);
|
---|
| 420 | thisLayout->addWidget(titleLabel);
|
---|
| 421 | thisLayout->addWidget(inputBox);
|
---|
| 422 |
|
---|
[257c77] | 423 | pipe = new MoleculeQTQueryPipe(&tmp,_dialog,inputBox);
|
---|
[d3a5ea] | 424 | pipe->update(inputBox->currentIndex());
|
---|
| 425 | connect(inputBox,SIGNAL(currentIndexChanged(int)),pipe,SLOT(update(int)));
|
---|
| 426 | }
|
---|
| 427 |
|
---|
| 428 | QTDialog::MoleculeQTQuery::~MoleculeQTQuery()
|
---|
| 429 | {
|
---|
| 430 | delete pipe;
|
---|
| 431 | }
|
---|
| 432 |
|
---|
| 433 | // Handling is easy, since the GUI makes it impossible to select invalid values
|
---|
| 434 | bool QTDialog::MoleculeQTQuery::handle()
|
---|
| 435 | {
|
---|
| 436 | return true;
|
---|
| 437 | }
|
---|
| 438 |
|
---|
[7cd6e7] | 439 | QTDialog::MoleculesQTQuery::MoleculesQTQuery(string _title, QBoxLayout *_parent,QTDialog *_dialog) :
|
---|
| 440 | Dialog::MoleculesQuery(_title),
|
---|
| 441 | parent(_parent)
|
---|
| 442 | {
|
---|
| 443 | thisLayout = new QHBoxLayout();
|
---|
| 444 | titleLabel = new QLabel(QString(getTitle().c_str()));
|
---|
| 445 | inputBox = new QComboBox();
|
---|
| 446 | // add all molecules to the combo box
|
---|
| 447 | vector<molecule*> molecules = World::getInstance().getAllMolecules();
|
---|
| 448 | for(vector<molecule*>::iterator iter = molecules.begin();
|
---|
| 449 | iter != molecules.end();
|
---|
| 450 | ++iter) {
|
---|
| 451 | stringstream sstr;
|
---|
| 452 | sstr << (*iter)->IndexNr << "\t" << (*iter)->getName();
|
---|
| 453 | inputBox->addItem(QString(sstr.str().c_str()),QVariant((*iter)->IndexNr));
|
---|
| 454 | }
|
---|
| 455 | parent->addLayout(thisLayout);
|
---|
| 456 | thisLayout->addWidget(titleLabel);
|
---|
| 457 | thisLayout->addWidget(inputBox);
|
---|
| 458 |
|
---|
| 459 | pipe = new MoleculesQTQueryPipe(&tmp,_dialog,inputBox);
|
---|
| 460 | pipe->update(inputBox->currentIndex());
|
---|
| 461 | connect(inputBox,SIGNAL(currentIndexChanged(int)),pipe,SLOT(update(int)));
|
---|
| 462 | }
|
---|
| 463 |
|
---|
| 464 | QTDialog::MoleculesQTQuery::~MoleculesQTQuery()
|
---|
| 465 | {
|
---|
| 466 | delete pipe;
|
---|
| 467 | }
|
---|
| 468 |
|
---|
| 469 | // Handling is easy, since the GUI makes it impossible to select invalid values
|
---|
| 470 | bool QTDialog::MoleculesQTQuery::handle()
|
---|
| 471 | {
|
---|
| 472 | return true;
|
---|
| 473 | }
|
---|
| 474 |
|
---|
[3731b4] | 475 | QTDialog::VectorQTQuery::VectorQTQuery(std::string title, bool _check,QBoxLayout *_parent,QTDialog *_dialog) :
|
---|
| 476 | Dialog::VectorQuery(title,_check),
|
---|
[b8d1aeb] | 477 | parent(_parent)
|
---|
| 478 | {
|
---|
[5ec8e3] | 479 | const Matrix& M = World::getInstance().getDomain().getM();
|
---|
[b8d1aeb] | 480 | const char *coords[3] = {"x:","y:","z:"};
|
---|
| 481 | mainLayout= new QHBoxLayout();
|
---|
| 482 | titleLabel = new QLabel(QString(getTitle().c_str()));
|
---|
| 483 | mainLayout->addWidget(titleLabel);
|
---|
| 484 | subLayout = new QVBoxLayout();
|
---|
| 485 | mainLayout->addLayout(subLayout);
|
---|
[7cd6e7] | 486 | QComboBox* inputBox = new QComboBox();
|
---|
| 487 | coordLayout = new QHBoxLayout();
|
---|
| 488 | subLayout->addLayout(coordLayout);
|
---|
| 489 | coordLabel = new QLabel(QString("x,y,z"));
|
---|
| 490 | coordLayout->addWidget(coordLabel);
|
---|
| 491 | coordInput = new QDoubleSpinBox();
|
---|
| 492 | // coordInput->setRange(0,M.at(i,i));
|
---|
| 493 | coordInput->setDecimals(3);
|
---|
| 494 | coordLayout->addWidget(coordInput);
|
---|
| 495 | pipe = new VectorQTQueryPipe(&(tmp),_dialog,inputBox);
|
---|
| 496 | //pipe->update(coordInput->value());
|
---|
| 497 | connect(coordInput,SIGNAL(valueChanged(double)),pipe,SLOT(update(double)));
|
---|
[b8d1aeb] | 498 | parent->addLayout(mainLayout);
|
---|
| 499 | }
|
---|
| 500 |
|
---|
| 501 | QTDialog::VectorQTQuery::~VectorQTQuery()
|
---|
| 502 | {}
|
---|
| 503 |
|
---|
| 504 | bool QTDialog::VectorQTQuery::handle() {
|
---|
| 505 | return true;
|
---|
| 506 | }
|
---|
| 507 |
|
---|
[d3a5ea] | 508 |
|
---|
[7cd6e7] | 509 | QTDialog::VectorsQTQuery::VectorsQTQuery(std::string title, bool _check,QBoxLayout *_parent,QTDialog *_dialog) :
|
---|
| 510 | Dialog::VectorsQuery(title,_check),
|
---|
| 511 | parent(_parent)
|
---|
| 512 | {
|
---|
| 513 | const Matrix& M = World::getInstance().getDomain().getM();
|
---|
| 514 | const char *coords[3] = {"x:","y:","z:"};
|
---|
| 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 |
|
---|
[3731b4] | 543 | QTDialog::ElementQTQuery::ElementQTQuery(std::string _title, QBoxLayout *_parent, QTDialog *_dialog) :
|
---|
| 544 | Dialog::ElementQuery(_title),
|
---|
[cbf01e] | 545 | parent(_parent)
|
---|
| 546 | {
|
---|
[cd032d] | 547 | periodentafel *periode = World::getInstance().getPeriode();
|
---|
[cbf01e] | 548 | thisLayout = new QHBoxLayout();
|
---|
| 549 | titleLabel = new QLabel(QString(getTitle().c_str()));
|
---|
| 550 | inputBox = new QComboBox();
|
---|
[68d781] | 551 | for(periodentafel::const_iterator iter = periode->begin();
|
---|
| 552 | iter!=periode->end();
|
---|
| 553 | ++iter)
|
---|
[cbf01e] | 554 | {
|
---|
| 555 | stringstream sstr;
|
---|
[68d781] | 556 | sstr << (*iter).first << "\t" << (*iter).second->name;
|
---|
| 557 | inputBox->addItem(QString(sstr.str().c_str()),QVariant((*iter).first));
|
---|
[cbf01e] | 558 | }
|
---|
| 559 | parent->addLayout(thisLayout);
|
---|
| 560 | thisLayout->addWidget(titleLabel);
|
---|
| 561 | thisLayout->addWidget(inputBox);
|
---|
| 562 |
|
---|
[3731b4] | 563 | pipe = new ElementQTQueryPipe(&tmp,_dialog,inputBox);
|
---|
[cbf01e] | 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 |
|
---|
[7cd6e7] | 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->name;
|
---|
| 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 |
|
---|
[d3a5ea] | 612 | /*************************** Plumbing *******************************/
|
---|
| 613 |
|
---|
[7cd6e7] | 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 |
|
---|
[d3a5ea] | 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 |
|
---|
[b8d1aeb] | 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 |
|
---|
[7cd6e7] | 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 |
|
---|
[257c77] | 783 | MoleculeQTQueryPipe::MoleculeQTQueryPipe(molecule **_content, QTDialog *_dialog, QComboBox *_theBox) :
|
---|
[d3a5ea] | 784 | content(_content),
|
---|
| 785 | dialog(_dialog),
|
---|
[257c77] | 786 | theBox(_theBox)
|
---|
[d3a5ea] | 787 | {}
|
---|
| 788 |
|
---|
| 789 | MoleculeQTQueryPipe::~MoleculeQTQueryPipe()
|
---|
| 790 | {}
|
---|
| 791 |
|
---|
| 792 | void MoleculeQTQueryPipe::update(int newIndex) {
|
---|
| 793 | QVariant data = theBox->itemData(newIndex);
|
---|
| 794 | int idx = data.toInt();
|
---|
[257c77] | 795 | (*content) = World::getInstance().getMolecule(MoleculeById(idx));
|
---|
[d3a5ea] | 796 | dialog->update();
|
---|
| 797 | }
|
---|
| 798 |
|
---|
[7cd6e7] | 799 |
|
---|
| 800 | MoleculesQTQueryPipe::MoleculesQTQueryPipe(std::vector<molecule *>*_content, QTDialog *_dialog, QComboBox *_theBox) :
|
---|
[cbf01e] | 801 | content(_content),
|
---|
| 802 | dialog(_dialog),
|
---|
| 803 | theBox(_theBox)
|
---|
[7cd6e7] | 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();
|
---|
[257c77] | 816 | }
|
---|
[cbf01e] | 817 |
|
---|
[7cd6e7] | 818 | ElementQTQueryPipe::ElementQTQueryPipe(element **_content, QTDialog *_dialog, QComboBox *_theBox) :
|
---|
| 819 | content(_content),
|
---|
| 820 | dialog(_dialog),
|
---|
| 821 | theBox(_theBox)
|
---|
| 822 | {}
|
---|
| 823 |
|
---|
[cbf01e] | 824 | ElementQTQueryPipe::~ElementQTQueryPipe()
|
---|
| 825 | {}
|
---|
| 826 |
|
---|
| 827 | void ElementQTQueryPipe::update(int newIndex) {
|
---|
| 828 | QVariant data = theBox->itemData(newIndex);
|
---|
| 829 | int idx = data.toInt();
|
---|
[7cd6e7] | 830 | *content = World::getInstance().getPeriode()->FindElement(idx);
|
---|
| 831 | dialog->update();
|
---|
| 832 | }
|
---|
| 833 |
|
---|
| 834 | ElementsQTQueryPipe::ElementsQTQueryPipe(std::vector<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 | element *elemental = World::getInstance().getPeriode()->FindElement(idx);
|
---|
| 847 | if(elemental)
|
---|
| 848 | (*content).push_back(elemental);
|
---|
[cbf01e] | 849 | dialog->update();
|
---|
| 850 | }
|
---|
| 851 |
|
---|
[7cd6e7] | 852 |
|
---|