COPASI API  4.16.103
Public Slots | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
ObjectBrowserWidget Class Reference

#include <ObjectBrowserWidget.h>

Inheritance diagram for ObjectBrowserWidget:
Inheritance graph
[legend]
Collaboration diagram for ObjectBrowserWidget:
Collaboration graph
[legend]

Public Slots

virtual void clearClicked ()
 
virtual void commitClicked ()
 
virtual void listviewChecked (QTreeWidgetItem *, int)
 
virtual void toggleViewClicked ()
 

Public Member Functions

void clickToReverseCheck (ObjectBrowserItem *pCurrent)
 
void eXport (ObjectBrowserItem *pCurrent, std::vector< const CCopasiObject * > *outputVector)
 
CCopasiObjectgetFieldCopasiObject (CCopasiContainer *pCurrent, const char *name)
 
void loadChild (ObjectBrowserItem *parent, const CCopasiContainer *copaParent, bool nField)
 
void loadData ()
 
void loadField (ObjectBrowserItem *parent, CCopasiVector< CCopasiObject > *copaParent)
 
void loadUI ()
 
 ObjectBrowserWidget (QWidget *parent=0, const char *name=0, Qt::WFlags fl=0, int state=0)
 
int partition (int, int, int, ObjectBrowserItem **)
 
void quick_sort (int, int, ObjectBrowserItem **)
 
void removeDuplicate (ObjectList *objectItemList)
 
void selectObjects (std::vector< const CCopasiObject * > *pObjectVector)
 
void setCheck (ObjectBrowserItem *pCurrent)
 
void setCheckMark (ObjectBrowserItem *pCurrent)
 
void setOutputVector (std::vector< const CCopasiObject * > *pObjectVector)
 
void setUncheck (ObjectBrowserItem *pCurrent)
 
void swap (int, int, ObjectBrowserItem **)
 
void updateUI ()
 
virtual ~ObjectBrowserWidget ()
 

Public Attributes

QPushButton * clearButton
 
QPushButton * commitButton
 
QFrame * Line1
 
QGridLayout * ObjectBrowserLayout
 
ObjectListobjectItemList
 
QTextEdit * ObjectItemText
 
QTreeWidget * ObjectListView
 
ObjectListrefreshList
 
QSpacerItem * spacer
 
QPushButton * toggleViewButton
 

Private Member Functions

void cleanup ()
 
void selectObjects (ObjectBrowserItem *browserItem, const CCopasiObject *selectObject)
 
void updateSelectedItemsView ()
 

Private Attributes

pageIndex currentPage
 
std::vector< const
CCopasiObject * > * 
mOutputObjectVector
 

Detailed Description

Definition at line 50 of file ObjectBrowserWidget.h.

Constructor & Destructor Documentation

ObjectBrowserWidget::ObjectBrowserWidget ( QWidget *  parent = 0,
const char *  name = 0,
Qt::WFlags  fl = 0,
int  state = 0 
)

Definition at line 59 of file ObjectBrowserWidget.cpp.

References clearButton, clearClicked(), commitButton, commitClicked(), currentPage, Line1, listviewChecked(), LISTVIEWPAGE, loadData(), ObjectBrowserLayout, objectItemList, ObjectItemText, ObjectListView, pObjectAll, pObjectNone, pObjectParts, refreshList, ObjectBrowserItem::resetKeySpace(), spacer, toggleViewButton, and toggleViewClicked().

