core: move constructLocationTags from divesite.cpp to taxonomy.cpp

After all it doesn't access any dive_site structure.

Moreover, rename it, since we use mostly snake_case in core.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-05-11 18:23:40 +02:00 committed by bstoeger
parent 7d7766be9a
commit 4ac2486a23
6 changed files with 55 additions and 55 deletions

View file

@ -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 = "<small><small>" + gettextFromC::tr("No dive site layout categories set in preferences!").toStdString() +
"</small></small>"s;
return locationTag;
}
else if (!prefs_set)
return locationTag;
if (for_maintab)
locationTag = "<small><small>("s + gettextFromC::tr("Tags").toStdString() + ": "s;
else
locationTag = "<small><small>"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 += ")</small></small>"s;
else
locationTag += "</small></small>"s;
return locationTag;
}