COPASI API  4.16.103
Signals | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
CQParameterOverviewDM Class Reference

#include <CQParameterOverviewDM.h>

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

Signals

void signalCloseEditor (const QModelIndex &) const
 
void signalOpenEditor (const QModelIndex &) const
 

Public Member Functions

virtual int columnCount (const QModelIndex &parent=QModelIndex()) const
 
 CQParameterOverviewDM (QObject *pParent)
 
virtual QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const
 
virtual Qt::ItemFlags flags (const QModelIndex &index) const
 
virtual QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
 
virtual QModelIndex index (int row, int column, const QModelIndex &parent=QModelIndex()) const
 
virtual QModelIndex parent (const QModelIndex &index) const
 
virtual int rowCount (const QModelIndex &parent=QModelIndex()) const
 
virtual bool setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
 
void setFramework (const int &framework)
 
void setModelParameterset (CModelParameterSet *pModelParameterSet)
 
virtual ~CQParameterOverviewDM ()
 

Static Public Member Functions

static CModelParameternodeFromIndex (const QModelIndex &index)
 

Private Member Functions

QModelIndex index (CModelParameter *pNode) const
 
QVariant unitData (const CModelParameter *pNode, int role) const
 
QVariant valueData (const CModelParameter *pNode, int role) const
 

Static Private Member Functions

static QVariant assignmentData (const CModelParameter *pNode, int role)
 
static QVariant diffData (const CModelParameter *pNode, int role)
 
static int getRow (const CModelParameter *pNode)
 
static QVariant nameData (const CModelParameter *pNode, int role)
 
static QVariant typeData (const CModelParameter *pNode, int role)
 

Private Attributes

int mFramework
 
CModelParameterGroupmpModelParameterSet
 

Detailed Description

Definition at line 17 of file CQParameterOverviewDM.h.

Constructor & Destructor Documentation

CQParameterOverviewDM::CQParameterOverviewDM ( QObject *  pParent)

Definition at line 29 of file CQParameterOverviewDM.cpp.

29  :
30  QAbstractItemModel(pParent),
31  mpModelParameterSet(NULL),
32  mFramework(0)
33 {
34 }
CModelParameterGroup * mpModelParameterSet
CQParameterOverviewDM::~CQParameterOverviewDM ( )
virtual

Definition at line 37 of file CQParameterOverviewDM.cpp.

38 {
39 }

Member Function Documentation

QVariant CQParameterOverviewDM::assignmentData ( const CModelParameter pNode,
int  role 
)
staticprivate

Definition at line 495 of file CQParameterOverviewDM.cpp.

References FROM_UTF8, CExpression::getDisplayString(), CModelParameter::getInitialExpression(), CModelParameter::getInitialExpressionPtr(), CModelParameterGroup::getModelParameter(), CModelParameter::getName(), CModelParameter::getSet(), CModelParameter::getType(), and CModelParameter::ReactionParameter.

Referenced by data().

496 {
497  if (role == Qt::DisplayRole)
498  {
500  {
501  CCopasiObjectName GlobalQuantityCN = static_cast< const CModelParameterReactionParameter *>(pNode)->getGlobalQuantityCN();
502  CModelParameter * pGlobalQuantity = pNode->getSet()->getModelParameter(GlobalQuantityCN);
503 
504  if (pGlobalQuantity != NULL)
505  {
506  return QVariant(QString(FROM_UTF8(pGlobalQuantity->getName())));
507  }
508 
509  return QVariant(QString(FROM_UTF8(GlobalQuantityCN)));
510  }
511 
512  const CExpression* pExpression = pNode->getInitialExpressionPtr();
513 
514  if (pExpression != NULL)
515  return QVariant(QString(FROM_UTF8(pExpression->getDisplayString())));
516  else
517  return QVariant(QString(FROM_UTF8(pNode->getInitialExpression())));
518  }
519 
520  return QVariant();
521 }
std::string getInitialExpression() const
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
virtual std::string getName() const
CModelParameter * getModelParameter(const std::string &cn) const
const std::string & getDisplayString() const
CModelParameterSet * getSet() const
const CExpression * getInitialExpressionPtr() const
const Type & getType() const
int CQParameterOverviewDM::columnCount ( const QModelIndex &  parent = QModelIndex()) const
virtual

