/* * 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 #include #include #include #include "UIElements/Views/Qt4/MoleculeList/QtMoleculeItem.hpp" #include "UIElements/Views/Qt4/MoleculeList/QtObservedMoleculeObserver.hpp" #include "UIElements/Qt4/InstanceBoard/QtObservedMolecule.hpp" #include "types.hpp" class QtMoleculeItem; class QtMoleculeListView; class QtObservedInstanceBoard; class QtMoleculeList : public QStandardItemModel { Q_OBJECT public: QtMoleculeList(QtObservedInstanceBoard *_board, QObject *_parent = NULL); virtual ~QtMoleculeList(); void resetUpdateTimer(); QVariant headerData(int section, Qt::Orientation orientation, int role) const; private slots: void formulaChanged(const QtObservedMolecule::ptr _mol); void nameChanged(const QtObservedMolecule::ptr _mol); void atomcountChanged(const QtObservedMolecule::ptr _mol); void moleculeNameChanged(QStandardItem*); void checkForVisibilityChange(QStandardItem*); signals: void moleculesVisibilityChanged(const moleculeId_t, bool); private slots: void moleculeInserted(QtObservedMolecule::ptr _mol); void moleculeRemoved(const moleculeId_t _id); void moleculeIndexChanged(const moleculeId_t _oldid, const moleculeId_t _newid); private: friend class QtMoleculeListView; bool isMoleculeItemPresent(const moleculeId_t _molid) const; QtMoleculeItem * MoleculeIdToItem(const moleculeId_t _molid) const; const moleculeId_t ItemToMoleculeId(const QtMoleculeItem * const _item) const; const QModelIndex MoleculeIdToIndex(const moleculeId_t _id) const; const moleculeId_t IndexToMoleculeId(const QModelIndex &_index) const; QtMoleculeItem * getSpecificMoleculeItem( const QtMoleculeItem * const _item, const enum QtMoleculeItem::COLUMNTYPES _type) const; bool isGroupItemPresent(const std::string &_formula) const; const std::string& GroupItemToFormula(const QStandardItem * const _item) const; QStandardItem * FormulaToGroupItem(const std::string &_formula) const; QStandardItem * getSpecificGroupItem( const QStandardItem * const _item, const enum QtMoleculeItem::COLUMNTYPES _type) const; std::string addMolecule( QtObservedMolecule::ptr &_ObservedMolecule); void addGroupItem( QStandardItem *&mainitem, const std::string &_molecule_formula); QList createMoleculeItems( QtObservedMolecule::ptr &_ObservedMolecule, std::string &molecule_formula); void removeMoleculeItem(QtMoleculeItem * const _item); int setOccurrence(QStandardItem * const _groupitem); void setVisibilityForMoleculeItem(QtMoleculeItem* _item); void setVisibilityForGroupItem(QStandardItem* _item); void moveItem(QtMoleculeItem *_molitem, const std::string &_new_formula); // void updateItemStates(); //!> reference to InstanceBoard QtObservedInstanceBoard *board; typedef std::map FormulaVisibilityCountMap_t; FormulaVisibilityCountMap_t FormulaVisibilityCountMap; typedef boost::bimap FormulaTreeItemBiMap_t; //!> map of (unique) formulas in the world FormulaTreeItemBiMap_t FormulaItemBiMap; typedef std::map MoleculeFormulaMap_t; //!> map of (unique) formulas in the world MoleculeFormulaMap_t MoleculeFormulaMap; typedef boost::bimap MoleculeItemBiMap_t; MoleculeItemBiMap_t MoleculeItemBiMap; typedef std::set< moleculeId_t > list_of_molecules_t; typedef std::set< std::pair > list_of_molecule_items_t; typedef std::set< std::pair > list_of_group_items_t; //!> listens to all QtObservedMolecule and relays important events to us QtObservedMoleculeObserver observer; }; #endif /* QTMOLECULELIST_HPP_ */