6 #include <QtCore/QString>
44 return QAbstractItemModel::flags(index);
46 switch (index.column())
49 return QAbstractItemModel::flags(index) & ~Qt::ItemIsEditable;
53 return QAbstractItemModel::flags(index) & ~Qt::ItemIsEditable;
57 return QAbstractItemModel::flags(index) | Qt::ItemIsEditable | Qt::ItemIsEnabled;
61 return QAbstractItemModel::flags(index);
68 if (!index.isValid())
return QVariant();
70 if (index.row() >=
rowCount())
return QVariant();
72 if (role == Qt::DisplayRole || role == Qt::EditRole)
74 switch (index.column())
77 return QVariant(index.row() + 1);
85 return (role == Qt::EditRole) ? QVariant(
"Show") : QVariant();
96 if (role != Qt::DisplayRole)
99 if (orientation == Qt::Horizontal)
104 return QVariant(QString(
"#"));
108 return QVariant(QString(
"Name"));
112 return QVariant(
"Show");
121 return QString(
"%1").arg(section + 1);
128 if (!index.isValid())
return false;
130 if (index.row() >=
rowCount())
return false;
132 if (index.isValid() && role == Qt::EditRole)
134 switch (index.column())
169 beginInsertRows(QModelIndex(), position, position + rows - 1);
171 for (
int row = 0; row < rows; ++row)
183 if (rows <= 0)
return true;
187 beginRemoveRows(QModelIndex(), position, position + rows - 1);
189 std::vector< CLayout * > DeletedLayouts;
190 DeletedLayouts.resize(rows);
192 std::vector< CLayout * >::iterator itDeletedLayout;
193 std::vector< CLayout * >::iterator endDeletedLayout = DeletedLayouts.end();
197 for (itDeletedLayout = DeletedLayouts.begin(); itDeletedLayout != endDeletedLayout; ++itDeletedLayout, ++itRow)
199 *itDeletedLayout = *itRow;
202 for (itDeletedLayout = DeletedLayouts.begin(); itDeletedLayout != endDeletedLayout; ++itDeletedLayout)
204 std::string Key = (*itDeletedLayout)->getKey();
218 if (rows.isEmpty())
return false;
224 QList< CLayout * > Layouts;
225 QModelIndexList::const_iterator i;
227 for (i = rows.begin(); i != rows.end(); ++i)
232 QList< CLayout * >::const_iterator j;
234 for (j = Layouts.begin(); j != Layouts.end(); ++j)
242 QMessageBox::StandardButton choice =
245 std::set< const CCopasiObject * >());
247 if (choice == QMessageBox::Ok)
bool removeRows(QModelIndexList rows, const QModelIndex &index=QModelIndex())
virtual int columnCount(const QModelIndex &parent=QModelIndex()) 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
virtual size_t size() const
CListOfLayouts * mpListOfLayouts
CQLayoutsDM(QObject *parent=0)
virtual bool isDefaultRow(const QModelIndex &i) const
virtual Qt::ItemFlags flags(const QModelIndex &index) const
virtual bool insertRows(int position, int rows, const QModelIndex &index=QModelIndex())
bool removeRow(int position)
std::vector< CType * >::const_iterator const_iterator
virtual QVariant data(const QModelIndex &index, int role) const
static StandardButton confirmDelete(QWidget *parent, const QString &objectType, const QString &objects, const std::set< const CCopasiObject * > &deletedObjects)
virtual size_t getIndex(const CCopasiObject *pObject) const
virtual QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
void setListOfLayouts(CListOfLayouts *pListOfLayouts)
virtual bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)