mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Map: reload on selection change directly
When changing the dive selection, we have to reload the map to show the correctly highlighted flags. Do this directly by hooking into the DiveListNotifier::divesChanged signal instead of indirectly via the MainTab. Moreover, on reload center on the highlighted dive sites. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
48b8129137
commit
d4a91a52fa
5 changed files with 12 additions and 12 deletions
|
@ -216,7 +216,6 @@ MainWindow::MainWindow() : QMainWindow(),
|
|||
connect(DivePlannerPointsModel::instance(), SIGNAL(planCanceled()), this, SLOT(planCanceled()));
|
||||
connect(DivePlannerPointsModel::instance(), SIGNAL(variationsComputed(QString)), this, SLOT(updateVariations(QString)));
|
||||
connect(plannerDetails->printPlan(), SIGNAL(pressed()), divePlannerWidget, SLOT(printDecoPlan()));
|
||||
connect(mainTab.get(), &MainTab::diveSiteChanged, mapWidget, &MapWidget::centerOnSelectedDiveSite);
|
||||
connect(this, &MainWindow::showError, ui.mainErrorMessage, &NotificationWidget::showError, Qt::AutoConnection);
|
||||
|
||||
connect(&windowTitleUpdate, &WindowTitleUpdate::updateTitle, this, &MainWindow::setAutomaticTitle);
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
#include "mapwidget.h"
|
||||
#include "core/divesite.h"
|
||||
#include "core/subsurface-qt/DiveListNotifier.h"
|
||||
#include "map-widget/qmlmapwidgethelper.h"
|
||||
#include "qt-models/maplocationmodel.h"
|
||||
#include "qt-models/divelocationmodel.h"
|
||||
|
@ -31,6 +30,7 @@ MapWidget::MapWidget(QWidget *parent) : QQuickWidget(parent)
|
|||
setResizeMode(QQuickWidget::SizeRootObjectToView);
|
||||
connect(this, &QQuickWidget::statusChanged, this, &MapWidget::doneLoading);
|
||||
connect(&diveListNotifier, &DiveListNotifier::diveSiteChanged, this, &MapWidget::diveSiteChanged);
|
||||
connect(&diveListNotifier, &DiveListNotifier::divesChanged, this, &MapWidget::divesChanged);
|
||||
setSource(urlMapWidget);
|
||||
}
|
||||
|
||||
|
@ -85,8 +85,10 @@ void MapWidget::repopulateLabels()
|
|||
void MapWidget::reload()
|
||||
{
|
||||
CHECK_IS_READY_RETURN_VOID();
|
||||
if (!skipReload)
|
||||
if (!skipReload) {
|
||||
m_mapHelper->reloadMapLocations();
|
||||
centerOnSelectedDiveSite();
|
||||
}
|
||||
}
|
||||
|
||||
void MapWidget::endGetDiveCoordinates()
|
||||
|
@ -129,6 +131,12 @@ void MapWidget::diveSiteChanged(struct dive_site *ds, int field)
|
|||
m_mapHelper->updateDiveSiteCoordinates(ds, ds->location);
|
||||
}
|
||||
|
||||
void MapWidget::divesChanged(dive_trip *, const QVector<dive *> &, DiveField field)
|
||||
{
|
||||
if (field == DiveField::DIVESITE)
|
||||
reload();
|
||||
}
|
||||
|
||||
MapWidget::~MapWidget()
|
||||
{
|
||||
m_instance = NULL;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#define MAPWIDGET_H
|
||||
|
||||
#include "core/units.h"
|
||||
#include "core/subsurface-qt/DiveListNotifier.h"
|
||||
#include <QQuickWidget>
|
||||
#include <QList>
|
||||
|
||||
|
@ -11,7 +12,6 @@
|
|||
class QResizeEvent;
|
||||
class QQuickItem;
|
||||
class MapWidgetHelper;
|
||||
struct dive_site;
|
||||
|
||||
class MapWidget : public QQuickWidget {
|
||||
|
||||
|
@ -35,6 +35,7 @@ public slots:
|
|||
void coordinatesChanged(struct dive_site *ds, const location_t &);
|
||||
void doneLoading(QQuickWidget::Status status);
|
||||
void diveSiteChanged(struct dive_site *ds, int field);
|
||||
void divesChanged(dive_trip *, const QVector<dive *> &, DiveField field);
|
||||
|
||||
private:
|
||||
static MapWidget *m_instance;
|
||||
|
|
|
@ -310,11 +310,6 @@ void MainTab::divesChanged(dive_trip *trip, const QVector<dive *> &dives, DiveFi
|
|||
break;
|
||||
case DiveField::DIVESITE:
|
||||
updateDiveSite(current_dive);
|
||||
// Since we only show dive sites with a dive, a new dive site may have appeared or an old one disappeared.
|
||||
// Therefore reload the map widget.
|
||||
// TODO: Call this only if a site *actually* went from usage count 0 to 1 or 1 to 0.
|
||||
MapWidget::instance()->repopulateLabels();
|
||||
emit diveSiteChanged();
|
||||
break;
|
||||
case DiveField::TAGS:
|
||||
ui.tagWidget->setText(get_taglist_string(current_dive->tag_list));
|
||||
|
@ -593,7 +588,6 @@ void MainTab::updateDiveInfo()
|
|||
|
||||
if (verbose && current_dive && current_dive->dive_site)
|
||||
qDebug() << "Set the current dive site:" << current_dive->dive_site->uuid;
|
||||
emit diveSiteChanged();
|
||||
}
|
||||
|
||||
void MainTab::reload()
|
||||
|
|
|
@ -44,8 +44,6 @@ public:
|
|||
void nextInputField(QKeyEvent *event);
|
||||
void stealFocus();
|
||||
|
||||
signals:
|
||||
void diveSiteChanged();
|
||||
public
|
||||
slots:
|
||||
void divesChanged(dive_trip *trip, const QVector<dive *> &dives, DiveField field);
|
||||
|
|
Loading…
Reference in a new issue