11 #include <QtCore/QString>
12 #include <QtCore/QList>
40 return Qt::ItemIsEnabled;
43 return QAbstractItemModel::flags(index);
46 return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
48 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(
""));
92 return QVariant(QString(
"New Function"));
96 return QVariant(QString(
""));
106 switch (index.column())
109 return QVariant(index.row() + 1);
132 if (role != Qt::DisplayRole)
135 if (orientation == Qt::Horizontal)
140 return QVariant(QString(
"#"));
142 return QVariant(QString(
"Name"));
144 return QVariant(QString(
"Type"));
146 return QVariant(QString(
"Mathematical Description"));
148 return QVariant(QString(
"SBML ID"));
154 return QString(
"%1").arg(section + 1);
160 if (index.isValid() && role == Qt::EditRole)
166 if (index.data() != value)
181 if (index.data() != value)
187 "Unable to change Function Type",
189 QMessageBox::Ok, QMessageBox::Ok);
194 if (index.data() != value)
202 "Unable to change mathematical description",
204 QMessageBox::Ok, QMessageBox::Ok);
212 emit dataChanged(index, index);
221 beginInsertRows(QModelIndex(), position, position + rows - 1);
223 for (
int row = 0; row < rows; ++row)
240 std::vector< std::string > DeletedKeys;
241 DeletedKeys.resize(rows);
243 std::vector< std::string >::iterator itDeletedKey;
244 std::vector< std::string >::iterator endDeletedKey = DeletedKeys.end();
250 for (itDeletedKey = DeletedKeys.begin(), row = 0; itDeletedKey != endDeletedKey; ++itDeletedKey, ++itRow, ++row)
258 *itDeletedKey = (*itRow)->getKey();
262 for (itDeletedKey = DeletedKeys.begin(), row = 0; itDeletedKey != endDeletedKey; ++itDeletedKey, ++row)
264 if (*itDeletedKey !=
"")
266 beginRemoveRows(QModelIndex(), position + row, position + row);
286 assert(pDataModel != NULL);
294 QList <CEvaluationTree *> pFunctions;
295 QModelIndexList::const_iterator i;
297 for (i = rows.begin(); i != rows.end(); ++i)
303 QList <CEvaluationTree *>::const_iterator j;
305 for (j = pFunctions.begin(); j != pFunctions.end(); ++j)
314 QMessageBox::StandardButton choice =
319 if (choice == QMessageBox::Ok)
CQFunctionDM(QObject *parent=0)
CCopasiVectorN< CFunction > & loadedFunctions()
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const
void notifyGUI(ListViews::ObjectType objectType, ListViews::Action action, const std::string &key="")
const std::string & getObjectName() const
virtual size_t size() const
const CEvaluationTree::Type & getType() const
static StandardButton information(QWidget *parent, const QString &title, const QString &text, StandardButtons buttons=Ok, StandardButton defaultButton=NoButton)
bool isFunctionReadOnly(const QModelIndex &index) const
const std::string & getKey() const
static const std::string TypeName[]
bool removeRow(int position)
virtual const std::string & getKey() const
bool removeRows(QModelIndexList rows, const QModelIndex &index=QModelIndex())
std::vector< CType * >::const_iterator const_iterator
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const
static StandardButton confirmDelete(QWidget *parent, const QString &objectType, const QString &objects, const std::set< const CCopasiObject * > &deletedObjects)
QVariant data(const QModelIndex &index, int role) const
static CCopasiVector< CCopasiDataModel > * getDatamodelList()
CCopasiObject::DataObjectSet getDeletedObjects() const
QString createNewName(const QString name, const int nameCol)
static CFunctionDB * getFunctionList()
bool insertRows(int position, int rows, const QModelIndex &index=QModelIndex())
bool removeFunction(size_t index)
#define COL_SBML_ID_FUNCTIONS
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
#define COL_MATH_DESC_FUNCTIONS
The class for handling a chemical kinetic function.
#define COL_TYPE_FUNCTIONS
#define TOTAL_COLS_FUNCTIONS
#define COL_NAME_FUNCTIONS
virtual bool isDefaultRow(const QModelIndex &i) const
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
bool setObjectName(const std::string &name)
Qt::ItemFlags flags(const QModelIndex &index) const
const std::string & getInfix() const
virtual bool setInfix(const std::string &infix)
bool add(CFunction *pFunction, const bool &adopt)