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