summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2017-05-29 20:36:00 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-05-29 12:01:02 -0700
commit52e07a63065a8207da6ebf81be6c9c1b9c901d4a (patch)
tree113e38e70d6462d6748b758ad24ae37779cb09d4
parent1de1a85e32176bf4d4bcd63d69b5cb83ff1cdc2d (diff)
downloadsubsurface-52e07a63065a8207da6ebf81be6c9c1b9c901d4a.tar.gz
QML UI: select / unselect dive by clicking on it
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--mobile-widgets/qml/DownloadFromDiveComputer.qml19
-rw-r--r--qt-models/diveimportedmodel.cpp9
-rw-r--r--qt-models/diveimportedmodel.h1
3 files changed, 27 insertions, 2 deletions
diff --git a/mobile-widgets/qml/DownloadFromDiveComputer.qml b/mobile-widgets/qml/DownloadFromDiveComputer.qml
index e17032dd9..1e93fc3ea 100644
--- a/mobile-widgets/qml/DownloadFromDiveComputer.qml
+++ b/mobile-widgets/qml/DownloadFromDiveComputer.qml
@@ -15,6 +15,8 @@ Kirigami.Page {
Layout.fillWidth: true;
title: qsTr("Dive Computer")
+ property bool selectAll : false
+
DCDownloadThread {
id: downloadThread
deviceData.vendor : comboVendor.currentText
@@ -99,9 +101,17 @@ Kirigami.Page {
model : importModel
delegate : DownloadedDiveDelegate {
+ id: delegate
datetime: model.datetime
duration: model.duration
depth: model.depth
+
+ backgroundColor: selectAll ? Kirigami.Theme.highlightColor : Kirigami.Theme.viewBackgroundColor
+
+ onClicked : {
+ console.log("Selecting index" + index);
+ importModel.selectRow(index)
+ }
}
}
@@ -126,10 +136,17 @@ Kirigami.Page {
}
Button {
text: qsTr("Select All")
+ onClicked : {
+ selectAll = true
+ importModel.selectAll()
+ }
}
Button {
- id: unselectbutton
text: qsTr("Unselect All")
+ onClicked : {
+ selectAll = false
+ importModel.selectNone()
+ }
}
}
}
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<int>() << 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<int, QByteArray> DiveImportedModel::roleNames() const {
static QHash<int, QByteArray> 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();