Definition at line 42 of file CQParameterOverviewDM.cpp.

References COLUMN_COUNT.

43 {
44  return COLUMN_COUNT;
45 }
#define COLUMN_COUNT
QVariant CQParameterOverviewDM::data ( const QModelIndex &  index,
int  role = Qt::DisplayRole 
) const
virtual

Definition at line 48 of file CQParameterOverviewDM.cpp.

References assignmentData(), COL_ASSIGNMENT, COL_DIFF, COL_NAME, COL_TYPE, COL_UNIT, COL_VALUE, diffData(), nameData(), nodeFromIndex(), typeData(), unitData(), and valueData().

49 {
51 
52  if (pNode == NULL) return QVariant();
53 
54  switch (index.column())
55  {
56  case COL_NAME:
57  return nameData(pNode, role);
58  break;
59 
60  case COL_DIFF:
61  return diffData(pNode, role);
62  break;
63 
64  case COL_TYPE:
65  return typeData(pNode, role);
66  break;
67 
68  case COL_VALUE:
69  return valueData(pNode, role);
70  break;
71 
72  case COL_UNIT:
73  return unitData(pNode, role);
74  break;
75 
76  case COL_ASSIGNMENT:
77  return assignmentData(pNode, role);
78  break;
79  }
80 
81  return QVariant();
82 }
static QVariant typeData(const CModelParameter *pNode, int role)
QVariant valueData(const CModelParameter *pNode, int role) const
#define COL_DIFF
static QVariant diffData(const CModelParameter *pNode, int role)
static QVariant assignmentData(const CModelParameter *pNode, int role)
#define COL_ASSIGNMENT
#define COL_UNIT
static CModelParameter * nodeFromIndex(const QModelIndex &index)
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
#define COL_VALUE
#define COL_TYPE
QVariant unitData(const CModelParameter *pNode, int role) const
#define COL_NAME
static QVariant nameData(const CModelParameter *pNode, int role)
QVariant CQParameterOverviewDM::diffData ( const CModelParameter pNode,
int  role 
)
staticprivate

Definition at line 362 of file CQParameterOverviewDM.cpp.

References CModelParameter::Conflict, CModelParameter::getCompareResult(), CModelParameter::getType(), CModelParameter::Group, CQIconResource::icon(), CModelParameter::Identical, CModelParameter::Missing, CModelParameter::Modified, CModelParameter::Obsolete, CQIconResource::parameterConflict, CQIconResource::parameterMissing, CQIconResource::parameterModified, CQIconResource::parameterObsolete, and CModelParameter::Set.

Referenced by data().

363 {
364  if (pNode->getType() == CModelParameter::Group ||
365  pNode->getType() == CModelParameter::Set)
366  {
367  return QVariant();
368  }
369 
370  switch (role)
371  {
372  case Qt::UserRole:
373 
374  switch (pNode->getCompareResult())
375  {
378  break;
379 
382  break;
383 
386  break;
387 
390  break;
391 
393  return QVariant();
394  break;
395  }
396 
397  break;
398 
399  case Qt::ToolTipRole:
400 
401  switch (pNode->getCompareResult())
402  {
404  return QVariant(QString("The item is no longer present in the model. \n\n"
405  "Click to remove from the set."));
406  break;
407 
409  return QVariant(QString("The item is present in the model but is missing in the parameter set. \n\n"
410  "Click to add to the set."));
411  break;
412 
414  return QVariant(QString("The item's value differs from the current model. \n\n"
415  "Click to update the sets value."));
416  break;
417 
419  return QVariant(QString("The item's value cannot be assigned to the model object since the\n"
420  "object is determined by an assignment. \n\n"
421  "Click to resolve conflict."));
422  break;
423 
425  return QVariant(QString("The item's value is identical with the current model."));
426  break;
427  }
428 
429  break;
430 
431  case Qt::SizeHintRole:
432  return QVariant(QSize(20, 20));
433  break;
434  }
435 
436  return QVariant();
437 }
const CompareResult & getCompareResult() const
static const QIcon & icon(const IconID &id)
const Type & getType() const
Qt::ItemFlags CQParameterOverviewDM::flags ( const QModelIndex &  index) const
virtual

