/* * QtMoleculeList.hpp * * Created on: Jan 21, 2010 * Author: crueger */ #ifndef QTMOLECULELIST_HPP_ #define QTMOLECULELIST_HPP_ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include #include "CodePatterns/Observer/Observer.hpp" #include "types.hpp" class molecule; class MoleculeListClass; class QtMoleculeListView; class QtMoleculeList : public QStandardItemModel, public Observer { Q_OBJECT public: QtMoleculeList(); virtual ~QtMoleculeList(); protected: virtual void update(Observable *publisher); virtual void recieveNotification(Observable *publisher, Notification_ptr notification); virtual void subjectKilled(Observable *publisher); // virtual void paintEvent(QPaintEvent * event); void refill(); static const int COLUMNCOUNT; enum {NAME,VISIBILITY,ATOMCOUNT,FORMULA,OCCURRENCE,COLUMNTYPES_MAX} COLUMNTYPES; static const char *COLUMNNAMES[]; QVariant headerData(int section, Qt::Orientation orientation, int role) const; private slots: void moleculeChanged(); // void visibilityChanged(QStandardItem*, int); // void rowsSelected(const QItemSelection & selected, const QItemSelection & deselected); signals: void moleculeSelected(molecule*); void moleculeUnSelected(molecule*); void moleculesVisibilityChanged(const moleculeId_t, bool); private: bool dirty; bool clearing; bool selecting; bool changing; bool ChangingChildrensVisibility; friend class QtMoleculeListView; QStandardItem * MoleculeToItem(const molecule * const _mol); void addItem(const molecule * const _mol); void addGroupItem(QStandardItem *&mainitem, const std::string &_molecule_formula); void addMoleculeItem(QStandardItem *_groupitem, const molecule *_mol, const std::string &molecule_formula); void removeItem(const molecule * const _mol); typedef std::map FormulaVisibilityCountMap_t; FormulaVisibilityCountMap_t FormulaVisibilityCountMap; typedef std::map FormulaTreeItemMap_t; //!> map of (unique) formulas in the world FormulaTreeItemMap_t formula; typedef boost::bimap MoleculeItemBiMap_t; MoleculeItemBiMap_t MoleculeItemBiMap; }; #endif /* QTMOLECULELIST_HPP_ */