Dive site: Pass dive-site pointer to MapWidgetHelper::enterEditMode()

Replace the uuid argument to MapWidgetHelper::enterEditMode() by a
pointer. Likewise, adapt the only caller prepareForGetDiveCoordinates().
This is a small step in a bigger effort to replace dive-site UUIDs
by pointers.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2018-10-25 10:07:45 +02:00 committed by Dirk Hohndel
parent b9b1b3146b
commit cedc23f487
5 changed files with 9 additions and 10 deletions

View file

@ -237,7 +237,7 @@ void LocationInformationWidget::initFields(dive_site *ds)
filter_model.set(0, location_t { degrees_t{ 0 }, degrees_t{ 0 } });
clearLabels();
}
MapWidget::instance()->prepareForGetDiveCoordinates(ds ? ds->uuid : 0);
MapWidget::instance()->prepareForGetDiveCoordinates(ds);
}
void LocationInformationWidget::markChangedWidget(QWidget *w)

View file

@ -94,10 +94,10 @@ void MapWidget::endGetDiveCoordinates()
m_mapHelper->exitEditMode();
}
void MapWidget::prepareForGetDiveCoordinates(uint32_t uuid)
void MapWidget::prepareForGetDiveCoordinates(struct dive_site *ds)
{
CHECK_IS_READY_RETURN_VOID();
m_mapHelper->enterEditMode(uuid);
m_mapHelper->enterEditMode(ds);
}
void MapWidget::selectedDivesChanged(QList<int> list)

View file

@ -33,7 +33,7 @@ public slots:
void centerOnIndex(const QModelIndex& idx);
void endGetDiveCoordinates();
void repopulateLabels();
void prepareForGetDiveCoordinates(uint32_t uuid);
void prepareForGetDiveCoordinates(struct dive_site *ds);
void selectedDivesChanged(QList<int>);
void coordinatesChangedLocal(const location_t &);
void doneLoading(QQuickWidget::Status status);

View file

@ -288,24 +288,23 @@ void MapWidgetHelper::exitEditMode()
emit editModeChanged();
}
void MapWidgetHelper::enterEditMode(quint32 uuid)
void MapWidgetHelper::enterEditMode(struct dive_site *ds)
{
// We don't support editing of a dive site that doesn't exist
struct dive_site *ds = get_dive_site_by_uuid(uuid);
if (!ds)
return;
m_editMode = true;
MapLocation *exists = m_mapLocationModel->getMapLocationForUuid(uuid);
MapLocation *exists = m_mapLocationModel->getMapLocationForUuid(ds->uuid);
QGeoCoordinate coord;
// if divesite doesn't exist in the model, add a new MapLocation.
if (!exists) {
coord = m_map->property("center").value<QGeoCoordinate>();
m_mapLocationModel->add(new MapLocation(uuid, coord, QString(ds->name)));
m_mapLocationModel->add(new MapLocation(ds->uuid, coord, QString(ds->name)));
} else {
coord = exists->coordinate();
}
centerOnDiveSiteUUID(uuid);
centerOnDiveSite(ds);
location_t location = mk_location(coord);
emit coordinatesChanged(location);
emit editModeChanged();

View file

@ -37,7 +37,7 @@ public:
Q_INVOKABLE void updateCurrentDiveSiteCoordinatesFromMap(quint32 uuid, QGeoCoordinate coord);
Q_INVOKABLE void selectVisibleLocations();
void updateDiveSiteCoordinates(uint32_t uuid, const location_t &);
void enterEditMode(uint32_t uuid);
void enterEditMode(struct dive_site *ds);
void exitEditMode();
QString pluginObject();