mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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 <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
0fc82e3398
commit
1f669f9714
3 changed files with 15 additions and 1 deletions
|
@ -54,7 +54,7 @@ Kirigami.ScrollablePage {
|
||||||
} else {
|
} else {
|
||||||
manager.appendTextToLog("clicked on dive")
|
manager.appendTextToLog("clicked on dive")
|
||||||
if (detailsWindow.state === "view") {
|
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)
|
// switch to detailsWindow (or push it if it's not in the stack)
|
||||||
var i = rootItem.pageIndex(detailsWindow)
|
var i = rootItem.pageIndex(detailsWindow)
|
||||||
if (i === -1)
|
if (i === -1)
|
||||||
|
|
|
@ -365,6 +365,19 @@ void QMLManager::openLocalThenRemote(QString url)
|
||||||
updateAllGlobalLists();
|
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()
|
void QMLManager::updateSiteList()
|
||||||
{
|
{
|
||||||
LocationInformationModel::instance()->update();
|
LocationInformationModel::instance()->update();
|
||||||
|
|
|
@ -106,6 +106,7 @@ public:
|
||||||
Q_INVOKABLE int getConnectionIndex(const QString &deviceSubstr);
|
Q_INVOKABLE int getConnectionIndex(const QString &deviceSubstr);
|
||||||
Q_INVOKABLE void setGitLocalOnly(const bool &value);
|
Q_INVOKABLE void setGitLocalOnly(const bool &value);
|
||||||
Q_INVOKABLE void setFilter(const QString filterText, int mode);
|
Q_INVOKABLE void setFilter(const QString filterText, int mode);
|
||||||
|
Q_INVOKABLE void selectRow(int row);
|
||||||
|
|
||||||
static QMLManager *instance();
|
static QMLManager *instance();
|
||||||
Q_INVOKABLE void registerError(QString error);
|
Q_INVOKABLE void registerError(QString error);
|
||||||
|
|
Loading…
Add table
Reference in a new issue