blob: 55ebb3aba03561bbdcfbbe6d9d8522e8a8cc177d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
// SPDX-License-Identifier: GPL-2.0
#include "divesite.h"
#include "pref.h"
#include "gettextfromc.h"
QString constructLocationTags(struct dive_site *ds, bool for_maintab)
{
QString locationTag;
if (!ds || !ds->taxonomy.nr)
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 = QString("<small><small>") + gettextFromC::tr("No dive site layout categories set in preferences!") +
QString("</small></small>");
return locationTag;
}
else if (!prefs_set)
return locationTag;
if (for_maintab)
locationTag = QString("<small><small>(") + gettextFromC::tr("Tags") + QString(": ");
else
locationTag = QString("<small><small>");
QString connector;
for (int i = 0; i < 3; i++) {
if (prefs.geocoding.category[i] == TC_NONE)
continue;
for (int j = 0; j < ds->taxonomy.nr; j++) {
if (ds->taxonomy.category[j].category == prefs.geocoding.category[i]) {
QString tag = ds->taxonomy.category[j].value;
if (!tag.isEmpty()) {
locationTag += connector + tag;
connector = " / ";
}
break;
}
}
}
if (for_maintab)
locationTag += ")</small></small>";
else
locationTag += "</small></small>";
return locationTag;
}
|