mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
core: activate qPrefGeocoding
remove Geocoding from SettingsObjectWrapper and reference qPrefFacebook update files using SettingsObjectWrapper/Geocoding to use qPrefFacebook this activated qPrefGeocoding and removed the similar class from SettingsObjectWrapper. Signed-off-by: Jan Iversen <jani@apache.org>
This commit is contained in:
parent
3cd698361c
commit
af22015452
6 changed files with 23 additions and 107 deletions
|
@ -20,6 +20,7 @@ void qPref::loadSync(bool doSync)
|
||||||
qPrefDiveComputer::instance()->loadSync(doSync);
|
qPrefDiveComputer::instance()->loadSync(doSync);
|
||||||
qPrefDivePlanner::instance()->loadSync(doSync);
|
qPrefDivePlanner::instance()->loadSync(doSync);
|
||||||
// qPrefFaceook does not use disk.
|
// qPrefFaceook does not use disk.
|
||||||
|
qPrefGeocoding::instance()->loadSync(doSync);
|
||||||
qPrefLanguage::instance()->loadSync(doSync);
|
qPrefLanguage::instance()->loadSync(doSync);
|
||||||
qPrefLocationService::instance()->loadSync(doSync);
|
qPrefLocationService::instance()->loadSync(doSync);
|
||||||
qPrefProxy::instance()->loadSync(doSync);
|
qPrefProxy::instance()->loadSync(doSync);
|
||||||
|
|
|
@ -134,60 +134,6 @@ void PartialPressureGasSettings::setPheThreshold(double value)
|
||||||
emit pheThresholdChanged(value);
|
emit pheThresholdChanged(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
GeocodingPreferences::GeocodingPreferences(QObject *parent) :
|
|
||||||
QObject(parent)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
taxonomy_category GeocodingPreferences::firstTaxonomyCategory() const
|
|
||||||
{
|
|
||||||
return prefs.geocoding.category[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
taxonomy_category GeocodingPreferences::secondTaxonomyCategory() const
|
|
||||||
{
|
|
||||||
return prefs.geocoding.category[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
taxonomy_category GeocodingPreferences::thirdTaxonomyCategory() const
|
|
||||||
{
|
|
||||||
return prefs.geocoding.category[2];
|
|
||||||
}
|
|
||||||
|
|
||||||
void GeocodingPreferences::setFirstTaxonomyCategory(taxonomy_category value)
|
|
||||||
{
|
|
||||||
if (value == prefs.geocoding.category[0])
|
|
||||||
return;
|
|
||||||
QSettings s;
|
|
||||||
s.beginGroup(group);
|
|
||||||
s.setValue("cat0", value);
|
|
||||||
prefs.geocoding.category[0] = value;
|
|
||||||
emit firstTaxonomyCategoryChanged(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GeocodingPreferences::setSecondTaxonomyCategory(taxonomy_category value)
|
|
||||||
{
|
|
||||||
if (value == prefs.geocoding.category[1])
|
|
||||||
return;
|
|
||||||
QSettings s;
|
|
||||||
s.beginGroup(group);
|
|
||||||
s.setValue("cat1", value);
|
|
||||||
prefs.geocoding.category[1]= value;
|
|
||||||
emit secondTaxonomyCategoryChanged(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GeocodingPreferences::setThirdTaxonomyCategory(taxonomy_category value)
|
|
||||||
{
|
|
||||||
if (value == prefs.geocoding.category[2])
|
|
||||||
return;
|
|
||||||
QSettings s;
|
|
||||||
s.beginGroup(group);
|
|
||||||
s.setValue("cat2", value);
|
|
||||||
prefs.geocoding.category[2] = value;
|
|
||||||
emit thirdTaxonomyCategoryChanged(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
GeneralSettingsObjectWrapper::GeneralSettingsObjectWrapper(QObject *parent) :
|
GeneralSettingsObjectWrapper::GeneralSettingsObjectWrapper(QObject *parent) :
|
||||||
QObject(parent)
|
QObject(parent)
|
||||||
{
|
{
|
||||||
|
@ -395,7 +341,7 @@ QObject(parent),
|
||||||
techDetails(new qPrefTechnicalDetails(this)),
|
techDetails(new qPrefTechnicalDetails(this)),
|
||||||
pp_gas(new PartialPressureGasSettings(this)),
|
pp_gas(new PartialPressureGasSettings(this)),
|
||||||
facebook(new qPrefFacebook(this)),
|
facebook(new qPrefFacebook(this)),
|
||||||
geocoding(new GeocodingPreferences(this)),
|
geocoding(new qPrefGeocoding(this)),
|
||||||
proxy(new qPrefProxy(this)),
|
proxy(new qPrefProxy(this)),
|
||||||
cloud_storage(new qPrefCloudStorage(this)),
|
cloud_storage(new qPrefCloudStorage(this)),
|
||||||
planner_settings(new qPrefDivePlanner(this)),
|
planner_settings(new qPrefDivePlanner(this)),
|
||||||
|
@ -443,14 +389,7 @@ void SettingsObjectWrapper::load()
|
||||||
qPrefCloudStorage::instance()->load();
|
qPrefCloudStorage::instance()->load();
|
||||||
qPrefDisplay::instance()->load();
|
qPrefDisplay::instance()->load();
|
||||||
qPrefProxy::instance()->load();
|
qPrefProxy::instance()->load();
|
||||||
|
qPrefGeocoding::instance()->load();
|
||||||
// GeoManagement
|
|
||||||
s.beginGroup("geocoding");
|
|
||||||
|
|
||||||
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();
|
|
||||||
|
|
||||||
// GPS service time and distance thresholds
|
// GPS service time and distance thresholds
|
||||||
qPrefLocationService::instance()->load();
|
qPrefLocationService::instance()->load();
|
||||||
|
|
|
@ -56,31 +56,6 @@ private:
|
||||||
const QString group = QStringLiteral("TecDetails");
|
const QString group = QStringLiteral("TecDetails");
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Control the state of the Geocoding preferences */
|
|
||||||
class GeocodingPreferences : public QObject {
|
|
||||||
Q_OBJECT
|
|
||||||
Q_PROPERTY(taxonomy_category first_category READ firstTaxonomyCategory WRITE setFirstTaxonomyCategory NOTIFY firstTaxonomyCategoryChanged)
|
|
||||||
Q_PROPERTY(taxonomy_category second_category READ secondTaxonomyCategory WRITE setSecondTaxonomyCategory NOTIFY secondTaxonomyCategoryChanged)
|
|
||||||
Q_PROPERTY(taxonomy_category third_category READ thirdTaxonomyCategory WRITE setThirdTaxonomyCategory NOTIFY thirdTaxonomyCategoryChanged)
|
|
||||||
public:
|
|
||||||
GeocodingPreferences(QObject *parent);
|
|
||||||
taxonomy_category firstTaxonomyCategory() const;
|
|
||||||
taxonomy_category secondTaxonomyCategory() const;
|
|
||||||
taxonomy_category thirdTaxonomyCategory() const;
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void setFirstTaxonomyCategory(taxonomy_category value);
|
|
||||||
void setSecondTaxonomyCategory(taxonomy_category value);
|
|
||||||
void setThirdTaxonomyCategory(taxonomy_category value);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void firstTaxonomyCategoryChanged(taxonomy_category value);
|
|
||||||
void secondTaxonomyCategoryChanged(taxonomy_category value);
|
|
||||||
void thirdTaxonomyCategoryChanged(taxonomy_category value);
|
|
||||||
private:
|
|
||||||
const QString group = QStringLiteral("geocoding");
|
|
||||||
};
|
|
||||||
|
|
||||||
class GeneralSettingsObjectWrapper : public QObject {
|
class GeneralSettingsObjectWrapper : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(QString default_filename READ defaultFilename WRITE setDefaultFilename NOTIFY defaultFilenameChanged)
|
Q_PROPERTY(QString default_filename READ defaultFilename WRITE setDefaultFilename NOTIFY defaultFilenameChanged)
|
||||||
|
@ -144,7 +119,7 @@ class SettingsObjectWrapper : public QObject {
|
||||||
Q_PROPERTY(qPrefTechnicalDetails* techical_details MEMBER techDetails CONSTANT)
|
Q_PROPERTY(qPrefTechnicalDetails* techical_details MEMBER techDetails CONSTANT)
|
||||||
Q_PROPERTY(PartialPressureGasSettings* pp_gas MEMBER pp_gas CONSTANT)
|
Q_PROPERTY(PartialPressureGasSettings* pp_gas MEMBER pp_gas CONSTANT)
|
||||||
Q_PROPERTY(qPrefFacebook* facebook MEMBER facebook CONSTANT)
|
Q_PROPERTY(qPrefFacebook* facebook MEMBER facebook CONSTANT)
|
||||||
Q_PROPERTY(GeocodingPreferences* geocoding MEMBER geocoding CONSTANT)
|
Q_PROPERTY(qPrefGeocoding* geocoding MEMBER geocoding CONSTANT)
|
||||||
Q_PROPERTY(qPrefProxy* proxy MEMBER proxy CONSTANT)
|
Q_PROPERTY(qPrefProxy* proxy MEMBER proxy CONSTANT)
|
||||||
Q_PROPERTY(qPrefCloudStorage* cloud_storage MEMBER cloud_storage CONSTANT)
|
Q_PROPERTY(qPrefCloudStorage* cloud_storage MEMBER cloud_storage CONSTANT)
|
||||||
Q_PROPERTY(qPrefDivePlanner* planner MEMBER planner_settings CONSTANT)
|
Q_PROPERTY(qPrefDivePlanner* planner MEMBER planner_settings CONSTANT)
|
||||||
|
@ -163,7 +138,7 @@ public:
|
||||||
qPrefTechnicalDetails *techDetails;
|
qPrefTechnicalDetails *techDetails;
|
||||||
PartialPressureGasSettings *pp_gas;
|
PartialPressureGasSettings *pp_gas;
|
||||||
qPrefFacebook *facebook;
|
qPrefFacebook *facebook;
|
||||||
GeocodingPreferences *geocoding;
|
qPrefGeocoding *geocoding;
|
||||||
qPrefProxy *proxy;
|
qPrefProxy *proxy;
|
||||||
qPrefCloudStorage *cloud_storage;
|
qPrefCloudStorage *cloud_storage;
|
||||||
qPrefDivePlanner *planner_settings;
|
qPrefDivePlanner *planner_settings;
|
||||||
|
|
|
@ -30,8 +30,8 @@ void PreferencesGeoreference::refreshSettings()
|
||||||
|
|
||||||
void PreferencesGeoreference::syncSettings()
|
void PreferencesGeoreference::syncSettings()
|
||||||
{
|
{
|
||||||
auto geocoding = SettingsObjectWrapper::instance()->geocoding;
|
auto geocoding = qPrefGeocoding::instance();
|
||||||
geocoding->setFirstTaxonomyCategory((taxonomy_category) ui->first_item->currentIndex());
|
geocoding->set_first_taxonomy_category((taxonomy_category) ui->first_item->currentIndex());
|
||||||
geocoding->setSecondTaxonomyCategory((taxonomy_category) ui->second_item->currentIndex());
|
geocoding->set_second_taxonomy_category((taxonomy_category) ui->second_item->currentIndex());
|
||||||
geocoding->setThirdTaxonomyCategory((taxonomy_category) ui->third_item->currentIndex());
|
geocoding->set_third_taxonomy_category((taxonomy_category) ui->third_item->currentIndex());
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,6 +162,7 @@ void register_qml_types()
|
||||||
REGISTER_TYPE(qPrefDiveComputer, "SsrfDiveComputerPrefs");
|
REGISTER_TYPE(qPrefDiveComputer, "SsrfDiveComputerPrefs");
|
||||||
REGISTER_TYPE(qPrefDivePlanner, "SsrfDivePlannerPrefs");
|
REGISTER_TYPE(qPrefDivePlanner, "SsrfDivePlannerPrefs");
|
||||||
REGISTER_TYPE(qPrefFacebook, "SsrfFacebookPrefs");
|
REGISTER_TYPE(qPrefFacebook, "SsrfFacebookPrefs");
|
||||||
|
REGISTER_TYPE(qPrefGeocoding, "SsrfGeocodingPrefs");
|
||||||
REGISTER_TYPE(qPrefLanguage, "SsrfLanguagePrefs");
|
REGISTER_TYPE(qPrefLanguage, "SsrfLanguagePrefs");
|
||||||
REGISTER_TYPE(qPrefLocationService, "SsrfLocationServicePrefs");
|
REGISTER_TYPE(qPrefLocationService, "SsrfLocationServicePrefs");
|
||||||
REGISTER_TYPE(qPrefProxy, "SsrfProxyPrefs");
|
REGISTER_TYPE(qPrefProxy, "SsrfProxyPrefs");
|
||||||
|
|
|
@ -57,22 +57,22 @@ void TestPreferences::testPreferences()
|
||||||
TEST(pp->po2ThresholdMin(), 4.0);
|
TEST(pp->po2ThresholdMin(), 4.0);
|
||||||
TEST(pp->po2ThresholdMax(), 5.0);
|
TEST(pp->po2ThresholdMax(), 5.0);
|
||||||
|
|
||||||
auto geo = pref->geocoding;
|
auto geo = qPrefGeocoding::instance();
|
||||||
geo->setFirstTaxonomyCategory(TC_NONE);
|
geo->set_first_taxonomy_category(TC_NONE);
|
||||||
geo->setSecondTaxonomyCategory(TC_OCEAN);
|
geo->set_second_taxonomy_category(TC_OCEAN);
|
||||||
geo->setThirdTaxonomyCategory(TC_COUNTRY);
|
geo->set_third_taxonomy_category(TC_COUNTRY);
|
||||||
|
|
||||||
TEST(geo->firstTaxonomyCategory(), TC_NONE);
|
TEST(geo->first_taxonomy_category(), TC_NONE);
|
||||||
TEST(geo->secondTaxonomyCategory(), TC_OCEAN);
|
TEST(geo->second_taxonomy_category(), TC_OCEAN);
|
||||||
TEST(geo->thirdTaxonomyCategory(), TC_COUNTRY);
|
TEST(geo->third_taxonomy_category(), TC_COUNTRY);
|
||||||
|
|
||||||
geo->setFirstTaxonomyCategory(TC_OCEAN);
|
geo->set_first_taxonomy_category(TC_OCEAN);
|
||||||
geo->setSecondTaxonomyCategory(TC_COUNTRY);
|
geo->set_second_taxonomy_category(TC_COUNTRY);
|
||||||
geo->setThirdTaxonomyCategory(TC_NONE);
|
geo->set_third_taxonomy_category(TC_NONE);
|
||||||
|
|
||||||
TEST(geo->firstTaxonomyCategory(), TC_OCEAN);
|
TEST(geo->first_taxonomy_category(), TC_OCEAN);
|
||||||
TEST(geo->secondTaxonomyCategory(), TC_COUNTRY);
|
TEST(geo->second_taxonomy_category(), TC_COUNTRY);
|
||||||
TEST(geo->thirdTaxonomyCategory(), TC_NONE);
|
TEST(geo->third_taxonomy_category(), TC_NONE);
|
||||||
|
|
||||||
auto general = pref->general_settings;
|
auto general = pref->general_settings;
|
||||||
general->setDefaultFilename("filename");
|
general->setDefaultFilename("filename");
|
||||||
|
|
Loading…
Add table
Reference in a new issue