From 797bf49129769842b5ca872e5efe40b4a575d1d5 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 8 Jan 2015 10:55:38 -0200 Subject: Dive d/l selection UI: Add the setData method Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/downloadfromdivecomputer.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'qt-ui/downloadfromdivecomputer.cpp') diff --git a/qt-ui/downloadfromdivecomputer.cpp b/qt-ui/downloadfromdivecomputer.cpp index 91e38ae36..a7363c4ed 100644 --- a/qt-ui/downloadfromdivecomputer.cpp +++ b/qt-ui/downloadfromdivecomputer.cpp @@ -539,6 +539,21 @@ QVariant DiveImportedModel::data(const QModelIndex& index, int role) const return QVariant(); } +bool DiveImportedModel::setData(const QModelIndex &index, const QVariant &value, int role) +{ + if (!index.isValid()) + return false; + + if (index.row() + firstIndex > lastIndex) + return false; + + if (role != Qt::CheckStateRole) + return false; + + checkStates[index.row() + firstIndex ] = value.toBool(); + dataChanged(index, index, QVector() << Qt::CheckStateRole); +} + void DiveImportedModel::setImportedDivesIndexes(int first, int last) { beginRemoveRows(QModelIndex(), 0, lastIndex - firstIndex); -- cgit v1.2.3-70-g09d2