diff --git a/core/divesite.cpp b/core/divesite.cpp
index ee76e58b1..f13b2e7d7 100644
--- a/core/divesite.cpp
+++ b/core/divesite.cpp
@@ -6,9 +6,7 @@
#include "divelog.h"
#include "errorhelper.h"
#include "format.h"
-#include "gettextfromc.h"
#include "membuffer.h"
-#include "pref.h"
#include "subsurface-string.h"
#include "sha1.h"
@@ -252,52 +250,3 @@ struct dive_site *unregister_dive_from_dive_site(struct dive *d)
d->dive_site = nullptr;
return ds;
}
-
-std::string constructLocationTags(const taxonomy_data &taxonomy, bool for_maintab)
-{
- using namespace std::string_literals;
- std::string locationTag;
-
- if (taxonomy.empty())
- return locationTag;
-
- /* Check if the user set any of the 3 geocoding categories */
- bool prefs_set = false;
- for (int i = 0; i < 3; i++) {
- if (prefs.geocoding.category[i] != TC_NONE)
- prefs_set = true;
- }
-
- if (!prefs_set && !for_maintab) {
- locationTag = "" + gettextFromC::tr("No dive site layout categories set in preferences!").toStdString() +
- ""s;
- return locationTag;
- }
- else if (!prefs_set)
- return locationTag;
-
- if (for_maintab)
- locationTag = "("s + gettextFromC::tr("Tags").toStdString() + ": "s;
- else
- locationTag = ""s;
- std::string connector;
- for (int i = 0; i < 3; i++) {
- if (prefs.geocoding.category[i] == TC_NONE)
- continue;
- for (auto const &t: taxonomy) {
- if (t.category == prefs.geocoding.category[i]) {
- if (!t.value.empty()) {
- locationTag += connector + t.value;
- connector = " / "s;
- }
- break;
- }
- }
- }
-
- if (for_maintab)
- locationTag += ")"s;
- else
- locationTag += ""s;
- return locationTag;
-}
diff --git a/core/divesite.h b/core/divesite.h
index d4c21894e..31c2a03c4 100644
--- a/core/divesite.h
+++ b/core/divesite.h
@@ -57,7 +57,6 @@ public:
struct dive_site *unregister_dive_from_dive_site(struct dive *d);
struct dive_site *get_same_dive_site(const struct dive_site &); // accesses global dive list
-std::string constructLocationTags(const taxonomy_data &taxonomy, bool for_maintab);
/* Make pointer-to-dive_site a "Qt metatype" so that we can pass it through QVariants */
Q_DECLARE_METATYPE(dive_site *);
diff --git a/core/taxonomy.cpp b/core/taxonomy.cpp
index 18f589b6b..562f1541d 100644
--- a/core/taxonomy.cpp
+++ b/core/taxonomy.cpp
@@ -2,7 +2,9 @@
#include "taxonomy.h"
#include "errorhelper.h"
#include "gettext.h"
+#include "pref.h"
#include "subsurface-string.h"
+#include "gettextfromc.h"
#include
#include
#include
@@ -57,3 +59,52 @@ void taxonomy_set_country(taxonomy_data &t, const std::string &country, enum tax
report_info("%s: set the taxonomy country to %s\n", __func__, country.c_str());
taxonomy_set_category(t, TC_COUNTRY, country, origin);
}
+
+std::string taxonomy_get_location_tags(const taxonomy_data &taxonomy, bool for_maintab)
+{
+ using namespace std::string_literals;
+ std::string locationTag;
+
+ if (taxonomy.empty())
+ return locationTag;
+
+ /* Check if the user set any of the 3 geocoding categories */
+ bool prefs_set = false;
+ for (int i = 0; i < 3; i++) {
+ if (prefs.geocoding.category[i] != TC_NONE)
+ prefs_set = true;
+ }
+
+ if (!prefs_set && !for_maintab) {
+ locationTag = "" + gettextFromC::tr("No dive site layout categories set in preferences!").toStdString() +
+ ""s;
+ return locationTag;
+ }
+ else if (!prefs_set)
+ return locationTag;
+
+ if (for_maintab)
+ locationTag = "("s + gettextFromC::tr("Tags").toStdString() + ": "s;
+ else
+ locationTag = ""s;
+ std::string connector;
+ for (int i = 0; i < 3; i++) {
+ if (prefs.geocoding.category[i] == TC_NONE)
+ continue;
+ for (auto const &t: taxonomy) {
+ if (t.category == prefs.geocoding.category[i]) {
+ if (!t.value.empty()) {
+ locationTag += connector + t.value;
+ connector = " / "s;
+ }
+ break;
+ }
+ }
+ }
+
+ if (for_maintab)
+ locationTag += ")"s;
+ else
+ locationTag += ""s;
+ return locationTag;
+}
diff --git a/core/taxonomy.h b/core/taxonomy.h
index f4279066e..7281ec513 100644
--- a/core/taxonomy.h
+++ b/core/taxonomy.h
@@ -37,6 +37,7 @@ using taxonomy_data = std::vector;
std::string taxonomy_get_value(const taxonomy_data &t, enum taxonomy_category cat);
std::string taxonomy_get_country(const taxonomy_data &t);
+std::string taxonomy_get_location_tags(const taxonomy_data &taxonomy, bool for_maintab);
void taxonomy_set_category(taxonomy_data &t, enum taxonomy_category category, const std::string &value, enum taxonomy_origin origin);
void taxonomy_set_country(taxonomy_data &t, const std::string &country, enum taxonomy_origin origin);
diff --git a/desktop-widgets/locationinformation.cpp b/desktop-widgets/locationinformation.cpp
index 93ea7e950..90cea3634 100644
--- a/desktop-widgets/locationinformation.cpp
+++ b/desktop-widgets/locationinformation.cpp
@@ -152,7 +152,7 @@ void LocationInformationWidget::updateLabels()
ui.diveSiteCoordinates->clear();
coordinatesSetWarning(false);
- ui.locationTags->setText(QString::fromStdString(constructLocationTags(diveSite->taxonomy, false)));
+ ui.locationTags->setText(QString::fromStdString(taxonomy_get_location_tags(diveSite->taxonomy, false)));
}
void LocationInformationWidget::unitsChanged()
@@ -182,7 +182,7 @@ void LocationInformationWidget::diveSiteChanged(struct dive_site *ds, int field)
return;
case LocationInformationModel::TAXONOMY:
ui.diveSiteCountry->setText(QString::fromStdString(taxonomy_get_country(diveSite->taxonomy)));
- ui.locationTags->setText(QString::fromStdString(constructLocationTags(diveSite->taxonomy, false)));
+ ui.locationTags->setText(QString::fromStdString(taxonomy_get_location_tags(diveSite->taxonomy, false)));
return;
case LocationInformationModel::LOCATION:
filter_model.setCoordinates(diveSite->location);
diff --git a/desktop-widgets/tab-widgets/TabDiveNotes.cpp b/desktop-widgets/tab-widgets/TabDiveNotes.cpp
index 35f69a5e7..85174aa67 100644
--- a/desktop-widgets/tab-widgets/TabDiveNotes.cpp
+++ b/desktop-widgets/tab-widgets/TabDiveNotes.cpp
@@ -178,7 +178,7 @@ void TabDiveNotes::updateDiveSite(struct dive *d)
struct dive_site *ds = d->dive_site;
ui.location->setCurrentDiveSite(d);
if (ds) {
- ui.locationTags->setText(QString::fromStdString(constructLocationTags(ds->taxonomy, true)));
+ ui.locationTags->setText(QString::fromStdString(taxonomy_get_location_tags(ds->taxonomy, true)));
if (ui.locationTags->text().isEmpty() && has_location(&ds->location))
ui.locationTags->setText(printGPSCoords(&ds->location));