src/RelpipeTableModel.h
branchv_0
changeset 25 da2e3739b197
parent 24 75f8fd148f06
child 26 97847181b724
--- 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);
+		}
 	}
 
 };