[8df74d] | 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 |
|
---|
| 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 |
|
---|
| 24 | #include "Helpers/MemDebug.hpp"
|
---|
| 25 |
|
---|
| 26 | #include "UIElements/Qt4/QtDialog.hpp"
|
---|
| 27 |
|
---|
| 28 | #include "molecule.hpp"
|
---|
| 29 | #include "World.hpp"
|
---|
| 30 |
|
---|
| 31 |
|
---|
| 32 | QtDialog::MoleculesQtQuery::MoleculesQtQuery(string _title, QBoxLayout *_parent,QtDialog *_dialog) :
|
---|
| 33 | Dialog::MoleculesQuery(_title),
|
---|
| 34 | parent(_parent)
|
---|
| 35 | {
|
---|
| 36 | thisLayout = new QHBoxLayout();
|
---|
| 37 | titleLabel = new QLabel(QString(getTitle().c_str()));
|
---|
| 38 | inputBox = new QComboBox();
|
---|
| 39 | // add all molecules to the combo box
|
---|
| 40 | vector<molecule*> molecules = World::getInstance().getAllMolecules();
|
---|
| 41 | for(vector<molecule*>::iterator iter = molecules.begin();
|
---|
| 42 | iter != molecules.end();
|
---|
| 43 | ++iter) {
|
---|
| 44 | std::stringstream sstr;
|
---|
| 45 | sstr << (*iter)->IndexNr << "\t" << (*iter)->getName();
|
---|
| 46 | inputBox->addItem(QString(sstr.str().c_str()),QVariant((*iter)->IndexNr));
|
---|
| 47 | }
|
---|
| 48 | parent->addLayout(thisLayout);
|
---|
| 49 | thisLayout->addWidget(titleLabel);
|
---|
| 50 | thisLayout->addWidget(inputBox);
|
---|
| 51 |
|
---|
| 52 | pipe = new MoleculesQtQueryPipe(&tmp,_dialog,inputBox);
|
---|
| 53 | pipe->update(inputBox->currentIndex());
|
---|
| 54 | connect(inputBox,SIGNAL(currentIndexChanged(int)),pipe,SLOT(update(int)));
|
---|
| 55 | }
|
---|
| 56 |
|
---|
| 57 | QtDialog::MoleculesQtQuery::~MoleculesQtQuery()
|
---|
| 58 | {
|
---|
| 59 | delete pipe;
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 | // Handling is easy, since the GUI makes it impossible to select invalid values
|
---|
| 63 | bool QtDialog::MoleculesQtQuery::handle()
|
---|
| 64 | {
|
---|
| 65 | return true;
|
---|
| 66 | }
|
---|
| 67 |
|
---|