Definition at line 85 of file CQParameterOverviewDM.cpp.

References COL_ASSIGNMENT, COL_DIFF, COL_VALUE, CModelParameter::getCompareResult(), CModelParameter::getType(), CModelParameter::Group, CModelParameter::Identical, CModelParameter::isReadOnly(), nodeFromIndex(), CModelParameter::ReactionParameter, CModelParameter::Set, signalCloseEditor(), and signalOpenEditor().

86 {
88 
89  if (pNode == NULL)
90  {
91  return Qt::ItemIsEnabled;
92  }
93 
94  if (index.column() == COL_VALUE &&
95  !pNode->isReadOnly())
96  {
97  return QAbstractItemModel::flags(index) | Qt::ItemIsEditable | Qt::ItemIsEnabled;
98  }
99 
100  if (index.column() == COL_DIFF)
101  {
103  pNode->getType() != CModelParameter::Group &&
104  pNode->getType() != CModelParameter::Set)
105  {
106  emit signalOpenEditor(index);
107 
108  return QAbstractItemModel::flags(index) | Qt::ItemIsEditable | Qt::ItemIsEnabled;
109  }
110 
111  emit signalCloseEditor(index);
112  }
113 
114  if (index.column() == COL_ASSIGNMENT)
115  {
117  {
118  emit signalOpenEditor(index);
119 
120  return QAbstractItemModel::flags(index) | Qt::ItemIsEditable | Qt::ItemIsEnabled;
121  }
122 
123  emit signalCloseEditor(index);
124  }
125 
126  return QAbstractItemModel::flags(index) & ~Qt::ItemIsEditable;
127 }
void signalOpenEditor(const QModelIndex &) const
const CompareResult & getCompareResult() const
#define COL_DIFF
bool isReadOnly() const
#define COL_ASSIGNMENT
void signalCloseEditor(const QModelIndex &) const
static CModelParameter * nodeFromIndex(const QModelIndex &index)
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
const Type & getType() const
#define COL_VALUE
int CQParameterOverviewDM::getRow ( const CModelParameter pNode)
staticprivate

Definition at line 322 of file CQParameterOverviewDM.cpp.

References CModelParameterGroup::begin(), CModelParameterGroup::end(), and CModelParameter::getParent().

Referenced by index(), and parent().

323 {
324  if (pNode == NULL)
325  {
326  return -1;
327  }
328 
329  CModelParameterGroup * pParent = pNode->getParent();
330 
331  if (pParent == NULL)
332  {
333  return 0;
334  }
335 
337  CModelParameterGroup::const_iterator end = pParent->end();
338 
339  for (int i = 0; it != end; ++it, ++i)
340  {
341  if (*it == pNode)
342  {
343  return i;
344  }
345  }
346 
347  return -1;
348 }
std::vector< CModelParameter * >::const_iterator const_iterator
CModelParameterGroup * getParent() const
QVariant CQParameterOverviewDM::headerData ( int  section,
Qt::Orientation  orientation,
int  role = Qt::DisplayRole 
) const
virtual

Definition at line 130 of file CQParameterOverviewDM.cpp.

References COL_ASSIGNMENT, COL_DIFF, COL_NAME, COL_TYPE, COL_UNIT, and COL_VALUE.

