Changes in src/UIElements/QT4/QTDialog.cpp [cd8e55:992fd7]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/QT4/QTDialog.cpp
rcd8e55 r992fd7 21 21 #include <Qt/qcombobox.h> 22 22 23 #include "Helpers/MemDebug.hpp"24 25 23 #include "World.hpp" 26 24 #include "periodentafel.hpp" … … 28 26 #include "element.hpp" 29 27 #include "molecule.hpp" 30 #include " Descriptors/MoleculeIdDescriptor.hpp"28 #include "Helpers/MemDebug.hpp" 31 29 32 30 … … 78 76 /************************** Query Infrastructure ************************/ 79 77 80 void QTDialog::queryEmpty(char const*, string){ 81 // TODO 82 ASSERT(false, "Not implemented yet"); 83 } 84 85 void QTDialog::queryBoolean(char const*, bool*,string){ 86 // TODO 87 ASSERT(false, "Not implemented yet"); 88 } 89 90 void QTDialog::queryAtom(char const*, atom**, string){ 91 // TODO 92 ASSERT(false, "Not implemented yet"); 93 } 94 95 void QTDialog::queryBox(char const*, double**, string){ 96 // TODO 97 ASSERT(false, "Not implemented yet"); 98 } 99 100 101 void QTDialog::queryInt(const char *title, int *target,string) 78 void QTDialog::queryInt(const char *title, int *target) 102 79 { 103 80 registerQuery(new IntQTQuery(title,target,inputLayout,this)); 104 81 } 105 82 106 void QTDialog::queryDouble(const char* title, double* target ,string){83 void QTDialog::queryDouble(const char* title, double* target){ 107 84 registerQuery(new DoubleQTQuery(title,target,inputLayout,this)); 108 85 } 109 86 110 void QTDialog::queryString(const char* title, std::string *target ,string)87 void QTDialog::queryString(const char* title, std::string *target) 111 88 { 112 89 registerQuery(new StringQTQuery(title,target,inputLayout,this)); 113 90 } 114 91 115 void QTDialog::queryStrings(const char* title, std::vector<std::string> *target,string) 116 { 117 registerQuery(new StringsQTQuery(title,target,inputLayout,this)); 118 } 119 120 void QTDialog::queryMolecule(const char *title,molecule **target,string) 121 { 122 registerQuery(new MoleculeQTQuery(title,target,inputLayout,this)); 123 } 124 125 void QTDialog::queryVector(const char* title, Vector *target,const double *const cellSize, bool check,string) { 92 void QTDialog::queryMolecule(const char *title,molecule **target,MoleculeListClass *molecules) 93 { 94 registerQuery(new MoleculeQTQuery(title,target,molecules,inputLayout,this)); 95 } 96 97 void QTDialog::queryVector(const char* title, Vector *target,const double *const cellSize, bool check) { 126 98 registerQuery(new VectorQTQuery(title,target,cellSize,check,inputLayout,this)); 127 99 } 128 100 129 void QTDialog::queryElement(const char* title, std::vector<element *> *target,string){101 void QTDialog::queryElement(const char* title, const element **target){ 130 102 registerQuery(new ElementQTQuery(title,target,inputLayout,this)); 131 103 } … … 217 189 } 218 190 219 QTDialog::StringsQTQuery::StringsQTQuery(string _title,vector<string> *_target,QBoxLayout *_parent,QTDialog *_dialog) : 220 Dialog::StringsQuery(_title,_target), 221 parent(_parent) 222 { 223 thisLayout = new QHBoxLayout(); 224 titleLabel = new QLabel(QString(getTitle().c_str())); 225 inputBox = new QLineEdit(); 226 parent->addLayout(thisLayout); 227 thisLayout->addWidget(titleLabel); 228 thisLayout->addWidget(inputBox); 229 230 pipe = new StringQTQueryPipe(&temp,_dialog); 231 pipe->update(inputBox->text()); 232 connect(inputBox,SIGNAL(textChanged(const QString&)),pipe,SLOT(update(const QString&))); 233 } 234 235 QTDialog::StringsQTQuery::~StringsQTQuery() 236 { 237 delete pipe; 238 } 239 240 // All values besides the empty string are valid 241 bool QTDialog::StringsQTQuery::handle() 242 { 243 // dissect by "," 244 string::iterator olditer = temp.begin(); 245 for(string::iterator iter = temp.begin(); iter != temp.end(); ++iter) { 246 if (*iter == ' ') { 247 tmp.push_back(string(iter, olditer)); 248 olditer = iter; 249 } 250 } 251 if (olditer != temp.begin()) // insert last part also 252 tmp.push_back(string(olditer, temp.end())); 253 254 return temp!=""; 255 } 256 257 QTDialog::MoleculeQTQuery::MoleculeQTQuery(string _title, molecule **_target, QBoxLayout *_parent,QTDialog *_dialog) : 258 Dialog::MoleculeQuery(_title,_target), 259 parent(_parent) 260 { 191 QTDialog::MoleculeQTQuery::MoleculeQTQuery(string _title, molecule **_target, MoleculeListClass *_molecules, QBoxLayout *_parent,QTDialog *_dialog) : 192 Dialog::MoleculeQuery(_title,_target,_molecules), 193 parent(_parent) 194 { 195 MoleculeList::iterator iter; 261 196 thisLayout = new QHBoxLayout(); 262 197 titleLabel = new QLabel(QString(getTitle().c_str())); 263 198 inputBox = new QComboBox(); 264 199 // add all molecules to the combo box 265 vector<molecule*> molecules = World::getInstance().getAllMolecules(); 266 for(vector<molecule*>::iterator iter = molecules.begin(); 267 iter != molecules.end(); 200 for(iter = molecules->ListOfMolecules.begin(); 201 iter != molecules->ListOfMolecules.end(); 268 202 ++iter) { 269 203 stringstream sstr; … … 275 209 thisLayout->addWidget(inputBox); 276 210 277 pipe = new MoleculeQTQueryPipe(&tmp,_dialog,inputBox );211 pipe = new MoleculeQTQueryPipe(&tmp,_dialog,inputBox,_molecules); 278 212 pipe->update(inputBox->currentIndex()); 279 213 connect(inputBox,SIGNAL(currentIndexChanged(int)),pipe,SLOT(update(int))); … … 329 263 330 264 331 QTDialog::ElementQTQuery::ElementQTQuery(std::string _title, vector<element *>*_target, QBoxLayout *_parent, QTDialog *_dialog) :265 QTDialog::ElementQTQuery::ElementQTQuery(std::string _title, const element **_target, QBoxLayout *_parent, QTDialog *_dialog) : 332 266 Dialog::ElementQuery(_title,_target), 333 267 parent(_parent) … … 349 283 thisLayout->addWidget(inputBox); 350 284 351 pipe = new ElementQTQueryPipe(& elements,_dialog,inputBox);285 pipe = new ElementQTQueryPipe(&tmp,_dialog,inputBox); 352 286 pipe->update(inputBox->currentIndex()); 353 287 connect(inputBox,SIGNAL(currentIndexChanged(int)),pipe,SLOT(update(int))); … … 404 338 } 405 339 406 MoleculeQTQueryPipe::MoleculeQTQueryPipe(molecule **_content, QTDialog *_dialog, QComboBox *_theBox ) :340 MoleculeQTQueryPipe::MoleculeQTQueryPipe(molecule **_content, QTDialog *_dialog, QComboBox *_theBox, MoleculeListClass *_molecules) : 407 341 content(_content), 408 342 dialog(_dialog), 409 theBox(_theBox) 343 theBox(_theBox), 344 molecules(_molecules) 410 345 {} 411 346 … … 416 351 QVariant data = theBox->itemData(newIndex); 417 352 int idx = data.toInt(); 418 (*content) = World::getInstance().getMolecule(MoleculeById(idx));419 dialog->update(); 420 } 421 422 ElementQTQueryPipe::ElementQTQueryPipe( std::vector<element *>*_content, QTDialog *_dialog, QComboBox *_theBox) :353 (*content) = molecules->ReturnIndex(idx); 354 dialog->update(); 355 } 356 357 ElementQTQueryPipe::ElementQTQueryPipe(const element **_content, QTDialog *_dialog, QComboBox *_theBox) : 423 358 content(_content), 424 359 dialog(_dialog), 425 360 theBox(_theBox) 426 { 427 content->resize(1); 428 } 361 {} 429 362 430 363 ElementQTQueryPipe::~ElementQTQueryPipe() … … 434 367 QVariant data = theBox->itemData(newIndex); 435 368 int idx = data.toInt(); 436 (*content) [0]= World::getInstance().getPeriode()->FindElement(idx);437 dialog->update(); 438 } 439 369 (*content) = World::getInstance().getPeriode()->FindElement(idx); 370 dialog->update(); 371 } 372
Note:
See TracChangeset
for help on using the changeset viewer.