From 70cabb968c481e566e8249465f153e05e6dc0347 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 8 Jan 2020 20:55:29 -0800 Subject: code cleanup: use explicit zero_location Again, several different ways to achieve the same thing. Signed-off-by: Dirk Hohndel --- core/units.h | 2 ++ desktop-widgets/locationinformation.cpp | 8 ++++---- 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{ 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) { } -- cgit v1.2.3-70-g09d2