[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 | * AtomsQtQuery.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/qlabel.h>
|
---|
| 22 | #include <Qt/qlineedit.h>
|
---|
| 23 | #include <Qt/qlistwidget.h>
|
---|
| 24 | #include <Qt/qpushbutton.h>
|
---|
| 25 |
|
---|
[ad011c] | 26 | #include "CodePatterns/MemDebug.hpp"
|
---|
[8df74d] | 27 |
|
---|
[308aa4] | 28 | #include "UIElements/Qt4/Query/QtQuery.hpp"
|
---|
[a5ddf0] | 29 | #include "UIElements/Qt4/Pipe/AtomsQtQueryPipe.hpp"
|
---|
[8df74d] | 30 |
|
---|
[6f0841] | 31 | #include "Atom/atom.hpp"
|
---|
[8df74d] | 32 | #include "World.hpp"
|
---|
| 33 |
|
---|
| 34 |
|
---|
[9d5531] | 35 | QtDialog::AtomsQtQuery::AtomsQtQuery(Parameter<std::vector<const atom *> > &_param, std::string _title,QBoxLayout *_parent,QtDialog *_dialog) :
|
---|
| 36 | Dialog::AtomsQuery(_param, _title),
|
---|
[7c9921] | 37 | parent(_parent),
|
---|
| 38 | dialog(_dialog)
|
---|
[8df74d] | 39 | {
|
---|
| 40 | QHBoxLayout * thisHLayout = new QHBoxLayout();
|
---|
| 41 | QVBoxLayout * thisV1Layout = new QVBoxLayout();
|
---|
| 42 | QVBoxLayout * thisV2Layout = new QVBoxLayout();
|
---|
| 43 |
|
---|
| 44 | titleLabel = new QLabel(QString(getTitle().c_str()));
|
---|
| 45 | inputLabel = new QLabel("Enter to add");
|
---|
| 46 | inputList = new QListWidget();
|
---|
| 47 | inputList->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
---|
| 48 | std::vector<atom *> atoms = World::getInstance().getAllAtoms();
|
---|
| 49 | for (std::vector<atom *>::const_iterator iter = atoms.begin(); iter != atoms.end(); ++iter)
|
---|
| 50 | inputList->insertItem((*iter)->getNr(),QString((*iter)->getNr()));
|
---|
| 51 |
|
---|
| 52 | QLineEdit* inputBox = new QLineEdit();
|
---|
| 53 | inputLabel->setBuddy(inputBox);
|
---|
| 54 | titleLabel->setBuddy(inputList);
|
---|
| 55 | QPushButton* AddButton = new QPushButton("Add");
|
---|
| 56 | AddButton->setEnabled(false);
|
---|
| 57 | QPushButton* RemoveButton = new QPushButton("Remove");
|
---|
| 58 | RemoveButton->setEnabled(false);
|
---|
| 59 |
|
---|
| 60 | thisV1Layout->addWidget(titleLabel);
|
---|
| 61 | thisV1Layout->addWidget(inputList);
|
---|
| 62 | thisV2Layout->addWidget(inputLabel);
|
---|
| 63 | thisV2Layout->addWidget(inputBox);
|
---|
| 64 | thisV2Layout->addWidget(AddButton);
|
---|
| 65 | thisV2Layout->addWidget(RemoveButton);
|
---|
| 66 | parent->addLayout(thisHLayout);
|
---|
| 67 | thisHLayout->addLayout(thisV1Layout);
|
---|
| 68 | thisHLayout->addLayout(thisV2Layout);
|
---|
| 69 |
|
---|
[9d5531] | 70 | pipe = new AtomsQtQueryPipe(temp,_dialog,inputList);
|
---|
[8df74d] | 71 | connect(inputList,SIGNAL(itemSelectionChanged()),pipe,SLOT(IntegerSelected()));
|
---|
| 72 | connect(AddButton,SIGNAL(Clicked()),pipe,SLOT(add()));
|
---|
| 73 | connect(RemoveButton,SIGNAL(Clicked()),pipe,SLOT(remove()));
|
---|
| 74 | }
|
---|
| 75 |
|
---|
| 76 | QtDialog::AtomsQtQuery::~AtomsQtQuery()
|
---|
| 77 | {
|
---|
| 78 | delete pipe;
|
---|
| 79 | }
|
---|
| 80 |
|
---|
[7c9921] | 81 | void QtDialog::AtomsQtQuery::onUpdate() {
|
---|
| 82 | dialog->update();
|
---|
| 83 | }
|
---|
| 84 |
|
---|
[8df74d] | 85 | bool QtDialog::AtomsQtQuery::handle() {
|
---|
[9d5531] | 86 | if (param.isValid(temp)){
|
---|
| 87 | param.set(temp);
|
---|
| 88 | return true;
|
---|
| 89 | }
|
---|
| 90 | return false;
|
---|
[8df74d] | 91 | }
|
---|
| 92 |
|
---|