11 #include <QtCore/QString>
39 return Qt::ItemIsEnabled;
42 return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
44 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 Event"));
73 return QVariant(QString(
""));
79 QString assignmentTarget =
"";
80 QString assignmentExpression =
"";
88 for (; it != end; ++it)
97 assignmentTarget +=
"\n";
98 assignmentExpression +=
"\n";
102 pExpression = (*it)->getExpressionPtr();
104 if (pExpression != NULL)
107 assignmentExpression +=
FROM_UTF8((*it)->getExpression());
112 switch (index.column())
115 return QVariant(index.row() + 1);
123 if (pExpression != NULL)
131 return QVariant(QString(
"No"));
133 return QVariant(QString(
"Assignment"));
135 return QVariant(QString(
"Calculation"));
141 if (pExpression != NULL)
147 return QVariant(assignmentTarget);
150 return QVariant(assignmentExpression);
161 if (role != Qt::DisplayRole)
164 if (orientation == Qt::Horizontal)
169 return QVariant(QString(
"#"));
172 return QVariant(QString(
"Name"));
175 return QVariant(QString(
"Trigger Expression"));
178 return QVariant(
"Delayed");
181 return QVariant(
"Delay Expression");
184 return QVariant(
"Assignment Target");
187 return QVariant(
"Assignment Expression");
194 return QString(
"%1").arg(section + 1);
200 if (index.isValid() && role == Qt::EditRole)
206 if (index.data() != value)
221 emit dataChanged(index, index);
230 beginInsertRows(QModelIndex(), position, position + rows - 1);
232 for (
int row = 0; row < rows; ++row)
249 beginRemoveRows(QModelIndex(), position, position + rows - 1);
253 std::vector< std::string > DeletedKeys;
254 DeletedKeys.resize(rows);
256 std::vector< std::string >::iterator itDeletedKey;
257 std::vector< std::string >::iterator endDeletedKey = DeletedKeys.end();
261 for (itDeletedKey = DeletedKeys.begin(); itDeletedKey != endDeletedKey; ++itDeletedKey, ++itRow)
263 *itDeletedKey = (*itRow)->getKey();
266 for (itDeletedKey = DeletedKeys.begin(); itDeletedKey != endDeletedKey; ++itDeletedKey)
284 assert(pDataModel != NULL);
292 QList <CEvent *> pEvents;
293 QModelIndexList::const_iterator i;
295 for (i = rows.begin(); i != rows.end(); ++i)
298 pEvents.append(pModel->
getEvents()[(*i).row()]);
301 QList <CEvent *>::const_iterator j;
303 for (j = pEvents.begin(); j != pEvents.end(); ++j)
308 pModel->
getEvents().CCopasiVector< CEvent >::getIndex(pEvent);
312 std::set< const CCopasiObject * > deletedObjects;
313 QMessageBox::StandardButton choice =
318 if (choice == QMessageBox::Ok)
#define COL_TRIGGER_EVENTS
const CCopasiVectorN< CEventAssignment > & getAssignments() const
virtual std::string getObjectDisplayName(bool regular=true, bool richtext=false) const
const bool & getDelayAssignment() const
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const
CCopasiVectorN< CEvent > & getEvents()
void notifyGUI(ListViews::ObjectType objectType, ListViews::Action action, const std::string &key="")
const std::string & getObjectName() const
CCopasiObject * get(const std::string &key)
#define COL_ASSIGNTARGET_EVENTS
const std::string & getDisplayString() const
std::string getTriggerExpression() const
#define COL_ASSIGNEXPRESSION_EVENTS
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
virtual int columnCount(const QModelIndex &parent=QModelIndex()) const
CExpression * getDelayExpressionPtr()
bool removeRow(int position)
bool insertRows(int position, int rows, const QModelIndex &index=QModelIndex())
static StandardButton confirmDelete(QWidget *parent, const QString &objectType, const QString &objects, const std::set< const CCopasiObject * > &deletedObjects)
static CCopasiVector< CCopasiDataModel > * getDatamodelList()
#define TOTAL_COLS_EVENTS
QString createNewName(const QString name, const int nameCol)
std::string getDelayExpression() const
const CExpression * getTriggerExpressionPtr() const
bool removeRows(QModelIndexList rows, const QModelIndex &index=QModelIndex())
static CKeyFactory * getKeyFactory()
QVariant data(const QModelIndex &index, int role) const
Qt::ItemFlags flags(const QModelIndex &index) const
virtual bool isDefaultRow(const QModelIndex &i) const
bool setObjectName(const std::string &name)
virtual const std::string & getKey() const
#define COL_DELAYED_EVENTS
CQEventDM(QObject *parent=0)
#define COL_DELAY_EXPRESSION_EVENTS