Ignore:
Timestamp:
Jan 28, 2015, 7:07:03 PM (10 years ago)
Author:
Frederik Heber <heber@…>
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:
d2dbb5d
Parents:
6d1e0a
git-author:
Frederik Heber <heber@…> (01/18/15 14:04:26)
git-committer:
Frederik Heber <heber@…> (01/28/15 19:07:03)
Message:

Modified QtMoleculeList to use QtMoleculeItemFactory.

  • setOccurrence() gives index of row back if it should be romoved.
  • i.e. moving a row and removing the row entirely does not mix. Updating it and then removing it is ill-spent time.
  • split off removing a group item from setting its occurrence.
  • emitDirtyState() only uses the first column item despite for the dirty items set. Otherwise we have multiple moves of the same row.
  • this is safer than removing the entry in MoleculeBiMap right away as thread in GUI and Action thread do not access in an orderly fashion.
  • using vector of molecule pointers and set operations to fulfil validity of updates.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/Views/Qt4/MoleculeList/QtMoleculeList.hpp

    r6d1e0a r53c1ff  
    1414#endif
    1515
     16#include <QtGui/QItemSelection>
    1617#include <QtGui/QStandardItem>
    1718#include <QtGui/QStandardItemModel>
     19#include <QTimer>
    1820
    1921#include <boost/bimap.hpp>
    2022#include <map>
     23#include <set>
    2124#include <string>
    2225
    2326#include "CodePatterns/Observer/Observer.hpp"
     27
     28#include "UIElements/Views/Qt4/MoleculeList/QtMoleculeItem.hpp"
    2429
    2530#include "types.hpp"
     
    2732class molecule;
    2833class MoleculeListClass;
     34class QtMoleculeItem;
    2935class QtMoleculeListView;
    3036
     
    4147  virtual void recieveNotification(Observable *publisher, Notification_ptr notification);
    4248  virtual void subjectKilled(Observable *publisher);
    43 //  virtual void paintEvent(QPaintEvent * event);
     49
    4450  void refill();
    45 
    46   static const int COLUMNCOUNT;
    47   enum {NAME,VISIBILITY,ATOMCOUNT,FORMULA,OCCURRENCE,COLUMNTYPES_MAX} COLUMNTYPES;
    48   static const char *COLUMNNAMES[];
    4951
    5052  QVariant headerData(int section, Qt::Orientation orientation, int role) const;
     
    5355  void moleculeChanged();
    5456//  void visibilityChanged(QStandardItem*, int);
     57  void checkState();
     58
     59  friend class QtMoleculeItem;
    5560
    5661//  void rowsSelected(const QItemSelection & selected, const QItemSelection & deselected);
    57 
     62  void readdItem(QtMoleculeItem *_molitem);
    5863
    5964signals:
     
    6368
    6469private:
    65   bool dirty;
    66   bool clearing;
     70
    6771  bool selecting;
    6872  bool changing;
    6973  bool ChangingChildrensVisibility;
     74  bool list_accessing;
     75
     76  //!> informs the view in regular intervals about updates
     77  QTimer *update_timer;
     78
     79  //!> how often per second update is signalled to view
     80  static const unsigned int update_times_per_second;
    7081
    7182  friend class QtMoleculeListView;
    72   QStandardItem * MoleculeToItem(const molecule * const _mol);
    7383
    74   void addItem(const molecule * const _mol);
     84  QtMoleculeItem * MoleculeToItem(const molecule * const _mol) const;
     85  const molecule * const IndexToMolecule(const QModelIndex &_index) const;
     86  const molecule * const ItemToMolecule(const QtMoleculeItem * const _item) const;
     87
     88  void addMolecule(const molecule * const _mol);
    7589  void addGroupItem(QStandardItem *&mainitem, const std::string &_molecule_formula);
    76   void addMoleculeItem(QStandardItem *_groupitem, const molecule *_mol, const std::string &molecule_formula);
    77   void removeItem(const molecule * const _mol);
     90  void addMoleculeItem(QStandardItem *_groupitem, const molecule * const _mol, const std::string &molecule_formula);
     91  void removeItem(QtMoleculeItem * const _item);
     92  int setOccurrence(QStandardItem * const _groupitem);
     93  bool areAnyItemsDirty();
     94  void addToBeSetOccurrence(QStandardItem *_groupitem);
     95
     96  void informDirtyState(QtMoleculeItem *_item, const QtMoleculeItem::MoveTypes _type);
     97
     98  void updateItemStates();
    7899
    79100  typedef std::map<std::string, unsigned int> FormulaVisibilityCountMap_t;
     
    84105  FormulaTreeItemMap_t formula;
    85106
    86   typedef boost::bimap<const molecule *, QStandardItem*> MoleculeItemBiMap_t;
     107  typedef boost::bimap<const molecule *, QtMoleculeItem*> MoleculeItemBiMap_t;
    87108  MoleculeItemBiMap_t MoleculeItemBiMap;
     109
     110  //!> callback function to hand over to items that inform about requiring update
     111  const QtMoleculeItem::emitDirtyState_t callback_DirtyItems;
     112
     113  typedef std::set<QtMoleculeItem*> list_of_items_t;
     114  //!> list of items that need an update
     115  list_of_items_t dirtyItems;
     116  //!> list of items to molecule's whose formulas has changed and need to be moved
     117  list_of_items_t toBeMovedItems;
     118  //!> list of items to new molecules which need to be added
     119  std::vector<const molecule *> newItems;
     120  //!> list of items to molecules that have been removed
     121  std::vector<const molecule *> toBeRemovedItems;
     122  //!> list of group items that need update due to moved molecule items
     123  std::set<QStandardItem*> toBeSetOccurrenceItems;
    88124};
    89125
Note: See TracChangeset for help on using the changeset viewer.