Changeset 2aafe8 for src


Ignore:
Timestamp:
Jul 17, 2012, 12:17:26 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:
99e8ea
Parents:
c7e000
git-author:
Michael Ankele <ankele@…> (06/05/12 12:38:27)
git-committer:
Michael Ankele <ankele@…> (07/17/12 12:17:26)
Message:

Fix: StringsQtQuery works

  • created StringsQtQueryPipe as its own class so moc can operate without template'ized classes
Location:
src/UIElements
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/Makefile.am

    rc7e000 r2aafe8  
    228228  UIElements/Qt4/Pipe/MoleculeQtQueryPipe.hpp \
    229229  UIElements/Qt4/Pipe/MoleculesQtQueryPipe.hpp \
     230  UIElements/Qt4/Pipe/QtQueryListPipe.hpp \
    230231  UIElements/Qt4/Pipe/RandomNumberDistribution_ParametersQtQueryPipe.hpp \
    231232  UIElements/Qt4/Pipe/RealSpaceMatrixQtQueryPipe.hpp \
  • src/UIElements/Qt4/Pipe/QtQueryListPipe.hpp

    rc7e000 r2aafe8  
    1818#include "QtQueryPipe.hpp"
    1919
     20// Qt moc needs these because it generates its own .cpp file from QtQueryListPipe.hpp.
     21#include <Qt/qboxlayout.h>
     22#include <Qt/qlabel.h>
     23#include <Qt/qlineedit.h>
     24#include <Qt/qlistwidget.h>
     25#include <Qt/qpushbutton.h>
     26
    2027#include <boost/lexical_cast.hpp>
    2128
     
    3643{}
    3744
    38 template<typename T> void QtQueryListPipe<T>::IntegerEntered(const QString&)
     45template<typename T> void QtQueryListPipe<T>::elementEntered(const QString& t)
    3946{
    40   AddButton->setEnabled(true);
     47  AddButton->setEnabled(t.length() > 0);
    4148}
    4249
    43 template<typename T> void QtQueryListPipe<T>::IntegerSelected()
     50template<typename T> void QtQueryListPipe<T>::elementSelected()
    4451{
    4552  if (inputList->selectedItems().empty())
     
    4956}
    5057
    51 template<typename T> void QtQueryListPipe<T>::AddInteger() {
     58template<typename T> void QtQueryListPipe<T>::addElement() {
    5259  // type-check
    5360  std::string text = inputBox->text().toStdString();
    54   int number = 0;
     61  T value;
    5562  try {
    56     number = boost::lexical_cast<int>(text);
     63    value = boost::lexical_cast<T>(text);
    5764  } catch (boost::bad_lexical_cast&) {
    5865    return;
    5966  };
    6067  // add item to both
    61   inputList->addItem(QString(number));
    62   AddValue(number);
     68  inputList->addItem(QString(toString(value).c_str()));
     69  addValue(value);
    6370}
    6471
    65 template<typename T> void QtQueryListPipe<T>::AddValue(T item) {
    66   content->push_back(item);
     72template<typename T> void QtQueryListPipe<T>::addValue(T item) {
     73  std::vector<T> temp = content.get();
     74  temp.push_back(item);
     75  content.set(temp);
    6776
    6877  dialog->update();
    6978}
    7079
    71 template<typename T> void QtQueryListPipe<T>::RemoveInteger() {
     80template<typename T> void QtQueryListPipe<T>::removeElement() {
    7281  QList<QListWidgetItem *> items = inputList->selectedItems();
    7382  for (QList<QListWidgetItem *>::iterator iter = items.begin(); !items.empty(); iter = items.begin()) {
     
    7584    inputList->setCurrentItem(*iter);
    7685    // remove
    77     QtQueryListPipe<T>::RemoteRow(inputList->currentRow()); // template parameters needs to be known, such that compiler knows which to call
    78     inputList->removeItemWidget(*iter);
     86    QtQueryListPipe<T>::removeRow(inputList->currentRow()); // template parameters needs to be known, such that compiler knows which to call
     87    inputList->takeItem(inputList->currentRow());
     88    items.erase(iter);
    7989  }
    8090}
    8191
    82 template<typename T> void QtQueryListPipe<T>::RemoveRow(int row) {
     92template<typename T> void QtQueryListPipe<T>::removeRow(int row) {
    8393  int counter = 0;
    84   typename std::vector<T>::iterator iter = content->begin();
    85   for (; iter != content->end(); ++iter)
     94  std::vector<T> temp = content.get();
     95  typename std::vector<T>::iterator iter = temp.begin();
     96  for (; iter != temp.end(); ++iter)
    8697    if (counter++ == row)
    8798      break;
    88   if (iter != content->end())
    89       content->erase(iter);
     99  if (iter != temp.end())
     100    temp.erase(iter);
     101  content.set(temp);
    90102}
     103
     104class StringsQtQueryPipe : public QtQueryListPipe<std::string>
     105{
     106  Q_OBJECT
     107public:
     108  StringsQtQueryPipe(Parameter<std::vector<std::string> > &_content, QtDialog *_dialog, QLineEdit *_inputBox, QListWidget *_inputList, QPushButton *_AddButton, QPushButton *_RemoveButton) :
     109    QtQueryListPipe<std::string>(_content, _dialog, _inputBox, _inputList, _AddButton, _RemoveButton) { }
     110
     111public slots:
     112  virtual void elementEntered(const QString& t)
     113  {
     114    QtQueryListPipe<std::string>::elementEntered(t);
     115  }
     116  virtual void elementSelected()
     117  {
     118    QtQueryListPipe<std::string>::elementSelected();
     119  }
     120  virtual void addElement()
     121  {
     122    QtQueryListPipe<std::string>::addElement();
     123  }
     124  virtual void removeElement()
     125  {
     126    QtQueryListPipe<std::string>::removeElement();
     127  }
     128};
    91129
    92130
  • src/UIElements/Qt4/Pipe/QtQueryPipe.hpp

    rc7e000 r2aafe8  
    2424#include <vector>
    2525
    26 #include "CodePatterns/MemDebug.hpp"
    27 
    2826class QLineEdit;
    2927class QListWidget;
     
    3634    QtQueryListPipe(Parameter<std::vector<T> > &_content, QtDialog *_dialog, QLineEdit *_inputBox, QListWidget *_inputList, QPushButton *_AddButton, QPushButton *_RemoveButton);
    3735    virtual ~QtQueryListPipe();
    38     void AddInteger();
    39     void RemoveInteger();
    40     void IntegerSelected();
    41     void IntegerEntered(const QString&);
     36
     37  // Slots to-be.
     38    virtual void addElement();
     39    virtual void removeElement();
     40    virtual void elementSelected();
     41    virtual void elementEntered(const QString&);
    4242
    4343  private:
    44     void AddValue(T item);
    45     void RemoveRow(int row);
     44    void addValue(T item);
     45    void removeRow(int row);
    4646
    4747    Parameter<std::vector<T> > &content;
  • src/UIElements/Qt4/Query/QtQuery.hpp

    rc7e000 r2aafe8  
    298298  QLineEdit *inputBox;
    299299
    300   QtQueryListPipe<std::string> *pipe;
     300  StringsQtQueryPipe *pipe;
    301301};
    302302
  • src/UIElements/Qt4/Query/StringsQtQuery.cpp

    rc7e000 r2aafe8  
    6060  thisHLayout->addLayout(thisV2Layout);
    6161
    62   pipe = new QtQueryListPipe<std::string>(tmp,_dialog,inputBox,inputList,AddButton,RemoveButton);
    63   connect(inputBox,SIGNAL(textChanged(const QString&)),pipe,SLOT(IntegerEntered(const QString&)));
    64   connect(inputList,SIGNAL(itemSelectionChanged()),pipe,SLOT(IntegerSelected()));
    65   connect(AddButton,SIGNAL(Clicked()),pipe,SLOT(AddValue()));
    66   connect(RemoveButton,SIGNAL(Clicked()),pipe,SLOT(RemoveRow()));}
     62  pipe = new StringsQtQueryPipe(tmp,_dialog,inputBox,inputList,AddButton,RemoveButton);
     63  connect(inputBox,SIGNAL(textChanged(const QString&)),pipe,SLOT(elementEntered(const QString&)));
     64  connect(inputList,SIGNAL(itemSelectionChanged()),pipe,SLOT(elementSelected()));
     65  connect(AddButton,SIGNAL(clicked()),pipe,SLOT(addElement()));
     66  connect(RemoveButton,SIGNAL(clicked()),pipe,SLOT(removeElement()));}
    6767
    6868QtDialog::StringsQtQuery::~StringsQtQuery()
     
    7474bool QtDialog::StringsQtQuery::handle()
    7575{
    76   // dissect by ","
     76/*  // dissect by ","
    7777  std::string::iterator olditer = temp.begin();
    7878  std::vector<std::string> temp_strings;
     
    8787  tmp.set(temp_strings);
    8888
    89   return temp!="";
     89  return temp!="";*/
     90  return true;
    9091}
    9192
Note: See TracChangeset for help on using the changeset viewer.