Added support for editable grid cells.

This commit is contained in:
2016-05-03 20:55:07 +02:00
parent 2ed7d7077b
commit 9db007b761
4 changed files with 48 additions and 0 deletions
+20
View File
@@ -83,6 +83,10 @@ public:
return Qt::AlignLeft;
}
if (role == Qt::EditRole)
{
return dispData;
}
return QVariant::Invalid;
}
@@ -208,6 +212,22 @@ private:
QList<QSharedPointer<T> > m_fullList;
bool filtered;
// QAbstractItemModel interface
public:
virtual bool setData(const QModelIndex &index, const QVariant &value, int role) override
{
if (role == Qt::EditRole)
{
QSharedPointer<T> entity = m_list.at(index.row());
QObject *rawEntity = (QObject*)entity.data();
rawEntity->setProperty(rawEntity->metaObject()->property(index.column() + 1).name(), value);
}
emit editCompleted();
return true;
}
};
#endif // ODBTABLEMODEL_H