2017-04-27 18:24:53 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2015-10-07 22:34:02 +00:00
|
|
|
#include "divesite.h"
|
|
|
|
#include "pref.h"
|
2018-07-03 14:52:20 +00:00
|
|
|
#include "gettextfromc.h"
|
2015-10-07 22:34:02 +00:00
|
|
|
|
2018-10-13 09:52:59 +00:00
|
|
|
QString constructLocationTags(struct taxonomy_data *taxonomy, bool for_maintab)
|
2015-10-07 22:34:02 +00:00
|
|
|
{
|
|
|
|
QString locationTag;
|
|
|
|
|
2018-10-13 09:52:59 +00:00
|
|
|
if (!taxonomy->nr)
|
2015-10-07 22:34:02 +00:00
|
|
|
return locationTag;
|
|
|
|
|
2017-10-16 13:52:13 +00:00
|
|
|
/* 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) {
|
2018-07-03 14:52:20 +00:00
|
|
|
locationTag = QString("<small><small>") + gettextFromC::tr("No dive site layout categories set in preferences!") +
|
2017-10-16 13:52:13 +00:00
|
|
|
QString("</small></small>");
|
|
|
|
return locationTag;
|
|
|
|
}
|
|
|
|
else if (!prefs_set)
|
|
|
|
return locationTag;
|
|
|
|
|
|
|
|
if (for_maintab)
|
2018-07-03 14:52:20 +00:00
|
|
|
locationTag = QString("<small><small>(") + gettextFromC::tr("Tags") + QString(": ");
|
2017-10-16 13:52:13 +00:00
|
|
|
else
|
|
|
|
locationTag = QString("<small><small>");
|
2015-10-07 22:34:02 +00:00
|
|
|
QString connector;
|
|
|
|
for (int i = 0; i < 3; i++) {
|
|
|
|
if (prefs.geocoding.category[i] == TC_NONE)
|
|
|
|
continue;
|
2018-10-13 09:52:59 +00:00
|
|
|
for (int j = 0; j < taxonomy->nr; j++) {
|
|
|
|
if (taxonomy->category[j].category == prefs.geocoding.category[i]) {
|
|
|
|
QString tag = taxonomy->category[j].value;
|
2015-10-07 22:34:02 +00:00
|
|
|
if (!tag.isEmpty()) {
|
|
|
|
locationTag += connector + tag;
|
|
|
|
connector = " / ";
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-16 13:52:13 +00:00
|
|
|
if (for_maintab)
|
|
|
|
locationTag += ")</small></small>";
|
|
|
|
else
|
|
|
|
locationTag += "</small></small>";
|
2015-10-07 22:34:02 +00:00
|
|
|
return locationTag;
|
|
|
|
}
|