summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mobile-widgets/qml/DiveList.qml2
-rw-r--r--mobile-widgets/qmlmanager.cpp13
-rw-r--r--mobile-widgets/qmlmanager.h1
3 files changed, 15 insertions, 1 deletions
diff --git a/mobile-widgets/qml/DiveList.qml b/mobile-widgets/qml/DiveList.qml
index 0aa3772e7..94289c6b7 100644
--- a/mobile-widgets/qml/DiveList.qml
+++ b/mobile-widgets/qml/DiveList.qml
@@ -54,7 +54,7 @@ Kirigami.ScrollablePage {
} else {
manager.appendTextToLog("clicked on dive")
if (detailsWindow.state === "view") {
- detailsWindow.showDiveIndex(id); // we need access to dive->id
+ manager.selectRow(model.row);
// switch to detailsWindow (or push it if it's not in the stack)
var i = rootItem.pageIndex(detailsWindow)
if (i === -1)
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp
index 3cc8ed0c5..06267d590 100644
--- a/mobile-widgets/qmlmanager.cpp
+++ b/mobile-widgets/qmlmanager.cpp
@@ -365,6 +365,19 @@ void QMLManager::openLocalThenRemote(QString url)
updateAllGlobalLists();
}
+// Convenience function to accesss dive directly via its row.
+static struct dive *diveInRow(const QAbstractItemModel *model, int row)
+{
+ QModelIndex index = model->index(row, 0, QModelIndex());
+ return index.isValid() ? model->data(index, DiveTripModelBase::DIVE_ROLE).value<struct dive *>() : nullptr;
+}
+
+void QMLManager::selectRow(int row)
+{
+ dive *d = diveInRow(MobileListModel::instance(), row);
+ select_single_dive(d);
+}
+
void QMLManager::updateSiteList()
{
LocationInformationModel::instance()->update();
diff --git a/mobile-widgets/qmlmanager.h b/mobile-widgets/qmlmanager.h
index 367faf325..482ba7ecc 100644
--- a/mobile-widgets/qmlmanager.h
+++ b/mobile-widgets/qmlmanager.h
@@ -106,6 +106,7 @@ public:
Q_INVOKABLE int getConnectionIndex(const QString &deviceSubstr);
Q_INVOKABLE void setGitLocalOnly(const bool &value);
Q_INVOKABLE void setFilter(const QString filterText, int mode);
+ Q_INVOKABLE void selectRow(int row);
static QMLManager *instance();
Q_INVOKABLE void registerError(QString error);