COPASI API  4.16.103
CQBrowserPaneDM.h
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/UI/CQBrowserPaneDM.h,v $
3 // $Revision: 1.3 $
4 // $Name: $
5 // $Author: shoops $
6 // $Date: 2012/05/11 16:53:06 $
7 // End CVS Header
8 
9 // Copyright (C) 2012 - 2011 by Pedro Mendes, Virginia Tech Intellectual
10 // Properties, Inc., University of Heidelberg, and The University
11 // of Manchester.
12 // All rights reserved.
13 
14 #ifndef COPASI_CQBrowserPaneDM
15 #define COPASI_CQBrowserPaneDM
16 
17 #include <QtGui/QSortFilterProxyModel>
18 
19 #include "copasi/UI/listviews.h"
20 
22 
23 class DataModelGUI;
24 class CCopasiDataModel;
25 
26 class CQBrowserPaneDM : public QAbstractItemModel
27 {
28  Q_OBJECT
29 
30 public:
31  class SData
32  {
33  public:
34  size_t mId;
35 
36  std::string mKey;
37 
38  QString mDisplayRole;
39  };
40 
41  class CNode : public CCopasiNode< SData >
42  {
43  private:
44  CNode();
45 
46  public:
47  friend std::ostream & operator<<(std::ostream & os, const CNode & d);
48 
49  CNode(const size_t & id,
50  const std::string & key,
51  const QString & displayRole,
52  CNode * pParent);
53 
54  ~CNode();
55 
56  const size_t & getId() const;
57 
58  void setDisplayRole(const QString & displayRole);
59 
60  const QString & getDisplayRole() const;
61 
62  QString getSortRole() const;
63 
64  void setKey(const std::string & key);
65 
66  const std::string & getKey() const;
67 
68  int getRow() const;
69  };
70 
71 public:
72  enum Type
73  {
74  Model = 0x01,
75  Tasks = 0x02,
76  Output = 0x04,
77  FunctionDB = 0x08,
78  };
79 
80  CQBrowserPaneDM(QObject * parent = 0);
81 
82  virtual ~CQBrowserPaneDM();
83 
84  virtual int columnCount(const QModelIndex & parent = QModelIndex()) const;
85 
86  virtual QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
87 
88  virtual QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const;
89 
90  virtual QModelIndex parent(const QModelIndex & index) const;
91 
92  virtual int rowCount(const QModelIndex & parent = QModelIndex()) const;
93 
94  virtual bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex());
95 
96  QModelIndex index(const size_t & id, const std::string & key) const;
97 
98  // virtual Qt::ItemFlags flags(const QModelIndex &index) const;
99 
100  CNode * findNodeFromId(const size_t & id) const;
101 
102  CNode * findNodeFromKey(const std::string & key) const;
103 
104  size_t getIdFromIndex(const QModelIndex & index) const;
105 
106  std::string getKeyFromIndex(const QModelIndex & index) const;
107 
108  void remove(const std::string & key);
109 
110  void rename(const std::string & key, const QString & displayRole);
111 
112  void add(const size_t & id,
113  const std::string & key,
114  const QString & displayRole,
115  const size_t & parentId = C_INVALID_INDEX);
116 
117  void setCopasiDM(const CCopasiDataModel * pDataModel);
118 
119  void setGuiDM(const DataModelGUI * pDataModel);
120 
121  void load();
122 
123  void load(const size_t & id);
124 
125 private slots:
126  bool slotNotify(ListViews::ObjectType objectType, ListViews::Action action, std::string key = "");
127 
128 private:
129  QModelIndex index(CNode * pNode) const;
130 
131  static CNode * nodeFromIndex(const QModelIndex & index);
132 
133  // bool isNodeFromTree(const void * pNode) const;
134 
135  void createStaticDM();
136 
137  void clear();
138 
140 
142 
144 
146 
147  int mFlags;
148 };
149 
150 #endif // COPASI_CQBrowserPaneDM
virtual QModelIndex parent(const QModelIndex &index) const
CNode * findNodeFromKey(const std::string &key) const
objectType
void setCopasiDM(const CCopasiDataModel *pDataModel)
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const
#define C_INVALID_INDEX
Definition: copasi.h:222
CNode * findNodeFromId(const size_t &id) const
friend std::ostream & operator<<(std::ostream &os, const CNode &d)
const CCopasiDataModel * mpCopasiDM
static CNode * nodeFromIndex(const QModelIndex &index)
void add(const size_t &id, const std::string &key, const QString &displayRole, const size_t &parentId=C_INVALID_INDEX)
virtual bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex())
virtual ~CQBrowserPaneDM()
CQBrowserPaneDM(QObject *parent=0)
void rename(const std::string &key, const QString &displayRole)
const size_t & getId() const
void setKey(const std::string &key)
const DataModelGUI * mpGuiDM
const std::string & getKey() const
size_t getIdFromIndex(const QModelIndex &index) const
const QString & getDisplayRole() const
void setDisplayRole(const QString &displayRole)
void setGuiDM(const DataModelGUI *pDataModel)
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
std::string getKeyFromIndex(const QModelIndex &index) const
QString getSortRole() const
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const
bool slotNotify(ListViews::ObjectType objectType, ListViews::Action action, std::string key="")