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