[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 | * ElementsQtQuery.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/ElementsQtQueryPipe.hpp"
|
---|
[8df74d] | 28 |
|
---|
[3bdb6d] | 29 | #include "Element/element.hpp"
|
---|
| 30 | #include "Element/periodentafel.hpp"
|
---|
[8df74d] | 31 | #include "World.hpp"
|
---|
| 32 |
|
---|
| 33 |
|
---|
[b3a54d] | 34 | QtDialog::ElementsQtQuery::ElementsQtQuery(Parameter<std::vector<const element *> > &_param, std::string _title, QBoxLayout *_parent, QtDialog *_dialog) :
|
---|
| 35 | Dialog::ElementsQuery(_param, _title),
|
---|
[7c9921] | 36 | parent(_parent),
|
---|
| 37 | dialog(_dialog)
|
---|
[8df74d] | 38 | {
|
---|
| 39 | periodentafel *periode = World::getInstance().getPeriode();
|
---|
| 40 | thisLayout = new QHBoxLayout();
|
---|
| 41 | titleLabel = new QLabel(QString(getTitle().c_str()));
|
---|
| 42 | inputBox = new QComboBox();
|
---|
| 43 | for(periodentafel::const_iterator iter = periode->begin();
|
---|
| 44 | iter!=periode->end();
|
---|
| 45 | ++iter)
|
---|
| 46 | {
|
---|
| 47 | std::stringstream sstr;
|
---|
| 48 | sstr << (*iter).first << "\t" << (*iter).second->getName();
|
---|
| 49 | inputBox->addItem(QString(sstr.str().c_str()),QVariant((*iter).first));
|
---|
| 50 | }
|
---|
| 51 | parent->addLayout(thisLayout);
|
---|
| 52 | thisLayout->addWidget(titleLabel);
|
---|
| 53 | thisLayout->addWidget(inputBox);
|
---|
| 54 |
|
---|
[9d5531] | 55 | pipe = new ElementsQtQueryPipe(temp,_dialog,inputBox);
|
---|
[8df74d] | 56 | pipe->update(inputBox->currentIndex());
|
---|
| 57 | connect(inputBox,SIGNAL(currentIndexChanged(int)),pipe,SLOT(update(int)));
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 | QtDialog::ElementsQtQuery::~ElementsQtQuery()
|
---|
| 61 | {
|
---|
| 62 | delete pipe;
|
---|
| 63 | }
|
---|
| 64 |
|
---|
[7c9921] | 65 | void QtDialog::ElementsQtQuery::onUpdate() {
|
---|
| 66 | dialog->update();
|
---|
| 67 | }
|
---|
| 68 |
|
---|
[8df74d] | 69 | bool QtDialog::ElementsQtQuery::handle(){
|
---|
[9d5531] | 70 | if (param.isValid(temp)){
|
---|
| 71 | param.set(temp);
|
---|
| 72 | return true;
|
---|
| 73 | }
|
---|
| 74 | return false;
|
---|
[8df74d] | 75 | }
|
---|
| 76 |
|
---|