131 {
132  if (role != Qt::DisplayRole)
133  return QVariant();
134 
135  switch (section)
136  {
137  case COL_NAME:
138  return QVariant("Name");
139  break;
140 
141  case COL_DIFF:
142  return QVariant("");
143  break;
144 
145  case COL_TYPE:
146  return QVariant("Type");
147  break;
148 
149  case COL_VALUE:
150  return QVariant("Value");
151  break;
152 
153  case COL_UNIT:
154  return QVariant("Unit");
155  break;
156 
157  case COL_ASSIGNMENT:
158  return QVariant("Expression");
159  break;
160  }
161 
162  return QVariant();
163 }
#define COL_DIFF
#define COL_ASSIGNMENT
#define COL_UNIT
#define COL_VALUE
#define COL_TYPE
#define COL_NAME
QModelIndex CQParameterOverviewDM::index ( int  row,
int  column,
const QModelIndex &  parent = QModelIndex() 
) const
virtual

Definition at line 166 of file CQParameterOverviewDM.cpp.

References CModelParameterGroup::begin(), mpModelParameterSet, nodeFromIndex(), and CModelParameterGroup::size().

Referenced by index(), and nodeFromIndex().

167 {
168  CModelParameterGroup * pParent = static_cast< CModelParameterGroup *>(nodeFromIndex(parent));
169 
170  if (pParent == NULL)
171  {
172  return createIndex(row, column, *(mpModelParameterSet->begin() + row));
173  }
174 
175  if (row < (int) pParent->size())
176  return createIndex(row, column, *(pParent->begin() + row));
177  else
178  return QModelIndex();
179 }
virtual QModelIndex parent(const QModelIndex &index) const
static CModelParameter * nodeFromIndex(const QModelIndex &index)
CModelParameterGroup * mpModelParameterSet
QModelIndex CQParameterOverviewDM::index ( CModelParameter pNode) const
private

Definition at line 287 of file CQParameterOverviewDM.cpp.

References CModelParameter::getParent(), getRow(), index(), and mpModelParameterSet.

288 {
289  if (pNode == NULL)
290  {
291  return QModelIndex();
292  }
293 
294  if (pNode == mpModelParameterSet)
295  {
296  return index(0, 0, QModelIndex());
297  }
298 
299  QModelIndex Parent = index(static_cast< CModelParameter * >(pNode->getParent()));
300 
301  return index(getRow(pNode), 0, Parent);
302 }
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
static int getRow(const CModelParameter *pNode)
CModelParameterGroup * mpModelParameterSet
CModelParameterGroup * getParent() const
QVariant CQParameterOverviewDM::nameData ( const CModelParameter pNode,
int  role 
)
staticprivate

Definition at line 351 of file CQParameterOverviewDM.cpp.

References FROM_UTF8, and CModelParameter::getName().

Referenced by data().

352 {
353  if (role == Qt::DisplayRole)
354  {
355  return QVariant(QString(FROM_UTF8(pNode->getName())));
356  }
357 
358  return QVariant();
359 }
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
virtual std::string getName() const
CModelParameter * CQParameterOverviewDM::nodeFromIndex ( const QModelIndex &  index)
static

Definition at line 305 of file CQParameterOverviewDM.cpp.

References index().

Referenced by data(), flags(), index(), parent(), rowCount(), setData(), and CQParameterOverviewWidget::slotResolve().

306 {
307  if (!index.isValid()) return NULL;
308 
309  QModelIndex Tmp = index;
310  const QAbstractItemModel *pModel = Tmp.model();
311 
312  while (pModel->inherits("QSortFilterProxyModel"))
313  {
314  Tmp = static_cast< const QSortFilterProxyModel *>(pModel)->mapToSource(index);
315  pModel = Tmp.model();
316  }
317 
318  return static_cast< CModelParameter * >(Tmp.internalPointer());
319 }
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
QModelIndex CQParameterOverviewDM::parent ( const QModelIndex &  index) const
virtual

Definition at line 182 of file CQParameterOverviewDM.cpp.

