[bcf653] | 1 | /*
|
---|
| 2 | * Project: MoleCuilder
|
---|
| 3 | * Description: creates and alters molecular systems
|
---|
| 4 | * Copyright (C) 2010 University of Bonn. All rights reserved.
|
---|
| 5 | * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
|
---|
| 6 | */
|
---|
| 7 |
|
---|
[d3a5ea] | 8 | /*
|
---|
[4cf323d] | 9 | * QtDialog.cpp
|
---|
[d3a5ea] | 10 | *
|
---|
| 11 | * Created on: Jan 18, 2010
|
---|
| 12 | * Author: crueger
|
---|
| 13 | */
|
---|
| 14 |
|
---|
[bf3817] | 15 | // include config.h
|
---|
| 16 | #ifdef HAVE_CONFIG_H
|
---|
| 17 | #include <config.h>
|
---|
| 18 | #endif
|
---|
[bbbad5] | 19 |
|
---|
[4cf323d] | 20 | #include "UIElements/Qt4/QtDialog.hpp"
|
---|
[d3a5ea] | 21 |
|
---|
[8df74d] | 22 | #include <QtGui/QDialogButtonBox>
|
---|
[d3a5ea] | 23 | #include <Qt/qpushbutton.h>
|
---|
[8df74d] | 24 | #include <Qt/qboxlayout.h>
|
---|
[4c9a97] | 25 |
|
---|
[257c77] | 26 | #include "Helpers/MemDebug.hpp"
|
---|
| 27 |
|
---|
[d3a5ea] | 28 |
|
---|
| 29 | using namespace std;
|
---|
| 30 |
|
---|
[4cf323d] | 31 | QtDialog::QtDialog() :
|
---|
[d3a5ea] | 32 | QDialog(0)
|
---|
| 33 | {
|
---|
| 34 | // creating and filling of the Dialog window
|
---|
| 35 | mainLayout = new QVBoxLayout();
|
---|
| 36 | inputLayout = new QVBoxLayout();
|
---|
| 37 | buttonLayout = new QVBoxLayout();
|
---|
| 38 | setLayout(mainLayout);
|
---|
| 39 | mainLayout->addLayout(inputLayout);
|
---|
| 40 | mainLayout->addLayout(buttonLayout);
|
---|
| 41 | buttons = new QDialogButtonBox(QDialogButtonBox::Ok| QDialogButtonBox::Cancel);
|
---|
| 42 | buttonLayout->addWidget(buttons);
|
---|
| 43 |
|
---|
| 44 | // Disable the ok button until something was entered
|
---|
| 45 | buttons->button(QDialogButtonBox::Ok)->setEnabled(false);
|
---|
| 46 |
|
---|
| 47 | // connect the buttons to their appropriate slots
|
---|
| 48 | connect(buttons, SIGNAL(accepted()), this, SLOT(accept()));
|
---|
| 49 | connect(buttons, SIGNAL(rejected()), this, SLOT(reject()));
|
---|
| 50 | }
|
---|
| 51 |
|
---|
[4cf323d] | 52 | QtDialog::~QtDialog()
|
---|
[d3a5ea] | 53 | {
|
---|
| 54 | }
|
---|
| 55 |
|
---|
[4cf323d] | 56 | bool QtDialog::display(){
|
---|
[d3a5ea] | 57 | // Button state might have changed by some update that
|
---|
| 58 | // was done during query construction. To make sure
|
---|
| 59 | // the state is correct, we just call update one more time.
|
---|
| 60 | update();
|
---|
| 61 | if(exec()) {
|
---|
| 62 | setAll();
|
---|
| 63 | return true;
|
---|
| 64 | }
|
---|
| 65 | else {
|
---|
| 66 | return false;
|
---|
| 67 | }
|
---|
| 68 | }
|
---|
| 69 |
|
---|
[4cf323d] | 70 | void QtDialog::update(){
|
---|
[d3a5ea] | 71 | buttons->button(QDialogButtonBox::Ok)->setEnabled(checkAll());
|
---|
| 72 | }
|
---|
| 73 |
|
---|
| 74 | /************************** Query Infrastructure ************************/
|
---|
| 75 |
|
---|
[4cf323d] | 76 | void QtDialog::queryEmpty(const char* title, std::string)
|
---|
[9d457d] | 77 | {
|
---|
[4cf323d] | 78 | registerQuery(new EmptyQtQuery(title,inputLayout,this));
|
---|
[257c77] | 79 | }
|
---|
| 80 |
|
---|
[4cf323d] | 81 | void QtDialog::queryBoolean(const char* title,string)
|
---|
[ee62e4] | 82 | {
|
---|
[4cf323d] | 83 | registerQuery(new BooleanQtQuery(title,inputLayout,this));
|
---|
[257c77] | 84 | }
|
---|
| 85 |
|
---|
[4cf323d] | 86 | void QtDialog::queryAtom(const char* title, std::string)
|
---|
[c96c66] | 87 | {
|
---|
[4cf323d] | 88 | registerQuery(new AtomQtQuery(title,inputLayout,this));
|
---|
[257c77] | 89 | }
|
---|
| 90 |
|
---|
[4cf323d] | 91 | void QtDialog::queryAtoms(const char* title, std::string)
|
---|
[c96c66] | 92 | {
|
---|
[4cf323d] | 93 | registerQuery(new AtomsQtQuery(title,inputLayout,this));
|
---|
[7cd6e7] | 94 | }
|
---|
| 95 |
|
---|
[4cf323d] | 96 | void QtDialog::queryBox(const char* title, std::string)
|
---|
[41167c] | 97 | {
|
---|
[4cf323d] | 98 | registerQuery(new BoxQtQuery(title,inputLayout,this));
|
---|
[257c77] | 99 | }
|
---|
| 100 |
|
---|
[4cf323d] | 101 | void QtDialog::queryInt(const char *title,string)
|
---|
[d3a5ea] | 102 | {
|
---|
[4cf323d] | 103 | registerQuery(new IntQtQuery(title,inputLayout,this));
|
---|
[d3a5ea] | 104 | }
|
---|
| 105 |
|
---|
[4cf323d] | 106 | void QtDialog::queryInts(const char *title,string)
|
---|
[7cd6e7] | 107 | {
|
---|
[4cf323d] | 108 | registerQuery(new IntsQtQuery(title,inputLayout,this));
|
---|
[7cd6e7] | 109 | }
|
---|
| 110 |
|
---|
[4cf323d] | 111 | void QtDialog::queryDouble(const char* title,string)
|
---|
[9d457d] | 112 | {
|
---|
[4cf323d] | 113 | registerQuery(new DoubleQtQuery(title,inputLayout,this));
|
---|
[b8d1aeb] | 114 | }
|
---|
| 115 |
|
---|
[4cf323d] | 116 | void QtDialog::queryDoubles(const char* title,string)
|
---|
[9d457d] | 117 | {
|
---|
[4cf323d] | 118 | registerQuery(new DoublesQtQuery(title,inputLayout,this));
|
---|
[7cd6e7] | 119 | }
|
---|
| 120 |
|
---|
[4cf323d] | 121 | void QtDialog::queryString(const char* title,string)
|
---|
[d3a5ea] | 122 | {
|
---|
[4cf323d] | 123 | registerQuery(new StringQtQuery(title,inputLayout,this));
|
---|
[d3a5ea] | 124 | }
|
---|
| 125 |
|
---|
[4cf323d] | 126 | void QtDialog::queryStrings(const char* title,string)
|
---|
[cd8e55] | 127 | {
|
---|
[4cf323d] | 128 | registerQuery(new StringsQtQuery(title,inputLayout,this));
|
---|
[cd8e55] | 129 | }
|
---|
| 130 |
|
---|
[4cf323d] | 131 | void QtDialog::queryMolecule(const char *title,string)
|
---|
[d3a5ea] | 132 | {
|
---|
[4cf323d] | 133 | registerQuery(new MoleculeQtQuery(title,inputLayout,this));
|
---|
[d3a5ea] | 134 | }
|
---|
| 135 |
|
---|
[4cf323d] | 136 | void QtDialog::queryMolecules(const char *title,string)
|
---|
[7cd6e7] | 137 | {
|
---|
[4cf323d] | 138 | registerQuery(new MoleculesQtQuery(title,inputLayout,this));
|
---|
[7cd6e7] | 139 | }
|
---|
| 140 |
|
---|
[4cf323d] | 141 | void QtDialog::queryVector(const char* title, bool check,string)
|
---|
[9d457d] | 142 | {
|
---|
[4cf323d] | 143 | registerQuery(new VectorQtQuery(title,check,inputLayout,this));
|
---|
[b8d1aeb] | 144 | }
|
---|
| 145 |
|
---|
[4cf323d] | 146 | void QtDialog::queryVectors(const char* title, bool check,string)
|
---|
[9d457d] | 147 | {
|
---|
[4cf323d] | 148 | registerQuery(new VectorsQtQuery(title,check,inputLayout,this));
|
---|
[7cd6e7] | 149 | }
|
---|
| 150 |
|
---|
[4cf323d] | 151 | void QtDialog::queryElement(const char* title, std::string)
|
---|
[9d457d] | 152 | {
|
---|
[4cf323d] | 153 | registerQuery(new ElementQtQuery(title,inputLayout,this));
|
---|
[cbf01e] | 154 | }
|
---|
| 155 |
|
---|
[4cf323d] | 156 | void QtDialog::queryElements(const char* title, std::string)
|
---|
[9d457d] | 157 | {
|
---|
[4cf323d] | 158 | registerQuery(new ElementsQtQuery(title,inputLayout,this));
|
---|
[7cd6e7] | 159 | }
|
---|
| 160 |
|
---|
[4cf323d] | 161 | void QtDialog::queryFile(const char* title, std::string)
|
---|
[9d457d] | 162 | {
|
---|
[4cf323d] | 163 | registerQuery(new FileQtQuery(title,inputLayout,this));
|
---|
[6f5dfe] | 164 | }
|
---|
| 165 |
|
---|
[8df74d] | 166 | /************************** Query Infrastructure ************************/
|
---|
| 167 | /* ---> shifted to folder Query */
|
---|
| 168 | /************************************************************************/
|
---|
[7cd6e7] | 169 |
|
---|
[8df74d] | 170 | /*************************** Pipe Infrastructure ************************/
|
---|
| 171 | /* ---> shifted to folder Pipe */
|
---|
| 172 | /************************************************************************/
|
---|