11 #include <QtCore/QString>
57 return Qt::ItemIsEnabled;
60 return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
64 return QAbstractItemModel::flags(index) & ~Qt::ItemIsEnabled;
66 return QAbstractItemModel::flags(index) | Qt::ItemIsEditable | Qt::ItemIsEnabled;
69 return QAbstractItemModel::flags(index);
80 if (index.column() > 0 && role == Qt::ForegroundRole && !(
flags(index) & Qt::ItemIsEditable))
81 return QColor(Qt::darkGray);
83 if (role == Qt::DisplayRole || role == Qt::EditRole)
87 switch (index.column())
90 return QVariant(QString(
""));
93 return QVariant(QString(
"New Quantity"));
99 return QVariant(QString::number(0.0,
'g', 10));
102 return QVariant(QString(
""));
110 switch (index.column())
113 return QVariant(index.row() + 1);
123 if (role == Qt::EditRole)
132 return QVariant(pGQ->
getRate());
140 if (pExpression != NULL)
152 if (pExpression != NULL)
167 if (role != Qt::DisplayRole)
170 if (orientation == Qt::Horizontal)
175 return QVariant(QString(
"#"));
178 return QVariant(QString(
"Name"));
181 return QVariant(QString(
" Type "));
184 return QVariant(
"Initial Value");
187 return QVariant(
"Transient Value");
190 return QVariant(
"Rate");
193 return QVariant(
"Initial Expression");
196 return QVariant(
"Expression");
203 return QString(
"%1").arg(section + 1);
209 if (index.isValid() && role == Qt::EditRole)
222 else if (index.data() != value)
238 if (defaultRow && this->index(index.row(),
COL_NAME_GQ).
data().toString() ==
"quantity")
241 emit dataChanged(index, index);
250 beginInsertRows(QModelIndex(), position, position + rows - 1);
252 for (
int row = 0; row < rows; ++row)
268 beginRemoveRows(QModelIndex(), position, position + rows - 1);
272 std::vector< std::string > DeletedKeys;
273 DeletedKeys.resize(rows);
275 std::vector< std::string >::iterator itDeletedKey;
276 std::vector< std::string >::iterator endDeletedKey = DeletedKeys.end();
280 for (itDeletedKey = DeletedKeys.begin(); itDeletedKey != endDeletedKey; ++itDeletedKey, ++itRow)
282 *itDeletedKey = (*itRow)->getKey();
285 for (itDeletedKey = DeletedKeys.begin(); itDeletedKey != endDeletedKey; ++itDeletedKey)
304 assert(pDataModel != NULL);
312 QList <CModelValue *> pGlobalQuantities;
313 QModelIndexList::const_iterator i;
315 for (i = rows.begin(); i != rows.end(); ++i)
321 QList <CModelValue *>::const_iterator j;
323 for (j = pGlobalQuantities.begin(); j != pGlobalQuantities.end(); ++j)
328 pModel->
getModelValues().CCopasiVector< CModelValue >::getIndex(pGQ);
332 QMessageBox::StandardButton choice =
337 if (choice == QMessageBox::Ok)
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const
const CExpression * getExpressionPtr() const
Header file of class CExpression.
const QStringList & getTypes()
#define COL_EXPRESSION_GQ
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
Header file of class CModelEntity and CModelValue.
static const std::string StatusName[]
const C_FLOAT64 & getRate() const
void notifyGUI(ListViews::ObjectType objectType, ListViews::Action action, const std::string &key="")
const std::string & getObjectName() const
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const
const CCopasiVectorN< CModelValue > & getModelValues() const
const std::string & getDisplayString() const
QVariant data(const QModelIndex &index, int role) const
bool removeRow(int position)
bool removeModelValue(const CModelValue *pModelValue, const bool &recursive=true)
const C_FLOAT64 & getInitialValue() const
std::vector< CType * >::const_iterator const_iterator
CQGlobalQuantityDM(QObject *parent=0)
virtual const std::string & getKey() const
virtual void setStatus(const CModelEntity::Status &status)
static StandardButton confirmDelete(QWidget *parent, const QString &objectType, const QString &objects, const std::set< const CCopasiObject * > &deletedObjects)
std::string getInitialExpression() const
static CCopasiVector< CCopasiDataModel > * getDatamodelList()
QString createNewName(const QString name, const int nameCol)
virtual std::set< const CCopasiObject * > getDeletedObjects() const
const C_FLOAT64 & getValue() const
Qt::ItemFlags flags(const QModelIndex &index) const
#define COL_IEXPRESSION_GQ
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
bool removeRows(QModelIndexList rows, const QModelIndex &index=QModelIndex())
virtual void setInitialValue(const C_FLOAT64 &initialValue)
const CModelEntity::Status & getStatus() const
std::vector< unsigned C_INT32 > mItemToType
virtual bool isDefaultRow(const QModelIndex &i) const
bool setObjectName(const std::string &name)
const std::vector< unsigned C_INT32 > & getItemToType()
const CExpression * getInitialExpressionPtr() const
bool insertRows(int position, int rows, const QModelIndex &index=QModelIndex())