COPASI API  4.16.103
CQEFMNetReactionDM.cpp
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/UI/CQEFMNetReactionDM.cpp,v $
3 // $Revision: 1.3 $
4 // $Name: $
5 // $Author: shoops $
6 // $Date: 2011/11/10 13:12:56 $
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 #include "CQEFMNetReactionDM.h"
20 #include "qtUtilities.h"
21 
25 #include "model/CModel.h"
27 
29  CQBaseDataModel(parent),
30  mpTask(NULL),
31  mBeginModes(),
32  mModesSize(0)
33 {}
34 
35 int CQEFMNetReactionDM::rowCount(const QModelIndex & C_UNUSED(parent)) const
36 {
37  if (mpTask == NULL)
38  return 0;
39 
40  return (int) mModesSize;
41 }
42 
43 int CQEFMNetReactionDM::columnCount(const QModelIndex & C_UNUSED(parent)) const
44 {
45  return NetReactionDM_COLUMNS;
46 }
47 
48 Qt::ItemFlags CQEFMNetReactionDM::flags(const QModelIndex &index) const
49 {
50  if (!index.isValid())
51  return Qt::ItemIsEnabled;
52 
53  return QAbstractItemModel::flags(index) & ~Qt::ItemIsEditable;
54 }
55 
56 QVariant CQEFMNetReactionDM::data(const QModelIndex &index, int role) const
57 {
58  if (!index.isValid())
59  return QVariant();
60 
61  if (index.row() >= rowCount())
62  return QVariant();
63 
64  if (role == Qt::DisplayRole || role == Qt::EditRole)
65  {
66  std::vector< CFluxMode >::const_iterator itMode = mBeginModes + index.row();
67 
68  switch (index.column())
69  {
70  case COL_ROW_NUMBER:
71  return QVariant(index.row() + 1);
72  break;
73 
74  case COL_REACTION:
75  return QVariant(QString(FROM_UTF8(mpTask->getNetReaction(*itMode))));
76  break;
77 
78  case COL_MODIFIER:
79  return QVariant(QString(FROM_UTF8(mpTask->getInternalSpecies(*itMode))));
80  break;
81  }
82  }
83 
84  return QVariant();
85 }
86 
87 QVariant CQEFMNetReactionDM::headerData(int section, Qt::Orientation orientation,
88  int role) const
89 {
90  if (role != Qt::DisplayRole)
91  return QVariant();
92 
93  if (orientation == Qt::Horizontal)
94  {
95  switch (section)
96  {
97  case COL_ROW_NUMBER:
98  return QVariant(QString("#"));
99  break;
100 
101  case COL_REACTION:
102  return QVariant(QString("Net Reaction"));
103  break;
104 
105  case COL_MODIFIER:
106  return QVariant(QString("Internal Species"));
107  break;
108  }
109  }
110 
111  return QString("%1").arg(section + 1);
112 }
113 
115 {
116  mpTask = pTask;
117 
118  if (mpTask != NULL)
119  {
120  mBeginModes = mpTask->getFluxModes().begin();
121  mModesSize = mpTask->getFluxModes().size();
122  }
123  else
124  {
125  mModesSize = 0;
126  }
127 }
128 
129 bool CQEFMNetReactionDM::setData(const QModelIndex & /* index */, const QVariant & /* value */, int /* role */)
130 {
131  return false;
132 }
133 
134 // virtual
135 bool CQEFMNetReactionDM::insertRows(int /* position */, int /* rows */, const QModelIndex & /* index */)
136 {
137  return false;
138 }
139 
140 // virtual
141 bool CQEFMNetReactionDM::removeRows(int /* position */, int /* rows */, const QModelIndex & /* index */)
142 {
143  return false;
144 }
145 
146 // virtual
147 bool CQEFMNetReactionDM::isDefaultRow(const QModelIndex& /* i */) const
148 {
149  return false;
150 }
std::string getNetReaction(const CFluxMode &fluxMode) const
Definition: CEFMTask.cpp:274
#define FROM_UTF8(__x)
Definition: qtUtilities.h:73
void setTask(const CEFMTask *pTask)
virtual bool removeRows(int position, int rows, const QModelIndex &index=QModelIndex())
const std::vector< CFluxMode > & getFluxModes() const
Definition: CEFMTask.cpp:183
#define C_UNUSED(p)
Definition: copasi.h:220
std::vector< CFluxMode >::const_iterator mBeginModes
CTSSATask * pTask
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const
std::string getInternalSpecies(const CFluxMode &fluxMode) const
Definition: CEFMTask.cpp:334
QVariant data(const QModelIndex &index, int role) const
#define COL_REACTION
virtual bool isDefaultRow(const QModelIndex &i) const
#define NetReactionDM_COLUMNS
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const
const CEFMTask * mpTask
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
CQEFMNetReactionDM(QObject *parent=0)
virtual bool insertRows(int position, int rows, const QModelIndex &index=QModelIndex())
#define COL_MODIFIER
Qt::ItemFlags flags(const QModelIndex &index) const
#define COL_ROW_NUMBER