| 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/QTreeWidget>
|
|---|
| 17 |
|
|---|
| 18 | #include <map>
|
|---|
| 19 | #include <string>
|
|---|
| 20 |
|
|---|
| 21 | #include "CodePatterns/Observer/Observer.hpp"
|
|---|
| 22 |
|
|---|
| 23 | #include "types.hpp"
|
|---|
| 24 |
|
|---|
| 25 | class molecule;
|
|---|
| 26 | class MoleculeListClass;
|
|---|
| 27 |
|
|---|
| 28 | class QtMoleculeList : public QTreeWidget, public Observer
|
|---|
| 29 | {
|
|---|
| 30 | Q_OBJECT
|
|---|
| 31 |
|
|---|
| 32 | public:
|
|---|
| 33 | QtMoleculeList(QWidget * _parent=0);
|
|---|
| 34 | virtual ~QtMoleculeList();
|
|---|
| 35 |
|
|---|
| 36 | protected:
|
|---|
| 37 | virtual void update(Observable *publisher);
|
|---|
| 38 | virtual void recieveNotification(Observable *publisher, Notification_ptr notification);
|
|---|
| 39 | virtual void subjectKilled(Observable *publisher);
|
|---|
| 40 | virtual void paintEvent(QPaintEvent * event);
|
|---|
| 41 | void refill();
|
|---|
| 42 |
|
|---|
| 43 | static const int COLUMNCOUNT;
|
|---|
| 44 | enum {NAME,VISIBILITY,ATOMCOUNT,FORMULA,OCCURRENCE,COLUMNTYPES_MAX} COLUMNTYPES;
|
|---|
| 45 | static const char *COLUMNNAMES[];
|
|---|
| 46 |
|
|---|
| 47 | private slots:
|
|---|
| 48 | void moleculeChanged();
|
|---|
| 49 | void visibilityChanged(QTreeWidgetItem*, int);
|
|---|
| 50 |
|
|---|
| 51 | void rowsSelected(const QItemSelection & selected, const QItemSelection & deselected);
|
|---|
| 52 |
|
|---|
| 53 | signals:
|
|---|
| 54 | void moleculeSelected(molecule*);
|
|---|
| 55 | void moleculeUnSelected(molecule*);
|
|---|
| 56 | void moleculesVisibilityChanged(const moleculeId_t, bool);
|
|---|
| 57 |
|
|---|
| 58 | private:
|
|---|
| 59 | bool dirty;
|
|---|
| 60 | bool clearing;
|
|---|
| 61 | bool selecting;
|
|---|
| 62 | bool changing;
|
|---|
| 63 | bool ChangingChildrensVisibility;
|
|---|
| 64 |
|
|---|
| 65 | void addItem(const molecule *_mol);
|
|---|
| 66 | void addGroupItem(QTreeWidgetItem *&_groupItem, const std::string &_molecule_formula);
|
|---|
| 67 | void addMoleculeItem(QTreeWidgetItem *&_groupItem, const molecule *_mol, const std::string &molecule_formula);
|
|---|
| 68 | void removeItem(const molecule *_mol);
|
|---|
| 69 |
|
|---|
| 70 | typedef std::map<std::string, unsigned int> FormulaVisibilityCountMap_t;
|
|---|
| 71 | FormulaVisibilityCountMap_t FormulaVisibilityCountMap;
|
|---|
| 72 |
|
|---|
| 73 | typedef std::map<std::string, QTreeWidgetItem*> FormulaTreeItemMap_t;
|
|---|
| 74 | //!> map of (unique) formulas in the world
|
|---|
| 75 | FormulaTreeItemMap_t formula;
|
|---|
| 76 | };
|
|---|
| 77 |
|
|---|
| 78 | #endif /* QTMOLECULELIST_HPP_ */
|
|---|