60  : QWidget(parent, fl),
61  objectItemList(NULL),
62  refreshList(NULL),
63  ObjectBrowserLayout(NULL),
64  clearButton(NULL),
65  toggleViewButton(NULL),
66  commitButton(NULL),
67  ObjectListView(NULL),
68  Line1(NULL),
69  spacer(NULL),
70  ObjectItemText(NULL),
71  mOutputObjectVector(NULL),
73 {
74  setObjectName(QString::fromUtf8(name));
75 
76  if (!name)
77  setObjectName("ObjectBrowser");
78 
79  if (state == 0)
80  ObjectBrowserLayout = new QGridLayout(this);
81  else
82  {
83  ObjectBrowserLayout = new QGridLayout(this);
84  ObjectBrowserLayout->setSpacing(6);
85  }
86 
87  ObjectBrowserLayout->setObjectName(QString::fromUtf8("ObjectListView"));
88 
89  ObjectListView = new QTreeWidget(this);
90  ObjectListView->setObjectName("");
91  // ObjectListView->addColumn(trUtf8("Object Browser"));
92  QStringList strList;
93  strList << trUtf8("Name") << trUtf8("Type");
94  ObjectListView->setHeaderLabels(strList);
95  //ObjectListView->header()->setClickEnabled(false, ObjectListView->header()->count() - 1);
96  ObjectListView->setAcceptDrops(false);
97  ObjectListView->setSortingEnabled(true);
98  ObjectListView->sortByColumn(0, Qt::AscendingOrder);
99  ObjectListView->header()->setResizeMode(QHeaderView::ResizeToContents);
100  ObjectListView->setSelectionMode(QAbstractItemView::NoSelection);
101 
102  ObjectItemText = new QTextEdit(this);
103  ObjectItemText->setObjectName("ObjectItemText");
104  ObjectItemText ->hide();
105 
106  ObjectBrowserLayout->addWidget(ObjectListView, 0, 0, 0, 3);
107  ObjectBrowserLayout->addWidget(ObjectItemText, 0, 0, 0, 3);
108 
109  if (state != 0)
110  {
111  Line1 = new QFrame(this);
112  Line1->setObjectName("Line1");
113  Line1->setFrameShape(QFrame::HLine);
114  Line1->setFrameShadow(QFrame::Sunken);
115  Line1->setFrameShape(QFrame::HLine);
116 
117  ObjectBrowserLayout->addWidget(Line1, 1, 1, 0, 3);
118 
119  clearButton = new QPushButton(this);
120  clearButton->setObjectName("clearButton");
121  clearButton->setText(trUtf8("Clear"));
122  ObjectBrowserLayout->addWidget(clearButton, 2, 0);
123 
124  commitButton = new QPushButton(this);
125  commitButton->setObjectName("commitButton");
126  commitButton->setText(trUtf8("Commit"));
127  ObjectBrowserLayout->addWidget(commitButton, 2, 3);
128 
129  toggleViewButton = new QPushButton(this);
130  toggleViewButton->setObjectName("toggleViewButton");
131  toggleViewButton->setText(trUtf8("Selected Items"));
132  ObjectBrowserLayout->addWidget(toggleViewButton, 2, 2);
133 
134  spacer = new QSpacerItem(131, 31, QSizePolicy::Expanding, QSizePolicy::Minimum);
135  ObjectBrowserLayout->addItem(spacer, 2, 1);
136 
137  // signals and slots connections
138  connect(clearButton, SIGNAL(clicked()), this, SLOT(clearClicked()));
139  connect(toggleViewButton, SIGNAL(clicked()), this, SLOT(toggleViewClicked()));
140  connect(commitButton, SIGNAL(clicked()), this, SLOT(commitClicked()));
141 
142  // tab order
143  setTabOrder(ObjectListView, clearButton);
144  setTabOrder(clearButton, toggleViewButton);
145  setTabOrder(toggleViewButton, commitButton);
146  }
147 
148  connect(ObjectListView, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, SLOT(listviewChecked(QTreeWidgetItem*, int)));
149 
150  pObjectAll = new QPixmap((const char**)ptrObjectAll);
151  pObjectNone = new QPixmap((const char**)ptrObjectNone);
152  pObjectParts = new QPixmap((const char**)ptrObjectParts);
153 
154  objectItemList = new ObjectList();
155  refreshList = new ObjectList();
157  loadData();
159 }
QGridLayout * ObjectBrowserLayout
QPixmap * pObjectAll
virtual void listviewChecked(QTreeWidgetItem *, int)
QPixmap * pObjectParts
QPixmap * pObjectNone
QTreeWidget * ObjectListView
virtual void toggleViewClicked()
bool fl(const C_FLOAT64 &d1, const C_FLOAT64 &d2)
static void resetKeySpace()
std::vector< const CCopasiObject * > * mOutputObjectVector
QPushButton * commitButton
QPushButton * toggleViewButton
ObjectBrowserWidget::~ObjectBrowserWidget ( )
virtual

Definition at line 161 of file ObjectBrowserWidget.cpp.

References cleanup().

162 {
163  cleanup();
164 }

Member Function Documentation

void ObjectBrowserWidget::cleanup ( )
private

Definition at line 166 of file ObjectBrowserWidget.cpp.

References objectItemList, and refreshList.

Referenced by ~ObjectBrowserWidget().

167 {
168  delete objectItemList;
169  delete refreshList;
170 }
void ObjectBrowserWidget::clearClicked ( )
virtualslot

Definition at line 172 of file ObjectBrowserWidget.cpp.

References ObjectList::getRoot(), ObjectListItem::pItem, refreshList, setUncheck(), and updateUI().

Referenced by ObjectBrowserWidget(), and setOutputVector().

173 {
174  if (!refreshList->getRoot()) return;
175 
176  ObjectBrowserItem* root = static_cast< ObjectBrowserItem * >(refreshList->getRoot()->pItem);
177  setUncheck(root);
178  updateUI();
179  // qWarning("ObjectBrowser::clearClicked(): Not implemented yet!");
180 }
void setUncheck(ObjectBrowserItem *pCurrent)
ObjectBrowserItem * pItem
ObjectListItem * getRoot()
void ObjectBrowserWidget::clickToReverseCheck ( ObjectBrowserItem pCurrent)

Definition at line 193 of file ObjectBrowserWidget.cpp.

References ALLCHECKED, ObjectList::insert(), ObjectBrowserItem::isChecked(), refreshList, ObjectBrowserItem::reverseChecked(), setCheck(), and setUncheck().

Referenced by listviewChecked().

194 {
195  refreshList->insert(pCurrent);
196 
197  ObjectBrowserItem* pTmp = pCurrent;
198 
199  while (pTmp->parent() != NULL)
200  {
201  pTmp = static_cast< ObjectBrowserItem * >(pTmp->parent());
202  refreshList->insert(pTmp);
203  }
204 
205  if (pCurrent->isChecked() == ALLCHECKED)
206  {
207  if (pCurrent->isChecked())
208  pCurrent->reverseChecked();
209 
210  setUncheck(static_cast< ObjectBrowserItem * >(pCurrent->child(0)));
211  return;
212  }
213 
214  //else no check or partly checked
215  if (!pCurrent->isChecked())
216  pCurrent->reverseChecked();
217 
218  setCheck(static_cast< ObjectBrowserItem * >(pCurrent->child(0)));
219  return;
220 }
void insert(ObjectBrowserItem *pItem)
void setUncheck(ObjectBrowserItem *pCurrent)
void setCheck(ObjectBrowserItem *pCurrent)
#define ALLCHECKED
void ObjectBrowserWidget::commitClicked ( )
virtualslot

Definition at line 332 of file ObjectBrowserWidget.cpp.

References eXport(), ObjectList::getRoot(), mOutputObjectVector, objectItemList, and ObjectListItem::pItem.

