mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-29 21:50:26 +00:00
8815f77ea0
The dive-site-edit widget uses a copy of the to-be-edited site to compare with old values. Generally, this seems overkill (the original dive-site can be used for such a comparison). But one place where it can't simply be removed is the taxonomy, because the widget needs a place to store the unsaved data. Change the code to use an explicit taxonomy structure instead of the one provided in the copy. This should ultimately allow removal of the latter. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
53 lines
1.3 KiB
C++
53 lines
1.3 KiB
C++
// SPDX-License-Identifier: GPL-2.0
|
|
#include "divesite.h"
|
|
#include "pref.h"
|
|
#include "gettextfromc.h"
|
|
|
|
QString constructLocationTags(struct taxonomy_data *taxonomy, bool for_maintab)
|
|
{
|
|
QString locationTag;
|
|
|
|
if (!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 < taxonomy->nr; j++) {
|
|
if (taxonomy->category[j].category == prefs.geocoding.category[i]) {
|
|
QString tag = taxonomy->category[j].value;
|
|
if (!tag.isEmpty()) {
|
|
locationTag += connector + tag;
|
|
connector = " / ";
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (for_maintab)
|
|
locationTag += ")</small></small>";
|
|
else
|
|
locationTag += "</small></small>";
|
|
return locationTag;
|
|
}
|