From ab29f6416b619c141de979b82dde24cee4d5cb1b Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Wed, 24 Oct 2018 16:34:43 +0200 Subject: [PATCH] Dive site: replace UUID_ROLE by DIVESITE_ROLE Access to dive-sites in the LocationInformationModel was via UUID. Replace this by a direct access to the struct dive_site pointer. Accordingly, rename the UUID_ROLE to DIVESITE_ROLE. This is a small step in replacing dive-site UUIDs by pointers throughout the code base. Signed-off-by: Berthold Stoeger --- desktop-widgets/locationinformation.cpp | 2 +- qt-models/divelocationmodel.cpp | 4 ++-- qt-models/divelocationmodel.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/desktop-widgets/locationinformation.cpp b/desktop-widgets/locationinformation.cpp index e24da5f7f..acafcfe7b 100644 --- a/desktop-widgets/locationinformation.cpp +++ b/desktop-widgets/locationinformation.cpp @@ -84,7 +84,7 @@ void LocationInformationWidget::mergeSelectedDiveSites() std::vector selected_dive_sites; selected_dive_sites.reserve(selection.count()); Q_FOREACH (const QModelIndex &idx, selection) { - struct dive_site *ds = get_dive_site_by_uuid(idx.data(LocationInformationModel::UUID_ROLE).toUInt()); + struct dive_site *ds = (struct dive_site *)idx.data(LocationInformationModel::DIVESITE_ROLE).value(); if (ds) selected_dive_sites.push_back(ds); } diff --git a/qt-models/divelocationmodel.cpp b/qt-models/divelocationmodel.cpp index 43ab8eac7..c1a7308f4 100644 --- a/qt-models/divelocationmodel.cpp +++ b/qt-models/divelocationmodel.cpp @@ -59,8 +59,8 @@ QVariant LocationInformationModel::getDiveSiteData(const struct dive_site *ds, i else return QVariant(); } - case UUID_ROLE: - return ds->uuid; + case DIVESITE_ROLE: + return QVariant::fromValue((void *)ds); // Not nice: casting away const } return QVariant(); } diff --git a/qt-models/divelocationmodel.h b/qt-models/divelocationmodel.h index 14077609c..5f95d5975 100644 --- a/qt-models/divelocationmodel.h +++ b/qt-models/divelocationmodel.h @@ -16,7 +16,7 @@ public: // Common columns, roles and accessor function for all dive-site models. // Thus, different views can connect to different models. enum Columns { UUID, NAME, LATITUDE, LONGITUDE, COORDS, DESCRIPTION, NOTES, TAXONOMY_1, TAXONOMY_2, TAXONOMY_3, COLUMNS}; - enum Roles { UUID_ROLE = Qt::UserRole + 1 }; + enum Roles { DIVESITE_ROLE = Qt::UserRole + 1 }; static QVariant getDiveSiteData(const struct dive_site *ds, int column, int role); LocationInformationModel(QObject *obj = 0);