Referenced by CCopasiSelectionWidget::commit(), ObjectBrowserWidget(), ObjectBrowserDialog::okClicked(), CCopasiSelectionWidget::setExpertMode(), and CPlotSelectionDialog::slotOKButtonClicked().

333 {
334  ObjectBrowserItem* rootItem;
335  rootItem = objectItemList->getRoot()->pItem;
336 
338 
339  eXport(rootItem, mOutputObjectVector);
340  return;
341 }
void eXport(ObjectBrowserItem *pCurrent, std::vector< const CCopasiObject * > *outputVector)
ObjectBrowserItem * pItem
std::vector< const CCopasiObject * > * mOutputObjectVector
ObjectListItem * getRoot()
void ObjectBrowserWidget::eXport ( ObjectBrowserItem pCurrent,
std::vector< const CCopasiObject * > *  outputVector 
)

Definition at line 343 of file ObjectBrowserWidget.cpp.

References C_INT32, FIELDATTR, CCopasiObject::getCN(), ObjectBrowserItem::getObject(), ObjectBrowserItem::getType(), ObjectBrowserItem::isChecked(), ObjectBrowserItem::nextSibling(), and CBrowserObject::pCopasiObject.

Referenced by commitClicked(), and updateSelectedItemsView().

344 {
345  if (!outputVector) return;
346 
347  if (pCurrent->child(0))
348  {
349  ObjectBrowserItem* pChild = static_cast< ObjectBrowserItem * >(pCurrent->child(0));
350 
351  for (; pChild != NULL; pChild = static_cast< ObjectBrowserItem * >(pChild->nextSibling()))
352  if (pChild->getType() != FIELDATTR)
353  eXport(pChild, outputVector);
354  }
355  else //it has no child
356  {
357  if (pCurrent->isChecked() && (pCurrent->getType() != FIELDATTR))
358  {
359  if (pCurrent->getObject())
360  {
361  bool insertFlag = true;
362  unsigned C_INT32 i = 0;
363 
364  for (; i < outputVector->size(); i++)
365  if (pCurrent->getObject()->pCopasiObject->getCN() == (*outputVector)[i]->getCN()) insertFlag = false;
366 
367  if (insertFlag)
368  outputVector->push_back(pCurrent->getObject()->pCopasiObject);
369  }
370  }
371 
372  // else skip current item
373  }
374 }
CBrowserObject * getObject()
QTreeWidgetItem * nextSibling()
virtual CCopasiObjectName getCN() const
const CCopasiObject * pCopasiObject
void eXport(ObjectBrowserItem *pCurrent, std::vector< const CCopasiObject * > *outputVector)
#define C_INT32
Definition: copasi.h:90
CCopasiObject * ObjectBrowserWidget::getFieldCopasiObject ( CCopasiContainer pCurrent,
const char *  name 
)

Definition at line 708 of file ObjectBrowserWidget.cpp.

References FROM_UTF8, and CCopasiContainer::getObjects().

Referenced by loadField().

709 {
710  const CCopasiContainer::objectMap * pObjectList = & pCurrent->getObjects();
711  CCopasiContainer::objectMap::const_iterator it = pObjectList->begin();
712  CCopasiContainer::objectMap::const_iterator end = pObjectList->end();
713 
714  // CCopasiObject* pResult;
715  while (it != end)
716  {
717  // if (it->second->isContainer())
718  // {
719  // pResult = getFieldCopasiObject((CCopasiContainer *)it->second, name);
720  // if (pResult)
721  // return pResult;
722  //}
723  if (FROM_UTF8(it->second->getObjectName()) == name)
724  return it->second;
725 
726  it++;
727  }
728 
729  return NULL;
730 }
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
virtual const objectMap & getObjects() const
std::multimap< std::string, CCopasiObject * > objectMap
void ObjectBrowserWidget::listviewChecked ( QTreeWidgetItem *  ,
int    
)
virtualslot

Definition at line 182 of file ObjectBrowserWidget.cpp.

References clickToReverseCheck(), and updateUI().

Referenced by ObjectBrowserWidget().

183 {
184  // if ((pCurrent == NULL)||((static_cast< ObjectBrowserItem * >(pCurrent))->getType() == FIELDATTR))
185  if ((pCurrent == NULL) || (pCurrent->text(0) == "Select by attribute"))
186  return;
187 
188  clickToReverseCheck(static_cast< ObjectBrowserItem * >(pCurrent));
189  updateUI();
190  //loadUI();
191 }
void clickToReverseCheck(ObjectBrowserItem *pCurrent)
void ObjectBrowserWidget::loadChild ( ObjectBrowserItem parent,
const CCopasiContainer copaParent,
bool  nField 
)

Definition at line 480 of file ObjectBrowserWidget.cpp.

References ObjectBrowserItem::attachKey(), CONTAINERATTR, FIELDATTR, FROM_UTF8, CCopasiObject::getObjectName(), CCopasiContainer::getObjects(), ObjectList::insert(), CCopasiObject::isContainer(), CCopasiObject::isVector(), ObjectList::len(), loadField(), OBJECTATTR, objectItemList, pdelete, ObjectList::pop(), ObjectBrowserItem::setObjectType(), and CCopasiVector< T >::size().

Referenced by loadData(), and loadField().

