Cleanup: remove MapWidgetHelper::m_selectedDiveIds member

This member variable was only used locally in functions.
Accordingly, make it a function-local variable.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2019-05-02 22:41:24 +02:00 committed by Dirk Hohndel
parent 79f3000630
commit 48b8129137
4 changed files with 20 additions and 22 deletions

View file

@ -48,8 +48,7 @@ void MapWidget::doneLoading(QQuickWidget::Status status)
isReady = true; isReady = true;
m_rootItem = qobject_cast<QQuickItem *>(rootObject()); m_rootItem = qobject_cast<QQuickItem *>(rootObject());
m_mapHelper = rootObject()->findChild<MapWidgetHelper *>(); m_mapHelper = rootObject()->findChild<MapWidgetHelper *>();
connect(m_mapHelper, SIGNAL(selectedDivesChanged(QList<int>)), connect(m_mapHelper, &MapWidgetHelper::selectedDivesChanged, this, &MapWidget::selectedDivesChanged);
this, SLOT(selectedDivesChanged(QList<int>)));
connect(m_mapHelper, &MapWidgetHelper::coordinatesChanged, this, &MapWidget::coordinatesChanged); connect(m_mapHelper, &MapWidgetHelper::coordinatesChanged, this, &MapWidget::coordinatesChanged);
} }
@ -108,7 +107,7 @@ void MapWidget::prepareForGetDiveCoordinates(struct dive_site *ds)
skipReload = true; skipReload = true;
} }
void MapWidget::selectedDivesChanged(QList<int> list) void MapWidget::selectedDivesChanged(const QList<int> &list)
{ {
CHECK_IS_READY_RETURN_VOID(); CHECK_IS_READY_RETURN_VOID();
skipReload = true; skipReload = true;

View file

@ -31,7 +31,7 @@ public slots:
void endGetDiveCoordinates(); void endGetDiveCoordinates();
void repopulateLabels(); void repopulateLabels();
void prepareForGetDiveCoordinates(struct dive_site *ds); void prepareForGetDiveCoordinates(struct dive_site *ds);
void selectedDivesChanged(QList<int>); void selectedDivesChanged(const QList<int> &);
void coordinatesChanged(struct dive_site *ds, const location_t &); void coordinatesChanged(struct dive_site *ds, const location_t &);
void doneLoading(QQuickWidget::Status status); void doneLoading(QQuickWidget::Status status);
void diveSiteChanged(struct dive_site *ds, int field); void diveSiteChanged(struct dive_site *ds, int field);

View file

@ -110,7 +110,7 @@ void MapWidgetHelper::selectedLocationChanged(MapLocation *location)
{ {
int idx; int idx;
struct dive *dive; struct dive *dive;
m_selectedDiveIds.clear(); QList<int> selectedDiveIds;
QGeoCoordinate locationCoord = location->coordinate(); QGeoCoordinate locationCoord = location->coordinate();
for_each_dive (idx, dive) { for_each_dive (idx, dive) {
struct dive_site *ds = get_dive_site_for_dive(dive); struct dive_site *ds = get_dive_site_for_dive(dive);
@ -121,27 +121,27 @@ void MapWidgetHelper::selectedLocationChanged(MapLocation *location)
const qreal longitude = ds->location.lon.udeg * 0.000001; const qreal longitude = ds->location.lon.udeg * 0.000001;
QGeoCoordinate dsCoord(latitude, longitude); QGeoCoordinate dsCoord(latitude, longitude);
if (locationCoord.distanceTo(dsCoord) < m_smallCircleRadius) if (locationCoord.distanceTo(dsCoord) < m_smallCircleRadius)
m_selectedDiveIds.append(idx); selectedDiveIds.append(idx);
} }
#else // the mobile version doesn't support multi-dive selection #else // the mobile version doesn't support multi-dive selection
if (ds == location->divesite()) if (ds == location->divesite())
m_selectedDiveIds.append(dive->id); // use id here instead of index selectedDiveIds.append(dive->id); // use id here instead of index
} }
int last; // get latest dive chronologically int last; // get latest dive chronologically
if (!m_selectedDiveIds.isEmpty()) { if (!selectedDiveIds.isEmpty()) {
last = m_selectedDiveIds.last(); last = selectedDiveIds.last();
m_selectedDiveIds.clear(); selectedDiveIds.clear();
m_selectedDiveIds.append(last); selectedDiveIds.append(last);
} }
#endif #endif
emit selectedDivesChanged(m_selectedDiveIds); emit selectedDivesChanged(selectedDiveIds);
} }
void MapWidgetHelper::selectVisibleLocations() void MapWidgetHelper::selectVisibleLocations()
{ {
int idx; int idx;
struct dive *dive; struct dive *dive;
m_selectedDiveIds.clear(); QList<int> selectedDiveIds;
for_each_dive (idx, dive) { for_each_dive (idx, dive) {
struct dive_site *ds = get_dive_site_for_dive(dive); struct dive_site *ds = get_dive_site_for_dive(dive);
if (!dive_site_has_gps_location(ds)) if (!dive_site_has_gps_location(ds))
@ -154,19 +154,19 @@ void MapWidgetHelper::selectVisibleLocations()
Q_ARG(QGeoCoordinate, dsCoord)); Q_ARG(QGeoCoordinate, dsCoord));
if (!qIsNaN(point.x())) if (!qIsNaN(point.x()))
#ifndef SUBSURFACE_MOBILE // indexes on desktop #ifndef SUBSURFACE_MOBILE // indexes on desktop
m_selectedDiveIds.append(idx); selectedDiveIds.append(idx);
} }
#else // use id on mobile instead of index #else // use id on mobile instead of index
m_selectedDiveIds.append(dive->id); selectedDiveIds.append(dive->id);
} }
int last; // get latest dive chronologically int last; // get latest dive chronologically
if (!m_selectedDiveIds.isEmpty()) { if (!selectedDiveIds.isEmpty()) {
last = m_selectedDiveIds.last(); last = selectedDiveIds.last();
m_selectedDiveIds.clear(); selectedDiveIds.clear();
m_selectedDiveIds.append(last); selectedDiveIds.append(last);
} }
#endif #endif
emit selectedDivesChanged(m_selectedDiveIds); emit selectedDivesChanged(selectedDiveIds);
} }
/* /*

View file

@ -43,7 +43,6 @@ private:
QObject *m_map; QObject *m_map;
MapLocationModel *m_mapLocationModel; MapLocationModel *m_mapLocationModel;
qreal m_smallCircleRadius; qreal m_smallCircleRadius;
QList<int> m_selectedDiveIds;
bool m_editMode; bool m_editMode;
private slots: private slots:
@ -52,7 +51,7 @@ private slots:
signals: signals:
void modelChanged(); void modelChanged();
void editModeChanged(); void editModeChanged();
void selectedDivesChanged(QList<int> list); void selectedDivesChanged(const QList<int> &list);
void coordinatesChanged(struct dive_site *ds, const location_t &); void coordinatesChanged(struct dive_site *ds, const location_t &);
void pluginObjectChanged(); void pluginObjectChanged();
}; };