COPASI API  4.16.103
CCopasiSelectionWidget.cpp
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/UI/CCopasiSelectionWidget.cpp,v $
3 // $Revision: 1.17 $
4 // $Name: $
5 // $Author: shoops $
6 // $Date: 2011/04/01 15:06:40 $
7 // End CVS Header
8 
9 // Copyright (C) 2011 - 2010 by Pedro Mendes, Virginia Tech Intellectual
10 // Properties, Inc., University of Heidelberg, and The University
11 // of Manchester.
12 // All rights reserved.
13 
14 // Copyright (C) 2008 by Pedro Mendes, Virginia Tech Intellectual
15 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
16 // and The University of Manchester.
17 // All rights reserved.
18 
19 // Copyright (C) 2001 - 2007 by Pedro Mendes, Virginia Tech Intellectual
20 // Properties, Inc. and EML Research, gGmbH.
21 // All rights reserved.
22 
23 #include <iostream>
24 
25 #include "copasi.h"
26 
27 #include "CCopasiSelectionWidget.h"
28 #include "ObjectBrowserWidget.h"
29 #include "CQSimpleSelectionTree.h"
30 
32  QStackedWidget(parent),
33  mpSimpleTree(NULL),
34  mpObjectBrowser(NULL),
35  mpOutputVector(NULL),
36  mSingleSelect(false),
37  mExpertMode(false)
38 {
39  this->mpSimpleTree = new CQSimpleSelectionTree(this);
40  this->addWidget(this->mpSimpleTree);
41  this->setSingleSelection(false);
42  this->setExpertMode(false);
43 }
44 
46 {
48  delete mpSimpleTree;
49 }
50 
53 {
54  this->mpSimpleTree->populateTree(model, classes);
55 }
56 
57 void CCopasiSelectionWidget::setOutputVector(std::vector< const CCopasiObject * > * outputVector)
58 {
59  this->mpOutputVector = outputVector;
60 
61  if (this->mExpertMode)
62  {
64  }
65  else
66  {
68  }
69 }
70 
72 {
73  if (this->mSingleSelect == singleSelection) return;
74 
75  this->mSingleSelect = singleSelection;
76  this->mpSimpleTree->clearSelection();
77 
78  if (this->mSingleSelect)
79  {
80  this->mpSimpleTree->setSelectionMode(QAbstractItemView::SingleSelection);
81 
82  if (this->mpObjectBrowser)
83  {
84  /* this needs to be implemented first !
85 
86  this->mpObjectBrowser->setSingleSelection(true);
87 
88  */
89  }
90  }
91  else
92  {
93  this->mpSimpleTree->setSelectionMode(QAbstractItemView::ExtendedSelection);
94 
95  if (this->mpObjectBrowser)
96  {
97  /* this needs to be implemented first !
98 
99  this->mpObjectBrowser->setSingleSelection(true);
100 
101  */
102  }
103  }
104 }
105 
107 {
108  return this->mSingleSelect;
109 }
110 
112 {
113  if (this->mExpertMode == expertMode) return;
114 
115  this->mExpertMode = expertMode;
116 
117  if (this->mExpertMode)
118  {
119  if (!this->mpObjectBrowser)
120  {
121  // create the object browser only if needed
122  // this saves some time if the model is large
123  this->mpObjectBrowser = new ObjectBrowserWidget(this);
124  this->addWidget(this->mpObjectBrowser);
125  }
126 
127  this->mpSimpleTree->commitClicked();
128  this->mpSimpleTree->setOutputVector(NULL);
130  this->setCurrentWidget(this->mpObjectBrowser);
131  }
132  else
133  {
134  // activate the SimpleTree and get the selection from the ObjectBrowser if there is one
135  if (this->mpObjectBrowser)
136  {
138  this->mpObjectBrowser->setOutputVector(NULL);
139  }
140 
142  this->setCurrentWidget(this->mpSimpleTree);
143  }
144 }
145 
147 {
148  return this->mExpertMode;
149 }
150 
152 {
153  if (this->mpOutputVector)
154  {
155  if (this->mExpertMode)
156  {
158 
159  if (this->mSingleSelect && this->mpOutputVector->size() > 1)
160  {
161  const CCopasiObject * object = this->mpOutputVector->at(0);
162  this->mpOutputVector->clear();
163  this->mpOutputVector->push_back(object);
164  }
165  }
166  else
167  {
168  this->mpSimpleTree->commitClicked();
169  }
170  }
171 }
std::vector< const CCopasiObject * > * mpOutputVector
#define pdelete(p)
Definition: copasi.h:215
void setExpertMode(bool expertMode)
void setOutputVector(std::vector< const CCopasiObject * > *outputVector)
CQSimpleSelectionTree * mpSimpleTree
void setSingleSelection(bool singleSelection)
void populateTree(const CModel *model, const CQSimpleSelectionTree::ObjectClasses &classes)
void setOutputVector(std::vector< const CCopasiObject * > *outputVector)
void setOutputVector(std::vector< const CCopasiObject * > *pObjectVector)
ObjectBrowserWidget * mpObjectBrowser
void populateTree(const CModel *pModel, const ObjectClasses &classes)
Definition: CModel.h:50
CCopasiSelectionWidget(QWidget *parent=0)