diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-10-23 12:42:01 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-10-29 00:09:31 +0000 |
commit | 68961a169efc37039cd3fda334efb9ad9927444f (patch) | |
tree | 19365422501eacee57b4cc71722a8a5d8a54f323 /mobile-widgets | |
parent | 4cea7b49016923e3f9bb00b60976d7635907e038 (diff) | |
download | subsurface-68961a169efc37039cd3fda334efb9ad9927444f.tar.gz |
Dive site: return pointer to dive_site in get_dive_site_*()
As a first step in removing dive-site uuids, change the interface
of the get_dive_site_*() functions to return pointers instead
of uuids. This makes code a bit more complicated in places where
the uuid is extracted afterwards (needed NULL check). Nevertheless,
these places should disappear once pointers instead of uuids are
stored in the dive-structures.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'mobile-widgets')
-rw-r--r-- | mobile-widgets/qmlmanager.cpp | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index 009b1b4db..c5c9469d9 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -872,16 +872,17 @@ parsed: bool QMLManager::checkLocation(DiveObjectHelper *myDive, struct dive *d, QString location, QString gps) { bool diveChanged = false; - uint32_t uuid = 0; struct dive_site *ds = get_dive_site_for_dive(d); qDebug() << "checkLocation" << location << "gps" << gps << "dive had" << myDive->location() << "gps" << myDive->gas(); if (myDive->location() != location) { diveChanged = true; if (!ds) - uuid = get_dive_site_uuid_by_name(qPrintable(location), NULL); - if (!uuid && !location.isEmpty()) - uuid = create_dive_site(qPrintable(location), d->when); - d->dive_site_uuid = uuid; + ds = get_dive_site_by_name(qPrintable(location)); + if (!ds && !location.isEmpty()) { + uint32_t uuid = create_dive_site(qPrintable(location), d->when); + ds = get_dive_site_by_uuid(uuid); + } + d->dive_site_uuid = ds ? ds->uuid : 0; } // now make sure that the GPS coordinates match - if the user changed the name but not // the GPS coordinates, this still does the right thing as the now new dive site will @@ -1474,15 +1475,13 @@ QString QMLManager::getVersion() const } QString QMLManager::getGpsFromSiteName(const QString& siteName) -{ uint32_t uuid; +{ struct dive_site *ds; - uuid = get_dive_site_uuid_by_name(qPrintable(siteName), NULL); - if (uuid) { - ds = get_dive_site_by_uuid(uuid); + ds = get_dive_site_by_name(qPrintable(siteName)); + if (ds) return QString(printGPSCoords(&ds->location)); - } - return ""; + return QString(); } void QMLManager::setNotificationText(QString text) |