mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Geo taxonomy: adjust the preferences to the new data structures
This allows us to pick which three categories of geo taxonomy will be shown in the UI. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
f7b7d4c2df
commit
a413141b33
4 changed files with 22 additions and 16 deletions
5
pref.h
5
pref.h
|
@ -6,6 +6,7 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "units.h"
|
#include "units.h"
|
||||||
|
#include "taxonomy.h"
|
||||||
|
|
||||||
/* can't use 'bool' for the boolean values - different size in C and C++ */
|
/* can't use 'bool' for the boolean values - different size in C and C++ */
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -28,9 +29,7 @@ typedef struct {
|
||||||
bool enable_geocoding;
|
bool enable_geocoding;
|
||||||
bool parse_dive_without_gps;
|
bool parse_dive_without_gps;
|
||||||
bool tag_existing_dives;
|
bool tag_existing_dives;
|
||||||
char *first_item;
|
enum taxonomy_category category[3];
|
||||||
char *second_item;
|
|
||||||
char *third_item;
|
|
||||||
} geocoding_prefs_t;
|
} geocoding_prefs_t;
|
||||||
|
|
||||||
struct preferences {
|
struct preferences {
|
||||||
|
|
|
@ -99,6 +99,8 @@ GeoReferencingOptionsModel *GeoReferencingOptionsModel::instance() {
|
||||||
GeoReferencingOptionsModel::GeoReferencingOptionsModel(QObject *parent) : QStringListModel(parent)
|
GeoReferencingOptionsModel::GeoReferencingOptionsModel(QObject *parent) : QStringListModel(parent)
|
||||||
{
|
{
|
||||||
QStringList list;
|
QStringList list;
|
||||||
list << "Country" << "State" << "District" << "Town" << "Suburb" << "Body of Water" << "Site Name";
|
int i;
|
||||||
|
for (i = 0; i < NR_CATEGORIES; i++)
|
||||||
|
list << taxonomy_category_names[i];
|
||||||
setStringList(list);
|
setStringList(list);
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,9 +241,9 @@ void PreferencesDialog::setUiFromPrefs()
|
||||||
ui.enable_geocoding->setChecked( prefs.geocoding.enable_geocoding );
|
ui.enable_geocoding->setChecked( prefs.geocoding.enable_geocoding );
|
||||||
ui.parse_without_gps->setChecked(prefs.geocoding.parse_dive_without_gps);
|
ui.parse_without_gps->setChecked(prefs.geocoding.parse_dive_without_gps);
|
||||||
ui.tag_existing_dives->setChecked(prefs.geocoding.tag_existing_dives);
|
ui.tag_existing_dives->setChecked(prefs.geocoding.tag_existing_dives);
|
||||||
ui.first_item->setCurrentText(prefs.geocoding.first_item);
|
ui.first_item->setCurrentIndex(prefs.geocoding.category[0]);
|
||||||
ui.second_item->setCurrentText(prefs.geocoding.second_item);
|
ui.second_item->setCurrentIndex(prefs.geocoding.category[1]);
|
||||||
ui.third_item->setCurrentText(prefs.geocoding.third_item);
|
ui.third_item->setCurrentIndex(prefs.geocoding.category[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreferencesDialog::restorePrefs()
|
void PreferencesDialog::restorePrefs()
|
||||||
|
@ -288,6 +288,13 @@ void PreferencesDialog::rememberPrefs()
|
||||||
else \
|
else \
|
||||||
prefs.field = default_prefs.field
|
prefs.field = default_prefs.field
|
||||||
|
|
||||||
|
#define GET_ENUM(name, type, field) \
|
||||||
|
v = s.value(QString(name)); \
|
||||||
|
if (v.isValid()) \
|
||||||
|
prefs.field = (enum type)v.toInt(); \
|
||||||
|
else \
|
||||||
|
prefs.field = default_prefs.field
|
||||||
|
|
||||||
#define GET_INT_DEF(name, field, defval) \
|
#define GET_INT_DEF(name, field, defval) \
|
||||||
v = s.value(QString(name)); \
|
v = s.value(QString(name)); \
|
||||||
if (v.isValid()) \
|
if (v.isValid()) \
|
||||||
|
@ -455,9 +462,9 @@ void PreferencesDialog::syncSettings()
|
||||||
s.setValue("enable_geocoding", ui.enable_geocoding->isChecked());
|
s.setValue("enable_geocoding", ui.enable_geocoding->isChecked());
|
||||||
s.setValue("parse_dives_without_gps", ui.parse_without_gps->isChecked());
|
s.setValue("parse_dives_without_gps", ui.parse_without_gps->isChecked());
|
||||||
s.setValue("tag_existing_dives", ui.tag_existing_dives->isChecked());
|
s.setValue("tag_existing_dives", ui.tag_existing_dives->isChecked());
|
||||||
s.setValue("first_item", ui.first_item->currentText());
|
s.setValue("cat0", ui.first_item->currentIndex());
|
||||||
s.setValue("second_item", ui.second_item->currentText());
|
s.setValue("cat1", ui.second_item->currentIndex());
|
||||||
s.setValue("third_item", ui.third_item->currentText());
|
s.setValue("cat2", ui.third_item->currentIndex());
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
|
||||||
loadSettings();
|
loadSettings();
|
||||||
|
@ -603,9 +610,9 @@ void PreferencesDialog::loadSettings()
|
||||||
GET_BOOL("enable_geocoding", geocoding.enable_geocoding);
|
GET_BOOL("enable_geocoding", geocoding.enable_geocoding);
|
||||||
GET_BOOL("parse_dives_without_gps", geocoding.parse_dive_without_gps);
|
GET_BOOL("parse_dives_without_gps", geocoding.parse_dive_without_gps);
|
||||||
GET_BOOL("tag_existing_dives", geocoding.tag_existing_dives);
|
GET_BOOL("tag_existing_dives", geocoding.tag_existing_dives);
|
||||||
GET_TXT("first_item", geocoding.first_item);
|
GET_ENUM("cat0", taxonomy_category, geocoding.category[0]);
|
||||||
GET_TXT("second_item", geocoding.second_item);
|
GET_ENUM("cat1", taxonomy_category, geocoding.category[1]);
|
||||||
GET_TXT("third_item", geocoding.third_item);
|
GET_ENUM("cat2", taxonomy_category, geocoding.category[2]);
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,9 +74,7 @@ struct preferences default_prefs = {
|
||||||
.enable_geocoding = false,
|
.enable_geocoding = false,
|
||||||
.parse_dive_without_gps = false,
|
.parse_dive_without_gps = false,
|
||||||
.tag_existing_dives = false,
|
.tag_existing_dives = false,
|
||||||
.first_item = NULL,
|
.category = { 0 }
|
||||||
.second_item = NULL,
|
|
||||||
.third_item = NULL
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue