From b9b1b3146b3a0a05efcb11c50a953f3e8f2e023c Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Thu, 25 Oct 2018 08:02:06 +0200 Subject: Dive site: remove UUIDs from LocationInformationModel Replace UUIDs from LocationInformationModel and fix the fallout. Notably, replace the UUID "column" by a DIVESITE "column". Getting pointers through Qt's QVariant is horrible, we'll have to think about a better solution. RECENTLY_ADDED_DIVESITE now defines to a special pointer to struct dive_site (defined as ~0). This fixes an interesting logic bug: The old code checked the uuid of the LocationInformationModel (currUuid) for the value "1", which corresponded to RECENTLY_ADDED_DIVESITE. If equal, currType would be set to NEW_DIVE_SITE. Later, _currType_ was compared against _RECENTLY_ADDED_DIVESITE_. This would only work because NEW_DIVE_SITE and RECENTLY_ADDED_DIVESITE both were defined as 1. Signed-off-by: Berthold Stoeger --- desktop-widgets/mapwidget.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'desktop-widgets/mapwidget.cpp') diff --git a/desktop-widgets/mapwidget.cpp b/desktop-widgets/mapwidget.cpp index 095565618..db92e2298 100644 --- a/desktop-widgets/mapwidget.cpp +++ b/desktop-widgets/mapwidget.cpp @@ -8,6 +8,7 @@ #include "core/divesite.h" #include "map-widget/qmlmapwidgethelper.h" #include "qt-models/maplocationmodel.h" +#include "qt-models/divelocationmodel.h" #include "mainwindow.h" #include "divelistview.h" @@ -66,8 +67,8 @@ void MapWidget::centerOnDiveSite(struct dive_site *ds) void MapWidget::centerOnIndex(const QModelIndex& idx) { CHECK_IS_READY_RETURN_VOID(); - struct dive_site *ds = get_dive_site_by_uuid(idx.model()->index(idx.row(), 0).data().toUInt()); - if (!ds || !dive_site_has_gps_location(ds)) + struct dive_site *ds = (struct dive_site *)idx.model()->index(idx.row(), LocationInformationModel::DIVESITE).data().value(); + if (!ds || ds == RECENTLY_ADDED_DIVESITE || !dive_site_has_gps_location(ds)) centerOnSelectedDiveSite(); else centerOnDiveSite(ds); -- cgit v1.2.3-70-g09d2