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