References CModelParameter::getParent(), getRow(), mpModelParameterSet, and nodeFromIndex().

183 {
185 
186  if (pNode == NULL || pNode == mpModelParameterSet)
187  {
188  return QModelIndex();
189  }
190 
191  if (pNode->getParent() == mpModelParameterSet)
192  {
193  return QModelIndex();
194  }
195 
196  CModelParameter * pParent = static_cast< CModelParameter * >(pNode->getParent());
197 
198  return createIndex(getRow(pParent), 0, pParent);
199 }
static CModelParameter * nodeFromIndex(const QModelIndex &index)
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
static int getRow(const CModelParameter *pNode)
CModelParameterGroup * mpModelParameterSet
CModelParameterGroup * getParent() const
int CQParameterOverviewDM::rowCount ( const QModelIndex &  parent = QModelIndex()) const
virtual

Definition at line 202 of file CQParameterOverviewDM.cpp.

References CModelParameter::getType(), CModelParameter::Group, mpModelParameterSet, nodeFromIndex(), CModelParameter::Reaction, and CModelParameter::Set.

203 {
204  if (!parent.isValid())
205  {
206  if (mpModelParameterSet != NULL)
207  return 5;
208  else
209  return 0;
210  }
211 
212  CModelParameter * pParent = nodeFromIndex(parent);
213 
214  switch (pParent->getType())
215  {
219  return (int) static_cast< CModelParameterGroup * >(pParent) ->size();
220  break;
221 
222  default:
223  break;
224  }
225 
226  return 0;
227 }
virtual QModelIndex parent(const QModelIndex &index) const
static CModelParameter * nodeFromIndex(const QModelIndex &index)
const Type & getType() const
CModelParameterGroup * mpModelParameterSet
bool CQParameterOverviewDM::setData ( const QModelIndex &  index,
const QVariant &  value,
int  role = Qt::EditRole 
)
virtual

Definition at line 230 of file CQParameterOverviewDM.cpp.

References COL_ASSIGNMENT, COL_VALUE, CModelParameter::getCN(), CModelParameterGroup::getModelParameter(), CModelParameter::getSet(), mFramework, CModelParameter::ModelValue, nodeFromIndex(), CModelParameter::setValue(), and TO_UTF8.

231 {
232  CModelParameter * pNode = nodeFromIndex(_index);
233  bool success = false;
234 
235  if (pNode != NULL &&
236  role == Qt::EditRole)
237  {
238  switch (_index.column())
239  {
240  case COL_VALUE:
241  pNode->setValue(value.toDouble(), static_cast< CModelParameter::Framework >(mFramework));
242  success = true;
243  break;
244 
245  case COL_ASSIGNMENT:
246  {
247  CModelParameter * pGlobalQuantity = pNode->getSet()->getModelParameter(TO_UTF8(value.toString()), CModelParameter::ModelValue);
248 
249  if (pGlobalQuantity != NULL)
250  {
251  static_cast< CModelParameterReactionParameter * >(pNode)->setGlobalQuantityCN(pGlobalQuantity->getCN());
252  }
253  else
254  {
255  static_cast< CModelParameterReactionParameter * >(pNode)->setGlobalQuantityCN("");
256  }
257  }
258 
259  success = true;
260  break;
261  }
262  }
263 
264  return success;
265 }
CModelParameter * getModelParameter(const std::string &cn) const
const CCopasiObjectName & getCN() const
virtual void setValue(const double &value, const Framework &framework)
#define COL_ASSIGNMENT
CModelParameterSet * getSet() const
static CModelParameter * nodeFromIndex(const QModelIndex &index)
#define TO_UTF8(__x)
Definition: qtUtilities.h:74
#define COL_VALUE
void CQParameterOverviewDM::setFramework ( const int &  framework)

Definition at line 277 of file CQParameterOverviewDM.cpp.

References mFramework, and mpModelParameterSet.

