--- 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<AttributeMetadata> attributes;
QList<QVector<QVariant> * > 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<AttributeMetadata> 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);
+ }
}
};