[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 | /*
|
---|
[4cf323d] | 9 | * QtDialog.cpp
|
---|
[d3a5ea] | 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 |
|
---|
[4cf323d] | 20 | #include "UIElements/Qt4/QtDialog.hpp"
|
---|
[d3a5ea] | 21 |
|
---|
[0bb05a] | 22 | #include <boost/lexical_cast.hpp>
|
---|
| 23 |
|
---|
[d3a5ea] | 24 | #include <string>
|
---|
| 25 | #include <sstream>
|
---|
[b8d1aeb] | 26 | #include <limits>
|
---|
[d3a5ea] | 27 |
|
---|
[41167c] | 28 | #include <QtGui/QDoubleSpinBox>
|
---|
[d3a5ea] | 29 | #include <Qt/qboxlayout.h>
|
---|
[41167c] | 30 | #include <Qt/qcombobox.h>
|
---|
| 31 | #include <Qt/qdialogbuttonbox.h>
|
---|
[d3a5ea] | 32 | #include <Qt/qlabel.h>
|
---|
| 33 | #include <Qt/qlineedit.h>
|
---|
[7cd6e7] | 34 | #include <Qt/qlistwidget.h>
|
---|
[d3a5ea] | 35 | #include <Qt/qpushbutton.h>
|
---|
[41167c] | 36 | #include <Qt/qspinbox.h>
|
---|
| 37 | #include <Qt/qtablewidget.h>
|
---|
[d3a5ea] | 38 |
|
---|
[4c9a97] | 39 | #include <boost/lexical_cast.hpp>
|
---|
| 40 |
|
---|
[257c77] | 41 | #include "Helpers/MemDebug.hpp"
|
---|
| 42 |
|
---|
[cbf01e] | 43 | #include "World.hpp"
|
---|
| 44 | #include "periodentafel.hpp"
|
---|
[d3a5ea] | 45 | #include "atom.hpp"
|
---|
[cbf01e] | 46 | #include "element.hpp"
|
---|
[d3a5ea] | 47 | #include "molecule.hpp"
|
---|
[7cd6e7] | 48 | #include "Descriptors/AtomIdDescriptor.hpp"
|
---|
[257c77] | 49 | #include "Descriptors/MoleculeIdDescriptor.hpp"
|
---|
[57f243] | 50 | #include "LinearAlgebra/Matrix.hpp"
|
---|
[5ec8e3] | 51 | #include "Box.hpp"
|
---|
[d3a5ea] | 52 |
|
---|
| 53 |
|
---|
| 54 | using namespace std;
|
---|
| 55 |
|
---|
[4cf323d] | 56 | QtDialog::QtDialog() :
|
---|
[d3a5ea] | 57 | QDialog(0)
|
---|
| 58 | {
|
---|
| 59 | // creating and filling of the Dialog window
|
---|
| 60 | mainLayout = new QVBoxLayout();
|
---|
| 61 | inputLayout = new QVBoxLayout();
|
---|
| 62 | buttonLayout = new QVBoxLayout();
|
---|
| 63 | setLayout(mainLayout);
|
---|
| 64 | mainLayout->addLayout(inputLayout);
|
---|
| 65 | mainLayout->addLayout(buttonLayout);
|
---|
| 66 | buttons = new QDialogButtonBox(QDialogButtonBox::Ok| QDialogButtonBox::Cancel);
|
---|
| 67 | buttonLayout->addWidget(buttons);
|
---|
| 68 |
|
---|
| 69 | // Disable the ok button until something was entered
|
---|
| 70 | buttons->button(QDialogButtonBox::Ok)->setEnabled(false);
|
---|
| 71 |
|
---|
| 72 | // connect the buttons to their appropriate slots
|
---|
| 73 | connect(buttons, SIGNAL(accepted()), this, SLOT(accept()));
|
---|
| 74 | connect(buttons, SIGNAL(rejected()), this, SLOT(reject()));
|
---|
| 75 | }
|
---|
| 76 |
|
---|
[4cf323d] | 77 | QtDialog::~QtDialog()
|
---|
[d3a5ea] | 78 | {
|
---|
| 79 | }
|
---|
| 80 |
|
---|
[4cf323d] | 81 | bool QtDialog::display(){
|
---|
[d3a5ea] | 82 | // Button state might have changed by some update that
|
---|
| 83 | // was done during query construction. To make sure
|
---|
| 84 | // the state is correct, we just call update one more time.
|
---|
| 85 | update();
|
---|
| 86 | if(exec()) {
|
---|
| 87 | setAll();
|
---|
| 88 | return true;
|
---|
| 89 | }
|
---|
| 90 | else {
|
---|
| 91 | return false;
|
---|
| 92 | }
|
---|
| 93 | }
|
---|
| 94 |
|
---|
[4cf323d] | 95 | void QtDialog::update(){
|
---|
[d3a5ea] | 96 | buttons->button(QDialogButtonBox::Ok)->setEnabled(checkAll());
|
---|
| 97 | }
|
---|
| 98 |
|
---|
| 99 | /************************** Query Infrastructure ************************/
|
---|
| 100 |
|
---|
[4cf323d] | 101 | void QtDialog::queryEmpty(const char* title, std::string)
|
---|
[9d457d] | 102 | {
|
---|
[4cf323d] | 103 | registerQuery(new EmptyQtQuery(title,inputLayout,this));
|
---|
[257c77] | 104 | }
|
---|
| 105 |
|
---|
[4cf323d] | 106 | void QtDialog::queryBoolean(const char* title,string)
|
---|
[ee62e4] | 107 | {
|
---|
[4cf323d] | 108 | registerQuery(new BooleanQtQuery(title,inputLayout,this));
|
---|
[257c77] | 109 | }
|
---|
| 110 |
|
---|
[4cf323d] | 111 | void QtDialog::queryAtom(const char* title, std::string)
|
---|
[c96c66] | 112 | {
|
---|
[4cf323d] | 113 | registerQuery(new AtomQtQuery(title,inputLayout,this));
|
---|
[257c77] | 114 | }
|
---|
| 115 |
|
---|
[4cf323d] | 116 | void QtDialog::queryAtoms(const char* title, std::string)
|
---|
[c96c66] | 117 | {
|
---|
[4cf323d] | 118 | registerQuery(new AtomsQtQuery(title,inputLayout,this));
|
---|
[7cd6e7] | 119 | }
|
---|
| 120 |
|
---|
[4cf323d] | 121 | void QtDialog::queryBox(const char* title, std::string)
|
---|
[41167c] | 122 | {
|
---|
[4cf323d] | 123 | registerQuery(new BoxQtQuery(title,inputLayout,this));
|
---|
[257c77] | 124 | }
|
---|
| 125 |
|
---|
[4cf323d] | 126 | void QtDialog::queryInt(const char *title,string)
|
---|
[d3a5ea] | 127 | {
|
---|
[4cf323d] | 128 | registerQuery(new IntQtQuery(title,inputLayout,this));
|
---|
[d3a5ea] | 129 | }
|
---|
| 130 |
|
---|
[4cf323d] | 131 | void QtDialog::queryInts(const char *title,string)
|
---|
[7cd6e7] | 132 | {
|
---|
[4cf323d] | 133 | registerQuery(new IntsQtQuery(title,inputLayout,this));
|
---|
[7cd6e7] | 134 | }
|
---|
| 135 |
|
---|
[4cf323d] | 136 | void QtDialog::queryDouble(const char* title,string)
|
---|
[9d457d] | 137 | {
|
---|
[4cf323d] | 138 | registerQuery(new DoubleQtQuery(title,inputLayout,this));
|
---|
[b8d1aeb] | 139 | }
|
---|
| 140 |
|
---|
[4cf323d] | 141 | void QtDialog::queryDoubles(const char* title,string)
|
---|
[9d457d] | 142 | {
|
---|
[4cf323d] | 143 | registerQuery(new DoublesQtQuery(title,inputLayout,this));
|
---|
[7cd6e7] | 144 | }
|
---|
| 145 |
|
---|
[4cf323d] | 146 | void QtDialog::queryString(const char* title,string)
|
---|
[d3a5ea] | 147 | {
|
---|
[4cf323d] | 148 | registerQuery(new StringQtQuery(title,inputLayout,this));
|
---|
[d3a5ea] | 149 | }
|
---|
| 150 |
|
---|
[4cf323d] | 151 | void QtDialog::queryStrings(const char* title,string)
|
---|
[cd8e55] | 152 | {
|
---|
[4cf323d] | 153 | registerQuery(new StringsQtQuery(title,inputLayout,this));
|
---|
[cd8e55] | 154 | }
|
---|
| 155 |
|
---|
[4cf323d] | 156 | void QtDialog::queryMolecule(const char *title,string)
|
---|
[d3a5ea] | 157 | {
|
---|
[4cf323d] | 158 | registerQuery(new MoleculeQtQuery(title,inputLayout,this));
|
---|
[d3a5ea] | 159 | }
|
---|
| 160 |
|
---|
[4cf323d] | 161 | void QtDialog::queryMolecules(const char *title,string)
|
---|
[7cd6e7] | 162 | {
|
---|
[4cf323d] | 163 | registerQuery(new MoleculesQtQuery(title,inputLayout,this));
|
---|
[7cd6e7] | 164 | }
|
---|
| 165 |
|
---|
[4cf323d] | 166 | void QtDialog::queryVector(const char* title, bool check,string)
|
---|
[9d457d] | 167 | {
|
---|
[4cf323d] | 168 | registerQuery(new VectorQtQuery(title,check,inputLayout,this));
|
---|
[b8d1aeb] | 169 | }
|
---|
| 170 |
|
---|
[4cf323d] | 171 | void QtDialog::queryVectors(const char* title, bool check,string)
|
---|
[9d457d] | 172 | {
|
---|
[4cf323d] | 173 | registerQuery(new VectorsQtQuery(title,check,inputLayout,this));
|
---|
[7cd6e7] | 174 | }
|
---|
| 175 |
|
---|
[4cf323d] | 176 | void QtDialog::queryElement(const char* title, std::string)
|
---|
[9d457d] | 177 | {
|
---|
[4cf323d] | 178 | registerQuery(new ElementQtQuery(title,inputLayout,this));
|
---|
[cbf01e] | 179 | }
|
---|
| 180 |
|
---|
[4cf323d] | 181 | void QtDialog::queryElements(const char* title, std::string)
|
---|
[9d457d] | 182 | {
|
---|
[4cf323d] | 183 | registerQuery(new ElementsQtQuery(title,inputLayout,this));
|
---|
[7cd6e7] | 184 | }
|
---|
| 185 |
|
---|
[4cf323d] | 186 | void QtDialog::queryFile(const char* title, std::string)
|
---|
[9d457d] | 187 | {
|
---|
[4cf323d] | 188 | registerQuery(new FileQtQuery(title,inputLayout,this));
|
---|
[6f5dfe] | 189 | }
|
---|
| 190 |
|
---|
[b8d1aeb] | 191 | /************************** Query Objects *******************************/
|
---|
| 192 |
|
---|
[4cf323d] | 193 | QtDialog::BoxQtQuery::BoxQtQuery(string _title,QBoxLayout *_parent,QtDialog *_dialog) :
|
---|
[41167c] | 194 | Dialog::BoxQuery(_title),
|
---|
| 195 | parent(_parent)
|
---|
| 196 | {
|
---|
| 197 | thisLayout = new QHBoxLayout();
|
---|
| 198 | titleLabel = new QLabel(QString(getTitle().c_str()));
|
---|
| 199 |
|
---|
| 200 | // init input table
|
---|
| 201 | inputTable = new QTableWidget(3,3, _dialog);
|
---|
| 202 | QStringList CoordinateList;
|
---|
| 203 | CoordinateList << "x" << "y" << "z";
|
---|
| 204 | inputTable->setHorizontalHeaderLabels(CoordinateList);
|
---|
| 205 | inputTable->setVerticalHeaderLabels(CoordinateList);
|
---|
| 206 |
|
---|
[4cf323d] | 207 | pipe = new BoxQtQueryPipe(tmp,_dialog, inputTable);
|
---|
[41167c] | 208 |
|
---|
| 209 | // fill the box with current matrix
|
---|
| 210 | const Matrix &domain = World::getInstance().getDomain().getM();
|
---|
| 211 | for (int i=0;i<3;i++)
|
---|
| 212 | for (int j=0;j<3;j++) {
|
---|
| 213 | QTableWidgetItem *newItem = new QTableWidgetItem(tr("%1").arg(domain.at(i,j)));
|
---|
| 214 | inputTable->setItem(i,j,newItem);
|
---|
| 215 | pipe->update(i,j);
|
---|
| 216 | }
|
---|
| 217 |
|
---|
| 218 | parent->addLayout(thisLayout);
|
---|
| 219 | thisLayout->addWidget(titleLabel);
|
---|
| 220 | thisLayout->addWidget(inputTable);
|
---|
| 221 |
|
---|
| 222 | connect(inputTable,SIGNAL(cellChanged(int,int)),pipe,SLOT(update(int,int)));
|
---|
| 223 | }
|
---|
| 224 |
|
---|
[4cf323d] | 225 | QtDialog::BoxQtQuery::~BoxQtQuery()
|
---|
[41167c] | 226 | {
|
---|
| 227 | delete pipe;
|
---|
| 228 | }
|
---|
| 229 |
|
---|
[4cf323d] | 230 | bool QtDialog::BoxQtQuery::handle() {
|
---|
[41167c] | 231 | return true;
|
---|
| 232 | }
|
---|
| 233 |
|
---|
| 234 |
|
---|
[4cf323d] | 235 | QtDialog::AtomQtQuery::AtomQtQuery(string _title,QBoxLayout *_parent,QtDialog *_dialog) :
|
---|
[c96c66] | 236 | Dialog::AtomQuery(_title),
|
---|
| 237 | parent(_parent)
|
---|
| 238 | {
|
---|
| 239 | thisLayout = new QHBoxLayout();
|
---|
| 240 | titleLabel = new QLabel(QString(getTitle().c_str()));
|
---|
| 241 | inputBox = new QComboBox();
|
---|
| 242 | inputBox->insertItem(-1, QString("no atom"));
|
---|
| 243 | std::vector<atom *> atoms = World::getInstance().getAllAtoms();
|
---|
| 244 | for (std::vector<atom *>::const_iterator iter = atoms.begin(); iter != atoms.end(); ++iter)
|
---|
| 245 | inputBox->insertItem((*iter)->getNr(),QString::fromStdString((*iter)->getName()));
|
---|
| 246 |
|
---|
| 247 | parent->addLayout(thisLayout);
|
---|
| 248 | thisLayout->addWidget(titleLabel);
|
---|
| 249 | thisLayout->addWidget(inputBox);
|
---|
| 250 |
|
---|
[4cf323d] | 251 | pipe = new AtomQtQueryPipe(&tmp,_dialog, inputBox);
|
---|
[c96c66] | 252 | pipe->update(inputBox->currentIndex());
|
---|
| 253 | connect(inputBox,SIGNAL(currentIndexChanged(int)),pipe,SLOT(update(int)));
|
---|
| 254 | }
|
---|
| 255 |
|
---|
[4cf323d] | 256 | QtDialog::AtomQtQuery::~AtomQtQuery()
|
---|
[c96c66] | 257 | {
|
---|
| 258 | delete pipe;
|
---|
| 259 | }
|
---|
| 260 |
|
---|
[4cf323d] | 261 | bool QtDialog::AtomQtQuery::handle() {
|
---|
[c96c66] | 262 | return true;
|
---|
| 263 | }
|
---|
| 264 |
|
---|
| 265 |
|
---|
[4cf323d] | 266 | QtDialog::AtomsQtQuery::AtomsQtQuery(string _title,QBoxLayout *_parent,QtDialog *_dialog) :
|
---|
[c96c66] | 267 | Dialog::AtomsQuery(_title),
|
---|
| 268 | parent(_parent)
|
---|
| 269 | {
|
---|
| 270 | QHBoxLayout * thisHLayout = new QHBoxLayout();
|
---|
| 271 | QVBoxLayout * thisV1Layout = new QVBoxLayout();
|
---|
| 272 | QVBoxLayout * thisV2Layout = new QVBoxLayout();
|
---|
| 273 |
|
---|
| 274 | QLabel *titleLabel = new QLabel(QString(getTitle().c_str()));
|
---|
| 275 | QLabel *inputLabel = new QLabel("Enter to add");
|
---|
| 276 | QListWidget* inputList = new QListWidget();
|
---|
| 277 | inputList->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
---|
| 278 | std::vector<atom *> atoms = World::getInstance().getAllAtoms();
|
---|
| 279 | for (std::vector<atom *>::const_iterator iter = atoms.begin(); iter != atoms.end(); ++iter)
|
---|
| 280 | inputBox->insertItem((*iter)->getNr(),QString((*iter)->getNr()));
|
---|
| 281 |
|
---|
| 282 | QLineEdit* inputBox = new QLineEdit();
|
---|
| 283 | inputLabel->setBuddy(inputBox);
|
---|
| 284 | titleLabel->setBuddy(inputList);
|
---|
| 285 | QPushButton* AddButton = new QPushButton("Add");
|
---|
| 286 | AddButton->setEnabled(false);
|
---|
| 287 | QPushButton* RemoveButton = new QPushButton("Remove");
|
---|
| 288 | RemoveButton->setEnabled(false);
|
---|
| 289 |
|
---|
| 290 | thisV1Layout->addWidget(titleLabel);
|
---|
| 291 | thisV1Layout->addWidget(inputList);
|
---|
| 292 | thisV2Layout->addWidget(inputLabel);
|
---|
| 293 | thisV2Layout->addWidget(inputBox);
|
---|
| 294 | thisV2Layout->addWidget(AddButton);
|
---|
| 295 | thisV2Layout->addWidget(RemoveButton);
|
---|
| 296 | parent->addLayout(thisHLayout);
|
---|
| 297 | thisHLayout->addLayout(thisV1Layout);
|
---|
| 298 | thisHLayout->addLayout(thisV2Layout);
|
---|
| 299 |
|
---|
[4cf323d] | 300 | pipe = new AtomsQtQueryPipe(&tmp,_dialog,inputList);
|
---|
[c96c66] | 301 | connect(inputList,SIGNAL(itemSelectionChanged()),pipe,SLOT(IntegerSelected()));
|
---|
| 302 | connect(AddButton,SIGNAL(Clicked()),pipe,SLOT(add()));
|
---|
| 303 | connect(RemoveButton,SIGNAL(Clicked()),pipe,SLOT(remove()));
|
---|
| 304 | }
|
---|
| 305 |
|
---|
[4cf323d] | 306 | QtDialog::AtomsQtQuery::~AtomsQtQuery()
|
---|
[c96c66] | 307 | {
|
---|
| 308 | delete pipe;
|
---|
| 309 | }
|
---|
| 310 |
|
---|
[4cf323d] | 311 | bool QtDialog::AtomsQtQuery::handle() {
|
---|
[c96c66] | 312 | return true;
|
---|
| 313 | }
|
---|
| 314 |
|
---|
[4cf323d] | 315 | QtDialog::IntQtQuery::IntQtQuery(string _title,QBoxLayout *_parent,QtDialog *_dialog) :
|
---|
[3731b4] | 316 | Dialog::IntQuery(_title),
|
---|
[d3a5ea] | 317 | parent(_parent)
|
---|
| 318 | {
|
---|
| 319 | thisLayout = new QHBoxLayout();
|
---|
| 320 | titleLabel = new QLabel(QString(getTitle().c_str()));
|
---|
| 321 | inputBox = new QSpinBox();
|
---|
| 322 | inputBox->setValue(0);
|
---|
| 323 | parent->addLayout(thisLayout);
|
---|
| 324 | thisLayout->addWidget(titleLabel);
|
---|
| 325 | thisLayout->addWidget(inputBox);
|
---|
| 326 |
|
---|
[4cf323d] | 327 | pipe = new IntQtQueryPipe(&tmp,_dialog);
|
---|
[d3a5ea] | 328 | pipe->update(inputBox->value());
|
---|
| 329 | connect(inputBox,SIGNAL(valueChanged(int)),pipe,SLOT(update(int)));
|
---|
| 330 | }
|
---|
| 331 |
|
---|
[4cf323d] | 332 | QtDialog::IntQtQuery::~IntQtQuery()
|
---|
[d3a5ea] | 333 | {
|
---|
| 334 | delete pipe;
|
---|
| 335 | }
|
---|
| 336 |
|
---|
[4cf323d] | 337 | bool QtDialog::IntQtQuery::handle() {
|
---|
[7cd6e7] | 338 | return true;
|
---|
| 339 | }
|
---|
| 340 |
|
---|
| 341 |
|
---|
[4cf323d] | 342 | QtDialog::IntsQtQuery::IntsQtQuery(string _title,QBoxLayout *_parent,QtDialog *_dialog) :
|
---|
[7cd6e7] | 343 | Dialog::IntsQuery(_title),
|
---|
| 344 | parent(_parent)
|
---|
| 345 | {
|
---|
| 346 | QHBoxLayout * thisHLayout = new QHBoxLayout();
|
---|
| 347 | QVBoxLayout * thisV1Layout = new QVBoxLayout();
|
---|
| 348 | QVBoxLayout * thisV2Layout = new QVBoxLayout();
|
---|
| 349 |
|
---|
| 350 | QLabel *titleLabel = new QLabel(QString(getTitle().c_str()));
|
---|
| 351 | QLabel *inputLabel = new QLabel("Enter to add");
|
---|
| 352 | QListWidget* inputList = new QListWidget();
|
---|
| 353 | inputList->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
---|
| 354 | QLineEdit* inputBox = new QLineEdit();
|
---|
| 355 | inputLabel->setBuddy(inputBox);
|
---|
| 356 | titleLabel->setBuddy(inputList);
|
---|
| 357 | QPushButton* AddButton = new QPushButton("Add");
|
---|
| 358 | AddButton->setEnabled(false);
|
---|
| 359 | QPushButton* RemoveButton = new QPushButton("Remove");
|
---|
| 360 | RemoveButton->setEnabled(false);
|
---|
| 361 |
|
---|
| 362 | thisV1Layout->addWidget(titleLabel);
|
---|
| 363 | thisV1Layout->addWidget(inputList);
|
---|
| 364 | thisV2Layout->addWidget(inputLabel);
|
---|
| 365 | thisV2Layout->addWidget(inputBox);
|
---|
| 366 | thisV2Layout->addWidget(AddButton);
|
---|
| 367 | thisV2Layout->addWidget(RemoveButton);
|
---|
| 368 | parent->addLayout(thisHLayout);
|
---|
| 369 | thisHLayout->addLayout(thisV1Layout);
|
---|
| 370 | thisHLayout->addLayout(thisV2Layout);
|
---|
| 371 |
|
---|
[4cf323d] | 372 | pipe = new QtQueryListPipe<int>(&tmp,_dialog,inputBox,inputList,AddButton,RemoveButton);
|
---|
[7cd6e7] | 373 | connect(inputBox,SIGNAL(textChanged(const QString&)),pipe,SLOT(IntegerEntered(const QString&)));
|
---|
| 374 | connect(inputList,SIGNAL(itemSelectionChanged()),pipe,SLOT(IntegerSelected()));
|
---|
| 375 | connect(AddButton,SIGNAL(Clicked()),pipe,SLOT(AddValue()));
|
---|
| 376 | connect(RemoveButton,SIGNAL(Clicked()),pipe,SLOT(RemoveRow()));
|
---|
| 377 | }
|
---|
| 378 |
|
---|
[4cf323d] | 379 | QtDialog::IntsQtQuery::~IntsQtQuery()
|
---|
[d3a5ea] | 380 | {
|
---|
[7cd6e7] | 381 | delete pipe;
|
---|
| 382 | }
|
---|
| 383 |
|
---|
[4cf323d] | 384 | bool QtDialog::IntsQtQuery::handle() {
|
---|
[d3a5ea] | 385 | return true;
|
---|
| 386 | }
|
---|
| 387 |
|
---|
[7cd6e7] | 388 |
|
---|
[4cf323d] | 389 | QtDialog::DoubleQtQuery::DoubleQtQuery(string title,QBoxLayout *_parent,QtDialog *_dialog) :
|
---|
[3731b4] | 390 | Dialog::DoubleQuery(title),
|
---|
[b8d1aeb] | 391 | parent(_parent)
|
---|
| 392 | {
|
---|
| 393 | thisLayout = new QHBoxLayout();
|
---|
| 394 | titleLabel = new QLabel(QString(getTitle().c_str()));
|
---|
| 395 | inputBox = new QDoubleSpinBox();
|
---|
| 396 | inputBox->setValue(0);
|
---|
| 397 | inputBox->setRange(-numeric_limits<double>::max(),numeric_limits<double>::max());
|
---|
| 398 | inputBox->setDecimals(3);
|
---|
| 399 | parent->addLayout(thisLayout);
|
---|
| 400 | thisLayout->addWidget(titleLabel);
|
---|
| 401 | thisLayout->addWidget(inputBox);
|
---|
| 402 |
|
---|
[4cf323d] | 403 | pipe = new DoubleQtQueryPipe(&tmp,_dialog);
|
---|
[b8d1aeb] | 404 | pipe->update(inputBox->value());
|
---|
| 405 | connect(inputBox,SIGNAL(valueChanged(double)),pipe,SLOT(update(double)));
|
---|
| 406 | }
|
---|
| 407 |
|
---|
[4cf323d] | 408 | QtDialog::DoubleQtQuery::~DoubleQtQuery()
|
---|
[b8d1aeb] | 409 | {
|
---|
| 410 | delete pipe;
|
---|
| 411 | }
|
---|
| 412 |
|
---|
[4cf323d] | 413 | bool QtDialog::DoubleQtQuery::handle() {
|
---|
[b8d1aeb] | 414 | return true;
|
---|
| 415 | }
|
---|
| 416 |
|
---|
[d3a5ea] | 417 |
|
---|
[4cf323d] | 418 | QtDialog::DoublesQtQuery::DoublesQtQuery(string title,QBoxLayout *_parent,QtDialog *_dialog) :
|
---|
[7cd6e7] | 419 | Dialog::DoublesQuery(title),
|
---|
| 420 | parent(_parent)
|
---|
| 421 | {
|
---|
| 422 | QHBoxLayout * thisHLayout = new QHBoxLayout();
|
---|
| 423 | QVBoxLayout * thisV1Layout = new QVBoxLayout();
|
---|
| 424 | QVBoxLayout * thisV2Layout = new QVBoxLayout();
|
---|
| 425 |
|
---|
| 426 | QLabel *titleLabel = new QLabel(QString(getTitle().c_str()));
|
---|
| 427 | QLabel *inputLabel = new QLabel("Enter to add");
|
---|
| 428 | QListWidget* inputList = new QListWidget();
|
---|
| 429 | inputList->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
---|
| 430 | QLineEdit* inputBox = new QLineEdit();
|
---|
| 431 | inputLabel->setBuddy(inputBox);
|
---|
| 432 | titleLabel->setBuddy(inputList);
|
---|
| 433 | QPushButton* AddButton = new QPushButton("Add");
|
---|
| 434 | AddButton->setEnabled(false);
|
---|
| 435 | QPushButton* RemoveButton = new QPushButton("Remove");
|
---|
| 436 | RemoveButton->setEnabled(false);
|
---|
| 437 |
|
---|
| 438 | thisV1Layout->addWidget(titleLabel);
|
---|
| 439 | thisV1Layout->addWidget(inputList);
|
---|
| 440 | thisV2Layout->addWidget(inputLabel);
|
---|
| 441 | thisV2Layout->addWidget(inputBox);
|
---|
| 442 | thisV2Layout->addWidget(AddButton);
|
---|
| 443 | thisV2Layout->addWidget(RemoveButton);
|
---|
| 444 | parent->addLayout(thisHLayout);
|
---|
| 445 | thisHLayout->addLayout(thisV1Layout);
|
---|
| 446 | thisHLayout->addLayout(thisV2Layout);
|
---|
| 447 |
|
---|
[4cf323d] | 448 | pipe = new QtQueryListPipe<double>(&tmp,_dialog,inputBox,inputList,AddButton,RemoveButton);
|
---|
[7cd6e7] | 449 | connect(inputBox,SIGNAL(textChanged(const QString&)),pipe,SLOT(IntegerEntered(const QString&)));
|
---|
| 450 | connect(inputList,SIGNAL(itemSelectionChanged()),pipe,SLOT(IntegerSelected()));
|
---|
| 451 | connect(AddButton,SIGNAL(Clicked()),pipe,SLOT(AddValue()));
|
---|
| 452 | connect(RemoveButton,SIGNAL(Clicked()),pipe,SLOT(RemoveRow()));}
|
---|
| 453 |
|
---|
[4cf323d] | 454 | QtDialog::DoublesQtQuery::~DoublesQtQuery()
|
---|
[7cd6e7] | 455 | {
|
---|
| 456 | delete pipe;
|
---|
| 457 | }
|
---|
| 458 |
|
---|
[4cf323d] | 459 | bool QtDialog::DoublesQtQuery::handle() {
|
---|
[7cd6e7] | 460 | return true;
|
---|
| 461 | }
|
---|
| 462 |
|
---|
| 463 |
|
---|
[4cf323d] | 464 | QtDialog::StringQtQuery::StringQtQuery(string _title,QBoxLayout *_parent,QtDialog *_dialog) :
|
---|
[3731b4] | 465 | Dialog::StringQuery(_title),
|
---|
[d3a5ea] | 466 | parent(_parent)
|
---|
| 467 | {
|
---|
| 468 | thisLayout = new QHBoxLayout();
|
---|
| 469 | titleLabel = new QLabel(QString(getTitle().c_str()));
|
---|
| 470 | inputBox = new QLineEdit();
|
---|
| 471 | parent->addLayout(thisLayout);
|
---|
| 472 | thisLayout->addWidget(titleLabel);
|
---|
| 473 | thisLayout->addWidget(inputBox);
|
---|
| 474 |
|
---|
[4cf323d] | 475 | pipe = new StringQtQueryPipe(&tmp,_dialog);
|
---|
[d3a5ea] | 476 | pipe->update(inputBox->text());
|
---|
| 477 | connect(inputBox,SIGNAL(textChanged(const QString&)),pipe,SLOT(update(const QString&)));
|
---|
| 478 | }
|
---|
| 479 |
|
---|
[4cf323d] | 480 | QtDialog::StringQtQuery::~StringQtQuery()
|
---|
[d3a5ea] | 481 | {
|
---|
| 482 | delete pipe;
|
---|
| 483 | }
|
---|
| 484 |
|
---|
[9ee38b] | 485 | // All values besides the empty std::string are valid
|
---|
[4cf323d] | 486 | bool QtDialog::StringQtQuery::handle()
|
---|
[d3a5ea] | 487 | {
|
---|
| 488 | return tmp!="";
|
---|
| 489 | }
|
---|
| 490 |
|
---|
[4cf323d] | 491 | QtDialog::StringsQtQuery::StringsQtQuery(string _title,QBoxLayout *_parent,QtDialog *_dialog) :
|
---|
[3731b4] | 492 | Dialog::StringsQuery(_title),
|
---|
[cd8e55] | 493 | parent(_parent)
|
---|
| 494 | {
|
---|
[7cd6e7] | 495 | QHBoxLayout * thisHLayout = new QHBoxLayout();
|
---|
| 496 | QVBoxLayout * thisV1Layout = new QVBoxLayout();
|
---|
| 497 | QVBoxLayout * thisV2Layout = new QVBoxLayout();
|
---|
| 498 |
|
---|
| 499 | QLabel *titleLabel = new QLabel(QString(getTitle().c_str()));
|
---|
| 500 | QLabel *inputLabel = new QLabel("Enter to add");
|
---|
| 501 | QListWidget* inputList = new QListWidget();
|
---|
| 502 | inputList->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
---|
| 503 | QLineEdit* inputBox = new QLineEdit();
|
---|
| 504 | inputLabel->setBuddy(inputBox);
|
---|
| 505 | titleLabel->setBuddy(inputList);
|
---|
| 506 | QPushButton* AddButton = new QPushButton("Add");
|
---|
| 507 | AddButton->setEnabled(false);
|
---|
| 508 | QPushButton* RemoveButton = new QPushButton("Remove");
|
---|
| 509 | RemoveButton->setEnabled(false);
|
---|
| 510 |
|
---|
| 511 | thisV1Layout->addWidget(titleLabel);
|
---|
| 512 | thisV1Layout->addWidget(inputList);
|
---|
| 513 | thisV2Layout->addWidget(inputLabel);
|
---|
| 514 | thisV2Layout->addWidget(inputBox);
|
---|
| 515 | thisV2Layout->addWidget(AddButton);
|
---|
| 516 | thisV2Layout->addWidget(RemoveButton);
|
---|
| 517 | parent->addLayout(thisHLayout);
|
---|
| 518 | thisHLayout->addLayout(thisV1Layout);
|
---|
| 519 | thisHLayout->addLayout(thisV2Layout);
|
---|
| 520 |
|
---|
[4cf323d] | 521 | pipe = new QtQueryListPipe<std::string>(&tmp,_dialog,inputBox,inputList,AddButton,RemoveButton);
|
---|
[7cd6e7] | 522 | connect(inputBox,SIGNAL(textChanged(const QString&)),pipe,SLOT(IntegerEntered(const QString&)));
|
---|
| 523 | connect(inputList,SIGNAL(itemSelectionChanged()),pipe,SLOT(IntegerSelected()));
|
---|
| 524 | connect(AddButton,SIGNAL(Clicked()),pipe,SLOT(AddValue()));
|
---|
| 525 | connect(RemoveButton,SIGNAL(Clicked()),pipe,SLOT(RemoveRow()));}
|
---|
[cd8e55] | 526 |
|
---|
[4cf323d] | 527 | QtDialog::StringsQtQuery::~StringsQtQuery()
|
---|
[cd8e55] | 528 | {
|
---|
| 529 | delete pipe;
|
---|
| 530 | }
|
---|
| 531 |
|
---|
[9ee38b] | 532 | // All values besides the empty std::string are valid
|
---|
[4cf323d] | 533 | bool QtDialog::StringsQtQuery::handle()
|
---|
[cd8e55] | 534 | {
|
---|
| 535 | // dissect by ","
|
---|
[9ee38b] | 536 | std::string::iterator olditer = temp.begin();
|
---|
[cd8e55] | 537 | for(string::iterator iter = temp.begin(); iter != temp.end(); ++iter) {
|
---|
| 538 | if (*iter == ' ') {
|
---|
| 539 | tmp.push_back(string(iter, olditer));
|
---|
| 540 | olditer = iter;
|
---|
| 541 | }
|
---|
| 542 | }
|
---|
| 543 | if (olditer != temp.begin()) // insert last part also
|
---|
| 544 | tmp.push_back(string(olditer, temp.end()));
|
---|
| 545 |
|
---|
| 546 | return temp!="";
|
---|
| 547 | }
|
---|
| 548 |
|
---|
[4cf323d] | 549 | QtDialog::MoleculeQtQuery::MoleculeQtQuery(string _title, QBoxLayout *_parent,QtDialog *_dialog) :
|
---|
[3731b4] | 550 | Dialog::MoleculeQuery(_title),
|
---|
[d3a5ea] | 551 | parent(_parent)
|
---|
| 552 | {
|
---|
| 553 | thisLayout = new QHBoxLayout();
|
---|
| 554 | titleLabel = new QLabel(QString(getTitle().c_str()));
|
---|
| 555 | inputBox = new QComboBox();
|
---|
| 556 | // add all molecules to the combo box
|
---|
[257c77] | 557 | vector<molecule*> molecules = World::getInstance().getAllMolecules();
|
---|
| 558 | for(vector<molecule*>::iterator iter = molecules.begin();
|
---|
| 559 | iter != molecules.end();
|
---|
[cbf01e] | 560 | ++iter) {
|
---|
[9ee38b] | 561 | std::stringstream sstr;
|
---|
[6adb96] | 562 | sstr << (*iter)->IndexNr << "\t" << (*iter)->getName();
|
---|
[d3a5ea] | 563 | inputBox->addItem(QString(sstr.str().c_str()),QVariant((*iter)->IndexNr));
|
---|
| 564 | }
|
---|
| 565 | parent->addLayout(thisLayout);
|
---|
| 566 | thisLayout->addWidget(titleLabel);
|
---|
| 567 | thisLayout->addWidget(inputBox);
|
---|
| 568 |
|
---|
[4cf323d] | 569 | pipe = new MoleculeQtQueryPipe(&tmp,_dialog,inputBox);
|
---|
[d3a5ea] | 570 | pipe->update(inputBox->currentIndex());
|
---|
| 571 | connect(inputBox,SIGNAL(currentIndexChanged(int)),pipe,SLOT(update(int)));
|
---|
| 572 | }
|
---|
| 573 |
|
---|
[4cf323d] | 574 | QtDialog::MoleculeQtQuery::~MoleculeQtQuery()
|
---|
[d3a5ea] | 575 | {
|
---|
| 576 | delete pipe;
|
---|
| 577 | }
|
---|
| 578 |
|
---|
| 579 | // Handling is easy, since the GUI makes it impossible to select invalid values
|
---|
[4cf323d] | 580 | bool QtDialog::MoleculeQtQuery::handle()
|
---|
[d3a5ea] | 581 | {
|
---|
| 582 | return true;
|
---|
| 583 | }
|
---|
| 584 |
|
---|
[4cf323d] | 585 | QtDialog::MoleculesQtQuery::MoleculesQtQuery(string _title, QBoxLayout *_parent,QtDialog *_dialog) :
|
---|
[7cd6e7] | 586 | Dialog::MoleculesQuery(_title),
|
---|
| 587 | parent(_parent)
|
---|
| 588 | {
|
---|
| 589 | thisLayout = new QHBoxLayout();
|
---|
| 590 | titleLabel = new QLabel(QString(getTitle().c_str()));
|
---|
| 591 | inputBox = new QComboBox();
|
---|
| 592 | // add all molecules to the combo box
|
---|
| 593 | vector<molecule*> molecules = World::getInstance().getAllMolecules();
|
---|
| 594 | for(vector<molecule*>::iterator iter = molecules.begin();
|
---|
| 595 | iter != molecules.end();
|
---|
| 596 | ++iter) {
|
---|
[9ee38b] | 597 | std::stringstream sstr;
|
---|
[7cd6e7] | 598 | sstr << (*iter)->IndexNr << "\t" << (*iter)->getName();
|
---|
| 599 | inputBox->addItem(QString(sstr.str().c_str()),QVariant((*iter)->IndexNr));
|
---|
| 600 | }
|
---|
| 601 | parent->addLayout(thisLayout);
|
---|
| 602 | thisLayout->addWidget(titleLabel);
|
---|
| 603 | thisLayout->addWidget(inputBox);
|
---|
| 604 |
|
---|
[4cf323d] | 605 | pipe = new MoleculesQtQueryPipe(&tmp,_dialog,inputBox);
|
---|
[7cd6e7] | 606 | pipe->update(inputBox->currentIndex());
|
---|
| 607 | connect(inputBox,SIGNAL(currentIndexChanged(int)),pipe,SLOT(update(int)));
|
---|
| 608 | }
|
---|
| 609 |
|
---|
[4cf323d] | 610 | QtDialog::MoleculesQtQuery::~MoleculesQtQuery()
|
---|
[7cd6e7] | 611 | {
|
---|
| 612 | delete pipe;
|
---|
| 613 | }
|
---|
| 614 |
|
---|
| 615 | // Handling is easy, since the GUI makes it impossible to select invalid values
|
---|
[4cf323d] | 616 | bool QtDialog::MoleculesQtQuery::handle()
|
---|
[7cd6e7] | 617 | {
|
---|
| 618 | return true;
|
---|
| 619 | }
|
---|
| 620 |
|
---|
[4cf323d] | 621 | QtDialog::VectorQtQuery::VectorQtQuery(std::string title, bool _check,QBoxLayout *_parent,QtDialog *_dialog) :
|
---|
[3731b4] | 622 | Dialog::VectorQuery(title,_check),
|
---|
[b8d1aeb] | 623 | parent(_parent)
|
---|
| 624 | {
|
---|
| 625 | mainLayout= new QHBoxLayout();
|
---|
| 626 | titleLabel = new QLabel(QString(getTitle().c_str()));
|
---|
| 627 | mainLayout->addWidget(titleLabel);
|
---|
| 628 | subLayout = new QVBoxLayout();
|
---|
| 629 | mainLayout->addLayout(subLayout);
|
---|
[7cd6e7] | 630 | QComboBox* inputBox = new QComboBox();
|
---|
| 631 | coordLayout = new QHBoxLayout();
|
---|
| 632 | subLayout->addLayout(coordLayout);
|
---|
| 633 | coordLabel = new QLabel(QString("x,y,z"));
|
---|
| 634 | coordLayout->addWidget(coordLabel);
|
---|
| 635 | coordInput = new QDoubleSpinBox();
|
---|
| 636 | // coordInput->setRange(0,M.at(i,i));
|
---|
| 637 | coordInput->setDecimals(3);
|
---|
| 638 | coordLayout->addWidget(coordInput);
|
---|
[4cf323d] | 639 | pipe = new VectorQtQueryPipe(&(tmp),_dialog,inputBox);
|
---|
[7cd6e7] | 640 | //pipe->update(coordInput->value());
|
---|
| 641 | connect(coordInput,SIGNAL(valueChanged(double)),pipe,SLOT(update(double)));
|
---|
[b8d1aeb] | 642 | parent->addLayout(mainLayout);
|
---|
| 643 | }
|
---|
| 644 |
|
---|
[4cf323d] | 645 | QtDialog::VectorQtQuery::~VectorQtQuery()
|
---|
[b8d1aeb] | 646 | {}
|
---|
| 647 |
|
---|
[4cf323d] | 648 | bool QtDialog::VectorQtQuery::handle() {
|
---|
[b8d1aeb] | 649 | return true;
|
---|
| 650 | }
|
---|
| 651 |
|
---|
[d3a5ea] | 652 |
|
---|
[4cf323d] | 653 | QtDialog::VectorsQtQuery::VectorsQtQuery(std::string title, bool _check,QBoxLayout *_parent,QtDialog *_dialog) :
|
---|
[7cd6e7] | 654 | Dialog::VectorsQuery(title,_check),
|
---|
| 655 | parent(_parent)
|
---|
| 656 | {
|
---|
| 657 | mainLayout= new QHBoxLayout();
|
---|
| 658 | titleLabel = new QLabel(QString(getTitle().c_str()));
|
---|
| 659 | mainLayout->addWidget(titleLabel);
|
---|
| 660 | subLayout = new QVBoxLayout();
|
---|
| 661 | mainLayout->addLayout(subLayout);
|
---|
| 662 | QComboBox* inputBox = new QComboBox();
|
---|
| 663 | coordLayout = new QHBoxLayout();
|
---|
| 664 | subLayout->addLayout(coordLayout);
|
---|
| 665 | coordLabel = new QLabel(QString("x,y,z"));
|
---|
| 666 | coordLayout->addWidget(coordLabel);
|
---|
| 667 | coordInput = new QDoubleSpinBox();
|
---|
| 668 | // coordInput->setRange(0,M.at(i,i));
|
---|
| 669 | coordInput->setDecimals(3);
|
---|
| 670 | coordLayout->addWidget(coordInput);
|
---|
[4cf323d] | 671 | pipe = new VectorsQtQueryPipe(&(tmp),_dialog,inputBox);
|
---|
[7cd6e7] | 672 | //pipe->update(coordInput->value());
|
---|
| 673 | connect(coordInput,SIGNAL(valueChanged(double)),pipe,SLOT(update(double)));
|
---|
| 674 | parent->addLayout(mainLayout);
|
---|
| 675 | }
|
---|
| 676 |
|
---|
[4cf323d] | 677 | QtDialog::VectorsQtQuery::~VectorsQtQuery()
|
---|
[7cd6e7] | 678 | {}
|
---|
| 679 |
|
---|
[4cf323d] | 680 | bool QtDialog::VectorsQtQuery::handle() {
|
---|
[7cd6e7] | 681 | return true;
|
---|
| 682 | }
|
---|
| 683 |
|
---|
| 684 |
|
---|
[4cf323d] | 685 | QtDialog::ElementQtQuery::ElementQtQuery(std::string _title, QBoxLayout *_parent, QtDialog *_dialog) :
|
---|
[3731b4] | 686 | Dialog::ElementQuery(_title),
|
---|
[cbf01e] | 687 | parent(_parent)
|
---|
| 688 | {
|
---|
[cd032d] | 689 | periodentafel *periode = World::getInstance().getPeriode();
|
---|
[cbf01e] | 690 | thisLayout = new QHBoxLayout();
|
---|
| 691 | titleLabel = new QLabel(QString(getTitle().c_str()));
|
---|
| 692 | inputBox = new QComboBox();
|
---|
[68d781] | 693 | for(periodentafel::const_iterator iter = periode->begin();
|
---|
| 694 | iter!=periode->end();
|
---|
| 695 | ++iter)
|
---|
[cbf01e] | 696 | {
|
---|
[9ee38b] | 697 | std::stringstream sstr;
|
---|
[2fe971] | 698 | sstr << (*iter).first << "\t" << (*iter).second->getName();
|
---|
[68d781] | 699 | inputBox->addItem(QString(sstr.str().c_str()),QVariant((*iter).first));
|
---|
[cbf01e] | 700 | }
|
---|
| 701 | parent->addLayout(thisLayout);
|
---|
| 702 | thisLayout->addWidget(titleLabel);
|
---|
| 703 | thisLayout->addWidget(inputBox);
|
---|
| 704 |
|
---|
[4cf323d] | 705 | pipe = new ElementQtQueryPipe(&tmp,_dialog,inputBox);
|
---|
[cbf01e] | 706 | pipe->update(inputBox->currentIndex());
|
---|
| 707 | connect(inputBox,SIGNAL(currentIndexChanged(int)),pipe,SLOT(update(int)));
|
---|
| 708 | }
|
---|
| 709 |
|
---|
[4cf323d] | 710 | QtDialog::ElementQtQuery::~ElementQtQuery()
|
---|
[cbf01e] | 711 | {
|
---|
| 712 | delete pipe;
|
---|
| 713 | }
|
---|
| 714 |
|
---|
[4cf323d] | 715 | bool QtDialog::ElementQtQuery::handle(){
|
---|
[cbf01e] | 716 | return true;
|
---|
| 717 | }
|
---|
| 718 |
|
---|
[7cd6e7] | 719 |
|
---|
[4cf323d] | 720 | QtDialog::ElementsQtQuery::ElementsQtQuery(std::string _title, QBoxLayout *_parent, QtDialog *_dialog) :
|
---|
[7cd6e7] | 721 | Dialog::ElementsQuery(_title),
|
---|
| 722 | parent(_parent)
|
---|
| 723 | {
|
---|
| 724 | periodentafel *periode = World::getInstance().getPeriode();
|
---|
| 725 | thisLayout = new QHBoxLayout();
|
---|
| 726 | titleLabel = new QLabel(QString(getTitle().c_str()));
|
---|
| 727 | inputBox = new QComboBox();
|
---|
| 728 | for(periodentafel::const_iterator iter = periode->begin();
|
---|
| 729 | iter!=periode->end();
|
---|
| 730 | ++iter)
|
---|
| 731 | {
|
---|
[9ee38b] | 732 | std::stringstream sstr;
|
---|
[2fe971] | 733 | sstr << (*iter).first << "\t" << (*iter).second->getName();
|
---|
[7cd6e7] | 734 | inputBox->addItem(QString(sstr.str().c_str()),QVariant((*iter).first));
|
---|
| 735 | }
|
---|
| 736 | parent->addLayout(thisLayout);
|
---|
| 737 | thisLayout->addWidget(titleLabel);
|
---|
| 738 | thisLayout->addWidget(inputBox);
|
---|
| 739 |
|
---|
[4cf323d] | 740 | pipe = new ElementsQtQueryPipe(&tmp,_dialog,inputBox);
|
---|
[7cd6e7] | 741 | pipe->update(inputBox->currentIndex());
|
---|
| 742 | connect(inputBox,SIGNAL(currentIndexChanged(int)),pipe,SLOT(update(int)));
|
---|
| 743 | }
|
---|
| 744 |
|
---|
[4cf323d] | 745 | QtDialog::ElementsQtQuery::~ElementsQtQuery()
|
---|
[7cd6e7] | 746 | {
|
---|
| 747 | delete pipe;
|
---|
| 748 | }
|
---|
| 749 |
|
---|
[4cf323d] | 750 | bool QtDialog::ElementsQtQuery::handle(){
|
---|
[7cd6e7] | 751 | return true;
|
---|
| 752 | }
|
---|
| 753 |
|
---|
[4cf323d] | 754 | QtDialog::EmptyQtQuery::EmptyQtQuery(std::string _title, QBoxLayout *_parent, QtDialog *_dialog) :
|
---|
[9d457d] | 755 | Dialog::EmptyQuery(_title),
|
---|
| 756 | parent(_parent)
|
---|
| 757 | {
|
---|
| 758 | titleLabel = new QLabel(QString(getTitle().c_str()));
|
---|
| 759 |
|
---|
| 760 | parent->addLayout(thisLayout);
|
---|
| 761 | thisLayout->addWidget(titleLabel);
|
---|
| 762 |
|
---|
[4cf323d] | 763 | pipe = new EmptyQtQueryPipe(_dialog,titleLabel);
|
---|
[9d457d] | 764 | }
|
---|
| 765 |
|
---|
[4cf323d] | 766 | QtDialog::EmptyQtQuery::~EmptyQtQuery()
|
---|
[9d457d] | 767 | {
|
---|
| 768 | delete pipe;
|
---|
| 769 | }
|
---|
| 770 |
|
---|
[4cf323d] | 771 | bool QtDialog::EmptyQtQuery::handle(){
|
---|
[9d457d] | 772 | return true;
|
---|
| 773 | }
|
---|
| 774 |
|
---|
| 775 |
|
---|
[4cf323d] | 776 | QtDialog::BooleanQtQuery::BooleanQtQuery(std::string _title, QBoxLayout *_parent, QtDialog *_dialog) :
|
---|
[ee62e4] | 777 | Dialog::BooleanQuery(_title),
|
---|
| 778 | parent(_parent)
|
---|
| 779 | {
|
---|
| 780 | titleLabel = new QLabel(QString(getTitle().c_str()),_dialog);
|
---|
| 781 | booleanComboBox = new QComboBox(_dialog);
|
---|
| 782 | booleanComboBox->insertItem(1, QString("true"));
|
---|
| 783 | booleanComboBox->insertItem(0, QString("false"));
|
---|
| 784 |
|
---|
| 785 | parent->addLayout(thisLayout);
|
---|
| 786 | thisLayout->addWidget(titleLabel);
|
---|
| 787 | thisLayout->addWidget(booleanComboBox);
|
---|
| 788 |
|
---|
[4cf323d] | 789 | pipe = new BooleanQtQueryPipe(&tmp,_dialog,booleanComboBox);
|
---|
[ee62e4] | 790 | connect(booleanComboBox, SIGNAL(currentIndexChanged()), pipe, SLOT(update()));
|
---|
| 791 | }
|
---|
| 792 |
|
---|
[4cf323d] | 793 | QtDialog::BooleanQtQuery::~BooleanQtQuery()
|
---|
[ee62e4] | 794 | {
|
---|
| 795 | delete pipe;
|
---|
| 796 | }
|
---|
| 797 |
|
---|
[4cf323d] | 798 | bool QtDialog::BooleanQtQuery::handle(){
|
---|
[ee62e4] | 799 | return true;
|
---|
| 800 | }
|
---|
| 801 |
|
---|
| 802 |
|
---|
[4cf323d] | 803 | QtDialog::FileQtQuery::FileQtQuery(std::string _title, QBoxLayout *_parent, QtDialog *_dialog) :
|
---|
[6f5dfe] | 804 | Dialog::FileQuery(_title),
|
---|
| 805 | parent(_parent)
|
---|
| 806 | {
|
---|
| 807 |
|
---|
| 808 | filenameLineEdit = new QLineEdit(_dialog);
|
---|
| 809 | filenameLineEdit->setText(QString());
|
---|
| 810 | filenameLineEdit->setReadOnly(true);
|
---|
| 811 |
|
---|
[f001ca] | 812 | filenameLabel = new QLabel(QString("Input file:"));
|
---|
| 813 | filenameLabel->setBuddy(filenameLineEdit);
|
---|
| 814 |
|
---|
[6f5dfe] | 815 | filedialogButton = new QPushButton("&Choose", _dialog);
|
---|
| 816 |
|
---|
[4cf323d] | 817 | pipe = new FileQtQueryPipe(&tmp,_dialog,filenameLineEdit,filedialogButton);
|
---|
[6f5dfe] | 818 |
|
---|
| 819 | thisLayout = new QHBoxLayout();
|
---|
| 820 | parent->addLayout(thisLayout);
|
---|
[f001ca] | 821 | thisLayout->addWidget(filenameLabel);
|
---|
[6f5dfe] | 822 | thisLayout->addWidget(filenameLineEdit);
|
---|
| 823 | thisLayout->addWidget(filedialogButton);
|
---|
| 824 |
|
---|
| 825 | QObject::connect(filedialogButton,SIGNAL(clicked()),pipe,SLOT(showFileDialog()));
|
---|
| 826 | }
|
---|
| 827 |
|
---|
[4cf323d] | 828 | QtDialog::FileQtQuery::~FileQtQuery()
|
---|
[6f5dfe] | 829 | {
|
---|
| 830 | delete pipe;
|
---|
| 831 | }
|
---|
| 832 |
|
---|
[4cf323d] | 833 | bool QtDialog::FileQtQuery::handle(){
|
---|
[6f5dfe] | 834 | return true;
|
---|
| 835 | }
|
---|
| 836 |
|
---|
[d3a5ea] | 837 | /*************************** Plumbing *******************************/
|
---|
| 838 |
|
---|
[7cd6e7] | 839 |
|
---|
[4cf323d] | 840 | template<typename T> QtQueryListPipe<T>::QtQueryListPipe(std::vector<T> *_content, QtDialog *_dialog, QLineEdit *_inputBox, QListWidget *_inputList, QPushButton *_AddButton, QPushButton *_RemoveButton) :
|
---|
[7cd6e7] | 841 | content(_content),
|
---|
| 842 | dialog(_dialog),
|
---|
| 843 | inputBox(_inputBox),
|
---|
| 844 | inputList(_inputList),
|
---|
| 845 | AddButton(_AddButton),
|
---|
| 846 | RemoveButton(_RemoveButton)
|
---|
| 847 | {}
|
---|
| 848 |
|
---|
[4cf323d] | 849 | template<typename T> QtQueryListPipe<T>::~QtQueryListPipe()
|
---|
[7cd6e7] | 850 | {}
|
---|
| 851 |
|
---|
[4cf323d] | 852 | template<typename T> void QtQueryListPipe<T>::IntegerEntered(const QString&)
|
---|
[7cd6e7] | 853 | {
|
---|
| 854 | AddButton->setEnabled(true);
|
---|
| 855 | }
|
---|
| 856 |
|
---|
[4cf323d] | 857 | template<typename T> void QtQueryListPipe<T>::IntegerSelected()
|
---|
[7cd6e7] | 858 | {
|
---|
| 859 | if (inputList->selectedItems().empty())
|
---|
| 860 | RemoveButton->setEnabled(false);
|
---|
| 861 | else
|
---|
| 862 | RemoveButton->setEnabled(true);
|
---|
| 863 | }
|
---|
| 864 |
|
---|
[4cf323d] | 865 | template<typename T> void QtQueryListPipe<T>::AddInteger() {
|
---|
[7cd6e7] | 866 | // type-check
|
---|
| 867 | std::string text = inputBox->text().toStdString();
|
---|
| 868 | int number = 0;
|
---|
| 869 | try {
|
---|
| 870 | number = boost::lexical_cast<int>(text);
|
---|
| 871 | } catch (boost::bad_lexical_cast&) {
|
---|
| 872 | return;
|
---|
| 873 | };
|
---|
| 874 | // add item to both
|
---|
| 875 | inputList->addItem(QString(number));
|
---|
| 876 | AddValue(number);
|
---|
| 877 | }
|
---|
| 878 |
|
---|
[4cf323d] | 879 | template<typename T> void QtQueryListPipe<T>::AddValue(T item) {
|
---|
[7cd6e7] | 880 | content->push_back(item);
|
---|
| 881 |
|
---|
| 882 | dialog->update();
|
---|
| 883 | }
|
---|
| 884 |
|
---|
[4cf323d] | 885 | template<typename T> void QtQueryListPipe<T>::RemoveInteger() {
|
---|
[7cd6e7] | 886 | QList<QListWidgetItem *> items = inputList->selectedItems();
|
---|
| 887 | for (QList<QListWidgetItem *>::iterator iter = items.begin(); !items.empty(); iter = items.begin()) {
|
---|
| 888 | // obtain which position item has (by making it current item)
|
---|
| 889 | inputList->setCurrentItem(*iter);
|
---|
| 890 | // remove
|
---|
[4cf323d] | 891 | QtQueryListPipe<T>::RemoteRow(inputList->currentRow()); // template parameters needs to be known, such that compiler knows which to call
|
---|
[7cd6e7] | 892 | inputList->removeItemWidget(*iter);
|
---|
| 893 | }
|
---|
| 894 | }
|
---|
| 895 |
|
---|
[4cf323d] | 896 | template<typename T> void QtQueryListPipe<T>::RemoveRow(int row) {
|
---|
[7cd6e7] | 897 | int counter = 0;
|
---|
| 898 | typename std::vector<T>::iterator iter = content->begin();
|
---|
| 899 | for (; iter != content->end(); ++iter)
|
---|
| 900 | if (counter++ == row)
|
---|
| 901 | break;
|
---|
| 902 | if (iter != content->end())
|
---|
| 903 | content->erase(iter);
|
---|
| 904 | }
|
---|
| 905 |
|
---|
| 906 |
|
---|
[4cf323d] | 907 | StringQtQueryPipe::StringQtQueryPipe(string *_content, QtDialog *_dialog) :
|
---|
[d3a5ea] | 908 | content(_content),
|
---|
| 909 | dialog(_dialog)
|
---|
| 910 | {}
|
---|
| 911 |
|
---|
[4cf323d] | 912 | StringQtQueryPipe::~StringQtQueryPipe()
|
---|
[d3a5ea] | 913 | {}
|
---|
| 914 |
|
---|
[4cf323d] | 915 | void StringQtQueryPipe::update(const QString& newText) {
|
---|
[d3a5ea] | 916 | content->assign(newText.toStdString());
|
---|
| 917 | dialog->update();
|
---|
| 918 | }
|
---|
| 919 |
|
---|
[4cf323d] | 920 | IntQtQueryPipe::IntQtQueryPipe(int *_content, QtDialog *_dialog) :
|
---|
[d3a5ea] | 921 | content(_content),
|
---|
| 922 | dialog(_dialog)
|
---|
| 923 | {}
|
---|
| 924 |
|
---|
[4cf323d] | 925 | IntQtQueryPipe::~IntQtQueryPipe()
|
---|
[d3a5ea] | 926 | {}
|
---|
| 927 |
|
---|
[4cf323d] | 928 | void IntQtQueryPipe::update(int newInt) {
|
---|
[d3a5ea] | 929 | (*content) = newInt;
|
---|
| 930 | dialog->update();
|
---|
| 931 | }
|
---|
| 932 |
|
---|
[4cf323d] | 933 | DoubleQtQueryPipe::DoubleQtQueryPipe(double *_content, QtDialog *_dialog) :
|
---|
[b8d1aeb] | 934 | content(_content),
|
---|
| 935 | dialog(_dialog)
|
---|
| 936 | {}
|
---|
| 937 |
|
---|
[4cf323d] | 938 | DoubleQtQueryPipe::~DoubleQtQueryPipe()
|
---|
[b8d1aeb] | 939 | {}
|
---|
| 940 |
|
---|
[4cf323d] | 941 | void DoubleQtQueryPipe::update(double newDbl) {
|
---|
[b8d1aeb] | 942 | (*content) = newDbl;
|
---|
| 943 | dialog->update();
|
---|
| 944 | }
|
---|
| 945 |
|
---|
[4cf323d] | 946 | VectorQtQueryPipe::VectorQtQueryPipe(Vector *_content, QtDialog *_dialog, QComboBox *_theBox) :
|
---|
[7cd6e7] | 947 | content(_content),
|
---|
| 948 | dialog(_dialog),
|
---|
| 949 | theBox(_theBox)
|
---|
| 950 | {}
|
---|
| 951 |
|
---|
[4cf323d] | 952 | VectorQtQueryPipe::~VectorQtQueryPipe()
|
---|
[7cd6e7] | 953 | {}
|
---|
| 954 |
|
---|
[4cf323d] | 955 | void VectorQtQueryPipe::update() {
|
---|
[7cd6e7] | 956 | dialog->update();
|
---|
| 957 | }
|
---|
| 958 |
|
---|
[4cf323d] | 959 | VectorsQtQueryPipe::VectorsQtQueryPipe(std::vector<Vector> *_content, QtDialog *_dialog, QComboBox *_theBox) :
|
---|
[7cd6e7] | 960 | content(_content),
|
---|
| 961 | dialog(_dialog),
|
---|
| 962 | theBox(_theBox)
|
---|
| 963 | {}
|
---|
| 964 |
|
---|
[4cf323d] | 965 | VectorsQtQueryPipe::~VectorsQtQueryPipe()
|
---|
[7cd6e7] | 966 | {}
|
---|
| 967 |
|
---|
[4cf323d] | 968 | void VectorsQtQueryPipe::update() {
|
---|
[7cd6e7] | 969 | dialog->update();
|
---|
| 970 | }
|
---|
| 971 |
|
---|
[4cf323d] | 972 | BoxQtQueryPipe::BoxQtQueryPipe(Box &_content, QtDialog *_dialog, QTableWidget *_inputTable) :
|
---|
[41167c] | 973 | content(_content),
|
---|
| 974 | dialog(_dialog),
|
---|
| 975 | inputTable(_inputTable)
|
---|
| 976 | {
|
---|
| 977 | tmpM = new Matrix();
|
---|
| 978 | tmpM->zero();
|
---|
| 979 | }
|
---|
| 980 |
|
---|
[4cf323d] | 981 | BoxQtQueryPipe::~BoxQtQueryPipe()
|
---|
[41167c] | 982 | {
|
---|
| 983 | delete tmpM;
|
---|
| 984 | }
|
---|
| 985 |
|
---|
[4cf323d] | 986 | void BoxQtQueryPipe::update(int row, int column)
|
---|
[41167c] | 987 | {
|
---|
| 988 | tmpM->at(row, column) = inputTable->item(row, column)->text().toDouble();
|
---|
| 989 | content.setM(*tmpM);
|
---|
| 990 | dialog->update();
|
---|
| 991 | }
|
---|
| 992 |
|
---|
| 993 |
|
---|
[4cf323d] | 994 | AtomQtQueryPipe::AtomQtQueryPipe(atom **_content, QtDialog *_dialog, QComboBox *_theBox) :
|
---|
[7cd6e7] | 995 | content(_content),
|
---|
| 996 | dialog(_dialog),
|
---|
| 997 | theBox(_theBox)
|
---|
| 998 | {}
|
---|
| 999 |
|
---|
[4cf323d] | 1000 | AtomQtQueryPipe::~AtomQtQueryPipe()
|
---|
[7cd6e7] | 1001 | {}
|
---|
| 1002 |
|
---|
[4cf323d] | 1003 | void AtomQtQueryPipe::update(int newIndex) {
|
---|
[7cd6e7] | 1004 | QVariant data = theBox->itemData(newIndex);
|
---|
| 1005 | int idx = data.toInt();
|
---|
| 1006 | (*content) = World::getInstance().getAtom(AtomById(idx));
|
---|
| 1007 | dialog->update();
|
---|
| 1008 | }
|
---|
| 1009 |
|
---|
| 1010 |
|
---|
[4cf323d] | 1011 | AtomsQtQueryPipe::AtomsQtQueryPipe(std::vector<atom *>*_content, QtDialog *_dialog, QListWidget *_theList) :
|
---|
[7cd6e7] | 1012 | content(_content),
|
---|
| 1013 | dialog(_dialog),
|
---|
[c96c66] | 1014 | theList(_theList)
|
---|
[7cd6e7] | 1015 | {}
|
---|
| 1016 |
|
---|
[4cf323d] | 1017 | AtomsQtQueryPipe::~AtomsQtQueryPipe()
|
---|
[7cd6e7] | 1018 | {}
|
---|
| 1019 |
|
---|
[4cf323d] | 1020 | void AtomsQtQueryPipe::update() {
|
---|
[c96c66] | 1021 | // clear target and put all atoms therein
|
---|
| 1022 | (*content).clear();
|
---|
| 1023 | for (std::set<atom *>::iterator iter = currentList.begin(); iter != currentList.end(); ++iter)
|
---|
| 1024 | (*content).push_back(*iter);
|
---|
[7cd6e7] | 1025 | dialog->update();
|
---|
| 1026 | }
|
---|
| 1027 |
|
---|
[4cf323d] | 1028 | void AtomsQtQueryPipe::add() {
|
---|
[c96c66] | 1029 | QList<QListWidgetItem *> items = theList->selectedItems();
|
---|
| 1030 | for (QList<QListWidgetItem *>::iterator iter = items.begin();iter != items.end();++iter) {
|
---|
| 1031 | const int index = (*iter)->text().toInt();
|
---|
| 1032 | atom *Walker = World::getInstance().getAtom(AtomById(index));
|
---|
| 1033 | if (Walker) {
|
---|
| 1034 | (*content).push_back(Walker);
|
---|
| 1035 | currentList.insert(Walker);
|
---|
| 1036 | if (lookup.find(index) != lookup.end())
|
---|
| 1037 | lookup.insert(pair<int, atom*>(index, Walker));
|
---|
| 1038 | }
|
---|
| 1039 | }
|
---|
| 1040 | update();
|
---|
| 1041 | }
|
---|
| 1042 |
|
---|
[4cf323d] | 1043 | void AtomsQtQueryPipe::remove() {
|
---|
[c96c66] | 1044 | QList<QListWidgetItem *> items = theList->selectedItems();
|
---|
| 1045 | for (QList<QListWidgetItem *>::iterator iter = items.begin();iter != items.end();++iter) {
|
---|
| 1046 | const int index = (*iter)->text().toInt();
|
---|
| 1047 | atom *Walker = World::getInstance().getAtom(AtomById(index));
|
---|
| 1048 | if (Walker) {
|
---|
| 1049 | currentList.erase(Walker);
|
---|
| 1050 | }
|
---|
| 1051 | }
|
---|
| 1052 | update();
|
---|
| 1053 | }
|
---|
| 1054 |
|
---|
[7cd6e7] | 1055 |
|
---|
[4cf323d] | 1056 | MoleculeQtQueryPipe::MoleculeQtQueryPipe(molecule **_content, QtDialog *_dialog, QComboBox *_theBox) :
|
---|
[d3a5ea] | 1057 | content(_content),
|
---|
| 1058 | dialog(_dialog),
|
---|
[257c77] | 1059 | theBox(_theBox)
|
---|
[d3a5ea] | 1060 | {}
|
---|
| 1061 |
|
---|
[4cf323d] | 1062 | MoleculeQtQueryPipe::~MoleculeQtQueryPipe()
|
---|
[d3a5ea] | 1063 | {}
|
---|
| 1064 |
|
---|
[4cf323d] | 1065 | void MoleculeQtQueryPipe::update(int newIndex) {
|
---|
[d3a5ea] | 1066 | QVariant data = theBox->itemData(newIndex);
|
---|
| 1067 | int idx = data.toInt();
|
---|
[257c77] | 1068 | (*content) = World::getInstance().getMolecule(MoleculeById(idx));
|
---|
[d3a5ea] | 1069 | dialog->update();
|
---|
| 1070 | }
|
---|
| 1071 |
|
---|
[7cd6e7] | 1072 |
|
---|
[4cf323d] | 1073 | MoleculesQtQueryPipe::MoleculesQtQueryPipe(std::vector<molecule *>*_content, QtDialog *_dialog, QComboBox *_theBox) :
|
---|
[cbf01e] | 1074 | content(_content),
|
---|
| 1075 | dialog(_dialog),
|
---|
| 1076 | theBox(_theBox)
|
---|
[7cd6e7] | 1077 | {}
|
---|
| 1078 |
|
---|
[4cf323d] | 1079 | MoleculesQtQueryPipe::~MoleculesQtQueryPipe()
|
---|
[7cd6e7] | 1080 | {}
|
---|
| 1081 |
|
---|
[4cf323d] | 1082 | void MoleculesQtQueryPipe::update(int newIndex) {
|
---|
[7cd6e7] | 1083 | QVariant data = theBox->itemData(newIndex);
|
---|
| 1084 | int idx = data.toInt();
|
---|
| 1085 | molecule *mol = World::getInstance().getMolecule(MoleculeById(idx));
|
---|
| 1086 | if (mol)
|
---|
| 1087 | (*content).push_back(mol);
|
---|
| 1088 | dialog->update();
|
---|
[257c77] | 1089 | }
|
---|
[cbf01e] | 1090 |
|
---|
[4cf323d] | 1091 | ElementQtQueryPipe::ElementQtQueryPipe(const element **_content, QtDialog *_dialog, QComboBox *_theBox) :
|
---|
[7cd6e7] | 1092 | content(_content),
|
---|
| 1093 | dialog(_dialog),
|
---|
| 1094 | theBox(_theBox)
|
---|
| 1095 | {}
|
---|
| 1096 |
|
---|
[4cf323d] | 1097 | ElementQtQueryPipe::~ElementQtQueryPipe()
|
---|
[cbf01e] | 1098 | {}
|
---|
| 1099 |
|
---|
[4cf323d] | 1100 | void ElementQtQueryPipe::update(int newIndex) {
|
---|
[cbf01e] | 1101 | QVariant data = theBox->itemData(newIndex);
|
---|
| 1102 | int idx = data.toInt();
|
---|
[7cd6e7] | 1103 | *content = World::getInstance().getPeriode()->FindElement(idx);
|
---|
| 1104 | dialog->update();
|
---|
| 1105 | }
|
---|
| 1106 |
|
---|
[4cf323d] | 1107 | ElementsQtQueryPipe::ElementsQtQueryPipe(std::vector<const element *>*_content, QtDialog *_dialog, QComboBox *_theBox) :
|
---|
[7cd6e7] | 1108 | content(_content),
|
---|
| 1109 | dialog(_dialog),
|
---|
| 1110 | theBox(_theBox)
|
---|
| 1111 | {}
|
---|
| 1112 |
|
---|
[4cf323d] | 1113 | ElementsQtQueryPipe::~ElementsQtQueryPipe()
|
---|
[7cd6e7] | 1114 | {}
|
---|
| 1115 |
|
---|
[4cf323d] | 1116 | void ElementsQtQueryPipe::update(int newIndex) {
|
---|
[7cd6e7] | 1117 | QVariant data = theBox->itemData(newIndex);
|
---|
| 1118 | int idx = data.toInt();
|
---|
[e5c0a1] | 1119 | const element *elemental = World::getInstance().getPeriode()->FindElement(idx);
|
---|
[7cd6e7] | 1120 | if(elemental)
|
---|
| 1121 | (*content).push_back(elemental);
|
---|
[cbf01e] | 1122 | dialog->update();
|
---|
| 1123 | }
|
---|
| 1124 |
|
---|
[4cf323d] | 1125 | EmptyQtQueryPipe::EmptyQtQueryPipe(QtDialog *_dialog, QLabel *_textLabel) :
|
---|
[9d457d] | 1126 | dialog(_dialog),
|
---|
| 1127 | textLabel(_textLabel)
|
---|
| 1128 | {}
|
---|
| 1129 |
|
---|
[4cf323d] | 1130 | EmptyQtQueryPipe::~EmptyQtQueryPipe()
|
---|
[9d457d] | 1131 | {}
|
---|
| 1132 |
|
---|
[4cf323d] | 1133 | void EmptyQtQueryPipe::update() {
|
---|
[9d457d] | 1134 | dialog->update();
|
---|
| 1135 | }
|
---|
| 1136 |
|
---|
[4cf323d] | 1137 | BooleanQtQueryPipe::BooleanQtQueryPipe(const bool *_content, QtDialog *_dialog, QComboBox *_booleanComboBox) :
|
---|
[ee62e4] | 1138 | content(_content),
|
---|
| 1139 | dialog(_dialog),
|
---|
| 1140 | booleanComboBox(_booleanComboBox)
|
---|
| 1141 | {}
|
---|
| 1142 |
|
---|
[4cf323d] | 1143 | BooleanQtQueryPipe::~BooleanQtQueryPipe()
|
---|
[ee62e4] | 1144 | {}
|
---|
| 1145 |
|
---|
[4cf323d] | 1146 | void BooleanQtQueryPipe::update() {
|
---|
[ee62e4] | 1147 | dialog->update();
|
---|
| 1148 | }
|
---|
| 1149 |
|
---|
[4cf323d] | 1150 | FileQtQueryPipe::FileQtQueryPipe(boost::filesystem::path *_content, QtDialog *_dialog, QLineEdit *_filenameLineEdit, QPushButton *_filedialogButton) :
|
---|
[6f5dfe] | 1151 | content(_content),
|
---|
| 1152 | dialog(_dialog),
|
---|
| 1153 | filenameLineEdit(_filenameLineEdit),
|
---|
| 1154 | filedialogButton(_filedialogButton)
|
---|
[f001ca] | 1155 | {
|
---|
| 1156 | theFileDialog = NULL;
|
---|
| 1157 | }
|
---|
[6f5dfe] | 1158 |
|
---|
[4cf323d] | 1159 | FileQtQueryPipe::~FileQtQueryPipe()
|
---|
[f001ca] | 1160 | {
|
---|
| 1161 | if (theFileDialog != NULL)
|
---|
| 1162 | delete theFileDialog;
|
---|
| 1163 | }
|
---|
[6f5dfe] | 1164 |
|
---|
[4cf323d] | 1165 | void FileQtQueryPipe::update() {
|
---|
[6f5dfe] | 1166 | QStringList ListOfFilenames = theFileDialog->selectedFiles();
|
---|
| 1167 | std::cout << "Selected File is " << ListOfFilenames.at(0).toStdString() << std::endl;
|
---|
[f001ca] | 1168 | (*content) = ListOfFilenames.at(0).toStdString();
|
---|
| 1169 | filenameLineEdit->setText(QString::fromStdString((*content).string()));
|
---|
[6f5dfe] | 1170 | dialog->update();
|
---|
| 1171 | }
|
---|
| 1172 |
|
---|
[4cf323d] | 1173 | void FileQtQueryPipe::showFileDialog() {
|
---|
[6f5dfe] | 1174 | filedialogButton->setFlat(true);
|
---|
| 1175 | if (theFileDialog == NULL) {
|
---|
| 1176 | theFileDialog = new QFileDialog(NULL, tr("Open input file"), QString(), tr("ParallelCarParrinello (*.conf);;MassivelyParallelQuantumChemistry (*.mpqc);;ParticleDataBase (*.pdb);;XYZ (*.xyz)"));
|
---|
| 1177 | theFileDialog->setAcceptMode(QFileDialog::AcceptOpen);
|
---|
| 1178 | theFileDialog->setFileMode(QFileDialog::ExistingFile);
|
---|
| 1179 | theFileDialog->setViewMode(QFileDialog::List);
|
---|
| 1180 | }
|
---|
[f001ca] | 1181 | theFileDialog->exec();
|
---|
[6f5dfe] | 1182 |
|
---|
[f001ca] | 1183 | update();
|
---|
[6f5dfe] | 1184 | filedialogButton->setFlat(false);
|
---|
| 1185 | }
|
---|
| 1186 |
|
---|
| 1187 |
|
---|
[7cd6e7] | 1188 |
|
---|