483 {
484  unsigned int i;
485  ObjectBrowserItem* last = NULL;
486  CCopasiObject* current = NULL;
487 
488  ObjectList* childStack = new ObjectList();
489 
490  const CCopasiContainer::objectMap * pObjectList = & copaParent->getObjects();
491  CCopasiContainer::objectMap::const_iterator it = pObjectList->begin();
492  CCopasiContainer::objectMap::const_iterator end = pObjectList->end();
493 
494  if ((copaParent->isVector()) && (nField))
495  {
496  if ((static_cast< const CCopasiVector < CCopasiObject > * >(copaParent)->size() >= 1) &&
497  ((*static_cast< const CCopasiVector < CCopasiObject > * >(copaParent))[0]->isContainer()))
498  {
499  //add attribute list
500  ObjectBrowserItem* fieldChild = new ObjectBrowserItem(parent, NULL, NULL, objectItemList);
501  fieldChild->setObjectType(FIELDATTR);
502  fieldChild->setText(0, "Select by attribute");
503  //fieldChild->setSelectable(false);
504  loadField(fieldChild, const_cast<CCopasiVector < CCopasiObject > *>(static_cast< const CCopasiVector < CCopasiObject > * >(copaParent)));
505  fieldChild->attachKey();
506  last = fieldChild;
507  }
508  }
509 
510  if (copaParent->isVector())
511  {
512  for (i = 0; i < static_cast< const CCopasiVector < CCopasiObject > * >(copaParent)->size(); i++)
513  {
514  current = (*static_cast< const CCopasiVector < CCopasiObject > * >(copaParent))[i];
515  ObjectBrowserItem* currentItem = new ObjectBrowserItem(parent, last, current, objectItemList);
516  last = currentItem;
517  currentItem->setText(0, FROM_UTF8(current->getObjectName()));
518 
519  if (current->isContainer())
520  {
521  currentItem->setObjectType(CONTAINERATTR);
522  currentItem->attachKey();
523 
524  if (current->isVector())
525  currentItem->setText(0, currentItem->text(0) + "[]");
526 
527  loadChild(currentItem, static_cast< CCopasiContainer * >(current), nField);
528  }
529  else
530  {
531  currentItem->setObjectType(OBJECTATTR);
532  childStack->insert(currentItem); //attach the key later
533  }
534  }
535  }
536  else
537  {
538  while (it != end)
539  {
540  current = it->second;
541 
542  // Skip all strings
543  if (dynamic_cast<CCopasiStaticString *>(current))
544  {
545  it++;
546  continue;
547  }
548 
549  ObjectBrowserItem* currentItem = new ObjectBrowserItem(parent, last, current, objectItemList);
550  last = currentItem;
551  currentItem->setText(0, FROM_UTF8(current->getObjectName()));
552 
553  if (current->isContainer())
554  {
555  currentItem->setObjectType(CONTAINERATTR);
556  currentItem->attachKey();
557 
558  if (current->isVector())
559  currentItem->setText(0, currentItem->text(0) + "[]");
560 
561  loadChild(currentItem, static_cast< CCopasiContainer * >(current), nField);
562  }
563  else
564  {
565  currentItem->setObjectType(OBJECTATTR);
566  childStack->insert(currentItem); //attach the key later
567  }
568 
569  it++;
570  }
571  }
572 
573  ObjectBrowserItem* pCurrent;
574 
575  while (childStack->len() > 0)
576  {
577  pCurrent = childStack->pop();
578  pCurrent->attachKey();
579  }
580 
581  pdelete(childStack);
582 }
bool isContainer() const
#define pdelete(p)
Definition: copasi.h:215
void insert(ObjectBrowserItem *pItem)
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
const std::string & getObjectName() const
virtual size_t size() const
void setObjectType(objectType newType)
virtual const objectMap & getObjects() const
std::multimap< std::string, CCopasiObject * > objectMap
void loadField(ObjectBrowserItem *parent, CCopasiVector< CCopasiObject > *copaParent)
void loadChild(ObjectBrowserItem *parent, const CCopasiContainer *copaParent, bool nField)
bool isVector() const
ObjectBrowserItem * pop()
void ObjectBrowserWidget::loadData ( )

Definition at line 428 of file ObjectBrowserWidget.cpp.

References ObjectBrowserItem::attachKey(), CONTAINERATTR, CCopasiRootContainer::getRoot(), loadChild(), loadUI(), objectItemList, ObjectListView, removeDuplicate(), and ObjectBrowserItem::setObjectType().

Referenced by ObjectBrowserWidget().

429 {
431  ObjectBrowserItem * itemRoot = new ObjectBrowserItem(ObjectListView, NULL, root, objectItemList);
432  itemRoot->attachKey();
433  itemRoot->setObjectType(CONTAINERATTR);
434  // itemRoot->setText(0, FROM_UTF8(root->getObjectName()));
435  itemRoot->setText(0, QString("COPASI"));
436  itemRoot->setExpanded(true);
437  loadChild(itemRoot, root, true);
439  loadUI();
440 }
void removeDuplicate(ObjectList *objectItemList)
void setObjectType(objectType newType)
void loadChild(ObjectBrowserItem *parent, const CCopasiContainer *copaParent, bool nField)
QTreeWidget * ObjectListView
static const CCopasiContainer * getRoot()
void ObjectBrowserWidget::loadField ( ObjectBrowserItem parent,
CCopasiVector< CCopasiObject > *  copaParent 
)

Definition at line 584 of file ObjectBrowserWidget.cpp.

References ObjectBrowserItem::attachKey(), FIELDATTR, FROM_UTF8, getFieldCopasiObject(), CCopasiObject::getObjectName(), CCopasiObject::isContainer(), loadChild(), objectItemList, ObjectBrowserItem::setObjectType(), and CCopasiVector< T >::size().

Referenced by loadChild().

