1 | /*
|
---|
2 | * Project: MoleCuilder
|
---|
3 | * Description: creates and alters molecular systems
|
---|
4 | * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
|
---|
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 |
|
---|
24 | #include "CodePatterns/MemDebug.hpp"
|
---|
25 |
|
---|
26 | #include "UIElements/Qt4/Query/QtQuery.hpp"
|
---|
27 |
|
---|
28 | #include "Atom/atom.hpp"
|
---|
29 | #include "World.hpp"
|
---|
30 |
|
---|
31 | QtDialog::AtomQtQuery::AtomQtQuery(Parameter<const atom *> &_param, std::string _title,QBoxLayout *_parent,Dialog *_dialog) :
|
---|
32 | QtQuery<const atom *>(_param, _title),
|
---|
33 | parent(_parent),
|
---|
34 | dialog(_dialog)
|
---|
35 | {
|
---|
36 | thisLayout = new QHBoxLayout();
|
---|
37 | titleLabel = new QLabel(QString(getTitle().c_str()));
|
---|
38 | inputBox = new QComboBox();
|
---|
39 | inputBox->insertItem(-1, QString("no atom"));
|
---|
40 | std::vector<atom *> atoms = World::getInstance().getAllAtoms();
|
---|
41 | for (std::vector<atom *>::const_iterator iter = atoms.begin(); iter != atoms.end(); ++iter)
|
---|
42 | inputBox->insertItem((*iter)->getNr(),QString::fromStdString((*iter)->getName()));
|
---|
43 |
|
---|
44 | parent->addLayout(thisLayout);
|
---|
45 | thisLayout->addWidget(titleLabel);
|
---|
46 | thisLayout->addWidget(inputBox);
|
---|
47 |
|
---|
48 | onUpdate(inputBox->currentIndex());
|
---|
49 | connect(inputBox,SIGNAL(currentIndexChanged(int)),this,SLOT(onUpdate(int)));
|
---|
50 | }
|
---|
51 |
|
---|
52 | QtDialog::AtomQtQuery::~AtomQtQuery()
|
---|
53 | {
|
---|
54 | }
|
---|
55 |
|
---|
56 | void QtDialog::AtomQtQuery::onUpdate(int newIndex) {
|
---|
57 | QVariant data = inputBox->itemData(newIndex);
|
---|
58 | int idx = data.toInt();
|
---|
59 | temp = World::getInstance().getAtom(AtomById(idx));
|
---|
60 | dialog->update();
|
---|
61 | }
|
---|
62 |
|
---|
63 |
|
---|