summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--desktop-widgets/mainwindow.cpp2
-rw-r--r--desktop-widgets/mapwidget.cpp7
-rw-r--r--desktop-widgets/mapwidget.h1
-rw-r--r--map-widget/qmlmapwidgethelper.cpp5
-rw-r--r--map-widget/qmlmapwidgethelper.h1
-rw-r--r--qt-models/maplocationmodel.cpp9
-rw-r--r--qt-models/maplocationmodel.h1
7 files changed, 25 insertions, 1 deletions
diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp
index 2a215b1b7..004d5823d 100644
--- a/desktop-widgets/mainwindow.cpp
+++ b/desktop-widgets/mainwindow.cpp
@@ -464,7 +464,7 @@ void MainWindow::selectionChanged()
configureToolbar();
enableDisableOtherDCsActions();
}
- MapWidget::instance()->reload();
+ MapWidget::instance()->selectionChanged();
}
void MainWindow::on_actionNew_triggered()
diff --git a/desktop-widgets/mapwidget.cpp b/desktop-widgets/mapwidget.cpp
index 27c30686f..376a29998 100644
--- a/desktop-widgets/mapwidget.cpp
+++ b/desktop-widgets/mapwidget.cpp
@@ -84,6 +84,13 @@ bool MapWidget::editMode() const
return isReady && m_mapHelper->editMode();
}
+void MapWidget::selectionChanged()
+{
+ CHECK_IS_READY_RETURN_VOID();
+ m_mapHelper->selectionChanged();
+ m_mapHelper->centerOnSelectedDiveSite();
+}
+
void MapWidget::selectedDivesChanged(const QList<int> &list)
{
CHECK_IS_READY_RETURN_VOID();
diff --git a/desktop-widgets/mapwidget.h b/desktop-widgets/mapwidget.h
index bc9303166..9e05ce48f 100644
--- a/desktop-widgets/mapwidget.h
+++ b/desktop-widgets/mapwidget.h
@@ -23,6 +23,7 @@ public:
static MapWidget *instance();
void reload();
+ void selectionChanged();
bool editMode() const;
public slots:
diff --git a/map-widget/qmlmapwidgethelper.cpp b/map-widget/qmlmapwidgethelper.cpp
index feaccdbef..02bfa78a2 100644
--- a/map-widget/qmlmapwidgethelper.cpp
+++ b/map-widget/qmlmapwidgethelper.cpp
@@ -113,6 +113,11 @@ void MapWidgetHelper::reloadMapLocations()
m_mapLocationModel->reload(m_map);
}
+void MapWidgetHelper::selectionChanged()
+{
+ 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 af469193e..046cb4ce1 100644
--- a/map-widget/qmlmapwidgethelper.h
+++ b/map-widget/qmlmapwidgethelper.h
@@ -36,6 +36,7 @@ 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();
QString pluginObject();
bool editMode() const;
diff --git a/qt-models/maplocationmodel.cpp b/qt-models/maplocationmodel.cpp
index 0fe86f596..ea7d4f098 100644
--- a/qt-models/maplocationmodel.cpp
+++ b/qt-models/maplocationmodel.cpp
@@ -150,6 +150,15 @@ static bool hasSelectedDive(const dive_site *ds)
[] (const dive *d) { return d->selected; });
}
+void MapLocationModel::selectionChanged()
+{
+ if (m_mapLocations.isEmpty())
+ return;
+ for(MapLocation *m: m_mapLocations)
+ m->m_selected = m_selectedDs.contains(m->divesite());
+ emit dataChanged(createIndex(0, 0), createIndex(m_mapLocations.size() - 1, 0));
+}
+
void MapLocationModel::reload(QObject *map)
{
beginResetModel();
diff --git a/qt-models/maplocationmodel.h b/qt-models/maplocationmodel.h
index 8cec08818..25ae159bd 100644
--- a/qt-models/maplocationmodel.h
+++ b/qt-models/maplocationmodel.h
@@ -67,6 +67,7 @@ public:
void add(MapLocation *);
// If map is not null, it will be used to place new dive sites without GPS location at the center of the map
void reload(QObject *map);
+ void selectionChanged();
MapLocation *getMapLocation(const struct dive_site *ds);
const QVector<dive_site *> &selectedDs() const;
Q_INVOKABLE void setSelected(struct dive_site *ds);