585 {
586  unsigned int i;
587  ObjectBrowserItem* lastFieldItem = NULL;
588  CCopasiObject* currentFieldObject = NULL;
589  ObjectBrowserItem* lastObjectItem = NULL;
590  CCopasiObject* currentObject = NULL;
591 
592  if ((copaParent->size() < 1) || (!(*copaParent)[0]->isContainer())) return; //empty list
593 
594  const CCopasiContainer::objectMap * pFieldList =
595  &(static_cast< CCopasiContainer * >((*copaParent)[0])->getObjects());
596 
597  CCopasiContainer::objectMap::const_iterator fieldIt = pFieldList->begin();
598  CCopasiContainer::objectMap::const_iterator fieldEnd = pFieldList->end();
599 
600  while (fieldIt != fieldEnd)
601  {
602  currentFieldObject = fieldIt->second;
603  ObjectBrowserItem* currentFieldItem = new ObjectBrowserItem(parent, lastFieldItem, NULL, objectItemList);
604  currentFieldItem->attachKey();
605  currentFieldItem->setObjectType(FIELDATTR);
606  currentFieldItem->setText(0, FROM_UTF8(currentFieldObject->getObjectName()));
607  lastFieldItem = currentFieldItem;
608  lastObjectItem = NULL;
609 
610  for (i = 0; i < copaParent->size(); i++)
611  {
612  CCopasiObject* pSubField;
613  currentObject = (*static_cast< CCopasiVector < CCopasiObject > * >(copaParent))[i];
614 
615  if (currentObject->isContainer())
616  pSubField =
617  getFieldCopasiObject(static_cast< CCopasiContainer * >(currentObject),
618  currentFieldObject->getObjectName().c_str());
619  else
620  {
621  pSubField = NULL; // this shall be an exception error
622  }
623 
624  ObjectBrowserItem* currentItem = new ObjectBrowserItem(currentFieldItem, lastObjectItem, pSubField, objectItemList);
625  currentItem->setText(0, FROM_UTF8(currentObject->getObjectName()));
626  // if ((pSubField)&&(pSubField->isVector()))
627  // currentItem->setText(0, currentItem->text(0) + "[]");
628  currentItem->setObjectType(FIELDATTR);
629  currentItem->attachKey();
630 
631  if (pSubField)
632  if (pSubField->isContainer()) //container field recursively to find all possible items
633  {
634  loadChild(currentItem, static_cast< CCopasiContainer * >(pSubField), false); // wont show the attribute and field list
635  }
636 
637  lastObjectItem = currentItem;
638  }
639 
640  fieldIt++;
641  }
642 }
bool isContainer() const
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
const std::string & getObjectName() const
virtual size_t size() const
void setObjectType(objectType newType)
std::multimap< std::string, CCopasiObject * > objectMap
void loadChild(ObjectBrowserItem *parent, const CCopasiContainer *copaParent, bool nField)
CCopasiObject * getFieldCopasiObject(CCopasiContainer *pCurrent, const char *name)
void ObjectBrowserWidget::loadUI ( )

Definition at line 699 of file ObjectBrowserWidget.cpp.

References ObjectList::getRoot(), objectItemList, ObjectListItem::pItem, ObjectListItem::pNext, and setCheckMark().

Referenced by loadData().

700 {
701  ObjectListItem* pCurrent = objectItemList->getRoot();
702  setCheckMark(pCurrent->pItem);
703 
704  for (; pCurrent != NULL; pCurrent = pCurrent->pNext)
705  setCheckMark(pCurrent->pItem);
706 }
ObjectListItem * pNext
void setCheckMark(ObjectBrowserItem *pCurrent)
ObjectBrowserItem * pItem
ObjectListItem * getRoot()
int ObjectBrowserWidget::partition ( int  split_pos,
int  start_pos,
int  end_pos,
ObjectBrowserItem **  quick_sort_array 
)

Definition at line 383 of file ObjectBrowserWidget.cpp.

References ObjectBrowserItem::getObject(), CBrowserObject::pCopasiObject, and swap().

Referenced by quick_sort().

384 {
385  const void * tmp = quick_sort_array[split_pos]->getObject()->pCopasiObject;
386 
387  if (split_pos != start_pos)
388  swap(split_pos, start_pos, quick_sort_array);
389 
390  split_pos = start_pos;
391  end_pos++;
392 
393  while (start_pos < end_pos)
394  {
395  while ((++start_pos < end_pos) && (quick_sort_array[start_pos]->getObject()->pCopasiObject <= tmp));
396 
397  while ((--end_pos > start_pos) && (quick_sort_array[end_pos]->getObject()->pCopasiObject > tmp));
398 
399  if (start_pos < end_pos)
400  swap(start_pos, end_pos, quick_sort_array);
401  else
402  break;
403  }
404 
405  start_pos--;
406 
407  if (split_pos != start_pos)
408  swap(split_pos, start_pos, quick_sort_array);
409 
410  return start_pos;
411 }
CBrowserObject * getObject()
const CCopasiObject * pCopasiObject
void swap(int, int, ObjectBrowserItem **)
void ObjectBrowserWidget::quick_sort ( int  m,
int  n,
ObjectBrowserItem **  quick_sort_array 
)

Definition at line 413 of file ObjectBrowserWidget.cpp.

References partition().

Referenced by removeDuplicate().

414 {
415  if (m < n)
416  {
417  int medium = (m + n) / 2;
418  medium = partition(medium, m, n, quick_sort_array);
419 
420  if (m < medium - 1)
421  quick_sort(m, medium - 1, quick_sort_array);
422 
423  if (medium + 1 < n)
424  quick_sort(medium + 1, n, quick_sort_array);
425  }
426 }
void quick_sort(int, int, ObjectBrowserItem **)
int partition(int, int, int, ObjectBrowserItem **)
void ObjectBrowserWidget::removeDuplicate ( ObjectList objectItemList)

Definition at line 442 of file ObjectBrowserWidget.cpp.

