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