[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 | * AtomQtQuery.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/AtomQtQueryPipe.hpp"
|
---|
[8df74d] | 28 |
|
---|
[6f0841] | 29 | #include "Atom/atom.hpp"
|
---|
[8df74d] | 30 | #include "World.hpp"
|
---|
| 31 |
|
---|
[7dfd07] | 32 | QtDialog::AtomQtQuery::AtomQtQuery(Parameter<const atom *> &_param, std::string _title,QBoxLayout *_parent,Dialog *_dialog) :
|
---|
[9d5531] | 33 | Dialog::AtomQuery(_param, _title),
|
---|
[7c9921] | 34 | parent(_parent),
|
---|
| 35 | dialog(_dialog)
|
---|
[8df74d] | 36 | {
|
---|
| 37 | thisLayout = new QHBoxLayout();
|
---|
| 38 | titleLabel = new QLabel(QString(getTitle().c_str()));
|
---|
| 39 | inputBox = new QComboBox();
|
---|
| 40 | inputBox->insertItem(-1, QString("no atom"));
|
---|
| 41 | std::vector<atom *> atoms = World::getInstance().getAllAtoms();
|
---|
| 42 | for (std::vector<atom *>::const_iterator iter = atoms.begin(); iter != atoms.end(); ++iter)
|
---|
| 43 | inputBox->insertItem((*iter)->getNr(),QString::fromStdString((*iter)->getName()));
|
---|
| 44 |
|
---|
| 45 | parent->addLayout(thisLayout);
|
---|
| 46 | thisLayout->addWidget(titleLabel);
|
---|
| 47 | thisLayout->addWidget(inputBox);
|
---|
| 48 |
|
---|
[7dfd07] | 49 | onUpdate(inputBox->currentIndex());
|
---|
[7c9921] | 50 | connect(inputBox,SIGNAL(currentIndexChanged(int)),this,SLOT(onUpdate(int)));
|
---|
[8df74d] | 51 | }
|
---|
| 52 |
|
---|
| 53 | QtDialog::AtomQtQuery::~AtomQtQuery()
|
---|
| 54 | {
|
---|
| 55 | }
|
---|
| 56 |
|
---|
[7c9921] | 57 | void QtDialog::AtomQtQuery::onUpdate(int newIndex) {
|
---|
| 58 | QVariant data = inputBox->itemData(newIndex);
|
---|
| 59 | int idx = data.toInt();
|
---|
| 60 | temp = World::getInstance().getAtom(AtomById(idx));
|
---|
| 61 | dialog->update();
|
---|
| 62 | }
|
---|
| 63 |
|
---|
[8df74d] | 64 | bool QtDialog::AtomQtQuery::handle() {
|
---|
[9d5531] | 65 | if (param.isValid(temp)){
|
---|
| 66 | param.set(temp);
|
---|
| 67 | return true;
|
---|
| 68 | }
|
---|
| 69 | return false;
|
---|
[8df74d] | 70 | }
|
---|
| 71 |
|
---|
| 72 |
|
---|