src/RelpipeTableModel.h
branchv_0
changeset 25 da2e3739b197
parent 24 75f8fd148f06
child 26 97847181b724
equal deleted inserted replaced
24:75f8fd148f06 25:da2e3739b197
    19 	Q_OBJECT
    19 	Q_OBJECT
    20 private:
    20 private:
    21 	std::vector<AttributeMetadata> attributes;
    21 	std::vector<AttributeMetadata> attributes;
    22 	QList<QVector<QVariant> * > records;
    22 	QList<QVector<QVariant> * > records;
    23 	int attributeCounter = 0;
    23 	int attributeCounter = 0;
       
    24 
       
    25 	/**
       
    26 	 * @param index
       
    27 	 * @return whether data at this row/clumn are already loaded (last row might contain columns that are still waiting to be filled)
       
    28 	 */
       
    29 	boolean_t isFilled(const QModelIndex &index) const {
       
    30 		return (index.row() * columnCount() + index.column()) <= attributeCounter;
       
    31 	}
    24 public:
    32 public:
    25 
    33 
    26 	RelpipeTableModel(std::vector<AttributeMetadata> attributes, QObject *parent = 0) : QAbstractTableModel(parent), attributes(attributes) {
    34 	RelpipeTableModel(std::vector<AttributeMetadata> attributes, QObject *parent = 0) : QAbstractTableModel(parent), attributes(attributes) {
    27 	}
    35 	}
    28 
    36 
    68 		if (column == 0) emit layoutChanged(); // FIXME: emit other signal ~ begin..., end..., rowsInserted(???  index(0,0), row, row);
    76 		if (column == 0) emit layoutChanged(); // FIXME: emit other signal ~ begin..., end..., rowsInserted(???  index(0,0), row, row);
    69 		attributeCounter++;
    77 		attributeCounter++;
    70 	}
    78 	}
    71 
    79 
    72 	Qt::ItemFlags flags(const QModelIndex &index) const {
    80 	Qt::ItemFlags flags(const QModelIndex &index) const {
    73 		// TODO: not editable if not yet filled with data
    81 		if (isFilled(index)) {
    74 		return QAbstractItemModel::flags(index) | Qt::ItemFlag::ItemIsEditable;
    82 			return QAbstractItemModel::flags(index) | Qt::ItemFlag::ItemIsEditable;
       
    83 		} else {
       
    84 			return QAbstractItemModel::flags(index);
       
    85 		}
    75 	}
    86 	}
    76 
    87 
    77 };
    88 };