References ObjectBrowserItem::getObject(), ObjectList::getRoot(), ObjectList::insert(), ObjectList::len(), CBrowserObject::pCopasiObject, ObjectListItem::pItem, ObjectListItem::pNext, ObjectList::pop(), quick_sort(), CBrowserObject::referenceList, and ObjectBrowserItem::setBrowserObject().

Referenced by loadData().

443 {
444  int length = objectItemList->len();
445  ObjectBrowserItem** bufferVector = new ObjectBrowserItem * [length];
446 
447  // copy out the list
448  ObjectListItem* pCurrent = objectItemList->getRoot();
449 
450  for (int i = 0; i < length; i++)
451  {
452  bufferVector[i] = pCurrent->pItem;
453  pCurrent = pCurrent->pNext;
454  }
455 
456  // sort list according to CCopasiObject
457  quick_sort(0, length - 1, bufferVector);
458 
459  int index;
460  CBrowserObject* pBrowserObject = NULL;
461  ObjectBrowserItem* pBrowserItem = NULL;
462 
463  for (index = 0; (index < length) && (!bufferVector[index]->getObject()->pCopasiObject); index++);
464 
465  pBrowserObject = bufferVector[index++]->getObject();
466 
467  for (; index < length; index++)
468  {
469  if (bufferVector[index]->getObject()->pCopasiObject == pBrowserObject->pCopasiObject) //duplicate point
470  {
471  pBrowserItem = bufferVector[index]->getObject()->referenceList->pop();
472  pBrowserObject->referenceList->insert(pBrowserItem);
473  pBrowserItem->setBrowserObject(pBrowserObject);
474  }
475  else
476  pBrowserObject = bufferVector[index]->getObject();
477  }
478 }
CBrowserObject * getObject()
void insert(ObjectBrowserItem *pItem)
const CCopasiObject * pCopasiObject
ObjectListItem * pNext
ObjectList * referenceList
void setBrowserObject(CBrowserObject *updateObject)
ObjectBrowserItem * pItem
void quick_sort(int, int, ObjectBrowserItem **)
ObjectListItem * getRoot()
ObjectBrowserItem * pop()
void ObjectBrowserWidget::selectObjects ( std::vector< const CCopasiObject * > *  pObjectVector)

Definition at line 732 of file ObjectBrowserWidget.cpp.

References ObjectList::getRoot(), objectItemList, ObjectListItem::pItem, and updateUI().

Referenced by ObjectBrowserDialog::selectObjects(), selectObjects(), and setOutputVector().

733 {
734  unsigned int i;
735  ObjectBrowserItem* rootItem;
736 
737  rootItem = objectItemList->getRoot()->pItem;
738 
739  for (i = 0; i < pObjectVector->size(); i++)
740  {
741  if ((*pObjectVector)[i]) selectObjects(rootItem, (*pObjectVector)[i]);
742  }
743 
744  updateUI();
745 }
ObjectBrowserItem * pItem
void selectObjects(std::vector< const CCopasiObject * > *pObjectVector)
ObjectListItem * getRoot()
void ObjectBrowserWidget::selectObjects ( ObjectBrowserItem browserItem,
const CCopasiObject selectObject 
)
private

Definition at line 747 of file ObjectBrowserWidget.cpp.

References ALLCHECKED, FIELDATTR, ObjectBrowserItem::getObject(), ObjectBrowserItem::getType(), ObjectList::insert(), CBrowserObject::mChecked, ObjectBrowserItem::nextSibling(), CBrowserObject::pCopasiObject, refreshList, selectObjects(), and setCheck().

749 {
750  ObjectBrowserItem* pCurrent;
751  pCurrent = browserItem;
752 
753  if (pCurrent->child(0))
754  {
755  ObjectBrowserItem* pChild = static_cast< ObjectBrowserItem * >(pCurrent->child(0));
756 
757  for (; pChild != NULL; pChild = static_cast< ObjectBrowserItem * >(pChild->nextSibling()))
758  if (pChild->getType() != FIELDATTR)
759  selectObjects(pChild, selectObject);
760  }
761  else
762  {
763  //it has no child
764  if (pCurrent->getType() != FIELDATTR)
765  {
766  if (pCurrent->getObject() && (pCurrent->getObject()->pCopasiObject == selectObject))
767  {
768  refreshList->insert(pCurrent);
769 
770  ObjectBrowserItem* pTmp = pCurrent;
771 
772  while (pTmp->parent() != NULL)
773  {
774  pTmp = static_cast< ObjectBrowserItem * >(pTmp->parent());
775  refreshList->insert(pTmp);
776  }
777 
778  pCurrent->getObject()->mChecked = ALLCHECKED;
779  setCheck(static_cast< ObjectBrowserItem * >(pCurrent->child(0)));
780  }
781 
782  // else skip current item
783  }
784  }
785 }
CBrowserObject * getObject()
void insert(ObjectBrowserItem *pItem)
QTreeWidgetItem * nextSibling()
const CCopasiObject * pCopasiObject
void setCheck(ObjectBrowserItem *pCurrent)
#define ALLCHECKED
void selectObjects(std::vector< const CCopasiObject * > *pObjectVector)
void ObjectBrowserWidget::setCheck ( ObjectBrowserItem pCurrent)

Definition at line 239 of file ObjectBrowserWidget.cpp.

References ObjectList::insert(), ObjectBrowserItem::isChecked(), ObjectBrowserItem::nextSibling(), refreshList, and ObjectBrowserItem::reverseChecked().

Referenced by clickToReverseCheck(), and selectObjects().

