- Timestamp:
- Jul 17, 2012, 12:17:26 PM (13 years ago)
- 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)
- Location:
- src/UIElements
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Makefile.am
rc7e000 r2aafe8 228 228 UIElements/Qt4/Pipe/MoleculeQtQueryPipe.hpp \ 229 229 UIElements/Qt4/Pipe/MoleculesQtQueryPipe.hpp \ 230 UIElements/Qt4/Pipe/QtQueryListPipe.hpp \ 230 231 UIElements/Qt4/Pipe/RandomNumberDistribution_ParametersQtQueryPipe.hpp \ 231 232 UIElements/Qt4/Pipe/RealSpaceMatrixQtQueryPipe.hpp \ -
src/UIElements/Qt4/Pipe/QtQueryListPipe.hpp
rc7e000 r2aafe8 18 18 #include "QtQueryPipe.hpp" 19 19 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 20 27 #include <boost/lexical_cast.hpp> 21 28 … … 36 43 {} 37 44 38 template<typename T> void QtQueryListPipe<T>:: IntegerEntered(const QString&)45 template<typename T> void QtQueryListPipe<T>::elementEntered(const QString& t) 39 46 { 40 AddButton->setEnabled(t rue);47 AddButton->setEnabled(t.length() > 0); 41 48 } 42 49 43 template<typename T> void QtQueryListPipe<T>:: IntegerSelected()50 template<typename T> void QtQueryListPipe<T>::elementSelected() 44 51 { 45 52 if (inputList->selectedItems().empty()) … … 49 56 } 50 57 51 template<typename T> void QtQueryListPipe<T>:: AddInteger() {58 template<typename T> void QtQueryListPipe<T>::addElement() { 52 59 // type-check 53 60 std::string text = inputBox->text().toStdString(); 54 int number = 0;61 T value; 55 62 try { 56 number = boost::lexical_cast<int>(text);63 value = boost::lexical_cast<T>(text); 57 64 } catch (boost::bad_lexical_cast&) { 58 65 return; 59 66 }; 60 67 // add item to both 61 inputList->addItem(QString( number));62 AddValue(number);68 inputList->addItem(QString(toString(value).c_str())); 69 addValue(value); 63 70 } 64 71 65 template<typename T> void QtQueryListPipe<T>::AddValue(T item) { 66 content->push_back(item); 72 template<typename T> void QtQueryListPipe<T>::addValue(T item) { 73 std::vector<T> temp = content.get(); 74 temp.push_back(item); 75 content.set(temp); 67 76 68 77 dialog->update(); 69 78 } 70 79 71 template<typename T> void QtQueryListPipe<T>:: RemoveInteger() {80 template<typename T> void QtQueryListPipe<T>::removeElement() { 72 81 QList<QListWidgetItem *> items = inputList->selectedItems(); 73 82 for (QList<QListWidgetItem *>::iterator iter = items.begin(); !items.empty(); iter = items.begin()) { … … 75 84 inputList->setCurrentItem(*iter); 76 85 // 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); 79 89 } 80 90 } 81 91 82 template<typename T> void QtQueryListPipe<T>:: RemoveRow(int row) {92 template<typename T> void QtQueryListPipe<T>::removeRow(int row) { 83 93 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) 86 97 if (counter++ == row) 87 98 break; 88 if (iter != content->end()) 89 content->erase(iter); 99 if (iter != temp.end()) 100 temp.erase(iter); 101 content.set(temp); 90 102 } 103 104 class StringsQtQueryPipe : public QtQueryListPipe<std::string> 105 { 106 Q_OBJECT 107 public: 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 111 public 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 }; 91 129 92 130 -
src/UIElements/Qt4/Pipe/QtQueryPipe.hpp
rc7e000 r2aafe8 24 24 #include <vector> 25 25 26 #include "CodePatterns/MemDebug.hpp"27 28 26 class QLineEdit; 29 27 class QListWidget; … … 36 34 QtQueryListPipe(Parameter<std::vector<T> > &_content, QtDialog *_dialog, QLineEdit *_inputBox, QListWidget *_inputList, QPushButton *_AddButton, QPushButton *_RemoveButton); 37 35 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&); 42 42 43 43 private: 44 void AddValue(T item);45 void RemoveRow(int row);44 void addValue(T item); 45 void removeRow(int row); 46 46 47 47 Parameter<std::vector<T> > &content; -
src/UIElements/Qt4/Query/QtQuery.hpp
rc7e000 r2aafe8 298 298 QLineEdit *inputBox; 299 299 300 QtQueryListPipe<std::string>*pipe;300 StringsQtQueryPipe *pipe; 301 301 }; 302 302 -
src/UIElements/Qt4/Query/StringsQtQuery.cpp
rc7e000 r2aafe8 60 60 thisHLayout->addLayout(thisV2Layout); 61 61 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()));} 67 67 68 68 QtDialog::StringsQtQuery::~StringsQtQuery() … … 74 74 bool QtDialog::StringsQtQuery::handle() 75 75 { 76 // dissect by ","76 /* // dissect by "," 77 77 std::string::iterator olditer = temp.begin(); 78 78 std::vector<std::string> temp_strings; … … 87 87 tmp.set(temp_strings); 88 88 89 return temp!=""; 89 return temp!="";*/ 90 return true; 90 91 } 91 92
Note:
See TracChangeset
for help on using the changeset viewer.