mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Dive site: replace dive->dive_site_uuid by dive_site
Replace the UUID reference of struct dive by a pointer to dive_site. This commit is rather large in lines, but nevertheless quite simple since most of the UUID->pointer work was done in previous commits. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
acd44467c1
commit
724055f0af
28 changed files with 181 additions and 169 deletions
|
|
@ -56,26 +56,26 @@ Item {
|
|||
anchorPoint.x: 0
|
||||
anchorPoint.y: mapItemImage.height
|
||||
coordinate: model.coordinate
|
||||
z: mapHelper.model.selectedUuid === model.uuid ? mapHelper.model.count - 1 : 0
|
||||
z: mapHelper.model.selectedDs === model.divesite ? mapHelper.model.count - 1 : 0
|
||||
sourceItem: Image {
|
||||
id: mapItemImage
|
||||
source: "qrc:///dive-location-marker" + (mapHelper.model.selectedUuid === model.uuid ? "-selected" : (mapHelper.editMode ? "-inactive" : "")) + "-icon"
|
||||
source: "qrc:///dive-location-marker" + (mapHelper.model.selectedDs === model.divesite ? "-selected" : (mapHelper.editMode ? "-inactive" : "")) + "-icon"
|
||||
SequentialAnimation {
|
||||
id: mapItemImageAnimation
|
||||
PropertyAnimation { target: mapItemImage; property: "scale"; from: 1.0; to: 0.7; duration: 120 }
|
||||
PropertyAnimation { target: mapItemImage; property: "scale"; from: 0.7; to: 1.0; duration: 80 }
|
||||
}
|
||||
MouseArea {
|
||||
drag.target: (mapHelper.editMode && mapHelper.model.selectedUuid === model.uuid) ? mapItem : undefined
|
||||
drag.target: (mapHelper.editMode && mapHelper.model.selectedDs === model.divesite) ? mapItem : undefined
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
if (!mapHelper.editMode)
|
||||
mapHelper.model.setSelectedUuid(model.uuid, true)
|
||||
mapHelper.model.setSelected(model.divesite, true)
|
||||
}
|
||||
onDoubleClicked: map.doubleClickHandler(mapItem.coordinate)
|
||||
onReleased: {
|
||||
if (mapHelper.editMode && mapHelper.model.selectedUuid === model.uuid) {
|
||||
mapHelper.updateCurrentDiveSiteCoordinatesFromMap(mapHelper.model.selectedUuid, mapItem.coordinate)
|
||||
if (mapHelper.editMode && mapHelper.model.selectedDs === model.divesite) {
|
||||
mapHelper.updateCurrentDiveSiteCoordinatesFromMap(mapHelper.model.selectedDs, mapItem.coordinate)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -94,7 +94,7 @@ Item {
|
|||
id: mapItemText
|
||||
text: model.name
|
||||
font.pointSize: 11.0
|
||||
color: mapHelper.model.selectedUuid === model.uuid ? "white" : "lightgrey"
|
||||
color: mapHelper.model.selectedDs === model.divesite ? "white" : "lightgrey"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,11 +41,11 @@ void MapWidgetHelper::centerOnDiveSite(struct dive_site *ds)
|
|||
{
|
||||
if (!ds || !dive_site_has_gps_location(ds)) {
|
||||
// dive site with no GPS
|
||||
m_mapLocationModel->setSelectedUuid(ds ? ds->uuid : 0, false);
|
||||
m_mapLocationModel->setSelected(ds, false);
|
||||
QMetaObject::invokeMethod(m_map, "deselectMapLocation");
|
||||
} else {
|
||||
// dive site with GPS
|
||||
m_mapLocationModel->setSelectedUuid(ds->uuid, false);
|
||||
m_mapLocationModel->setSelected(ds, false);
|
||||
QGeoCoordinate dsCoord (ds->location.lat.udeg * 0.000001, ds->location.lon.udeg * 0.000001);
|
||||
QMetaObject::invokeMethod(m_map, "centerOnCoordinate", Q_ARG(QVariant, QVariant::fromValue(dsCoord)));
|
||||
}
|
||||
|
|
@ -72,15 +72,14 @@ void MapWidgetHelper::centerOnSelectedDiveSite()
|
|||
|
||||
if (selDS.isEmpty()) {
|
||||
// no selected dives with GPS coordinates
|
||||
m_mapLocationModel->setSelectedUuid(0, false);
|
||||
m_mapLocationModel->setSelected(nullptr, false);
|
||||
QMetaObject::invokeMethod(m_map, "deselectMapLocation");
|
||||
|
||||
} else if (selDS.size() == 1) {
|
||||
centerOnDiveSite(selDS[0]);
|
||||
} else if (selDS.size() > 1) {
|
||||
/* more than one dive sites with GPS selected.
|
||||
* find the most top-left and bottom-right dive sites on the map coordinate system. */
|
||||
m_mapLocationModel->setSelectedUuid(selDS[0]->uuid, false);
|
||||
m_mapLocationModel->setSelected(selDS[0], false);
|
||||
qreal minLat = 0.0, minLon = 0.0, maxLat = 0.0, maxLon = 0.0;
|
||||
bool start = true;
|
||||
for(struct dive_site *dss: selDS) {
|
||||
|
|
@ -143,7 +142,7 @@ void MapWidgetHelper::reloadMapLocations()
|
|||
if (dsCoord.distanceTo(coord) < MIN_DISTANCE_BETWEEN_DIVE_SITES_M)
|
||||
continue;
|
||||
}
|
||||
location = new MapLocation(ds->uuid, dsCoord, name);
|
||||
location = new MapLocation(ds, dsCoord, name);
|
||||
locationList.append(location);
|
||||
locations.append(ds);
|
||||
locationNameMap[name] = location;
|
||||
|
|
@ -169,7 +168,7 @@ void MapWidgetHelper::selectedLocationChanged(MapLocation *location)
|
|||
m_selectedDiveIds.append(idx);
|
||||
}
|
||||
#else // the mobile version doesn't support multi-dive selection
|
||||
if (ds->uuid == location->uuid())
|
||||
if (ds == location->divesite())
|
||||
m_selectedDiveIds.append(dive->id); // use id here instead of index
|
||||
}
|
||||
int last; // get latest dive chronologically
|
||||
|
|
@ -200,7 +199,7 @@ void MapWidgetHelper::selectVisibleLocations()
|
|||
Q_ARG(QGeoCoordinate, dsCoord));
|
||||
if (!qIsNaN(point.x())) {
|
||||
if (!selectedFirst) {
|
||||
m_mapLocationModel->setSelectedUuid(ds->uuid, false);
|
||||
m_mapLocationModel->setSelected(ds, false);
|
||||
selectedFirst = true;
|
||||
}
|
||||
#ifndef SUBSURFACE_MOBILE // indexes on desktop
|
||||
|
|
@ -262,9 +261,9 @@ void MapWidgetHelper::copyToClipboardCoordinates(QGeoCoordinate coord, bool form
|
|||
prefs.coordinates_traditional = savep;
|
||||
}
|
||||
|
||||
void MapWidgetHelper::updateCurrentDiveSiteCoordinatesFromMap(quint32 uuid, QGeoCoordinate coord)
|
||||
void MapWidgetHelper::updateCurrentDiveSiteCoordinatesFromMap(struct dive_site *ds, QGeoCoordinate coord)
|
||||
{
|
||||
MapLocation *loc = m_mapLocationModel->getMapLocationForUuid(uuid);
|
||||
MapLocation *loc = m_mapLocationModel->getMapLocation(ds);
|
||||
if (loc)
|
||||
loc->setCoordinate(coord);
|
||||
location_t location = mk_location(coord);
|
||||
|
|
@ -278,7 +277,7 @@ void MapWidgetHelper::updateDiveSiteCoordinates(struct dive_site *ds, const loca
|
|||
const qreal latitude_r = location.lat.udeg * 0.000001;
|
||||
const qreal longitude_r = location.lon.udeg * 0.000001;
|
||||
QGeoCoordinate coord(latitude_r, longitude_r);
|
||||
m_mapLocationModel->updateMapLocationCoordinates(ds->uuid, coord);
|
||||
m_mapLocationModel->updateMapLocationCoordinates(ds, coord);
|
||||
QMetaObject::invokeMethod(m_map, "centerOnCoordinate", Q_ARG(QVariant, QVariant::fromValue(coord)));
|
||||
}
|
||||
|
||||
|
|
@ -295,12 +294,12 @@ void MapWidgetHelper::enterEditMode(struct dive_site *ds)
|
|||
return;
|
||||
|
||||
m_editMode = true;
|
||||
MapLocation *exists = m_mapLocationModel->getMapLocationForUuid(ds->uuid);
|
||||
MapLocation *exists = m_mapLocationModel->getMapLocation(ds);
|
||||
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(ds->uuid, coord, QString(ds->name)));
|
||||
m_mapLocationModel->add(new MapLocation(ds, coord, QString(ds->name)));
|
||||
} else {
|
||||
coord = exists->coordinate();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ public:
|
|||
Q_INVOKABLE void reloadMapLocations();
|
||||
Q_INVOKABLE void copyToClipboardCoordinates(QGeoCoordinate coord, bool formatTraditional);
|
||||
Q_INVOKABLE void calculateSmallCircleRadius(QGeoCoordinate coord);
|
||||
Q_INVOKABLE void updateCurrentDiveSiteCoordinatesFromMap(quint32 uuid, QGeoCoordinate coord);
|
||||
Q_INVOKABLE void updateCurrentDiveSiteCoordinatesFromMap(struct dive_site *ds, QGeoCoordinate coord);
|
||||
Q_INVOKABLE void selectVisibleLocations();
|
||||
void updateDiveSiteCoordinates(struct dive_site *ds, const location_t &);
|
||||
void enterEditMode(struct dive_site *ds);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue