Ignore:
Timestamp:
Jul 19, 2012, 3:28:07 PM (13 years ago)
Author:
Michael Ankele <ankele@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
7dfd07
Parents:
3c53fa
git-author:
Michael Ankele <ankele@…> (07/19/12 15:14:14)
git-committer:
Michael Ankele <ankele@…> (07/19/12 15:28:07)
Message:

Refactoring: smarter QtQueries won't need pipes

  • derived all xxxQtQuery classes from QWidget (multiple inheritance officially allowed in this particular case)
  • xxxQtQuery uses its own slots

TODO: ListQueries not rewritten yet!

Location:
src/UIElements/Qt4/Query
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/Qt4/Query/AtomQtQuery.cpp

    r3c53fa r7c9921  
    3232QtDialog::AtomQtQuery::AtomQtQuery(Parameter<const atom *> &_param, std::string _title,QBoxLayout *_parent,QtDialog *_dialog) :
    3333    Dialog::AtomQuery(_param, _title),
    34     parent(_parent)
     34    parent(_parent),
     35    dialog(_dialog)
    3536{
    3637  thisLayout = new QHBoxLayout();
     
    4849  pipe = new AtomQtQueryPipe(temp,_dialog, inputBox);
    4950  pipe->update(inputBox->currentIndex());
    50   connect(inputBox,SIGNAL(currentIndexChanged(int)),pipe,SLOT(update(int)));
     51  connect(inputBox,SIGNAL(currentIndexChanged(int)),this,SLOT(onUpdate(int)));
    5152}
    5253
     
    5455{
    5556  delete pipe;
     57}
     58
     59void QtDialog::AtomQtQuery::onUpdate(int newIndex) {
     60  QVariant data = inputBox->itemData(newIndex);
     61  int idx = data.toInt();
     62  temp = World::getInstance().getAtom(AtomById(idx));
     63  dialog->update();
    5664}
    5765
  • src/UIElements/Qt4/Query/AtomsQtQuery.cpp

    r3c53fa r7c9921  
    3535QtDialog::AtomsQtQuery::AtomsQtQuery(Parameter<std::vector<const atom *> > &_param, std::string _title,QBoxLayout *_parent,QtDialog *_dialog) :
    3636    Dialog::AtomsQuery(_param, _title),
    37     parent(_parent)
     37    parent(_parent),
     38    dialog(_dialog)
    3839{
    3940  QHBoxLayout * thisHLayout = new QHBoxLayout();
     
    7879}
    7980
     81void QtDialog::AtomsQtQuery::onUpdate() {
     82  dialog->update();
     83}
     84
    8085bool QtDialog::AtomsQtQuery::handle() {
    8186  if (param.isValid(temp)){
  • src/UIElements/Qt4/Query/BooleanQtQuery.cpp

    r3c53fa r7c9921  
    3030QtDialog::BooleanQtQuery::BooleanQtQuery(Parameter<bool> &_param, std::string _title, QBoxLayout *_parent, QtDialog *_dialog) :
    3131    Dialog::BooleanQuery(_param, _title),
    32     parent(_parent)
     32    parent(_parent),
     33    dialog(_dialog)
    3334{
    3435  temp = false;
     
    4546
    4647  pipe = new BooleanQtQueryPipe(temp,_dialog,booleanCheckBox);
    47   connect(booleanCheckBox, SIGNAL(stateChanged(int)), pipe, SLOT(update(int)));
     48  connect(booleanCheckBox, SIGNAL(stateChanged(int)), this, SLOT(onUpdate(int)));
    4849}
    4950
     
    5152{
    5253  delete pipe;
     54}
     55
     56void QtDialog::BooleanQtQuery::onUpdate(int state) {
     57  temp = (state == Qt::Checked);
     58  dialog->update();
    5359}
    5460
  • src/UIElements/Qt4/Query/DoubleQtQuery.cpp

    r3c53fa r7c9921  
    3030QtDialog::DoubleQtQuery::DoubleQtQuery(Parameter<double> &_param, std::string title,QBoxLayout *_parent,QtDialog *_dialog) :
    3131    Dialog::DoubleQuery(_param, title),
    32     parent(_parent)
     32    parent(_parent),
     33    dialog(_dialog)
    3334{
    3435  temp = 0.0;
     
    4546  thisLayout->addWidget(inputBox);
    4647
    47   pipe = new DoubleQtQueryPipe(temp,_dialog);
    48   pipe->update(inputBox->value());
    49   connect(inputBox,SIGNAL(valueChanged(double)),pipe,SLOT(update(double)));
     48  //pipe = new DoubleQtQueryPipe(temp,_dialog);
     49  //pipe->update(inputBox->value());
     50  connect(inputBox,SIGNAL(valueChanged(double)),this,SLOT(onUpdate(double)));
    5051}
    5152
    5253QtDialog::DoubleQtQuery::~DoubleQtQuery()
    5354{
    54   delete pipe;
     55  //delete pipe;
     56}
     57
     58void QtDialog::DoubleQtQuery::onUpdate(double newDbl) {
     59  temp = newDbl;
     60  dialog->update();
    5561}
    5662
  • src/UIElements/Qt4/Query/DoublesQtQuery.cpp

    r3c53fa r7c9921  
    3232QtDialog::DoublesQtQuery::DoublesQtQuery(Parameter<std::vector<double> > &_param, std::string title,QBoxLayout *_parent,QtDialog *_dialog) :
    3333    Dialog::DoublesQuery(_param, title),
    34     parent(_parent)
     34    parent(_parent),
     35    dialog(_dialog)
    3536{
    3637  QHBoxLayout * thisHLayout = new QHBoxLayout();
     
    7172}
    7273
     74void QtDialog::DoublesQtQuery::onUpdate() {
     75  dialog->update();
     76}
     77
    7378bool QtDialog::DoublesQtQuery::handle() {
    7479  if (param.isValid(temp)){
  • src/UIElements/Qt4/Query/ElementQtQuery.cpp

    r3c53fa r7c9921  
    3333QtDialog::ElementQtQuery::ElementQtQuery(Parameter<const element *> &_param, std::string _title, QBoxLayout *_parent, QtDialog *_dialog) :
    3434    Dialog::ElementQuery(_param, _title),
    35     parent(_parent)
     35    parent(_parent),
     36    dialog(_dialog)
    3637{
    3738  periodentafel *periode = World::getInstance().getPeriode();
     
    5354  pipe = new ElementQtQueryPipe(temp,_dialog,inputBox);
    5455  pipe->update(inputBox->currentIndex());
    55   connect(inputBox,SIGNAL(currentIndexChanged(int)),pipe,SLOT(update(int)));
     56  connect(inputBox,SIGNAL(currentIndexChanged(int)),this,SLOT(onUpdate(int)));
    5657}
    5758
     
    5960{
    6061  delete pipe;
     62}
     63
     64void QtDialog::ElementQtQuery::onUpdate(int newIndex) {
     65  QVariant data = inputBox->itemData(newIndex);
     66  int idx = data.toInt();
     67  temp = World::getInstance().getPeriode()->FindElement(idx);
     68  dialog->update();
    6169}
    6270
  • src/UIElements/Qt4/Query/ElementsQtQuery.cpp

    r3c53fa r7c9921  
    3434QtDialog::ElementsQtQuery::ElementsQtQuery(Parameter<std::vector<const element *> > &_param, std::string _title, QBoxLayout *_parent, QtDialog *_dialog) :
    3535    Dialog::ElementsQuery(_param, _title),
    36     parent(_parent)
     36    parent(_parent),
     37    dialog(_dialog)
    3738{
    3839  periodentafel *periode = World::getInstance().getPeriode();
     
    6263}
    6364
     65void QtDialog::ElementsQtQuery::onUpdate() {
     66  dialog->update();
     67}
     68
    6469bool QtDialog::ElementsQtQuery::handle(){
    6570  if (param.isValid(temp)){
  • src/UIElements/Qt4/Query/EmptyQtQuery.cpp

    r3c53fa r7c9921  
    2929QtDialog::EmptyQtQuery::EmptyQtQuery(std::string _title, QBoxLayout *_parent, QtDialog *_dialog) :
    3030    Dialog::EmptyQuery(_title),
    31     parent(_parent)
     31    parent(_parent),
     32    dialog(_dialog)
    3233{
    3334  thisLayout = new QHBoxLayout();
  • src/UIElements/Qt4/Query/FileQtQuery.cpp

    r3c53fa r7c9921  
    2222#include <Qt/qlineedit.h>
    2323#include <Qt/qpushbutton.h>
     24#include <QtGui/QFileDialog>
    2425
    2526#include "CodePatterns/MemDebug.hpp"
     
    3132QtDialog::FileQtQuery::FileQtQuery(Parameter<boost::filesystem::path> &_param, std::string _title, QBoxLayout *_parent, QtDialog *_dialog) :
    3233    Dialog::FileQuery(_param, _title),
    33     parent(_parent)
     34    parent(_parent),
     35    dialog(_dialog)
    3436{
    3537
     
    4244
    4345  filedialogButton = new QPushButton("&Choose", _dialog);
     46  theFileDialog = NULL;
    4447
    4548  pipe = new FileQtQueryPipe(temp,_dialog,filenameLineEdit,filedialogButton);
     
    5154  thisLayout->addWidget(filedialogButton);
    5255
    53   QObject::connect(filedialogButton,SIGNAL(clicked()),pipe,SLOT(showFileDialog()));
     56  QObject::connect(filedialogButton,SIGNAL(clicked()),this,SLOT(showFileDialog()));
    5457}
    5558
     
    5760{
    5861  delete pipe;
     62  if (theFileDialog != NULL)
     63    delete theFileDialog;
     64}
     65
     66void QtDialog::FileQtQuery::onUpdate() {
     67  QStringList ListOfFilenames = theFileDialog->selectedFiles();
     68  std::cout << "Selected File is " << ListOfFilenames.at(0).toStdString() << std::endl;
     69  temp = ListOfFilenames.at(0).toStdString();
     70  filenameLineEdit->setText(QString::fromStdString(temp.string()));
     71  dialog->update();
     72}
     73
     74void QtDialog::FileQtQuery::showFileDialog() {
     75  filedialogButton->setFlat(true);
     76  if (theFileDialog == NULL) {
     77    theFileDialog = new QFileDialog(NULL, tr("Open input file"), QString(), tr("ParallelCarParrinello (*.conf);;MassivelyParallelQuantumChemistry (*.mpqc);;ParticleDataBase (*.pdb);;XYZ (*.xyz)"));
     78    theFileDialog->setAcceptMode(QFileDialog::AcceptOpen);
     79    theFileDialog->setFileMode(QFileDialog::AnyFile);
     80    theFileDialog->setViewMode(QFileDialog::List);
     81  }
     82  theFileDialog->exec();
     83
     84  onUpdate();
     85  filedialogButton->setFlat(false);
    5986}
    6087
  • src/UIElements/Qt4/Query/FilesQtQuery.cpp

    r3c53fa r7c9921  
    3434QtDialog::FilesQtQuery::FilesQtQuery(Parameter<std::vector< boost::filesystem::path> > &param, std::string _title, QBoxLayout *_parent, QtDialog *_dialog) :
    3535    Dialog::FilesQuery(param, _title),
    36     parent(_parent)
     36    parent(_parent),
     37    dialog(_dialog)
    3738{
    3839  QHBoxLayout * thisHLayout = new QHBoxLayout();
     
    7475}
    7576
     77void QtDialog::FilesQtQuery::onUpdate() {
     78  dialog->update();
     79}
     80
    7681bool QtDialog::FilesQtQuery::handle(){
    7782  if (param.isValid(temp)){
  • src/UIElements/Qt4/Query/IntQtQuery.cpp

    r3c53fa r7c9921  
    3030QtDialog::IntQtQuery::IntQtQuery(Parameter<int> &_param, std::string _title,QBoxLayout *_parent,QtDialog *_dialog) :
    3131    Dialog::IntQuery(_param, _title),
    32     parent(_parent)
     32    parent(_parent),
     33    dialog(_dialog)
    3334{
    3435  temp = 0;
     
    4546  pipe = new IntQtQueryPipe(temp,_dialog);
    4647  pipe->update(inputBox->value());
    47   connect(inputBox,SIGNAL(valueChanged(int)),pipe,SLOT(update(int)));
     48  connect(inputBox,SIGNAL(valueChanged(int)),this,SLOT(onUpdate(int)));
    4849}
    4950
     
    5152{
    5253  delete pipe;
     54}
     55
     56void QtDialog::IntQtQuery::onUpdate(int newInt) {
     57  temp = newInt;
     58  dialog->update();
    5359}
    5460
  • src/UIElements/Qt4/Query/IntsQtQuery.cpp

    r3c53fa r7c9921  
    3232QtDialog::IntsQtQuery::IntsQtQuery(Parameter<std::vector<int> > &_param, std::string _title,QBoxLayout *_parent,QtDialog *_dialog) :
    3333    Dialog::IntsQuery(_param, _title),
    34     parent(_parent)
     34    parent(_parent),
     35    dialog(_dialog)
    3536{
    3637  QHBoxLayout * thisHLayout = new QHBoxLayout();
     
    7273}
    7374
     75void QtDialog::IntsQtQuery::onUpdate() {
     76  dialog->update();
     77}
     78
    7479bool QtDialog::IntsQtQuery::handle() {
    7580  if (param.isValid(temp)){
  • src/UIElements/Qt4/Query/MoleculeQtQuery.cpp

    r3c53fa r7c9921  
    3333QtDialog::MoleculeQtQuery::MoleculeQtQuery(Parameter<const molecule *> &_param, std::string _title, QBoxLayout *_parent,QtDialog *_dialog) :
    3434    Dialog::MoleculeQuery(_param, _title),
    35     parent(_parent)
     35    parent(_parent),
     36    dialog(_dialog)
    3637{
    3738  thisLayout = new QHBoxLayout();
     
    5354  pipe = new MoleculeQtQueryPipe(temp,_dialog,inputBox);
    5455  pipe->update(inputBox->currentIndex());
    55   connect(inputBox,SIGNAL(currentIndexChanged(int)),pipe,SLOT(update(int)));
     56  connect(inputBox,SIGNAL(currentIndexChanged(int)),this,SLOT(onUpdate(int)));
    5657}
    5758
     
    5960{
    6061  delete pipe;
     62}
     63
     64void QtDialog::MoleculeQtQuery::onUpdate(int newIndex) {
     65  QVariant data = inputBox->itemData(newIndex);
     66  int idx = data.toInt();
     67  temp = World::getInstance().getMolecule(MoleculeById(idx));
     68  dialog->update();
    6169}
    6270
  • src/UIElements/Qt4/Query/MoleculesQtQuery.cpp

    r3c53fa r7c9921  
    3333QtDialog::MoleculesQtQuery::MoleculesQtQuery(Parameter<std::vector<const molecule *> > &_param, std::string _title, QBoxLayout *_parent,QtDialog *_dialog) :
    3434    Dialog::MoleculesQuery(_param, _title),
    35     parent(_parent)
     35    parent(_parent),
     36    dialog(_dialog)
    3637{
    3738  thisLayout = new QHBoxLayout();
     
    6162}
    6263
     64void QtDialog::MoleculesQtQuery::onUpdate() {
     65  dialog->update();
     66}
     67
    6368// Handling is easy, since the GUI makes it impossible to select invalid values
    6469bool QtDialog::MoleculesQtQuery::handle()
  • src/UIElements/Qt4/Query/QtQuery.hpp

    r3c53fa r7c9921  
    1515
    1616
     17#include <Qt/qwidget.h>
    1718#include "Qt4/QtDialog.hpp"
    1819#include "Parameters/Parameter.hpp"
     
    3132class QComboBox;
    3233class QCheckBox;
     34class QFileDialog;
    3335
    3436// Forward declarations for plumbing
     
    5658class RandomNumberDistribution_ParametersQtQueryPipe;
    5759
    58 class QtDialog::AtomQtQuery : public Dialog::AtomQuery {
     60class QtDialog::AtomQtQuery : public QWidget, public Dialog::AtomQuery {
     61  Q_OBJECT
    5962public:
    6063  AtomQtQuery(Parameter<const atom *> &, std::string _title, QBoxLayout *_parent,QtDialog *_dialog);
    6164  virtual ~AtomQtQuery();
    6265  virtual bool handle();
     66
     67public slots:
     68  void onUpdate(int);
     69
    6370private:
    6471  QBoxLayout *parent;
     
    6673  QLabel *titleLabel;
    6774  QComboBox *inputBox;
     75  QtDialog *dialog;
    6876
    6977  AtomQtQueryPipe *pipe;
    7078};
    7179
    72 class QtDialog::AtomsQtQuery : public Dialog::AtomsQuery {
     80class QtDialog::AtomsQtQuery : public QWidget, public Dialog::AtomsQuery {
     81  Q_OBJECT
    7382public:
    7483  AtomsQtQuery(Parameter<std::vector<const atom *> > &, std::string _title, QBoxLayout *_parent,QtDialog *_dialog);
    7584  virtual ~AtomsQtQuery();
    7685  virtual bool handle();
     86
     87public slots:
     88  void onUpdate();
     89
    7790private:
    7891  QBoxLayout *parent;
     
    8194  QLabel *inputLabel;
    8295  QListWidget *inputList;
     96  QtDialog *dialog;
    8397
    8498  AtomsQtQueryPipe *pipe;
    8599};
    86100
    87 class QtDialog::BooleanQtQuery : public Dialog::BooleanQuery {
     101class QtDialog::BooleanQtQuery : public QWidget, public Dialog::BooleanQuery {
     102  Q_OBJECT
    88103public:
    89104  BooleanQtQuery(Parameter<bool> &, std::string _title, QBoxLayout *_parent, QtDialog *_dialog);
    90105  virtual ~BooleanQtQuery();
    91106  virtual bool handle();
     107
     108public slots:
     109  void onUpdate(int);
     110
    92111private:
    93112  QBoxLayout *parent;
     
    95114  QLabel *titleLabel;
    96115  QCheckBox *booleanCheckBox;
     116  QtDialog *dialog;
    97117
    98118  BooleanQtQueryPipe *pipe;
    99119};
    100120
    101 class QtDialog::RealSpaceMatrixQtQuery : public Dialog::RealSpaceMatrixQuery {
     121class QtDialog::RealSpaceMatrixQtQuery : public QWidget, public Dialog::RealSpaceMatrixQuery {
     122  Q_OBJECT
    102123public:
    103124  RealSpaceMatrixQtQuery(Parameter<RealSpaceMatrix> &, std::string _title, QBoxLayout *_parent,QtDialog *_dialog);
    104125  virtual ~RealSpaceMatrixQtQuery();
    105126  virtual bool handle();
     127
     128public slots:
     129  void onUpdate(int, int);
     130
    106131private:
    107132  QBoxLayout *parent;
     
    109134  QLabel *titleLabel;
    110135  QTableWidget *inputTable;
     136  QtDialog *dialog;
    111137
    112138  RealSpaceMatrixQtQueryPipe *pipe;
    113139};
    114140
    115 class QtDialog::DoubleQtQuery : public Dialog::DoubleQuery {
     141class QtDialog::DoubleQtQuery : public QWidget, public Dialog::DoubleQuery {
     142  Q_OBJECT
    116143public:
    117144  DoubleQtQuery(Parameter<double> &, std::string title,QBoxLayout *_parent,QtDialog *_dialog);
    118145  virtual ~DoubleQtQuery();
    119146  virtual bool handle();
     147
     148public slots:
     149  void onUpdate(double);
     150
    120151private:
    121152  QBoxLayout *parent;
     
    123154  QLabel *titleLabel;
    124155  QDoubleSpinBox *inputBox;
     156  QtDialog *dialog;
    125157
    126158  DoubleQtQueryPipe *pipe;
    127159};
    128160
    129 class QtDialog::DoublesQtQuery : public Dialog::DoublesQuery {
     161class QtDialog::DoublesQtQuery : public QWidget, public Dialog::DoublesQuery {
     162  Q_OBJECT
    130163public:
    131164  DoublesQtQuery(Parameter<std::vector<double> > &, std::string title,QBoxLayout *_parent,QtDialog *_dialog);
    132165  virtual ~DoublesQtQuery();
    133166  virtual bool handle();
     167
     168public slots:
     169  void onUpdate();
     170
    134171private:
    135172  QBoxLayout *parent;
     
    137174  QLabel *titleLabel;
    138175  QDoubleSpinBox *inputBox;
     176  QtDialog *dialog;
    139177
    140178  QtQueryListPipe<double> *pipe;
    141179};
    142180
    143 class QtDialog::ElementQtQuery : public Dialog::ElementQuery {
     181class QtDialog::ElementQtQuery : public QWidget, public Dialog::ElementQuery {
     182  Q_OBJECT
    144183public:
    145184  ElementQtQuery(Parameter<const element *> &, std::string _title, QBoxLayout *_parent, QtDialog *_dialog);
    146185  virtual ~ElementQtQuery();
    147186  virtual bool handle();
     187
     188public slots:
     189  void onUpdate(int);
     190
    148191private:
    149192  QBoxLayout *parent;
     
    151194  QLabel *titleLabel;
    152195  QComboBox *inputBox;
     196  QtDialog *dialog;
    153197
    154198  ElementQtQueryPipe *pipe;
    155199};
    156200
    157 class QtDialog::ElementsQtQuery : public Dialog::ElementsQuery {
     201class QtDialog::ElementsQtQuery : public QWidget, public Dialog::ElementsQuery {
     202  Q_OBJECT
    158203public:
    159204  ElementsQtQuery(Parameter<std::vector<const element *> > &, std::string _title, QBoxLayout *_parent, QtDialog *_dialog);
    160205  virtual ~ElementsQtQuery();
    161206  virtual bool handle();
     207
     208public slots:
     209  void onUpdate();
     210
    162211private:
    163212  QBoxLayout *parent;
     
    165214  QLabel *titleLabel;
    166215  QComboBox *inputBox;
     216  QtDialog *dialog;
    167217
    168218  ElementsQtQueryPipe *pipe;
     
    178228  QBoxLayout *thisLayout;
    179229  QLabel *titleLabel;
     230  QtDialog *dialog;
    180231
    181232  EmptyQtQueryPipe *pipe;
    182233};
    183234
    184 class QtDialog::FileQtQuery : public Dialog::FileQuery {
     235class QtDialog::FileQtQuery : public QWidget, public Dialog::FileQuery {
     236  Q_OBJECT
    185237public:
    186238  FileQtQuery(Parameter<boost::filesystem::path> &, std::string _title, QBoxLayout *_parent, QtDialog *_dialog);
    187239  virtual ~FileQtQuery();
    188240  virtual bool handle();
     241
     242public slots:
     243  void onUpdate();
     244  void showFileDialog();
     245
    189246private:
    190247  QBoxLayout *parent;
     
    193250  QLineEdit *filenameLineEdit;
    194251  QPushButton *filedialogButton;
     252  QFileDialog *theFileDialog;
     253  QtDialog *dialog;
    195254
    196255  FileQtQueryPipe *pipe;
    197256};
    198257
    199 class QtDialog::FilesQtQuery : public Dialog::FilesQuery {
     258class QtDialog::FilesQtQuery : public QWidget, public Dialog::FilesQuery {
     259  Q_OBJECT
    200260public:
    201261  FilesQtQuery(Parameter<std::vector< boost::filesystem::path> > &, std::string _title, QBoxLayout *_parent, QtDialog *_dialog);
     
    206266  void AddInteger();
    207267  void RemoveInteger();
    208 private:
    209   QBoxLayout *parent;
    210   QBoxLayout *thisLayout;
    211   QLabel *titleLabel;
     268
     269public slots:
     270  void onUpdate();
     271
     272private:
     273  QBoxLayout *parent;
     274  QBoxLayout *thisLayout;
     275  QLabel *titleLabel;
     276  QtDialog *dialog;
    212277
    213278  QtQueryListPipe<boost::filesystem::path> *pipe;
    214279};
    215280
    216 class QtDialog::IntQtQuery : public Dialog::IntQuery {
     281class QtDialog::IntQtQuery : public QWidget, public Dialog::IntQuery {
     282  Q_OBJECT
    217283public:
    218284  IntQtQuery(Parameter<int> &, std::string _title,QBoxLayout *_parent,QtDialog *_dialog);
    219285  virtual ~IntQtQuery();
    220286  virtual bool handle();
     287
     288public slots:
     289  void onUpdate(int);
     290
    221291private:
    222292  QBoxLayout *parent;
     
    224294  QLabel *titleLabel;
    225295  QSpinBox *inputBox;
     296  QtDialog *dialog;
    226297
    227298  IntQtQueryPipe *pipe;
    228299};
    229300
    230 class QtDialog::IntsQtQuery : public Dialog::IntsQuery {
     301class QtDialog::IntsQtQuery : public QWidget, public Dialog::IntsQuery {
     302  Q_OBJECT
    231303public:
    232304  IntsQtQuery(Parameter<std::vector<int> > &, std::string _title,QBoxLayout *_parent,QtDialog *_dialog);
     
    237309  void AddInteger();
    238310  void RemoveInteger();
    239 private:
    240   QBoxLayout *parent;
    241   QBoxLayout *thisLayout;
    242   QLabel *titleLabel;
     311
     312public slots:
     313  void onUpdate();
     314
     315private:
     316  QBoxLayout *parent;
     317  QBoxLayout *thisLayout;
     318  QLabel *titleLabel;
     319  QtDialog *dialog;
    243320
    244321  QtQueryListPipe<int> *pipe;
    245322};
    246323
    247 class QtDialog::MoleculeQtQuery : public Dialog::MoleculeQuery {
     324class QtDialog::MoleculeQtQuery : public QWidget, public Dialog::MoleculeQuery {
     325  Q_OBJECT
    248326public:
    249327  MoleculeQtQuery(Parameter<const molecule *> &, std::string _title, QBoxLayout *_parent,QtDialog *_dialog);
    250328  virtual ~MoleculeQtQuery();
    251329  virtual bool handle();
     330
     331public slots:
     332  void onUpdate(int);
     333
    252334private:
    253335  QBoxLayout *parent;
     
    255337  QLabel *titleLabel;
    256338  QComboBox *inputBox;
     339  QtDialog *dialog;
    257340
    258341  MoleculeQtQueryPipe *pipe;
    259342};
    260343
    261 class QtDialog::MoleculesQtQuery : public Dialog::MoleculesQuery {
     344class QtDialog::MoleculesQtQuery : public QWidget, public Dialog::MoleculesQuery {
     345  Q_OBJECT
    262346public:
    263347  MoleculesQtQuery(Parameter<std::vector<const molecule *> > &, std::string _title, QBoxLayout *_parent,QtDialog *_dialog);
    264348  virtual ~MoleculesQtQuery();
    265349  virtual bool handle();
     350
     351public slots:
     352  void onUpdate();
     353
    266354private:
    267355  QBoxLayout *parent;
     
    269357  QLabel *titleLabel;
    270358  QComboBox *inputBox;
     359  QtDialog *dialog;
    271360
    272361  MoleculesQtQueryPipe *pipe;
    273362};
    274363
    275 class QtDialog::StringQtQuery : public Dialog::StringQuery {
     364class QtDialog::StringQtQuery : public QWidget, public Dialog::StringQuery {
     365  Q_OBJECT
    276366public:
    277367  StringQtQuery(Parameter<std::string> &, std::string _title, QBoxLayout *_parent,QtDialog *_dialog);
    278368  virtual ~StringQtQuery();
    279369  virtual bool handle();
     370
     371public slots:
     372  void onUpdate(const QString&);
     373
    280374private:
    281375  QBoxLayout *parent;
     
    283377  QLabel *titleLabel;
    284378  QLineEdit *inputBox;
     379  QtDialog *dialog;
    285380
    286381  StringQtQueryPipe *pipe;
    287382};
    288383
    289 class QtDialog::StringsQtQuery : public Dialog::StringsQuery {
     384class QtDialog::StringsQtQuery : public QWidget, public Dialog::StringsQuery {
     385  Q_OBJECT
    290386public:
    291387  StringsQtQuery(Parameter<std::vector<std::string> > &, std::string _title, QBoxLayout *_parent,QtDialog *_dialog);
    292388  virtual ~StringsQtQuery();
    293389  virtual bool handle();
     390
     391public slots:
     392  void onUpdate();
     393
    294394private:
    295395  QBoxLayout *parent;
     
    297397  QLabel *titleLabel;
    298398  QLineEdit *inputBox;
     399  QtDialog *dialog;
    299400
    300401  StringsQtQueryPipe *pipe;
    301402};
    302403
    303 class QtDialog::UnsignedIntQtQuery : public Dialog::UnsignedIntQuery {
     404class QtDialog::UnsignedIntQtQuery : public QWidget, public Dialog::UnsignedIntQuery {
     405  Q_OBJECT
    304406public:
    305407  UnsignedIntQtQuery(Parameter<unsigned int> &, std::string _title,QBoxLayout *_parent,QtDialog *_dialog);
    306408  virtual ~UnsignedIntQtQuery();
    307409  virtual bool handle();
     410
     411public slots:
     412  void onUpdate(unsigned int);
     413
    308414private:
    309415  QBoxLayout *parent;
     
    311417  QLabel *titleLabel;
    312418  QSpinBox *inputBox;
     419  QtDialog *dialog;
    313420
    314421  UnsignedIntQtQueryPipe *pipe;
    315422};
    316423
    317 class QtDialog::UnsignedIntsQtQuery : public Dialog::UnsignedIntsQuery {
     424class QtDialog::UnsignedIntsQtQuery : public QWidget, public Dialog::UnsignedIntsQuery {
     425  Q_OBJECT
    318426public:
    319427  UnsignedIntsQtQuery(Parameter<std::vector<unsigned int> > &, std::string _title,QBoxLayout *_parent,QtDialog *_dialog);
     
    324432  void AddInteger();
    325433  void RemoveInteger();
    326 private:
    327   QBoxLayout *parent;
    328   QBoxLayout *thisLayout;
    329   QLabel *titleLabel;
     434
     435public slots:
     436  void onUpdate();
     437
     438private:
     439  QBoxLayout *parent;
     440  QBoxLayout *thisLayout;
     441  QLabel *titleLabel;
     442  QtDialog *dialog;
    330443
    331444  QtQueryListPipe<unsigned int> *pipe;
     
    333446
    334447
    335 class QtDialog::VectorQtQuery : public Dialog::VectorQuery {
     448class QtDialog::VectorQtQuery : public QWidget, public Dialog::VectorQuery {
     449  Q_OBJECT
    336450public:
    337451  VectorQtQuery(Parameter<Vector> &, std::string title,QBoxLayout *,QtDialog *);
    338452  virtual ~VectorQtQuery();
    339453  virtual bool handle();
     454
     455public slots:
     456  void onUpdateX(double);
     457  void onUpdateY(double);
     458  void onUpdateZ(double);
     459
    340460private:
    341461  QBoxLayout *parent;
     
    348468  QDoubleSpinBox *coordInputY;
    349469  QDoubleSpinBox *coordInputZ;
     470  QtDialog *dialog;
    350471
    351472  VectorQtQueryPipe *pipe;
    352473};
    353474
    354 class QtDialog::VectorsQtQuery : public Dialog::VectorsQuery {
     475class QtDialog::VectorsQtQuery : public QWidget, public Dialog::VectorsQuery {
     476  Q_OBJECT
    355477public:
    356478  VectorsQtQuery(Parameter<std::vector<Vector> > &, std::string title,QBoxLayout *,QtDialog *);
    357479  virtual ~VectorsQtQuery();
    358480  virtual bool handle();
     481
     482public slots:
     483  void onUpdate();
     484
    359485private:
    360486  QBoxLayout *parent;
     
    365491  QLabel *coordLabel;
    366492  QDoubleSpinBox *coordInput;
     493  QtDialog *dialog;
    367494
    368495  VectorsQtQueryPipe *pipe;
    369496};
    370497
    371 class QtDialog::RandomNumberDistribution_ParametersQtQuery : public Dialog::RandomNumberDistribution_ParametersQuery {
     498class QtDialog::RandomNumberDistribution_ParametersQtQuery : public QWidget, public Dialog::RandomNumberDistribution_ParametersQuery {
     499  Q_OBJECT
    372500public:
    373501  RandomNumberDistribution_ParametersQtQuery(Parameter<RandomNumberDistribution_Parameters> &, std::string title,QBoxLayout *,QtDialog *);
    374502  virtual ~RandomNumberDistribution_ParametersQtQuery();
    375503  virtual bool handle();
     504
     505public slots:
     506  void onUpdate();
     507
    376508private:
    377509  QBoxLayout *parent;
     
    380512  QTextEdit *inputBox;
    381513  QPushButton *okButton;
     514  QtDialog *dialog;
    382515
    383516  RandomNumberDistribution_ParametersQtQueryPipe *pipe;
  • src/UIElements/Qt4/Query/RandomNumberDistribution_ParametersQtQuery.cpp

    r3c53fa r7c9921  
    3333QtDialog::RandomNumberDistribution_ParametersQtQuery::RandomNumberDistribution_ParametersQtQuery(Parameter<RandomNumberDistribution_Parameters> &_param, std::string _title,QBoxLayout *_parent,QtDialog *_dialog) :
    3434    Dialog::RandomNumberDistribution_ParametersQuery(_param, _title),
    35     parent(_parent)
     35    parent(_parent),
     36    dialog(_dialog)
    3637{
    3738  thisLayout = new QHBoxLayout();
     
    5152
    5253  pipe = new RandomNumberDistribution_ParametersQtQueryPipe(temp,_dialog, inputBox);
    53   connect(okButton,SIGNAL(clicked()),pipe,SLOT(update()));
     54  connect(okButton,SIGNAL(clicked()),this,SLOT(onUpdate()));
    5455}
    5556
     
    5758{
    5859  delete pipe;
     60}
     61
     62void QtDialog::RandomNumberDistribution_ParametersQtQuery::onUpdate() {
     63  QString data = inputBox->toPlainText();
     64  std::stringstream text(data.toStdString());
     65  // TODO: check error
     66  //text >> temp;
     67  dialog->update();
    5968}
    6069
  • src/UIElements/Qt4/Query/RealSpaceMatrixQtQuery.cpp

    r3c53fa r7c9921  
    3232QtDialog::RealSpaceMatrixQtQuery::RealSpaceMatrixQtQuery(Parameter<RealSpaceMatrix> &_param, std::string _title,QBoxLayout *_parent,QtDialog *_dialog) :
    3333    Dialog::RealSpaceMatrixQuery(_param, _title),
    34     parent(_parent)
     34    parent(_parent),
     35    dialog(_dialog)
    3536{
    3637  thisLayout = new QHBoxLayout();
     
    5960  thisLayout->addWidget(inputTable);
    6061
    61   connect(inputTable,SIGNAL(cellChanged(int,int)),pipe,SLOT(update(int,int)));
     62  connect(inputTable,SIGNAL(cellChanged(int,int)),this,SLOT(onUpdate(int,int)));
    6263}
    6364
     
    6566{
    6667  delete pipe;
     68}
     69
     70void QtDialog::RealSpaceMatrixQtQuery::onUpdate(int row, int column)
     71{
     72  temp.at(row, column) = inputTable->item(row, column)->text().toDouble();
     73  dialog->update();
    6774}
    6875
  • src/UIElements/Qt4/Query/StringQtQuery.cpp

    r3c53fa r7c9921  
    3030QtDialog::StringQtQuery::StringQtQuery(Parameter<std::string> &_param, std::string _title,QBoxLayout *_parent,QtDialog *_dialog) :
    3131    Dialog::StringQuery(_param, _title),
    32     parent(_parent)
     32    parent(_parent),
     33    dialog(_dialog)
    3334{
    3435  temp = "";
     
    4445  pipe = new StringQtQueryPipe(temp,_dialog);
    4546  pipe->update(inputBox->text());
    46   connect(inputBox,SIGNAL(textChanged(const QString&)),pipe,SLOT(update(const QString&)));
     47  connect(inputBox,SIGNAL(textChanged(const QString&)),this,SLOT(onUpdate(const QString&)));
    4748}
    4849
     
    5051{
    5152  delete pipe;
     53}
     54
     55void QtDialog::StringQtQuery::onUpdate(const QString& newText) {
     56  temp = newText.toStdString();
     57  dialog->update();
    5258}
    5359
  • src/UIElements/Qt4/Query/StringsQtQuery.cpp

    r3c53fa r7c9921  
    3232QtDialog::StringsQtQuery::StringsQtQuery(Parameter<std::vector<std::string> > &_param, std::string _title,QBoxLayout *_parent,QtDialog *_dialog) :
    3333    Dialog::StringsQuery(_param, _title),
    34     parent(_parent)
     34    parent(_parent),
     35    dialog(_dialog)
    3536{
    3637  QHBoxLayout * thisHLayout = new QHBoxLayout();
     
    7172}
    7273
     74void QtDialog::StringsQtQuery::onUpdate() {
     75  dialog->update();
     76}
     77
    7378// All values besides the empty std::string are valid
    7479bool QtDialog::StringsQtQuery::handle()
  • src/UIElements/Qt4/Query/UnsignedIntQtQuery.cpp

    r3c53fa r7c9921  
    3030QtDialog::UnsignedIntQtQuery::UnsignedIntQtQuery(Parameter<unsigned int> &_param, std::string _title,QBoxLayout *_parent,QtDialog *_dialog) :
    3131    Dialog::UnsignedIntQuery(_param, _title),
    32     parent(_parent)
     32    parent(_parent),
     33    dialog(_dialog)
    3334{
    3435  temp = 0;
     
    4546  pipe = new UnsignedIntQtQueryPipe(temp,_dialog);
    4647  pipe->update(inputBox->value());
    47   connect(inputBox,SIGNAL(valueChanged(unsigned int)),pipe,SLOT(update(unsigned int)));
     48  connect(inputBox,SIGNAL(valueChanged(unsigned int)),this,SLOT(onUpdate(unsigned int)));
    4849}
    4950
     
    5152{
    5253  delete pipe;
     54}
     55
     56void QtDialog::UnsignedIntQtQuery::onUpdate(unsigned int newUnsignedInt) {
     57  temp = newUnsignedInt;
     58  dialog->update();
    5359}
    5460
  • src/UIElements/Qt4/Query/UnsignedIntsQtQuery.cpp

    r3c53fa r7c9921  
    3232QtDialog::UnsignedIntsQtQuery::UnsignedIntsQtQuery(Parameter<std::vector<unsigned int> > &_param, std::string _title,QBoxLayout *_parent,QtDialog *_dialog) :
    3333    Dialog::UnsignedIntsQuery(_param, _title),
    34     parent(_parent)
     34    parent(_parent),
     35    dialog(_dialog)
    3536{
    3637  QHBoxLayout * thisHLayout = new QHBoxLayout();
     
    7273}
    7374
     75void QtDialog::UnsignedIntsQtQuery::onUpdate() {
     76  dialog->update();
     77}
     78
    7479bool QtDialog::UnsignedIntsQtQuery::handle() {
    7580  if (param.isValid(temp)){
  • src/UIElements/Qt4/Query/VectorQtQuery.cpp

    r3c53fa r7c9921  
    3131QtDialog::VectorQtQuery::VectorQtQuery(Parameter<Vector> &_param, std::string title, QBoxLayout *_parent,QtDialog *_dialog) :
    3232    Dialog::VectorQuery(_param, title),
    33     parent(_parent)
     33    parent(_parent),
     34    dialog(_dialog)
    3435{
    3536  temp = Vector(0, 0, 0);
     
    6667  pipe = new VectorQtQueryPipe(temp,_dialog,inputBox);
    6768  //pipe->update(coordInput->value());
    68   connect(coordInputX,SIGNAL(valueChanged(double)),pipe,SLOT(updateX(double)));
    69   connect(coordInputY,SIGNAL(valueChanged(double)),pipe,SLOT(updateY(double)));
    70   connect(coordInputZ,SIGNAL(valueChanged(double)),pipe,SLOT(updateZ(double)));
     69  connect(coordInputX,SIGNAL(valueChanged(double)),this,SLOT(onUpdateX(double)));
     70  connect(coordInputY,SIGNAL(valueChanged(double)),this,SLOT(onUpdateY(double)));
     71  connect(coordInputZ,SIGNAL(valueChanged(double)),this,SLOT(onUpdateZ(double)));
    7172  parent->addLayout(mainLayout);
    7273}
     
    7475QtDialog::VectorQtQuery::~VectorQtQuery()
    7576{}
     77
     78void QtDialog::VectorQtQuery::onUpdateX(double newDouble) {
     79  temp[0] = newDouble;
     80  dialog->update();
     81}
     82
     83void QtDialog::VectorQtQuery::onUpdateY(double newDouble) {
     84  temp[1] = newDouble;
     85  dialog->update();
     86}
     87
     88void QtDialog::VectorQtQuery::onUpdateZ(double newDouble) {
     89  temp[2] = newDouble;
     90  dialog->update();
     91}
    7692
    7793bool QtDialog::VectorQtQuery::handle() {
  • src/UIElements/Qt4/Query/VectorsQtQuery.cpp

    r3c53fa r7c9921  
    3131QtDialog::VectorsQtQuery::VectorsQtQuery(Parameter<std::vector<Vector> > &_param, std::string title, QBoxLayout *_parent,QtDialog *_dialog) :
    3232    Dialog::VectorsQuery(_param, title),
    33     parent(_parent)
     33    parent(_parent),
     34    dialog(_dialog)
    3435{
    3536  mainLayout= new QHBoxLayout();
     
    5657{}
    5758
     59void QtDialog::VectorsQtQuery::onUpdate() {
     60  dialog->update();
     61}
     62
    5863bool QtDialog::VectorsQtQuery::handle() {
    5964  if (param.isValid(temp)){
Note: See TracChangeset for help on using the changeset viewer.