diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-08-15 00:15:30 +0200 |
---|---|---|
committer | bstoeger <32835590+bstoeger@users.noreply.github.com> | 2019-09-14 13:20:59 +0200 |
commit | bf081866e9a15a8e9bdee46cbdf3058fcdab3450 (patch) | |
tree | 3a278686caadecc494d411dc9e8b483592332650 | |
parent | c6b3309d1360e329252f5ab4c9dc7f345ea22694 (diff) | |
download | subsurface-bf081866e9a15a8e9bdee46cbdf3058fcdab3450.tar.gz |
Mobile: return dive-id directly from DiveListModel
We don't want to generate a DiveObjectHelper numerous times for
every item in the dive list. Therefore, return this datum directly
from the model. In this case, don't remove from DiveObjectHelper,
as this datum might be used by grantlee templates.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
-rw-r--r-- | mobile-widgets/qml/DiveList.qml | 8 | ||||
-rw-r--r-- | qt-models/divelistmodel.cpp | 2 | ||||
-rw-r--r-- | qt-models/divelistmodel.h | 3 |
3 files changed, 8 insertions, 5 deletions
diff --git a/mobile-widgets/qml/DiveList.qml b/mobile-widgets/qml/DiveList.qml index ddcb81834..7d887368a 100644 --- a/mobile-widgets/qml/DiveList.qml +++ b/mobile-widgets/qml/DiveList.qml @@ -229,11 +229,11 @@ Kirigami.ScrollablePage { copyButtonVisible = false pasteButtonVisible = false timer.stop() - manager.copyDiveData(dive.id) + manager.copyDiveData(id) } onPressAndHold: { globalDrawer.close() - manager.copyDiveData(dive.id) + manager.copyDiveData(id) pageStack.push(settingsCopyWindow) } } @@ -270,7 +270,7 @@ Kirigami.ScrollablePage { copyButtonVisible = false pasteButtonVisible = false timer.stop() - manager.pasteDiveData(dive.id) + manager.pasteDiveData(id) } } } @@ -307,7 +307,7 @@ Kirigami.ScrollablePage { copyButtonVisible = false pasteButtonVisible = false timer.stop() - manager.deleteDive(dive.id) + manager.deleteDive(id) } } } diff --git a/qt-models/divelistmodel.cpp b/qt-models/divelistmodel.cpp index b41a16003..ba2a7a407 100644 --- a/qt-models/divelistmodel.cpp +++ b/qt-models/divelistmodel.cpp @@ -254,6 +254,7 @@ QVariant DiveListModel::data(const QModelIndex &index, int role) const return QStringLiteral("%1 %2").arg(localTime.date().toString(prefs.date_format_short), localTime.time().toString(prefs.time_format)); } + case IdRole: return d->id; } return QVariant(); } @@ -266,6 +267,7 @@ QHash<int, QByteArray> DiveListModel::roleNames() const roles[TripIdRole] = "tripId"; roles[TripNrDivesRole] = "tripNrDives"; roles[DateTimeRole] = "dateTime"; + roles[IdRole] = "id"; return roles; } diff --git a/qt-models/divelistmodel.h b/qt-models/divelistmodel.h index c0d7aa0a0..9b39e5513 100644 --- a/qt-models/divelistmodel.h +++ b/qt-models/divelistmodel.h @@ -40,7 +40,8 @@ public: DiveDateRole, TripIdRole, TripNrDivesRole, - DateTimeRole + DateTimeRole, + IdRole }; static DiveListModel *instance(); |