summaryrefslogtreecommitdiffstats
path: root/core/divesite-helper.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2017-12-08 08:13:08 -0600
committerGravatar Lubomir I. Ivanov <neolit123@gmail.com>2017-12-08 16:29:49 +0100
commitef8b2e6bb75e79b3f600980e8b7d89389df18970 (patch)
tree45284547c5173f9e87948bccdc0c8015746e04e7 /core/divesite-helper.cpp
parent03b02c935211afd978a928a3d2882e6c69de0b43 (diff)
downloadsubsurface-ef8b2e6bb75e79b3f600980e8b7d89389df18970.tar.gz
Cleanup: rename file to avoid confusion
Depending on the tooling, both divesite.c and divesite.cpp would compile into divesite.o. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core/divesite-helper.cpp')
-rw-r--r--core/divesite-helper.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/core/divesite-helper.cpp b/core/divesite-helper.cpp
new file mode 100644
index 000000000..56030afd1
--- /dev/null
+++ b/core/divesite-helper.cpp
@@ -0,0 +1,52 @@
+// SPDX-License-Identifier: GPL-2.0
+#include "divesite.h"
+#include "pref.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>") + QObject::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>(") + QObject::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;
+}