source: src/UIElements/Views/Qt4/MoleculeList/QtMoleculeList.hpp@ ea2663

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 ea2663 was 5771e6, checked in by Frederik Heber <heber@…>, 9 years ago

Removed all mutexes and updateDirtyStates() in QtMoleculeList, replaced by simpler slots.

  • thanks to events we don't need this humonguous system of lists, update timers, and mutexes. We simply need to take action whenever an event comes in.
  • Property mode set to 100644
File size: 4.2 KB
Line 
1/*
2 * QtMoleculeList.hpp
3 *
4 * Created on: Jan 21, 2010
5 * Author: crueger
6 */
7
8#ifndef QTMOLECULELIST_HPP_
9#define QTMOLECULELIST_HPP_
10
11// include config.h
12#ifdef HAVE_CONFIG_H
13#include <config.h>
14#endif
15
16#include <QtGui/QItemSelection>
17#include <QtGui/QStandardItem>
18#include <QtGui/QStandardItemModel>
19#include <QTimer>
20
21#include <boost/bimap.hpp>
22#include <boost/thread/recursive_mutex.hpp>
23#include <map>
24#include <set>
25#include <string>
26
27#include "UIElements/Views/Qt4/MoleculeList/QtMoleculeItem.hpp"
28#include "UIElements/Views/Qt4/MoleculeList/QtObservedMoleculeObserver.hpp"
29#include "UIElements/Qt4/InstanceBoard/QtObservedMolecule.hpp"
30
31#include "types.hpp"
32
33class QtMoleculeItem;
34class QtMoleculeListView;
35class QtObservedInstanceBoard;
36
37class QtMoleculeList : public QStandardItemModel
38{
39 Q_OBJECT
40
41public:
42 QtMoleculeList(QtObservedInstanceBoard *_board, QObject *_parent = NULL);
43 virtual ~QtMoleculeList();
44
45 void resetUpdateTimer();
46
47 QVariant headerData(int section, Qt::Orientation orientation, int role) const;
48
49private slots:
50 void formulaChanged(const QtObservedMolecule::ptr _mol);
51 void nameChanged(const QtObservedMolecule::ptr _mol);
52
53 void moleculeNameChanged(QStandardItem*);
54 void checkForVisibilityChange(QStandardItem*);
55
56signals:
57 void moleculeSelected(const QtObservedMolecule::ptr _mol);
58 void moleculeUnSelected(const QtObservedMolecule::ptr _mol);
59 void moleculesVisibilityChanged(const moleculeId_t, bool);
60
61private:
62
63private slots:
64 void moleculeInserted(QtObservedMolecule::ptr _mol);
65 void moleculeRemoved(const moleculeId_t _id);
66 void moleculeIndexChanged(const moleculeId_t _oldid, const moleculeId_t _newid);
67
68private:
69 friend class QtMoleculeListView;
70
71 bool isMoleculeItemPresent(const moleculeId_t _molid) const;
72 QtMoleculeItem * MoleculeIdToItem(const moleculeId_t _molid) const;
73 const moleculeId_t ItemToMoleculeId(const QtMoleculeItem * const _item) const;
74 const QModelIndex MoleculeIdToIndex(const moleculeId_t _id) const;
75 const moleculeId_t IndexToMoleculeId(const QModelIndex &_index) const;
76 QtMoleculeItem * getSpecificMoleculeItem(
77 const QtMoleculeItem * const _item,
78 const enum QtMoleculeItem::COLUMNTYPES _type) const;
79 bool isGroupItemPresent(const std::string &_formula) const;
80 const std::string& GroupItemToFormula(const QStandardItem * const _item) const;
81 QStandardItem * FormulaToGroupItem(const std::string &_formula) const;
82 QStandardItem * getSpecificGroupItem(
83 const QStandardItem * const _item,
84 const enum QtMoleculeItem::COLUMNTYPES _type) const;
85
86 std::string addMolecule(
87 QtObservedMolecule::ptr &_ObservedMolecule);
88 void addGroupItem(
89 QStandardItem *&mainitem,
90 const std::string &_molecule_formula);
91 QList<QStandardItem *> createMoleculeItems(
92 QtObservedMolecule::ptr &_ObservedMolecule,
93 std::string &molecule_formula);
94 void removeMoleculeItem(QtMoleculeItem * const _item);
95 int setOccurrence(QStandardItem * const _groupitem);
96 void setVisibilityForMoleculeItem(QtMoleculeItem* _item);
97 void setVisibilityForGroupItem(QStandardItem* _item);
98 void moveItem(QtMoleculeItem *_molitem, const std::string &_new_formula);
99
100// void updateItemStates();
101
102 //!> reference to InstanceBoard
103 QtObservedInstanceBoard *board;
104
105 typedef std::map<std::string, unsigned int> FormulaVisibilityCountMap_t;
106 FormulaVisibilityCountMap_t FormulaVisibilityCountMap;
107
108 typedef boost::bimap<std::string, QStandardItem*> FormulaTreeItemBiMap_t;
109 //!> map of (unique) formulas in the world
110 FormulaTreeItemBiMap_t FormulaItemBiMap;
111
112 typedef std::map<moleculeId_t, std::string> MoleculeFormulaMap_t;
113 //!> map of (unique) formulas in the world
114 MoleculeFormulaMap_t MoleculeFormulaMap;
115
116 typedef boost::bimap<moleculeId_t, QtMoleculeItem*> MoleculeItemBiMap_t;
117 MoleculeItemBiMap_t MoleculeItemBiMap;
118
119 typedef std::set< moleculeId_t > list_of_molecules_t;
120 typedef std::set< std::pair<moleculeId_t, QtMoleculeItem::COLUMNTYPES> > list_of_molecule_items_t;
121 typedef std::set< std::pair<std::string, QtMoleculeItem::COLUMNTYPES> > list_of_group_items_t;
122
123 //!> listens to all QtObservedMolecule and relays important events to us
124 QtObservedMoleculeObserver observer;
125};
126
127#endif /* QTMOLECULELIST_HPP_ */
Note: See TracBrowser for help on using the repository browser.