240 {
241  if (pCurrent == NULL)
242  return;
243 
244  refreshList->insert(pCurrent);
245 
246  if (!pCurrent->isChecked())
247  pCurrent->reverseChecked();
248 
249  if (pCurrent->child(0) != NULL)
250  setCheck(static_cast< ObjectBrowserItem * >(pCurrent->child(0)));
251 
252  if (pCurrent->nextSibling() != NULL)
253  setCheck(static_cast< ObjectBrowserItem * >(pCurrent->nextSibling()));
254 }
void insert(ObjectBrowserItem *pItem)
QTreeWidgetItem * nextSibling()
void setCheck(ObjectBrowserItem *pCurrent)
void ObjectBrowserWidget::setCheckMark ( ObjectBrowserItem pCurrent)

Definition at line 677 of file ObjectBrowserWidget.cpp.

References ALLCHECKED, NOCHECKED, ObjectBrowserItem::nUserChecked(), PARTCHECKED, pObjectAll, pObjectNone, and pObjectParts.

Referenced by loadUI(), and updateUI().

678 {
679  if (pCurrent->text(0) == "Select by attribute")
680  {
681  pCurrent->setIcon(0, QIcon());
682  return;
683  }
684 
685  switch (pCurrent->nUserChecked())
686  {
687  case NOCHECKED:
688  pCurrent->setIcon(0, QIcon(*pObjectNone));
689  break;
690  case ALLCHECKED:
691  pCurrent->setIcon(0, QIcon(*pObjectAll));
692  break;
693  case PARTCHECKED:
694  pCurrent->setIcon(0, QIcon(*pObjectParts));
695  break;
696  }
697 }
#define NOCHECKED
QPixmap * pObjectAll
QPixmap * pObjectParts
QPixmap * pObjectNone
#define PARTCHECKED
#define ALLCHECKED
void ObjectBrowserWidget::setOutputVector ( std::vector< const CCopasiObject * > *  pObjectVector)

Definition at line 324 of file ObjectBrowserWidget.cpp.

References clearClicked(), mOutputObjectVector, and selectObjects().

Referenced by CCopasiSelectionWidget::setExpertMode(), CCopasiSelectionWidget::setOutputVector(), and ObjectBrowserDialog::setOutputVector().

325 {
326  mOutputObjectVector = pObjectVector;
327  this->clearClicked();
328 
330 }
std::vector< const CCopasiObject * > * mOutputObjectVector
void selectObjects(std::vector< const CCopasiObject * > *pObjectVector)
void ObjectBrowserWidget::setUncheck ( ObjectBrowserItem pCurrent)

Definition at line 222 of file ObjectBrowserWidget.cpp.

References ObjectList::insert(), ObjectBrowserItem::isChecked(), ObjectBrowserItem::nextSibling(), refreshList, and ObjectBrowserItem::reverseChecked().

Referenced by clearClicked(), and clickToReverseCheck().

223 {
224  if (pCurrent == NULL)
225  return;
226 
227  refreshList->insert(pCurrent);
228 
229  if (pCurrent->isChecked())
230  pCurrent->reverseChecked();
231 
232  if (pCurrent->child(0) != NULL)
233  setUncheck(static_cast< ObjectBrowserItem * >(pCurrent->child(0)));
234 
235  if (pCurrent->nextSibling() != NULL)
236  setUncheck(static_cast< ObjectBrowserItem * >(pCurrent->nextSibling()));
237 }
void insert(ObjectBrowserItem *pItem)
QTreeWidgetItem * nextSibling()
void setUncheck(ObjectBrowserItem *pCurrent)
void ObjectBrowserWidget::swap ( int  first_pos,
int  second_pos,
ObjectBrowserItem **  array 
)

Definition at line 376 of file ObjectBrowserWidget.cpp.

Referenced by partition().

377 {
378  ObjectBrowserItem* tmp = array[first_pos];
379  array[first_pos] = array[second_pos];
380  array[second_pos] = tmp;
381 }
void ObjectBrowserWidget::toggleViewClicked ( )
virtualslot

Definition at line 256 of file ObjectBrowserWidget.cpp.

References currentPage, LISTVIEWPAGE, ObjectItemText, ObjectListView, SELECTEDITEMPAGE, toggleViewButton, and updateSelectedItemsView().

Referenced by ObjectBrowserWidget(), and ObjectBrowserDialog::toggleViewClicked().

257 {
258  switch (currentPage)
259  {
260  case LISTVIEWPAGE:
263 
264  if (toggleViewButton) toggleViewButton->setText(trUtf8("Tree View"));
265 
266  ObjectListView->hide();
267  ObjectItemText->show();
268  break;
269  case SELECTEDITEMPAGE:
271 
272  if (toggleViewButton) toggleViewButton->setText(trUtf8("Selected Items"));
273 
274  ObjectListView->show();
275  ObjectItemText->hide();
276  break;
277  }
278 }
QTreeWidget * ObjectListView
QPushButton * toggleViewButton
void ObjectBrowserWidget::updateSelectedItemsView ( )
private

Definition at line 280 of file ObjectBrowserWidget.cpp.

References C_INT32, eXport(), FROM_UTF8, ObjectList::getRoot(), objectItemList, ObjectItemText, pdelete, and ObjectListItem::pItem.

Referenced by toggleViewClicked(), and updateUI().

