COPASI API  4.16.103
ObjectBrowserItem.h
Go to the documentation of this file.
1 // Copyright (C) 2010 - 2013 by Pedro Mendes, Virginia Tech Intellectual
2 // Properties, Inc., University of Heidelberg, and The University
3 // of Manchester.
4 // All rights reserved.
5 
6 // Copyright (C) 2008 - 2009 by Pedro Mendes, Virginia Tech Intellectual
7 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
8 // and The University of Manchester.
9 // All rights reserved.
10 
11 // Copyright (C) 2003 - 2007 by Pedro Mendes, Virginia Tech Intellectual
12 // Properties, Inc. and EML Research, gGmbH.
13 // All rights reserved.
14 
15 /********************************************************
16 Author: Liang Xu
17 Version : 1.xx <first>
18 Description:
19 Date: 04/03
20 Comment : Copasi Object Browser including:
21 
22 CBrowserObject: A complex structure uiniquely map to a CopasiObject
23 ObjectBrowserItem: A wraper to a CBrowserObject,
24 there may exist multiply wrappers to one CBrowserObject
25 ObjectListItem
26 ObjectList: A queue for all element:
27 The reason I dont use std:vector is
28 for efficiency requirement for all
29 object browser item update
30 Contact: Please contact lixu1@vt.edu.
31  *********************************************************/
32 
33 #ifndef OBJECT_BROWSER_ITEM_H
34 #define OBJECT_BROWSER_ITEM_H
35 
36 #include "copasi.h"
37 #include <QtGui/QTreeWidgetItem>
38 
39 class CCopasiObject;
40 
41 /* Macro:
42  define the status of Objects(items) in object browser
43  */
44 #define NOCHECKED -1
45 #define ALLCHECKED 1
46 #define PARTCHECKED 0
47 /* Macro:
48  define the number space for the key
49  KEYBASE: represent the base address for key
50  */
51 #define KEYBASE 0
52 
53 /* Enumerate:
54  define 3 types of objects/items in Object Browser
55  */
57 
58 class ObjectList;
59 
60 /* class CBrowserObject
61  define the structure wrapper for a copasiObject
62  */
64 {
65 public:
67  bool mChecked;
68  ObjectList* referenceList; //keep pointer to all its referenced items for later update
71 };
72 
73 /* class ObjectBrowserItem
74  define the UI wrapper for a CBrowserObject
75  */
76 class ObjectBrowserItem : public QTreeWidgetItem
77 {
78 private:
79  static long KeySpace;
82  QString mKey;
83 
84 public:
85  static void resetKeySpace()
86  {
87  KeySpace = KEYBASE;
88  }
89 
90  static long getKeySpace()
91  {
92  return KeySpace;
93  }
94 
96  {
97  return pBrowserObject;
98  }
99 
100  virtual QString key(int C_UNUSED(column), bool C_UNUSED(ascending)) const
101  {
102  return mKey;
103  }
104 
105  ObjectBrowserItem(QTreeWidget * parent = NULL, ObjectBrowserItem * after = NULL, const CCopasiObject* mObject = NULL, ObjectList* pList = NULL);
106  ObjectBrowserItem(ObjectBrowserItem * parent, ObjectBrowserItem * after = NULL, const CCopasiObject* mObject = NULL, ObjectList* pList = NULL);
108  {
109  // if (getType() != FIELDATTR) //To avoid cross reference/multi deletion
111  }
112 
113  void attachKey();
114 
115  void reverseChecked();
116  bool isChecked() const;
117 
118  void setObjectType(objectType newType)
119  {
120  mType = newType;
121  }
122 
123  void setBrowserObject(CBrowserObject* updateObject)
124  {
125  pBrowserObject = updateObject;
126  }
127 
129  {
130  return mType;
131  }
132 
133  //-1 if this is no user checked
134  //0 if this is only partly checked
135  //1 if this is full checked
136  int nUserChecked();
137  QTreeWidgetItem* nextSibling();
138 };
139 
141 /* class ObjectListItem
142  define the status of Objects(items) in object browser
143  */
145 {
147  {
148  pItem = item;
149  pNext = next;
150  pLast = last;
151  }
155 };
156 
158 {
159 private:
160  bool* quickIndex;
164  int length;
165 
166 public:
167  ObjectList();
169  {
170  if (index_length != 0)
171  {
172  delete[] quickIndex;
173  delete[] pointerList;
174  }
175 
176  while (length > 0)
177  pop();
178  }
179  void insert(ObjectBrowserItem* pItem); //insert at the first position
182 
183  inline int len() {return length;};
184 
185  void sortList();
186  void delDuplicate();
187  bool sortListInsert(ObjectBrowserItem* pItem); //insert and keep the sort order
188 
189  void createBucketIndex(int max);
190  void insertBucket(ObjectBrowserItem* pItem);
191  ObjectBrowserItem* bucketPop(int& cursor);
192  void destroyBucket();
193 };
194 
195 #endif
CBrowserObject * getObject()
#define pdelete(p)
Definition: copasi.h:215
void insert(ObjectBrowserItem *pItem)
objectType
void createBucketIndex(int max)
ObjectListItem(ObjectBrowserItem *item, ObjectListItem *next, ObjectListItem *last)
ObjectBrowserItem * bucketPop(int &cursor)
bool sortListInsert(ObjectBrowserItem *pItem)
QTreeWidgetItem * nextSibling()
void setObjectType(objectType newType)
const CCopasiObject * pCopasiObject
virtual ~ObjectBrowserItem()
ObjectListItem * pNext
ObjectListItem * pLast
ObjectList * referenceList
void insertBucket(ObjectBrowserItem *pItem)
#define C_UNUSED(p)
Definition: copasi.h:220
void setBrowserObject(CBrowserObject *updateObject)
ObjectBrowserItem * pObjectBrowserItem
ObjectBrowserItem ** pointerList
ObjectListItem * root
ObjectBrowserItem * pItem
ObjectBrowserItem(QTreeWidget *parent=NULL, ObjectBrowserItem *after=NULL, const CCopasiObject *mObject=NULL, ObjectList *pList=NULL)
virtual QString key(int C_UNUSED(column), bool C_UNUSED(ascending)) const
static void resetKeySpace()
static long getKeySpace()
#define KEYBASE
CBrowserObject * pBrowserObject
ObjectListItem * getRoot()
ObjectBrowserItem * pop()
#define max(a, b)
Definition: f2c.h:176