aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-10-26 17:03:54 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-10-29 00:09:31 +0000
commit724055f0af4fb7cdb9f1570967fe4b34797f3419 (patch)
tree6aab8c34e7d0a6df1d6fe84bc5794e8eb5404b7d /desktop-widgets
parentacd44467c1100a1a774cc644921b1dc33dca1266 (diff)
downloadsubsurface-724055f0af4fb7cdb9f1570967fe4b34797f3419.tar.gz
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>
Diffstat (limited to 'desktop-widgets')
-rw-r--r--desktop-widgets/divelogexportdialog.cpp2
-rw-r--r--desktop-widgets/locationinformation.cpp4
-rw-r--r--desktop-widgets/subsurfacewebservices.cpp6
-rw-r--r--desktop-widgets/tab-widgets/maintab.cpp33
4 files changed, 22 insertions, 23 deletions
diff --git a/desktop-widgets/divelogexportdialog.cpp b/desktop-widgets/divelogexportdialog.cpp
index 928256df4..5c337f0a5 100644
--- a/desktop-widgets/divelogexportdialog.cpp
+++ b/desktop-widgets/divelogexportdialog.cpp
@@ -286,7 +286,7 @@ void DiveLogExportDialog::export_TeX(const char *filename, const bool selected_o
struct tm tm;
utc_mkdate(dive->when, &tm);
- dive_site *site = get_dive_site_by_uuid(dive->dive_site_uuid);
+ dive_site *site = dive->dive_site;
QRegExp ct("countrytag: (\\w+)");
QString country;
if (ct.indexIn(site->notes) >= 0)
diff --git a/desktop-widgets/locationinformation.cpp b/desktop-widgets/locationinformation.cpp
index e48c46008..2b57c122c 100644
--- a/desktop-widgets/locationinformation.cpp
+++ b/desktop-widgets/locationinformation.cpp
@@ -206,7 +206,7 @@ void LocationInformationWidget::acceptChanges()
parseGpsText(ui.diveSiteCoordinates->text(), diveSite->location);
if (dive_site_is_empty(diveSite)) {
LocationInformationModel::instance()->removeRow(get_divesite_idx(diveSite));
- displayed_dive.dive_site_uuid = 0;
+ displayed_dive.dive_site = nullptr;
diveSite = nullptr;
}
mark_divelist_changed(true);
@@ -386,7 +386,7 @@ QVariant DiveLocationModel::data(const QModelIndex &index, int role) const
case Qt::DisplayRole:
return new_ds_value[index.row()];
case Qt::ToolTipRole:
- return displayed_dive.dive_site_uuid ?
+ return displayed_dive.dive_site ?
tr("Create a new dive site, copying relevant information from the current dive.") :
tr("Create a new dive site with this name");
case Qt::DecorationRole:
diff --git a/desktop-widgets/subsurfacewebservices.cpp b/desktop-widgets/subsurfacewebservices.cpp
index 7e67366eb..2acc7451e 100644
--- a/desktop-widgets/subsurfacewebservices.cpp
+++ b/desktop-widgets/subsurfacewebservices.cpp
@@ -45,7 +45,7 @@ static void copy_gps_location(struct dive *from, struct dive *to)
struct dive_site *gds = get_dive_site_for_dive(from);
if (!ds) {
// simply link to the one created for the fake dive
- to->dive_site_uuid = gds->uuid;
+ to->dive_site = gds;
} else {
ds->latitude = gds->latitude;
ds->longitude = gds->longitude;
@@ -198,10 +198,10 @@ bool DivelogsDeWebServices::prepare_dives_for_divelogs(const QString &tempfile,
/* make sure the buffer is empty and add the dive */
mb.len = 0;
- struct dive_site *ds = get_dive_site_by_uuid(dive->dive_site_uuid);
+ struct dive_site *ds = dive->dive_site;
if (ds) {
- put_format(&mb, "<divelog><divesites><site uuid='%8x' name='", dive->dive_site_uuid);
+ put_format(&mb, "<divelog><divesites><site uuid='%8x' name='", dive->dive_site->uuid);
put_quoted(&mb, ds->name, 1, 0);
put_format(&mb, "'");
put_location(&mb, &ds->location, " gps='", "'");
diff --git a/desktop-widgets/tab-widgets/maintab.cpp b/desktop-widgets/tab-widgets/maintab.cpp
index 7d5df7488..1c0914e7f 100644
--- a/desktop-widgets/tab-widgets/maintab.cpp
+++ b/desktop-widgets/tab-widgets/maintab.cpp
@@ -222,7 +222,7 @@ MainTab::~MainTab()
void MainTab::setCurrentLocationIndex()
{
if (current_dive) {
- struct dive_site *ds = get_dive_site_by_uuid(current_dive->dive_site_uuid);
+ struct dive_site *ds = current_dive->dive_site;
if (ds)
ui.location->setCurrentDiveSite(ds);
else
@@ -415,7 +415,7 @@ void MainTab::updateDiveInfo(bool clear)
if (!clear) {
struct dive_site *ds = NULL;
- ds = get_dive_site_by_uuid(displayed_dive.dive_site_uuid);
+ ds = displayed_dive.dive_site;
if (ds) {
ui.location->setCurrentDiveSite(ds);
ui.locationTags->setText(constructLocationTags(&ds->taxonomy, true));
@@ -605,7 +605,7 @@ void MainTab::updateDiveInfo(bool clear)
ui.cylinders->view()->hideColumn(CylindersModel::USE);
if (verbose)
- qDebug() << "Set the current dive site:" << displayed_dive.dive_site_uuid;
+ qDebug() << "Set the current dive site:" << displayed_dive.dive_site->uuid;
emit diveSiteChanged();
}
@@ -678,8 +678,7 @@ struct dive_site *MainTab::updateDiveSite(struct dive_site *pickedDs, dive *d)
if (!pickedDs)
return 0;
- const uint32_t origUuid = d->dive_site_uuid;
- struct dive_site *origDs = get_dive_site_by_uuid(origUuid);
+ struct dive_site *origDs = d->dive_site;
bool createdNewDive = false;
if (pickedDs == origDs)
@@ -706,7 +705,7 @@ struct dive_site *MainTab::updateDiveSite(struct dive_site *pickedDs, dive *d)
}
}
- d->dive_site_uuid = pickedDs->uuid;
+ d->dive_site = pickedDs;
qDebug() << "Setting the dive site id on the dive:" << pickedDs->uuid;
return pickedDs;
}
@@ -808,8 +807,8 @@ void MainTab::acceptChanges()
if (displayed_dive.watertemp.mkelvin != cd->watertemp.mkelvin)
MODIFY_DIVES(selectedDives, EDIT_VALUE(watertemp.mkelvin));
- if (displayed_dive.dive_site_uuid != cd->dive_site_uuid)
- MODIFY_DIVES(selectedDives, EDIT_VALUE(dive_site_uuid));
+ if (displayed_dive.dive_site != cd->dive_site)
+ MODIFY_DIVES(selectedDives, EDIT_VALUE(dive_site));
// three text fields are somewhat special and are represented as tags
// in the UI - they need somewhat smarter handling
@@ -877,10 +876,10 @@ void MainTab::acceptChanges()
}
// update the dive site for the selected dives that had the same dive site as the current dive
- struct dive_site *oldDs = get_dive_site_by_uuid(cd->dive_site_uuid);
- struct dive_site *newDs = 0;
+ struct dive_site *oldDs = cd->dive_site;
+ struct dive_site *newDs = nullptr;
MODIFY_DIVES(selectedDives,
- if (mydive->dive_site_uuid == current_dive->dive_site_uuid)
+ if (mydive->dive_site == current_dive->dive_site)
newDs = updateDiveSite(!newDs ? ui.location->currDiveSite() : newDs, mydive);
);
if (oldDs && !is_dive_site_used(oldDs, false)) {
@@ -893,7 +892,7 @@ void MainTab::acceptChanges()
// code below triggers an update of the display without re-initializing displayed_dive
// so let's make sure here that our data is consistent now that we have handled the
// dive sites
- displayed_dive.dive_site_uuid = current_dive->dive_site_uuid;
+ displayed_dive.dive_site = current_dive->dive_site;
// each dive that was selected might have had the temperatures in its active divecomputer changed
// so re-populate the temperatures - easiest way to do this is by calling fixup_dive
@@ -1009,7 +1008,7 @@ void MainTab::rejectChanges()
}
// the user could have edited the location and then canceled the edit
// let's get the correct location back in view
- MapWidget::instance()->centerOnDiveSite(get_dive_site_by_uuid(displayed_dive.dive_site_uuid));
+ MapWidget::instance()->centerOnDiveSite(displayed_dive.dive_site);
// show the profile and dive info
MainWindow::instance()->graphics->replot();
MainWindow::instance()->setEnabledToolbar(true);
@@ -1325,7 +1324,7 @@ void MainTab::on_location_textChanged()
// we don't want to act on the edit until editing is finished,
// but we want to mark the field so it's obvious it is being edited
QString currentLocation;
- struct dive_site *ds = get_dive_site_by_uuid(displayed_dive.dive_site_uuid);
+ struct dive_site *ds = displayed_dive.dive_site;
if (ds)
currentLocation = ds->name;
if (ui.location->text() != currentLocation)
@@ -1338,12 +1337,12 @@ void MainTab::on_location_diveSiteSelected()
return;
if (ui.location->text().isEmpty()) {
- displayed_dive.dive_site_uuid = 0;
+ displayed_dive.dive_site = nullptr;
markChangedWidget(ui.location);
emit diveSiteChanged();
return;
} else {
- if (ui.location->currDiveSite() != get_dive_site_by_uuid(displayed_dive.dive_site_uuid)) {
+ if (ui.location->currDiveSite() != displayed_dive.dive_site) {
markChangedWidget(ui.location);
} else {
QPalette p;
@@ -1480,7 +1479,7 @@ void MainTab::showAndTriggerEditSelective(struct dive_components what)
if (what.visibility)
ui.visibility->setCurrentStars(displayed_dive.visibility);
if (what.divesite)
- ui.location->setCurrentDiveSite(get_dive_site_by_uuid(displayed_dive.dive_site_uuid));
+ ui.location->setCurrentDiveSite(displayed_dive.dive_site);
if (what.tags) {
ui.tagWidget->setText(get_taglist_string(displayed_dive.tag_list));
}