281 {
282  std::vector< const CCopasiObject * > * outputVector;
283  ObjectBrowserItem* rootItem;
284  unsigned C_INT32 i;
285  rootItem = objectItemList->getRoot()->pItem;
286  outputVector = new std::vector< const CCopasiObject * >();
287  eXport(rootItem, outputVector);
288  // CQMessageBox::information(this, "Output object list done!", "Selected CopasiObject list done!");
289  // ObjectListItem* pHead;
290  ObjectItemText->clear();
291 
292  for (i = 0; i < outputVector->size(); i++)
293  {
294  // if (double(i) / 2 == int(i / 2))
295  // ObjectItemText->setColor(red);
296  // else
297  // ObjectItemText->setColor(blue);
298  if ((*outputVector)[i])
299  {
300  ObjectItemText->append(FROM_UTF8((*outputVector)[i]->getObjectDisplayName()));
301  //ObjectItemText->insertParagraph(pHead->pItem->getObject()->pCopasiObject->getCN()., -1);
302  //ObjectItemText->insertParagraph(FROM_UTF8((*outputVector)[i]->getObjectType()), -1);
303  }
304  }
305 
306  /*
307  for (pHead = outputVector->getRoot(), i = 1; pHead != NULL; pHead = pHead->pNext)
308  {
309  if (double(i) / 2 == int(i / 2))
310  ObjectItemText->setColor(red);
311  else
312  ObjectItemText->setColor(blue);
313  if (pHead->pItem->getObject()->pCopasiObject)
314  {
315  //ObjectItemText->insertParagraph(pHead->pItem->getObject()->pCopasiObject->getCN()., -1);
316  ObjectItemText->insertParagraph(pHead->pItem->getObject()->pCopasiObject->getObjectType()., -1);
317  i++;
318  }
319  }
320  */
321  pdelete(outputVector);
322 }
#define pdelete(p)
Definition: copasi.h:215
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
void eXport(ObjectBrowserItem *pCurrent, std::vector< const CCopasiObject * > *outputVector)
#define C_INT32
Definition: copasi.h:90
ObjectBrowserItem * pItem
ObjectListItem * getRoot()
void ObjectBrowserWidget::updateUI ( )

Definition at line 644 of file ObjectBrowserWidget.cpp.

References ObjectList::bucketPop(), ObjectList::createBucketIndex(), currentPage, ObjectList::destroyBucket(), ObjectBrowserItem::getKeySpace(), ObjectBrowserItem::getObject(), ObjectList::getRoot(), ObjectList::insertBucket(), ObjectListItem::pItem, ObjectListItem::pNext, CBrowserObject::referenceList, refreshList, SELECTEDITEMPAGE, setCheckMark(), and updateSelectedItemsView().

Referenced by clearClicked(), listviewChecked(), and selectObjects().

645 {
646  //refresh List stores all affected items,
647 
648  refreshList->createBucketIndex((int)ObjectBrowserItem::getKeySpace()); //construct index to do binary search
649 
650  for (ObjectListItem* pCurrent = refreshList->getRoot(); pCurrent != NULL; pCurrent = pCurrent->pNext)
651  {
652  ObjectListItem * pHead = pCurrent->pItem->getObject()->referenceList->getRoot();
653 
654  while (pHead != NULL)
655  {
656  ObjectBrowserItem * pCurrentLevel = pHead->pItem;
657 
658  if (pCurrent != pHead)
659  for (; (pCurrentLevel != NULL); pCurrentLevel =
660  static_cast< ObjectBrowserItem * >(pCurrentLevel->parent()))
661  refreshList->insertBucket(pCurrentLevel);
662 
663  pHead = pHead->pNext;
664  }
665  }
666 
667  int cursor = 0;
668 
669  for (ObjectBrowserItem* pUpdate = refreshList->bucketPop(cursor); pUpdate != NULL; pUpdate = refreshList->bucketPop(cursor))
670  setCheckMark(pUpdate);
671 
673 
675 }
CBrowserObject * getObject()
void createBucketIndex(int max)
ObjectBrowserItem * bucketPop(int &cursor)
ObjectListItem * pNext
ObjectList * referenceList
void insertBucket(ObjectBrowserItem *pItem)
void setCheckMark(ObjectBrowserItem *pCurrent)
ObjectBrowserItem * pItem
static long getKeySpace()
ObjectListItem * getRoot()

Member Data Documentation

QPushButton* ObjectBrowserWidget::clearButton

Definition at line 62 of file ObjectBrowserWidget.h.

Referenced by ObjectBrowserWidget().

QPushButton* ObjectBrowserWidget::commitButton

Definition at line 64 of file ObjectBrowserWidget.h.

Referenced by ObjectBrowserWidget().

pageIndex ObjectBrowserWidget::currentPage
private

Definition at line 99 of file ObjectBrowserWidget.h.

Referenced by ObjectBrowserWidget(), toggleViewClicked(), and updateUI().

QFrame* ObjectBrowserWidget::Line1

Definition at line 66 of file ObjectBrowserWidget.h.

Referenced by ObjectBrowserWidget().

std::vector< const CCopasiObject * >* ObjectBrowserWidget::mOutputObjectVector
private

Definition at line 98 of file ObjectBrowserWidget.h.

Referenced by commitClicked(), and setOutputVector().

QGridLayout* ObjectBrowserWidget::ObjectBrowserLayout

Definition at line 61 of file ObjectBrowserWidget.h.

Referenced by ObjectBrowserWidget().

ObjectList* ObjectBrowserWidget::objectItemList
QTextEdit* ObjectBrowserWidget::ObjectItemText
QTreeWidget* ObjectBrowserWidget::ObjectListView

Definition at line 65 of file ObjectBrowserWidget.h.

Referenced by loadData(), ObjectBrowserWidget(), and toggleViewClicked().

ObjectList* ObjectBrowserWidget::refreshList
QSpacerItem* ObjectBrowserWidget::spacer

Definition at line 67 of file ObjectBrowserWidget.h.

Referenced by ObjectBrowserWidget().

QPushButton* ObjectBrowserWidget::toggleViewButton

Definition at line 63 of file ObjectBrowserWidget.h.

Referenced by ObjectBrowserWidget(), and toggleViewClicked().


The documentation for this class was generated from the following files: