mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
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>
This commit is contained in:
parent
eccbf01a22
commit
75ef8b68a1
1 changed files with 10 additions and 3 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue