From 52e07a63065a8207da6ebf81be6c9c1b9c901d4a Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Mon, 29 May 2017 20:36:00 +0200 Subject: QML UI: select / unselect dive by clicking on it Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-models/diveimportedmodel.cpp | 9 ++++++++- qt-models/diveimportedmodel.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'qt-models') diff --git a/qt-models/diveimportedmodel.cpp b/qt-models/diveimportedmodel.cpp index be25d6a2a..eeb564fc8 100644 --- a/qt-models/diveimportedmodel.cpp +++ b/qt-models/diveimportedmodel.cpp @@ -101,6 +101,12 @@ void DiveImportedModel::selectAll() dataChanged(index(0, 0), index(lastIndex - firstIndex, 0), QVector() << Qt::CheckStateRole); } +void DiveImportedModel::selectRow(int row) +{ + checkStates[row] = !checkStates[row]; + dataChanged(index(row, 0), index(row, 0)); +} + void DiveImportedModel::selectNone() { memset(checkStates, false, lastIndex - firstIndex + 1); @@ -169,6 +175,7 @@ QHash DiveImportedModel::roleNames() const { static QHash roles = { { DateTime, "datetime"}, { Depth, "depth"}, - { Duration, "duration"}}; + { Duration, "duration"}, + }; return roles; } diff --git a/qt-models/diveimportedmodel.h b/qt-models/diveimportedmodel.h index 240f7f4b5..21674480d 100644 --- a/qt-models/diveimportedmodel.h +++ b/qt-models/diveimportedmodel.h @@ -25,6 +25,7 @@ public: public slots: void changeSelected(QModelIndex clickedIndex); + void selectRow(int row); void selectAll(); void selectNone(); -- cgit v1.2.3-70-g09d2