[8df74d] | 1 | /*
|
---|
| 2 | * Project: MoleCuilder
|
---|
| 3 | * Description: creates and alters molecular systems
|
---|
[0aa122] | 4 | * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
|
---|
[8df74d] | 5 | * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | /*
|
---|
| 9 | * MoleculesQtQuery.cpp
|
---|
| 10 | *
|
---|
| 11 | * Created on: Oct 25, 2010
|
---|
| 12 | * Author: heber
|
---|
| 13 | */
|
---|
| 14 |
|
---|
| 15 | // include config.h
|
---|
| 16 | #ifdef HAVE_CONFIG_H
|
---|
| 17 | #include <config.h>
|
---|
| 18 | #endif
|
---|
| 19 |
|
---|
| 20 | #include <Qt/qboxlayout.h>
|
---|
| 21 | #include <Qt/qcombobox.h>
|
---|
| 22 | #include <Qt/qlabel.h>
|
---|
| 23 |
|
---|
[ad011c] | 24 | #include "CodePatterns/MemDebug.hpp"
|
---|
[8df74d] | 25 |
|
---|
[308aa4] | 26 | #include "UIElements/Qt4/Query/QtQuery.hpp"
|
---|
[a5ddf0] | 27 | #include "UIElements/Qt4/Pipe/MoleculesQtQueryPipe.hpp"
|
---|
[8df74d] | 28 |
|
---|
| 29 | #include "molecule.hpp"
|
---|
| 30 | #include "World.hpp"
|
---|
| 31 |
|
---|
| 32 |
|
---|
[b3a54d] | 33 | QtDialog::MoleculesQtQuery::MoleculesQtQuery(Parameter<std::vector<const molecule *> > &_param, std::string _title, QBoxLayout *_parent,QtDialog *_dialog) :
|
---|
| 34 | Dialog::MoleculesQuery(_param, _title),
|
---|
[7c9921] | 35 | parent(_parent),
|
---|
| 36 | dialog(_dialog)
|
---|
[8df74d] | 37 | {
|
---|
| 38 | thisLayout = new QHBoxLayout();
|
---|
| 39 | titleLabel = new QLabel(QString(getTitle().c_str()));
|
---|
| 40 | inputBox = new QComboBox();
|
---|
| 41 | // add all molecules to the combo box
|
---|
| 42 | vector<molecule*> molecules = World::getInstance().getAllMolecules();
|
---|
| 43 | for(vector<molecule*>::iterator iter = molecules.begin();
|
---|
| 44 | iter != molecules.end();
|
---|
| 45 | ++iter) {
|
---|
| 46 | std::stringstream sstr;
|
---|
| 47 | sstr << (*iter)->IndexNr << "\t" << (*iter)->getName();
|
---|
| 48 | inputBox->addItem(QString(sstr.str().c_str()),QVariant((*iter)->IndexNr));
|
---|
| 49 | }
|
---|
| 50 | parent->addLayout(thisLayout);
|
---|
| 51 | thisLayout->addWidget(titleLabel);
|
---|
| 52 | thisLayout->addWidget(inputBox);
|
---|
| 53 |
|
---|
[9d5531] | 54 | pipe = new MoleculesQtQueryPipe(temp,_dialog,inputBox);
|
---|
[8df74d] | 55 | pipe->update(inputBox->currentIndex());
|
---|
| 56 | connect(inputBox,SIGNAL(currentIndexChanged(int)),pipe,SLOT(update(int)));
|
---|
| 57 | }
|
---|
| 58 |
|
---|
| 59 | QtDialog::MoleculesQtQuery::~MoleculesQtQuery()
|
---|
| 60 | {
|
---|
| 61 | delete pipe;
|
---|
| 62 | }
|
---|
| 63 |
|
---|
[7c9921] | 64 | void QtDialog::MoleculesQtQuery::onUpdate() {
|
---|
| 65 | dialog->update();
|
---|
| 66 | }
|
---|
| 67 |
|
---|
[8df74d] | 68 | // Handling is easy, since the GUI makes it impossible to select invalid values
|
---|
| 69 | bool QtDialog::MoleculesQtQuery::handle()
|
---|
| 70 | {
|
---|
[9d5531] | 71 | if (param.isValid(temp)){
|
---|
| 72 | param.set(temp);
|
---|
| 73 | return true;
|
---|
| 74 | }
|
---|
| 75 | return false;
|
---|
[8df74d] | 76 | }
|
---|
| 77 |
|
---|