diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2020-01-08 20:55:29 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-01-10 02:37:03 +0900 |
commit | 70cabb968c481e566e8249465f153e05e6dc0347 (patch) | |
tree | 7b2af4fb86ed467f99250ddaaf091a7da9f22e9a | |
parent | 247194e839cec81304734861db8e8e6e381a5483 (diff) | |
download | subsurface-70cabb968c481e566e8249465f153e05e6dc0347.tar.gz |
code cleanup: use explicit zero_location
Again, several different ways to achieve the same thing.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | core/units.h | 2 | ||||
-rw-r--r-- | desktop-widgets/locationinformation.cpp | 8 | ||||
-rw-r--r-- | desktop-widgets/modeldelegates.cpp | 2 |
3 files changed, 7 insertions, 5 deletions
diff --git a/core/units.h b/core/units.h index 95a9b0eb1..ff34991f7 100644 --- a/core/units.h +++ b/core/units.h @@ -139,6 +139,8 @@ typedef struct pos { degrees_t lat, lon; } location_t; +static const location_t zero_location = { { 0 }, { 0 }}; + extern void parse_location(const char *, location_t *); static inline bool has_location(const location_t *loc) diff --git a/desktop-widgets/locationinformation.cpp b/desktop-widgets/locationinformation.cpp index 2f7b8ffb1..1595db3eb 100644 --- a/desktop-widgets/locationinformation.cpp +++ b/desktop-widgets/locationinformation.cpp @@ -177,7 +177,7 @@ static location_t parseGpsText(const QString &text) double lat, lon; if (parseGpsText(text, &lat, &lon)) return create_location(lat, lon); - return { {0}, {0} }; + return zero_location; } void LocationInformationWidget::diveSiteDeleted(struct dive_site *ds, int) @@ -215,7 +215,7 @@ void LocationInformationWidget::initFields(dive_site *ds) DiveFilter::instance()->startFilterDiveSites(QVector<dive_site *>{ ds }); filter_model.invalidate(); } else { - filter_model.set(0, location_t { degrees_t{ 0 }, degrees_t{ 0 } }); + filter_model.set(0, zero_location); clearLabels(); } } @@ -270,7 +270,7 @@ void LocationInformationWidget::reverseGeocode() Command::editDiveSiteTaxonomy(diveSite, taxonomy); } -DiveLocationFilterProxyModel::DiveLocationFilterProxyModel(QObject *) : currentLocation({{0}, {0}}) +DiveLocationFilterProxyModel::DiveLocationFilterProxyModel(QObject *) : currentLocation(zero_location) { } @@ -574,7 +574,7 @@ void DiveLocationLineEdit::setCurrentDiveSite(struct dive *d) currentLocation = dive_get_gps_location(d); } else { currDs = nullptr; - currentLocation = location_t{{0}, {0}}; + currentLocation = zero_location; } if (!currDs) clear(); diff --git a/desktop-widgets/modeldelegates.cpp b/desktop-widgets/modeldelegates.cpp index d9955f19c..ae8755292 100644 --- a/desktop-widgets/modeldelegates.cpp +++ b/desktop-widgets/modeldelegates.cpp @@ -419,7 +419,7 @@ QWidget *DoubleSpinBoxDelegate::createEditor(QWidget *parent, const QStyleOption return w; } -LocationFilterDelegate::LocationFilterDelegate(QObject *) : currentLocation({0, 0}) +LocationFilterDelegate::LocationFilterDelegate(QObject *) : currentLocation(zero_location) { } |