Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/QT4/QTDialog.cpp

    rcd8e55 r992fd7  
    2121#include <Qt/qcombobox.h>
    2222
    23 #include "Helpers/MemDebug.hpp"
    24 
    2523#include "World.hpp"
    2624#include "periodentafel.hpp"
     
    2826#include "element.hpp"
    2927#include "molecule.hpp"
    30 #include "Descriptors/MoleculeIdDescriptor.hpp"
     28#include "Helpers/MemDebug.hpp"
    3129
    3230
     
    7876/************************** Query Infrastructure ************************/
    7977
    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)
     78void QTDialog::queryInt(const char *title, int *target)
    10279{
    10380  registerQuery(new IntQTQuery(title,target,inputLayout,this));
    10481}
    10582
    106 void QTDialog::queryDouble(const char* title, double* target,string){
     83void QTDialog::queryDouble(const char* title, double* target){
    10784  registerQuery(new DoubleQTQuery(title,target,inputLayout,this));
    10885}
    10986
    110 void QTDialog::queryString(const char* title, std::string *target,string)
     87void QTDialog::queryString(const char* title, std::string *target)
    11188{
    11289  registerQuery(new StringQTQuery(title,target,inputLayout,this));
    11390}
    11491
    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) {
     92void QTDialog::queryMolecule(const char *title,molecule **target,MoleculeListClass *molecules)
     93{
     94  registerQuery(new MoleculeQTQuery(title,target,molecules,inputLayout,this));
     95}
     96
     97void QTDialog::queryVector(const char* title, Vector *target,const double *const cellSize, bool check) {
    12698  registerQuery(new VectorQTQuery(title,target,cellSize,check,inputLayout,this));
    12799}
    128100
    129 void QTDialog::queryElement(const char* title, std::vector<element *> *target,string){
     101void QTDialog::queryElement(const char* title, const element **target){
    130102  registerQuery(new ElementQTQuery(title,target,inputLayout,this));
    131103}
     
    217189}
    218190
    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 {
     191QTDialog::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;
    261196  thisLayout = new QHBoxLayout();
    262197  titleLabel = new QLabel(QString(getTitle().c_str()));
    263198  inputBox = new QComboBox();
    264199  // 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();
    268202      ++iter) {
    269203    stringstream sstr;
     
    275209  thisLayout->addWidget(inputBox);
    276210
    277   pipe = new MoleculeQTQueryPipe(&tmp,_dialog,inputBox);
     211  pipe = new MoleculeQTQueryPipe(&tmp,_dialog,inputBox,_molecules);
    278212  pipe->update(inputBox->currentIndex());
    279213  connect(inputBox,SIGNAL(currentIndexChanged(int)),pipe,SLOT(update(int)));
     
    329263
    330264
    331 QTDialog::ElementQTQuery::ElementQTQuery(std::string _title, vector<element *> *_target, QBoxLayout *_parent, QTDialog *_dialog) :
     265QTDialog::ElementQTQuery::ElementQTQuery(std::string _title, const element **_target, QBoxLayout *_parent, QTDialog *_dialog) :
    332266    Dialog::ElementQuery(_title,_target),
    333267    parent(_parent)
     
    349283  thisLayout->addWidget(inputBox);
    350284
    351   pipe = new ElementQTQueryPipe(&elements,_dialog,inputBox);
     285  pipe = new ElementQTQueryPipe(&tmp,_dialog,inputBox);
    352286  pipe->update(inputBox->currentIndex());
    353287  connect(inputBox,SIGNAL(currentIndexChanged(int)),pipe,SLOT(update(int)));
     
    404338}
    405339
    406 MoleculeQTQueryPipe::MoleculeQTQueryPipe(molecule **_content, QTDialog *_dialog, QComboBox *_theBox) :
     340MoleculeQTQueryPipe::MoleculeQTQueryPipe(molecule **_content, QTDialog *_dialog, QComboBox *_theBox, MoleculeListClass *_molecules) :
    407341  content(_content),
    408342  dialog(_dialog),
    409   theBox(_theBox)
     343  theBox(_theBox),
     344  molecules(_molecules)
    410345{}
    411346
     
    416351  QVariant data = theBox->itemData(newIndex);
    417352  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
     357ElementQTQueryPipe::ElementQTQueryPipe(const element **_content, QTDialog *_dialog, QComboBox *_theBox) :
    423358  content(_content),
    424359  dialog(_dialog),
    425360  theBox(_theBox)
    426 {
    427   content->resize(1);
    428 }
     361{}
    429362
    430363ElementQTQueryPipe::~ElementQTQueryPipe()
     
    434367  QVariant data = theBox->itemData(newIndex);
    435368  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.