11 #include <QtCore/QString>
12 #include <QtCore/QList>
41 return Qt::ItemIsEnabled;
44 return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
46 return QAbstractItemModel::flags(index);
57 if (index.column() > 0 && role == Qt::ForegroundRole && !(
flags(index) & Qt::ItemIsEditable))
58 return QColor(Qt::darkGray);
60 if (role == Qt::DisplayRole || role == Qt::EditRole)
64 switch (index.column())
67 return QVariant(QString(
""));
70 return QVariant(QString(
"New Reaction"));
73 return QVariant(QString(
""));
80 switch (index.column())
83 return QVariant(index.row() + 1);
107 return QVariant(pRea->
getFlux());
121 if (role != Qt::DisplayRole)
124 if (orientation == Qt::Horizontal)
129 return QVariant(QString(
"#"));
132 return QVariant(QString(
"Name"));
135 return QVariant(QString(
"Reaction"));
138 return QVariant(QString(
"Rate Law"));
144 if (pModel == NULL)
return QVariant();
151 if (!RateUnits.isEmpty())
152 RateUnits =
"\n(" + RateUnits +
")";
154 return QVariant(
"Flux" + RateUnits);
161 if (pModel == NULL)
return QVariant();
163 QString FrequencyUnits;
168 if (!FrequencyUnits.isEmpty())
169 FrequencyUnits =
"\n(" + FrequencyUnits +
")";
171 return QVariant(
"Flux" + FrequencyUnits);
179 return QString(
"%1").arg(section + 1);
185 if (index.isValid() && role == Qt::EditRole)
191 if (index.data() != value)
211 emit dataChanged(index, index);
220 std::string objKey = pRea->
getKey();
225 assert(pDataModel != NULL);
228 if (pModel == NULL)
return;
257 if (DeletedParameters.size() != 0)
259 QString ObjectType =
"parameter(s) of reaction " + this->index(index.row(),
COL_NAME_REACTIONS).
data().toString();
262 std::set< const CCopasiObject * >::const_iterator itParameter, endParameter = DeletedParameters.end();
263 std::set< const CCopasiObject * > DeletedObjects;
265 for (itParameter = DeletedParameters.begin(); itParameter != endParameter; ++itParameter)
267 Objects.append(
FROM_UTF8((*itParameter)->getObjectName()) +
", ");
268 DeletedObjects.insert(static_cast< const CCopasiObject * >((*itParameter)->getObject(
CCopasiObjectName(
"Reference=Value"))));
271 Objects.remove(Objects.length() - 2, 2);
273 QMessageBox::StandardButton choice =
275 Objects, DeletedObjects);
279 case QMessageBox::Ok:
281 for (itParameter = DeletedParameters.begin(); itParameter != endParameter; ++itParameter)
314 if (createdObjects ||
315 DeletedParameters.size() != 0)
319 else if (createdMetabs)
329 beginInsertRows(QModelIndex(), position, position + rows - 1);
331 for (
int row = 0; row < rows; ++row)
347 beginRemoveRows(QModelIndex(), position, position + rows - 1);
351 std::vector< std::string > DeletedKeys;
352 DeletedKeys.resize(rows);
354 std::vector< std::string >::iterator itDeletedKey;
355 std::vector< std::string >::iterator endDeletedKey = DeletedKeys.end();
359 for (itDeletedKey = DeletedKeys.begin(); itDeletedKey != endDeletedKey; ++itDeletedKey, ++itRow)
361 *itDeletedKey = (*itRow)->getKey();
364 for (itDeletedKey = DeletedKeys.begin(); itDeletedKey != endDeletedKey; ++itDeletedKey)
383 assert(pDataModel != NULL);
391 QList <CReaction *> pReactions;
392 QModelIndexList::const_iterator i;
394 for (i = rows.begin(); i != rows.end(); ++i)
400 QList <CReaction *>::const_iterator j;
402 for (j = pReactions.begin(); j != pReactions.end(); ++j)
407 pModel->
getReactions().CCopasiVector< CReaction >::getIndex(pReaction);
411 QMessageBox::StandardButton choice =
416 if (choice == QMessageBox::Ok)
void setChemEqString(const std::string &eq, const std::string &newFunction)
bool createOtherObjects() const
const C_FLOAT64 & getParticleFlux() const
void notifyGUI(ListViews::ObjectType objectType, ListViews::Action action, const std::string &key="")
const std::string & getObjectName() const
std::string getFrequencyUnitsDisplayString() const
CCopasiObject * get(const std::string &key)
virtual const std::string & getKey() const
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const
std::string getQuantityRateUnitsDisplayString() const
void initFromReaction(const std::string &key)
void setEquation(const CReaction *pRea, const QModelIndex &index, const QVariant &value)
const C_FLOAT64 & getFlux() const
virtual std::set< const CCopasiObject * > getDeletedObjects() const
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
bool removeRow(int position)
QVariant data(const QModelIndex &index, int role) const
#define COL_PARTICLE_FLUX
static bool isValidEq(const std::string &eq)
const CFunction * getFunction() const
std::vector< CType * >::const_iterator const_iterator
#define COL_NAME_REACTIONS
static StandardButton confirmDelete(QWidget *parent, const QString &objectType, const QString &objects, const std::set< const CCopasiObject * > &deletedObjects)
static CCopasiVector< CCopasiDataModel > * getDatamodelList()
std::string getChemEqString(bool expanded) const
QString createNewName(const QString name, const int nameCol)
std::set< const CCopasiObject * > getDeletedParameters() const
static CKeyFactory * getKeyFactory()
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
CCopasiVectorNS< CReaction > & getReactions()
std::string getChemEqString() const
bool writeBackToReaction(CReaction *rea)
#define TOTAL_COLS_REACTIONS
virtual bool isDefaultRow(const QModelIndex &i) const
bool setObjectName(const std::string &name)
bool insertRows(int position, int rows, const QModelIndex &index=QModelIndex())
bool removeRows(QModelIndexList rows, const QModelIndex &index=QModelIndex())
bool removeLocalReactionParameter(const std::string &key, const bool &recursive=true)
CQReactionDM(QObject *parent=0)
bool removeReaction(const CReaction *pReaction, const bool &recursive=true)
void setFunctionWithEmptyMapping(const std::string &fn)
Qt::ItemFlags flags(const QModelIndex &index) const