summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-04-25 20:54:12 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-04-25 13:20:25 -0700
commit75ef8b68a1d5147ab15fd63b227bed0aa92940b1 (patch)
tree9207b97cc63e04c3facc7c9445ce296b762b2253
parenteccbf01a223965d89dcbeb6f763d85b18038bd0e (diff)
downloadsubsurface-75ef8b68a1d5147ab15fd63b227bed0aa92940b1.tar.gz
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 <bstoeger@mail.tuwien.ac.at>
-rw-r--r--desktop-widgets/mapwidget.cpp13
1 files changed, 10 insertions, 3 deletions
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<int> &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<dive *> 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)