From bce31ab8621537441b42389801e20de56861438c Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Fri, 30 Aug 2019 15:25:59 +0200 Subject: Map: generate pixmap name in model Experimentation has shown that the image of a flag will only be changed after dataChanged() if it is a simple property. The old code had a complex QML expression and then - for some reason - it didn't work. To give us better control over the flags and avoid full reloads of the map therefore introduce a model-property pixmap name. The name depends on whether the site is selected and if not, whether we are in divesite-edit mode. This makes the code rather convoluted. Firstly, we have to save whether the site is selected in the map-item. Secondly we have to access the global map-widget, which in turn has to go to the map-widget helper (layering violation!). Signed-off-by: Berthold Stoeger --- desktop-widgets/mapwidget.cpp | 5 +++++ desktop-widgets/mapwidget.h | 1 + 2 files changed, 6 insertions(+) (limited to 'desktop-widgets') diff --git a/desktop-widgets/mapwidget.cpp b/desktop-widgets/mapwidget.cpp index 233b825eb..27c30686f 100644 --- a/desktop-widgets/mapwidget.cpp +++ b/desktop-widgets/mapwidget.cpp @@ -79,6 +79,11 @@ void MapWidget::reload() m_mapHelper->centerOnSelectedDiveSite(); } +bool MapWidget::editMode() const +{ + return isReady && m_mapHelper->editMode(); +} + void MapWidget::selectedDivesChanged(const QList &list) { CHECK_IS_READY_RETURN_VOID(); diff --git a/desktop-widgets/mapwidget.h b/desktop-widgets/mapwidget.h index c534c1bb3..bc9303166 100644 --- a/desktop-widgets/mapwidget.h +++ b/desktop-widgets/mapwidget.h @@ -23,6 +23,7 @@ public: static MapWidget *instance(); void reload(); + bool editMode() const; public slots: void centerOnDiveSite(struct dive_site *); -- cgit v1.2.3-70-g09d2