mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 21:03:23 +00:00
Rename enum values for taxonomy
This avoids confusion and namespace collisions. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
08f8eb6eb5
commit
bc8c54f1ee
10 changed files with 22 additions and 22 deletions
|
@ -176,7 +176,7 @@ void copy_dive_site(struct dive_site *orig, struct dive_site *copy)
|
|||
} else {
|
||||
if (copy->taxonomy.category == NULL)
|
||||
copy->taxonomy.category = alloc_taxonomy();
|
||||
for (int i = 0; i < NR_CATEGORIES; i++) {
|
||||
for (int i = 0; i < TC_NR_CATEGORIES; i++) {
|
||||
free((void *)copy->taxonomy.category[i].value);
|
||||
copy->taxonomy.category[i] = orig->taxonomy.category[i];
|
||||
copy->taxonomy.category[i].value = copy_string(orig->taxonomy.category[i].value);
|
||||
|
|
|
@ -89,7 +89,7 @@ void ReverseGeoLookupThread::run() {
|
|||
if (ds->taxonomy.category == NULL)
|
||||
ds->taxonomy.category = alloc_taxonomy();
|
||||
// get all the data - OCEAN is special, so start at COUNTRY
|
||||
for (int j = COUNTRY; j < NR_CATEGORIES; j++) {
|
||||
for (int j = TC_COUNTRY; j < TC_NR_CATEGORIES; j++) {
|
||||
if (firstData[taxonomy_api_names[j]].isValid()) {
|
||||
ds->taxonomy.category[ri].category = j;
|
||||
ds->taxonomy.category[ri].origin = taxonomy::GEOCODED;
|
||||
|
@ -137,7 +137,7 @@ void ReverseGeoLookupThread::run() {
|
|||
if (oceanName["name"].isValid()) {
|
||||
if (ds->taxonomy.category == NULL)
|
||||
ds->taxonomy.category = alloc_taxonomy();
|
||||
ds->taxonomy.category[ds->taxonomy.nr].category = OCEAN;
|
||||
ds->taxonomy.category[ds->taxonomy.nr].category = TC_OCEAN;
|
||||
ds->taxonomy.category[ds->taxonomy.nr].origin = taxonomy::GEOCODED;
|
||||
ds->taxonomy.category[ds->taxonomy.nr].value = copy_string(qPrintable(oceanName["name"].toString()));
|
||||
ds->taxonomy.nr++;
|
||||
|
|
|
@ -307,7 +307,7 @@ static void parse_site_geo(char *line, struct membuffer *str, void *_ds)
|
|||
if (ds->taxonomy.category == NULL)
|
||||
ds->taxonomy.category = alloc_taxonomy();
|
||||
int nr = ds->taxonomy.nr;
|
||||
if (nr < NR_CATEGORIES) {
|
||||
if (nr < TC_NR_CATEGORIES) {
|
||||
struct taxonomy *t = &ds->taxonomy.category[nr];
|
||||
t->value = strdup(mb_cstring(str));
|
||||
sscanf(line, "cat %d origin %d \"", &t->category, &t->origin);
|
||||
|
|
|
@ -1449,7 +1449,7 @@ static void try_to_fill_dive_site(struct dive_site **ds_p, const char *name, cha
|
|||
if (MATCH("origin.geo", get_index, (int *)&ds->taxonomy.category[ds->taxonomy.nr].origin))
|
||||
return;
|
||||
if (MATCH("value.geo", utf8_string, &ds->taxonomy.category[ds->taxonomy.nr].value)) {
|
||||
if (ds->taxonomy.nr < NR_CATEGORIES)
|
||||
if (ds->taxonomy.nr < TC_NR_CATEGORIES)
|
||||
ds->taxonomy.nr++;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ GeoReferencingOptionsModel::GeoReferencingOptionsModel(QObject *parent) : QStrin
|
|||
{
|
||||
QStringList list;
|
||||
int i;
|
||||
for (i = 0; i < NR_CATEGORIES; i++)
|
||||
for (i = 0; i < TC_NR_CATEGORIES; i++)
|
||||
list << taxonomy_category_names[i];
|
||||
setStringList(list);
|
||||
}
|
||||
|
|
|
@ -515,7 +515,7 @@ void MainTab::updateDiveInfo(bool clear)
|
|||
locationTag = "<small><small>(tags: ";
|
||||
QString connector = "";
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < NR_CATEGORIES; j++) {
|
||||
for (int j = 0; j < TC_NR_CATEGORIES; j++) {
|
||||
if (ds->taxonomy.category[j].category == prefs.geocoding.category[i]) {
|
||||
locationTag += connector + QString(ds->taxonomy.category[j].value);
|
||||
connector = " / ";
|
||||
|
|
|
@ -900,7 +900,7 @@ static void save_divesites(git_repository *repo, struct dir *tree)
|
|||
if (prefs.geocoding.enable_geocoding)
|
||||
for (int j = 0; j < ds->taxonomy.nr; j++) {
|
||||
struct taxonomy *t = &ds->taxonomy.category[j];
|
||||
if (t->category != NONE) {
|
||||
if (t->category != TC_NONE) {
|
||||
put_format(&b, "geo cat %d origin %d ", t->category, t->origin);
|
||||
show_utf8(&b, "", t->value, "\n" );
|
||||
}
|
||||
|
|
|
@ -543,7 +543,7 @@ void save_dives_buffer(struct membuffer *b, const bool select_only)
|
|||
put_format(b, ">\n");
|
||||
for (int j = 0; j < ds->taxonomy.nr; j++) {
|
||||
struct taxonomy *t = &ds->taxonomy.category[j];
|
||||
if (t->category != NONE) {
|
||||
if (t->category != TC_NONE) {
|
||||
put_format(b, "<geo cat='%d'", t->category);
|
||||
put_format(b, " origin='%d'", t->origin);
|
||||
show_utf8(b, t->value, " value='", "'/>\n", 1);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "gettext.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
char *taxonomy_category_names[NR_CATEGORIES] = {
|
||||
char *taxonomy_category_names[TC_NR_CATEGORIES] = {
|
||||
QT_TRANSLATE_NOOP("getTextFromC", "None"),
|
||||
QT_TRANSLATE_NOOP("getTextFromC", "Ocean"),
|
||||
QT_TRANSLATE_NOOP("getTextFromC", "Country"),
|
||||
|
@ -12,7 +12,7 @@ char *taxonomy_category_names[NR_CATEGORIES] = {
|
|||
};
|
||||
|
||||
// these are the names for geoname.org
|
||||
char *taxonomy_api_names[NR_CATEGORIES] = {
|
||||
char *taxonomy_api_names[TC_NR_CATEGORIES] = {
|
||||
"none",
|
||||
"name",
|
||||
"countryName",
|
||||
|
@ -23,13 +23,13 @@ char *taxonomy_api_names[NR_CATEGORIES] = {
|
|||
|
||||
struct taxonomy *alloc_taxonomy()
|
||||
{
|
||||
return calloc(NR_CATEGORIES, sizeof(struct taxonomy));
|
||||
return calloc(TC_NR_CATEGORIES, sizeof(struct taxonomy));
|
||||
}
|
||||
|
||||
void free_taxonomy(struct taxonomy *t)
|
||||
{
|
||||
if (t) {
|
||||
for (int i = 0; i < NR_CATEGORIES; i++)
|
||||
for (int i = 0; i < TC_NR_CATEGORIES; i++)
|
||||
free((void *)t[i].value);
|
||||
free(t);
|
||||
}
|
||||
|
|
18
taxonomy.h
18
taxonomy.h
|
@ -6,17 +6,17 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
enum taxonomy_category {
|
||||
NONE,
|
||||
OCEAN,
|
||||
COUNTRY,
|
||||
ADMIN_L1,
|
||||
ADMIN_L2,
|
||||
LOCALNAME,
|
||||
NR_CATEGORIES
|
||||
TC_NONE,
|
||||
TC_OCEAN,
|
||||
TC_COUNTRY,
|
||||
TC_ADMIN_L1,
|
||||
TC_ADMIN_L2,
|
||||
TC_LOCALNAME,
|
||||
TC_NR_CATEGORIES
|
||||
};
|
||||
|
||||
extern char *taxonomy_category_names[NR_CATEGORIES];
|
||||
extern char *taxonomy_api_names[NR_CATEGORIES];
|
||||
extern char *taxonomy_category_names[TC_NR_CATEGORIES];
|
||||
extern char *taxonomy_api_names[TC_NR_CATEGORIES];
|
||||
|
||||
struct taxonomy {
|
||||
int category; /* the category for this tag: ocean, country, admin_l1, admin_l2, localname, etc */
|
||||
|
|
Loading…
Add table
Reference in a new issue