diff options
-rw-r--r-- | pref.h | 5 | ||||
-rw-r--r-- | qt-models/divelocationmodel.cpp | 4 | ||||
-rw-r--r-- | qt-ui/preferences.cpp | 25 | ||||
-rw-r--r-- | subsurfacestartup.c | 4 |
4 files changed, 22 insertions, 16 deletions
@@ -6,6 +6,7 @@ extern "C" { #endif #include "units.h" +#include "taxonomy.h" /* can't use 'bool' for the boolean values - different size in C and C++ */ typedef struct @@ -28,9 +29,7 @@ typedef struct { bool enable_geocoding; bool parse_dive_without_gps; bool tag_existing_dives; - char *first_item; - char *second_item; - char *third_item; + enum taxonomy_category category[3]; } geocoding_prefs_t; struct preferences { diff --git a/qt-models/divelocationmodel.cpp b/qt-models/divelocationmodel.cpp index e34e20a5d..32bccd5e1 100644 --- a/qt-models/divelocationmodel.cpp +++ b/qt-models/divelocationmodel.cpp @@ -99,6 +99,8 @@ GeoReferencingOptionsModel *GeoReferencingOptionsModel::instance() { GeoReferencingOptionsModel::GeoReferencingOptionsModel(QObject *parent) : QStringListModel(parent) { 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); } diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp index c93460f9a..25638c991 100644 --- a/qt-ui/preferences.cpp +++ b/qt-ui/preferences.cpp @@ -241,9 +241,9 @@ void PreferencesDialog::setUiFromPrefs() ui.enable_geocoding->setChecked( prefs.geocoding.enable_geocoding ); ui.parse_without_gps->setChecked(prefs.geocoding.parse_dive_without_gps); ui.tag_existing_dives->setChecked(prefs.geocoding.tag_existing_dives); - ui.first_item->setCurrentText(prefs.geocoding.first_item); - ui.second_item->setCurrentText(prefs.geocoding.second_item); - ui.third_item->setCurrentText(prefs.geocoding.third_item); + ui.first_item->setCurrentIndex(prefs.geocoding.category[0]); + ui.second_item->setCurrentIndex(prefs.geocoding.category[1]); + ui.third_item->setCurrentIndex(prefs.geocoding.category[2]); } void PreferencesDialog::restorePrefs() @@ -288,6 +288,13 @@ void PreferencesDialog::rememberPrefs() else \ 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) \ v = s.value(QString(name)); \ if (v.isValid()) \ @@ -455,9 +462,9 @@ void PreferencesDialog::syncSettings() s.setValue("enable_geocoding", ui.enable_geocoding->isChecked()); s.setValue("parse_dives_without_gps", ui.parse_without_gps->isChecked()); s.setValue("tag_existing_dives", ui.tag_existing_dives->isChecked()); - s.setValue("first_item", ui.first_item->currentText()); - s.setValue("second_item", ui.second_item->currentText()); - s.setValue("third_item", ui.third_item->currentText()); + s.setValue("cat0", ui.first_item->currentIndex()); + s.setValue("cat1", ui.second_item->currentIndex()); + s.setValue("cat2", ui.third_item->currentIndex()); s.endGroup(); loadSettings(); @@ -603,9 +610,9 @@ void PreferencesDialog::loadSettings() GET_BOOL("enable_geocoding", geocoding.enable_geocoding); GET_BOOL("parse_dives_without_gps", geocoding.parse_dive_without_gps); GET_BOOL("tag_existing_dives", geocoding.tag_existing_dives); - GET_TXT("first_item", geocoding.first_item); - GET_TXT("second_item", geocoding.second_item); - GET_TXT("third_item", geocoding.third_item); + GET_ENUM("cat0", taxonomy_category, geocoding.category[0]); + GET_ENUM("cat1", taxonomy_category, geocoding.category[1]); + GET_ENUM("cat2", taxonomy_category, geocoding.category[2]); s.endGroup(); } diff --git a/subsurfacestartup.c b/subsurfacestartup.c index f5b0e7b4b..3005e7e04 100644 --- a/subsurfacestartup.c +++ b/subsurfacestartup.c @@ -74,9 +74,7 @@ struct preferences default_prefs = { .enable_geocoding = false, .parse_dive_without_gps = false, .tag_existing_dives = false, - .first_item = NULL, - .second_item = NULL, - .third_item = NULL + .category = { 0 } } }; |