Changes in src/UIElements/QT4/QTDialog.cpp [992fd7:cd8e55]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/QT4/QTDialog.cpp
r992fd7 rcd8e55 21 21 #include <Qt/qcombobox.h> 22 22 23 #include "Helpers/MemDebug.hpp" 24 23 25 #include "World.hpp" 24 26 #include "periodentafel.hpp" … … 26 28 #include "element.hpp" 27 29 #include "molecule.hpp" 28 #include " Helpers/MemDebug.hpp"30 #include "Descriptors/MoleculeIdDescriptor.hpp" 29 31 30 32 … … 76 78 /************************** Query Infrastructure ************************/ 77 79 78 void QTDialog::queryInt(const char *title, int *target) 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) 79 102 { 80 103 registerQuery(new IntQTQuery(title,target,inputLayout,this)); 81 104 } 82 105 83 void QTDialog::queryDouble(const char* title, double* target ){106 void QTDialog::queryDouble(const char* title, double* target,string){ 84 107 registerQuery(new DoubleQTQuery(title,target,inputLayout,this)); 85 108 } 86 109 87 void QTDialog::queryString(const char* title, std::string *target )110 void QTDialog::queryString(const char* title, std::string *target,string) 88 111 { 89 112 registerQuery(new StringQTQuery(title,target,inputLayout,this)); 90 113 } 91 114 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) { 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) { 98 126 registerQuery(new VectorQTQuery(title,target,cellSize,check,inputLayout,this)); 99 127 } 100 128 101 void QTDialog::queryElement(const char* title, const element **target){129 void QTDialog::queryElement(const char* title, std::vector<element *> *target,string){ 102 130 registerQuery(new ElementQTQuery(title,target,inputLayout,this)); 103 131 } … … 189 217 } 190 218 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; 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 { 196 261 thisLayout = new QHBoxLayout(); 197 262 titleLabel = new QLabel(QString(getTitle().c_str())); 198 263 inputBox = new QComboBox(); 199 264 // add all molecules to the combo box 200 for(iter = molecules->ListOfMolecules.begin(); 201 iter != molecules->ListOfMolecules.end(); 265 vector<molecule*> molecules = World::getInstance().getAllMolecules(); 266 for(vector<molecule*>::iterator iter = molecules.begin(); 267 iter != molecules.end(); 202 268 ++iter) { 203 269 stringstream sstr; … … 209 275 thisLayout->addWidget(inputBox); 210 276 211 pipe = new MoleculeQTQueryPipe(&tmp,_dialog,inputBox ,_molecules);277 pipe = new MoleculeQTQueryPipe(&tmp,_dialog,inputBox); 212 278 pipe->update(inputBox->currentIndex()); 213 279 connect(inputBox,SIGNAL(currentIndexChanged(int)),pipe,SLOT(update(int))); … … 263 329 264 330 265 QTDialog::ElementQTQuery::ElementQTQuery(std::string _title, const element **_target, QBoxLayout *_parent, QTDialog *_dialog) :331 QTDialog::ElementQTQuery::ElementQTQuery(std::string _title, vector<element *> *_target, QBoxLayout *_parent, QTDialog *_dialog) : 266 332 Dialog::ElementQuery(_title,_target), 267 333 parent(_parent) … … 283 349 thisLayout->addWidget(inputBox); 284 350 285 pipe = new ElementQTQueryPipe(& tmp,_dialog,inputBox);351 pipe = new ElementQTQueryPipe(&elements,_dialog,inputBox); 286 352 pipe->update(inputBox->currentIndex()); 287 353 connect(inputBox,SIGNAL(currentIndexChanged(int)),pipe,SLOT(update(int))); … … 338 404 } 339 405 340 MoleculeQTQueryPipe::MoleculeQTQueryPipe(molecule **_content, QTDialog *_dialog, QComboBox *_theBox , MoleculeListClass *_molecules) :406 MoleculeQTQueryPipe::MoleculeQTQueryPipe(molecule **_content, QTDialog *_dialog, QComboBox *_theBox) : 341 407 content(_content), 342 408 dialog(_dialog), 343 theBox(_theBox), 344 molecules(_molecules) 409 theBox(_theBox) 345 410 {} 346 411 … … 351 416 QVariant data = theBox->itemData(newIndex); 352 417 int idx = data.toInt(); 353 (*content) = molecules->ReturnIndex(idx);418 (*content) = World::getInstance().getMolecule(MoleculeById(idx)); 354 419 dialog->update(); 355 420 } 356 421 357 ElementQTQueryPipe::ElementQTQueryPipe( const element **_content, QTDialog *_dialog, QComboBox *_theBox) :422 ElementQTQueryPipe::ElementQTQueryPipe(std::vector<element *> *_content, QTDialog *_dialog, QComboBox *_theBox) : 358 423 content(_content), 359 424 dialog(_dialog), 360 425 theBox(_theBox) 361 {} 426 { 427 content->resize(1); 428 } 362 429 363 430 ElementQTQueryPipe::~ElementQTQueryPipe() … … 367 434 QVariant data = theBox->itemData(newIndex); 368 435 int idx = data.toInt(); 369 (*content) = World::getInstance().getPeriode()->FindElement(idx);436 (*content)[0] = World::getInstance().getPeriode()->FindElement(idx); 370 437 dialog->update(); 371 438 }
Note:
See TracChangeset
for help on using the changeset viewer.