From de2c4d93e02f2568be30c3b02fa1e4933c3b143b Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 3 Sep 2022 23:00:03 +0200 Subject: [PATCH] map: fold selectionChanged() into setSelection() This was very weird: a setSelection() call was always followed by a selectionChanged() call, though sometimes in convoluted ways. Notably, the formed was called by the DiveListView, the lattern then by the MainWindow. Let's just merge these two functions. Signed-off-by: Berthold Stoeger --- core/divefilter.cpp | 1 - desktop-widgets/mainwindow.cpp | 3 --- desktop-widgets/mapwidget.cpp | 6 ------ desktop-widgets/mapwidget.h | 1 - map-widget/qmlmapwidgethelper.cpp | 8 ++------ map-widget/qmlmapwidgethelper.h | 1 - 6 files changed, 2 insertions(+), 18 deletions(-) diff --git a/core/divefilter.cpp b/core/divefilter.cpp index 2c72c1ac9..62ad820c9 100644 --- a/core/divefilter.cpp +++ b/core/divefilter.cpp @@ -181,7 +181,6 @@ void DiveFilter::setFilterDiveSite(QVector ds) emit diveListNotifier.filterReset(); #ifdef MAP_SUPPORT MapWidget::instance()->setSelected(dive_sites); - MapWidget::instance()->selectionChanged(); #endif MainWindow::instance()->diveList->expandAll(); } diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index d94739653..5924d4fa1 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -337,9 +337,6 @@ void MainWindow::divesSelected(const std::vector &selection, dive *curre if (currentDive) enableDisableOtherDCsActions(); profile->plotCurrentDive(); -#ifdef MAP_SUPPORT - MapWidget::instance()->selectionChanged(); -#endif } void MainWindow::on_actionNew_triggered() diff --git a/desktop-widgets/mapwidget.cpp b/desktop-widgets/mapwidget.cpp index 4c8757f50..8fac1a041 100644 --- a/desktop-widgets/mapwidget.cpp +++ b/desktop-widgets/mapwidget.cpp @@ -83,12 +83,6 @@ void MapWidget::setSelected(const QVector &divesites) { CHECK_IS_READY_RETURN_VOID(); m_mapHelper->setSelected(divesites); -} - -void MapWidget::selectionChanged() -{ - CHECK_IS_READY_RETURN_VOID(); - m_mapHelper->selectionChanged(); m_mapHelper->centerOnSelectedDiveSite(); } diff --git a/desktop-widgets/mapwidget.h b/desktop-widgets/mapwidget.h index 74ff0c8c0..123b7ad52 100644 --- a/desktop-widgets/mapwidget.h +++ b/desktop-widgets/mapwidget.h @@ -23,7 +23,6 @@ public: static MapWidget *instance(); void reload(); - void selectionChanged(); void setSelected(const QVector &divesites); bool editMode() const; diff --git a/map-widget/qmlmapwidgethelper.cpp b/map-widget/qmlmapwidgethelper.cpp index f6a0bb64b..e5c4ed9b5 100644 --- a/map-widget/qmlmapwidgethelper.cpp +++ b/map-widget/qmlmapwidgethelper.cpp @@ -49,6 +49,8 @@ void MapWidgetHelper::centerOnDiveSite(struct dive_site *ds) void MapWidgetHelper::setSelected(const QVector &divesites) { m_mapLocationModel->setSelected(divesites); + m_mapLocationModel->selectionChanged(); + updateEditMode(); } void MapWidgetHelper::centerOnSelectedDiveSite() @@ -118,12 +120,6 @@ void MapWidgetHelper::reloadMapLocations() m_mapLocationModel->reload(m_map); } -void MapWidgetHelper::selectionChanged() -{ - updateEditMode(); - m_mapLocationModel->selectionChanged(); -} - void MapWidgetHelper::selectedLocationChanged(struct dive_site *ds_in) { int idx; diff --git a/map-widget/qmlmapwidgethelper.h b/map-widget/qmlmapwidgethelper.h index e093ffa54..9aa1d8723 100644 --- a/map-widget/qmlmapwidgethelper.h +++ b/map-widget/qmlmapwidgethelper.h @@ -36,7 +36,6 @@ public: Q_INVOKABLE void updateCurrentDiveSiteCoordinatesFromMap(struct dive_site *ds, QGeoCoordinate coord); Q_INVOKABLE void selectVisibleLocations(); Q_INVOKABLE void selectedLocationChanged(struct dive_site *ds); - void selectionChanged(); void setSelected(const QVector &divesites); QString pluginObject(); bool editMode() const;