mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 21:03:23 +00:00
Use for_each_dive_site to populate the dives in the globe
When we didn't have a proper dive_site_table, the dive sites where scattered across all dives and so we looped over all dives to find the dive sites and add them to the tree. Now this is a bit cleaner, a bit faster. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
fa373fd544
commit
34b406556d
1 changed files with 11 additions and 17 deletions
|
@ -187,29 +187,19 @@ void GlobeGPS::mouseClicked(qreal lon, qreal lat, GeoDataCoordinates::Unit unit)
|
||||||
|
|
||||||
void GlobeGPS::repopulateLabels()
|
void GlobeGPS::repopulateLabels()
|
||||||
{
|
{
|
||||||
|
if (!current_dive)
|
||||||
|
return;
|
||||||
|
|
||||||
struct dive_site *ds;
|
struct dive_site *ds;
|
||||||
|
int idx;
|
||||||
|
QMap<QString, GeoDataPlacemark *> locationMap;
|
||||||
if (loadedDives) {
|
if (loadedDives) {
|
||||||
model()->treeModel()->removeDocument(loadedDives);
|
model()->treeModel()->removeDocument(loadedDives);
|
||||||
delete loadedDives;
|
delete loadedDives;
|
||||||
}
|
}
|
||||||
loadedDives = new GeoDataDocument;
|
loadedDives = new GeoDataDocument;
|
||||||
QMap<QString, GeoDataPlacemark *> locationMap;
|
|
||||||
|
|
||||||
int idx = -2;
|
for_each_dive_site(idx, ds) {
|
||||||
struct dive *dive;
|
|
||||||
// normally we use for_each_dive (idx, dive) to loop over all dives,
|
|
||||||
// but we need to include the displayed_dive while things are
|
|
||||||
// edited, so let's hand roll this loop
|
|
||||||
while (++idx < dive_table.nr) {
|
|
||||||
dive = (idx == -1 ? &displayed_dive : get_dive(idx));
|
|
||||||
if (dive == current_dive)
|
|
||||||
// don't show that flag, it's either already shown as displayed_dive
|
|
||||||
// or it's the one that we are moving right now...
|
|
||||||
continue;
|
|
||||||
if (idx == -1)
|
|
||||||
ds = &displayed_dive_site;
|
|
||||||
else
|
|
||||||
ds = get_dive_site_for_dive(dive);
|
|
||||||
if (dive_site_has_gps_location(ds)) {
|
if (dive_site_has_gps_location(ds)) {
|
||||||
GeoDataPlacemark *place = new GeoDataPlacemark(ds->name);
|
GeoDataPlacemark *place = new GeoDataPlacemark(ds->name);
|
||||||
place->setCoordinate(ds->longitude.udeg / 1000000.0, ds->latitude.udeg / 1000000.0, 0, GeoDataCoordinates::Degree);
|
place->setCoordinate(ds->longitude.udeg / 1000000.0, ds->latitude.udeg / 1000000.0, 0, GeoDataCoordinates::Degree);
|
||||||
|
@ -230,8 +220,12 @@ void GlobeGPS::repopulateLabels()
|
||||||
loadedDives->append(place);
|
loadedDives->append(place);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
model()->treeModel()->addDocument(loadedDives);
|
model()->treeModel()->addDocument(loadedDives);
|
||||||
centerOn(displayed_dive_site.longitude.udeg / 1000000.0, displayed_dive_site.latitude.udeg / 1000000.0, true);
|
struct dive_site *center = displayed_dive_site.uuid != 0 ?
|
||||||
|
&displayed_dive_site : get_dive_site_by_uuid(current_dive->dive_site_uuid);
|
||||||
|
if(center)
|
||||||
|
centerOn(displayed_dive_site.longitude.udeg / 1000000.0, displayed_dive_site.latitude.udeg / 1000000.0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobeGPS::reload()
|
void GlobeGPS::reload()
|
||||||
|
|
Loading…
Add table
Reference in a new issue