# HG changeset patch # User František Kučera # Date 1539120125 -7200 # Node ID da2e3739b19715a5ab66039c73e1655e69789a7d # Parent 75f8fd148f065418ed07b3d8881981161e1b4c70 table cells are not editable if not yet loaded diff -r 75f8fd148f06 -r da2e3739b197 src/RelpipeTableModel.h --- a/src/RelpipeTableModel.h Tue Oct 09 23:10:00 2018 +0200 +++ b/src/RelpipeTableModel.h Tue Oct 09 23:22:05 2018 +0200 @@ -21,6 +21,14 @@ std::vector attributes; QList * > records; int attributeCounter = 0; + + /** + * @param index + * @return whether data at this row/clumn are already loaded (last row might contain columns that are still waiting to be filled) + */ + boolean_t isFilled(const QModelIndex &index) const { + return (index.row() * columnCount() + index.column()) <= attributeCounter; + } public: RelpipeTableModel(std::vector attributes, QObject *parent = 0) : QAbstractTableModel(parent), attributes(attributes) { @@ -70,8 +78,11 @@ } Qt::ItemFlags flags(const QModelIndex &index) const { - // TODO: not editable if not yet filled with data - return QAbstractItemModel::flags(index) | Qt::ItemFlag::ItemIsEditable; + if (isFilled(index)) { + return QAbstractItemModel::flags(index) | Qt::ItemFlag::ItemIsEditable; + } else { + return QAbstractItemModel::flags(index); + } } };