From 75ef8b68a1d5147ab15fd63b227bed0aa92940b1 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 25 Apr 2020 20:54:12 +0200 Subject: map: call set_selection() core function to select dives The map widget called the dive list to select dives. This is inconsistent and complex. The dive list has to call down to the core anyway. Therefore, change the code to call the common core function. This means that we have to transform integer ids into dive-pointers. That is a bit sad, because the dives were just transformed into indices. Let's address that in a future commit. Signed-off-by: Berthold Stoeger --- desktop-widgets/mapwidget.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'desktop-widgets') diff --git a/desktop-widgets/mapwidget.cpp b/desktop-widgets/mapwidget.cpp index 07d440530..0e04ae282 100644 --- a/desktop-widgets/mapwidget.cpp +++ b/desktop-widgets/mapwidget.cpp @@ -6,11 +6,10 @@ #include "mapwidget.h" #include "core/divesite.h" +#include "core/selection.h" #include "map-widget/qmlmapwidgethelper.h" #include "qt-models/maplocationmodel.h" #include "qt-models/divelocationmodel.h" -#include "mainwindow.h" -#include "divelistview.h" #include "commands/command.h" static const QUrl urlMapWidget = QUrl(QStringLiteral("qrc:/qml/MapWidget.qml")); @@ -94,7 +93,15 @@ void MapWidget::selectionChanged() void MapWidget::selectedDivesChanged(const QList &list) { CHECK_IS_READY_RETURN_VOID(); - MainWindow::instance()->diveList->selectDives(list); + // We get a list of dive indices, but the selection code wants a list of dives. + // Therefore, transform them here. + std::vector selection; + selection.reserve(list.size()); + for (int idx: list) { + if (dive *d = get_dive(idx)) + selection.push_back(d); + } + setSelection(selection, current_dive); } void MapWidget::coordinatesChanged(struct dive_site *ds, const location_t &location) -- cgit v1.2.3-70-g09d2