mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
map-widget: start dive site editing with coords pre-entered
Once the user starts editing a dive site, make sure to pass coordinates of either the current map center (if a new MapLocation is being added) or the coordinates of the existing MapLocation. The "Dive site management" coordinates text field would receive these new coordinates after the displayed_dive_site struct is updated and the coordinatesChanged() signal is emitted. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
parent
d9cfcae88b
commit
b564debe21
1 changed files with 13 additions and 5 deletions
|
@ -238,11 +238,19 @@ void MapWidgetHelper::setEditMode(bool editMode)
|
|||
{
|
||||
m_editMode = editMode;
|
||||
MapLocation *exists = m_mapLocationModel->getMapLocationForUuid(displayed_dive_site.uuid);
|
||||
// if divesite uuid doesn't exist in the model, add a new MapLocation.
|
||||
if (editMode && !exists) {
|
||||
QGeoCoordinate coord = m_map->property("center").value<QGeoCoordinate>();
|
||||
m_mapLocationModel->add(new MapLocation(displayed_dive_site.uuid, coord,
|
||||
QString(displayed_dive_site.name)));
|
||||
if (editMode) {
|
||||
QGeoCoordinate coord;
|
||||
// if divesite uuid doesn't exist in the model, add a new MapLocation.
|
||||
if (!exists) {
|
||||
coord = m_map->property("center").value<QGeoCoordinate>();
|
||||
m_mapLocationModel->add(new MapLocation(displayed_dive_site.uuid, coord,
|
||||
QString(displayed_dive_site.name)));
|
||||
} else {
|
||||
coord = exists->coordinate();
|
||||
}
|
||||
displayed_dive_site.latitude.udeg = lrint(coord.latitude() * 1000000.0);
|
||||
displayed_dive_site.longitude.udeg = lrint(coord.longitude() * 1000000.0);
|
||||
emit coordinatesChanged();
|
||||
}
|
||||
emit editModeChanged();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue