| [b47bfc] | 1 | /*
|
|---|
| [0eb7bf3] | 2 | * QtMoleculeList.hpp
|
|---|
| [b47bfc] | 3 | *
|
|---|
| 4 | * Created on: Jan 21, 2010
|
|---|
| 5 | * Author: crueger
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| [0eb7bf3] | 8 | #ifndef QTMOLECULELIST_HPP_
|
|---|
| 9 | #define QTMOLECULELIST_HPP_
|
|---|
| [b47bfc] | 10 |
|
|---|
| [56f73b] | 11 | // include config.h
|
|---|
| 12 | #ifdef HAVE_CONFIG_H
|
|---|
| 13 | #include <config.h>
|
|---|
| 14 | #endif
|
|---|
| 15 |
|
|---|
| [79b59b] | 16 | #include <QtGui/QTreeWidget>
|
|---|
| [3eb91c] | 17 |
|
|---|
| 18 | #include <map>
|
|---|
| 19 | #include <string>
|
|---|
| 20 |
|
|---|
| [02ce36] | 21 | #include "CodePatterns/Observer/Observer.hpp"
|
|---|
| [b47bfc] | 22 |
|
|---|
| [739ee9] | 23 | #include "types.hpp"
|
|---|
| 24 |
|
|---|
| [b47bfc] | 25 | class molecule;
|
|---|
| 26 | class MoleculeListClass;
|
|---|
| 27 |
|
|---|
| [0eb7bf3] | 28 | class QtMoleculeList : public QTreeWidget, public Observer
|
|---|
| [b47bfc] | 29 | {
|
|---|
| 30 | Q_OBJECT
|
|---|
| 31 |
|
|---|
| 32 | public:
|
|---|
| [0eb7bf3] | 33 | QtMoleculeList(QWidget * _parent=0);
|
|---|
| 34 | virtual ~QtMoleculeList();
|
|---|
| [b47bfc] | 35 |
|
|---|
| 36 | protected:
|
|---|
| 37 | virtual void update(Observable *publisher);
|
|---|
| [3eb91c] | 38 | virtual void recieveNotification(Observable *publisher, Notification_ptr notification);
|
|---|
| [b47bfc] | 39 | virtual void subjectKilled(Observable *publisher);
|
|---|
| [a39006] | 40 | virtual void paintEvent(QPaintEvent * event);
|
|---|
| 41 | void refill();
|
|---|
| [b47bfc] | 42 |
|
|---|
| 43 | static const int COLUMNCOUNT;
|
|---|
| [739ee9] | 44 | enum {NAME,VISIBILITY,ATOMCOUNT,FORMULA,OCCURRENCE,COLUMNTYPES_MAX} COLUMNTYPES;
|
|---|
| [b47bfc] | 45 | static const char *COLUMNNAMES[];
|
|---|
| 46 |
|
|---|
| 47 | private slots:
|
|---|
| [79b59b] | 48 | void moleculeChanged();
|
|---|
| [739ee9] | 49 | void visibilityChanged(QTreeWidgetItem*, int);
|
|---|
| [b47bfc] | 50 |
|
|---|
| [41815a3] | 51 | void rowsSelected(const QItemSelection & selected, const QItemSelection & deselected);
|
|---|
| [b47bfc] | 52 |
|
|---|
| 53 | signals:
|
|---|
| 54 | void moleculeSelected(molecule*);
|
|---|
| 55 | void moleculeUnSelected(molecule*);
|
|---|
| [739ee9] | 56 | void moleculesVisibilityChanged(const moleculeId_t, bool);
|
|---|
| [b47bfc] | 57 |
|
|---|
| 58 | private:
|
|---|
| [a39006] | 59 | bool dirty;
|
|---|
| [99e8ea] | 60 | bool clearing;
|
|---|
| [41815a3] | 61 | bool selecting;
|
|---|
| [6770fa] | 62 | bool changing;
|
|---|
| [3eb91c] | 63 | bool ChangingChildrensVisibility;
|
|---|
| 64 |
|
|---|
| [6770fa] | 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 |
|
|---|
| [3eb91c] | 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;
|
|---|
| [b47bfc] | 76 | };
|
|---|
| 77 |
|
|---|
| [0eb7bf3] | 78 | #endif /* QTMOLECULELIST_HPP_ */
|
|---|