source: src/UIElements/Qt4/Query/QtQueryList.hpp@ 125841

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
Last change on this file since 125841 was 7e6a1b, checked in by Michael Ankele <ankele@…>, 13 years ago

Fix: list queries called wrong update function

  • Property mode set to 100644
File size: 4.2 KB
Line 
1/*
2 * QtQueryList.hpp
3 *
4 * Created on: Jul 24, 2012
5 * Author: ankele
6 */
7
8#ifndef QTQUERYLIST_HPP_
9#define QTQUERYLIST_HPP_
10
11
12// include config.h
13#ifdef HAVE_CONFIG_H
14#include <config.h>
15#endif
16
17#include "UIElements/Dialog.hpp"
18#include "Parameters/Parameter.hpp"
19
20class QListWidget;
21class QPushButton;
22class QVBoxLayout;
23class QHBoxLayout;
24class QBoxLayout;
25
26class QtQueryListUntyped {
27public:
28 QtQueryListUntyped(QBoxLayout *parent, Dialog *_dialog);
29 virtual ~QtQueryListUntyped(){}
30
31 virtual void onSubUpdate() = 0;
32
33 void onUpdate();
34 void elementSelected();
35 void addElementToListWidget(const std::string &str);
36 std::vector<int> getSelectedRows();
37 void removeSelectedRows(const std::vector<int> &rows);
38
39protected:
40 QListWidget *inputList;
41 QPushButton *addButton;
42 QPushButton *removeButton;
43 QVBoxLayout *thisVLayout;
44 QHBoxLayout *thisHLayout;
45 QVBoxLayout *buttonBox;
46 Dialog *dialog;
47};
48
49template<class T>
50class QtQueryList : public QtQueryListUntyped {
51public:
52 QtQueryList(QBoxLayout *parent, Dialog *_dialog, std::vector<T> &_temp) : QtQueryListUntyped(parent, _dialog), tempRef(_temp)
53 {
54 subParam = new Parameter<T>("sub-param");
55 }
56 virtual ~QtQueryList()
57 {
58 delete(subParam);
59 }
60
61 void addElement() {
62 // add item to both
63 addElementToListWidget(subParam->getAsString());
64 tempRef.push_back(subParam->get());
65 onUpdate();
66 }
67 void removeElements()
68 {
69 std::vector<int> rows = getSelectedRows();
70 removeSelectedRows(rows);
71 for (int i = rows.size() - 1; i >= 0; i --){
72 ASSERT(rows[i] < tempRef.size(), "QtQueryList<T>::removeElements() trying to remove invalid element.");
73 tempRef.erase(tempRef.begin() + rows[i]);
74 }
75 onUpdate();
76 }
77protected:
78 std::vector<T> &tempRef;
79 Parameter<T> *subParam;
80};
81
82
83
84class ListQuerySubDialog : public Dialog
85{
86public:
87 ListQuerySubDialog(QtQueryListUntyped *_parent) : parent(_parent), sub(NULL){}
88 virtual void update()
89 {
90 if (sub)
91 if (sub->isValid())
92 sub->setResult();
93 parent->onSubUpdate();
94 }
95 void setSubQuery(Query *_sub){ sub = _sub; }
96
97 virtual void queryEmpty(const char*, std::string){}
98 virtual void queryBoolean(Parameter<bool> &, const char *, std::string = ""){}
99 virtual void queryInt(Parameter<int> &, const char *,std::string = ""){}
100 virtual void queryInts(Parameter<std::vector<int> > &, const char *,std::string = ""){}
101 virtual void queryUnsignedInt(Parameter<unsigned int> &, const char *,std::string = ""){}
102 virtual void queryUnsignedInts(Parameter<std::vector<unsigned int> > &, const char *,std::string = ""){}
103 virtual void queryDouble(Parameter<double> &, const char*,std::string = ""){}
104 virtual void queryDoubles(Parameter<std::vector<double> > &, const char*,std::string = ""){}
105 virtual void queryString(Parameter<std::string> &, const char*,std::string = ""){}
106 virtual void queryStrings(Parameter<std::vector<std::string> > &, const char*,std::string = ""){}
107 virtual void queryAtom(Parameter<const atom *> &, const char*,std::string = ""){}
108 virtual void queryAtoms(Parameter<std::vector<const atom *> > &, const char*,std::string = ""){}
109 virtual void queryMolecule(Parameter<const molecule *> &, const char*,std::string = ""){}
110 virtual void queryMolecules(Parameter<std::vector<const molecule *> > &, const char*,std::string = ""){}
111 virtual void queryVector(Parameter<Vector> &, const char*,std::string = ""){}
112 virtual void queryVectors(Parameter<std::vector<Vector> > &, const char*,std::string = ""){}
113 virtual void queryRealSpaceMatrix(Parameter<RealSpaceMatrix> &, const char*, std::string = ""){}
114 virtual void queryElement(Parameter<const element *> &, const char*,std::string = ""){}
115 virtual void queryElements(Parameter<std::vector<const element *> > &, const char*,std::string = ""){}
116 virtual void queryFile(Parameter<boost::filesystem::path> &, const char*,std::string = ""){}
117 virtual void queryFiles(Parameter<std::vector< boost::filesystem::path> > &, const char*,std::string = ""){}
118 virtual void queryRandomNumberDistribution_Parameters(Parameter<RandomNumberDistribution_Parameters> &, const char*,std::string = ""){}
119private:
120 QtQueryListUntyped *parent;
121 Query *sub;
122};
123
124
125#endif /* QTQUERYLIST_HPP_ */
Note: See TracBrowser for help on using the repository browser.