Referenced by CQParameterOverviewWidget::setFramework(), and CQParameterOverviewWidget::slotResolve().

278 {
279  if (mpModelParameterSet != NULL)
280  {
281  beginResetModel();
282  mFramework = framework;
283  endResetModel();
284  }
285 }
CModelParameterGroup * mpModelParameterSet
void CQParameterOverviewDM::setModelParameterset ( CModelParameterSet pModelParameterSet)

Definition at line 267 of file CQParameterOverviewDM.cpp.

References mpModelParameterSet.

Referenced by CQParameterOverviewWidget::enterProtected(), and CQParameterOverviewWidget::slotBtnDelete().

268 {
269  if (mpModelParameterSet != pModelParameterSet)
270  {
271  beginResetModel();
272  mpModelParameterSet = pModelParameterSet;
273  endResetModel();
274  }
275 }
CModelParameterGroup * mpModelParameterSet
void CQParameterOverviewDM::signalCloseEditor ( const QModelIndex &  ) const
signal

Referenced by flags().

void CQParameterOverviewDM::signalOpenEditor ( const QModelIndex &  ) const
signal

Referenced by flags().

QVariant CQParameterOverviewDM::typeData ( const CModelParameter pNode,
int  role 
)
staticprivate

Definition at line 440 of file CQParameterOverviewDM.cpp.

References FROM_UTF8, CModelParameter::getSimulationType(), CModelParameter::getType(), CModelParameter::Group, CModelParameter::Reaction, CModelParameter::Set, and CModelEntity::StatusName.

Referenced by data().

441 {
442  switch (pNode->getType())
443  {
447  break;
448 
449  default:
450 
451  if (role == Qt::DisplayRole)
452  {
453  return QVariant(QString(FROM_UTF8(CModelEntity::StatusName[pNode->getSimulationType()])));
454  }
455 
456  break;
457  }
458 
459  return QVariant();
460 }
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
static const std::string StatusName[]
Definition: CModelValue.h:67
const CModelEntity::Status & getSimulationType() const
const Type & getType() const
QVariant CQParameterOverviewDM::unitData ( const CModelParameter pNode,
int  role 
) const
private

Definition at line 484 of file CQParameterOverviewDM.cpp.

References FROM_UTF8, CModelParameter::getUnit(), and mFramework.

Referenced by data().

485 {
486  if (role == Qt::DisplayRole)
487  {
488  return QVariant(QString(FROM_UTF8(pNode->getUnit(static_cast< CModelParameter::Framework >(mFramework)))));
489  }
490 
491  return QVariant();
492 }
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
const std::string getUnit(const Framework &framework) const
QVariant CQParameterOverviewDM::valueData ( const CModelParameter pNode,
int  role 
) const
private

Definition at line 462 of file CQParameterOverviewDM.cpp.

References CModelParameter::getType(), CModelParameter::getValue(), CModelParameter::Group, mFramework, CModelParameter::Reaction, and CModelParameter::Set.

Referenced by data().

463 {
464  switch (pNode->getType())
465  {
469  break;
470 
471  default:
472 
473  if (role == Qt::EditRole)
474  return QVariant(QString::number(pNode->getValue(static_cast< CModelParameter::Framework >(mFramework)), 'g', 10));
475  else if (role == Qt::DisplayRole)
476  return QVariant(pNode->getValue(static_cast< CModelParameter::Framework >(mFramework)));
477 
478  break;
479  }
480 
481  return QVariant();
482 }
virtual const double & getValue(const Framework &framework) const
const Type & getType() const

Member Data Documentation

int CQParameterOverviewDM::mFramework
private

Definition at line 73 of file CQParameterOverviewDM.h.

Referenced by setData(), setFramework(), unitData(), and valueData().

CModelParameterGroup* CQParameterOverviewDM::mpModelParameterSet
private

Definition at line 71 of file CQParameterOverviewDM.h.

Referenced by index(), parent(), rowCount(), setFramework(), and setModelParameterset().


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