From 1f669f9714ec87657eb276dc538822d8abbe77a5 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Fri, 6 Dec 2019 14:14:00 +0100 Subject: mobile/divelist: when clicking on a row, use select_single_dive() This is a small step in unifying mobile and desktop. I'm unsure whether it is correct to play this via the QMLManager or whether we should call form QML directly into the model? Signed-off-by: Berthold Stoeger Signed-off-by: Dirk Hohndel --- mobile-widgets/qmlmanager.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'mobile-widgets/qmlmanager.cpp') 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() : nullptr; +} + +void QMLManager::selectRow(int row) +{ + dive *d = diveInRow(MobileListModel::instance(), row); + select_single_dive(d); +} + void QMLManager::updateSiteList() { LocationInformationModel::instance()->update(); -- cgit v1.2.3-70-g09d2