mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 14:25:27 +00:00
core: remove location service preferences
Including the related tests. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
6f813b9f8e
commit
2a0d14b100
13 changed files with 0 additions and 301 deletions
|
@ -111,7 +111,6 @@ SOURCES += subsurface-mobile-main.cpp \
|
||||||
core/settings/qPrefGeneral.cpp \
|
core/settings/qPrefGeneral.cpp \
|
||||||
core/settings/qPrefGeocoding.cpp \
|
core/settings/qPrefGeocoding.cpp \
|
||||||
core/settings/qPrefLanguage.cpp \
|
core/settings/qPrefLanguage.cpp \
|
||||||
core/settings/qPrefLocationService.cpp \
|
|
||||||
core/settings/qPrefPartialPressureGas.cpp \
|
core/settings/qPrefPartialPressureGas.cpp \
|
||||||
core/settings/qPrefPrivate.cpp \
|
core/settings/qPrefPrivate.cpp \
|
||||||
core/settings/qPrefProxy.cpp \
|
core/settings/qPrefProxy.cpp \
|
||||||
|
@ -265,7 +264,6 @@ HEADERS += \
|
||||||
core/settings/qPrefGeneral.h \
|
core/settings/qPrefGeneral.h \
|
||||||
core/settings/qPrefGeocoding.h \
|
core/settings/qPrefGeocoding.h \
|
||||||
core/settings/qPrefLanguage.h \
|
core/settings/qPrefLanguage.h \
|
||||||
core/settings/qPrefLocationService.h \
|
|
||||||
core/settings/qPrefPartialPressureGas.h \
|
core/settings/qPrefPartialPressureGas.h \
|
||||||
core/settings/qPrefPrivate.h \
|
core/settings/qPrefPrivate.h \
|
||||||
core/settings/qPrefProxy.h \
|
core/settings/qPrefProxy.h \
|
||||||
|
|
|
@ -221,8 +221,6 @@ set(SUBSURFACE_CORE_LIB_SRCS
|
||||||
settings/qPrefGeocoding.h
|
settings/qPrefGeocoding.h
|
||||||
settings/qPrefLanguage.cpp
|
settings/qPrefLanguage.cpp
|
||||||
settings/qPrefLanguage.h
|
settings/qPrefLanguage.h
|
||||||
settings/qPrefLocationService.cpp
|
|
||||||
settings/qPrefLocationService.h
|
|
||||||
settings/qPrefLog.cpp
|
settings/qPrefLog.cpp
|
||||||
settings/qPrefLog.h
|
settings/qPrefLog.h
|
||||||
settings/qPrefMedia.cpp
|
settings/qPrefMedia.cpp
|
||||||
|
|
|
@ -84,8 +84,6 @@ struct preferences default_prefs = {
|
||||||
},
|
},
|
||||||
.planner_deco_mode = BUEHLMANN,
|
.planner_deco_mode = BUEHLMANN,
|
||||||
.vpmb_conservatism = 3,
|
.vpmb_conservatism = 3,
|
||||||
.distance_threshold = 100,
|
|
||||||
.time_threshold = 300,
|
|
||||||
#if defined(SUBSURFACE_MOBILE)
|
#if defined(SUBSURFACE_MOBILE)
|
||||||
.cloud_timeout = 10,
|
.cloud_timeout = 10,
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -134,10 +134,6 @@ struct preferences {
|
||||||
const char *time_format;
|
const char *time_format;
|
||||||
bool time_format_override;
|
bool time_format_override;
|
||||||
|
|
||||||
// ********** LocationService **********
|
|
||||||
int time_threshold;
|
|
||||||
int distance_threshold;
|
|
||||||
|
|
||||||
// ********** Network **********
|
// ********** Network **********
|
||||||
bool proxy_auth;
|
bool proxy_auth;
|
||||||
const char *proxy_host;
|
const char *proxy_host;
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
#include "qPrefGeneral.h"
|
#include "qPrefGeneral.h"
|
||||||
#include "qPrefGeocoding.h"
|
#include "qPrefGeocoding.h"
|
||||||
#include "qPrefLanguage.h"
|
#include "qPrefLanguage.h"
|
||||||
#include "qPrefLocationService.h"
|
|
||||||
#include "qPrefPartialPressureGas.h"
|
#include "qPrefPartialPressureGas.h"
|
||||||
#include "qPrefProxy.h"
|
#include "qPrefProxy.h"
|
||||||
#include "qPrefTechnicalDetails.h"
|
#include "qPrefTechnicalDetails.h"
|
||||||
|
@ -32,7 +31,6 @@ void qPref::loadSync(bool doSync)
|
||||||
qPrefGeneral::loadSync(doSync);
|
qPrefGeneral::loadSync(doSync);
|
||||||
qPrefGeocoding::loadSync(doSync);
|
qPrefGeocoding::loadSync(doSync);
|
||||||
qPrefLanguage::loadSync(doSync);
|
qPrefLanguage::loadSync(doSync);
|
||||||
qPrefLocationService::loadSync(doSync);
|
|
||||||
qPrefPartialPressureGas::loadSync(doSync);
|
qPrefPartialPressureGas::loadSync(doSync);
|
||||||
qPrefProxy::loadSync(doSync);
|
qPrefProxy::loadSync(doSync);
|
||||||
qPrefTechnicalDetails::loadSync(doSync);
|
qPrefTechnicalDetails::loadSync(doSync);
|
||||||
|
@ -67,7 +65,6 @@ void qPref::registerQML(QQmlEngine *engine)
|
||||||
ct->setContextProperty("PrefGeneral", qPrefGeneral::instance());
|
ct->setContextProperty("PrefGeneral", qPrefGeneral::instance());
|
||||||
ct->setContextProperty("PrefGeocoding", qPrefGeocoding::instance());
|
ct->setContextProperty("PrefGeocoding", qPrefGeocoding::instance());
|
||||||
ct->setContextProperty("PrefLanguage", qPrefLanguage::instance());
|
ct->setContextProperty("PrefLanguage", qPrefLanguage::instance());
|
||||||
ct->setContextProperty("PrefLocationService", qPrefLocationService::instance());
|
|
||||||
ct->setContextProperty("PrefPartialPressureGas", qPrefPartialPressureGas::instance());
|
ct->setContextProperty("PrefPartialPressureGas", qPrefPartialPressureGas::instance());
|
||||||
ct->setContextProperty("PrefProxy", qPrefProxy::instance());
|
ct->setContextProperty("PrefProxy", qPrefProxy::instance());
|
||||||
ct->setContextProperty("PrefTechnicalDetails", qPrefTechnicalDetails::instance());
|
ct->setContextProperty("PrefTechnicalDetails", qPrefTechnicalDetails::instance());
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0
|
|
||||||
#include "qPrefLocationService.h"
|
|
||||||
#include "qPrefPrivate.h"
|
|
||||||
|
|
||||||
static const QString group = QStringLiteral("LocationService");
|
|
||||||
|
|
||||||
qPrefLocationService *qPrefLocationService::instance()
|
|
||||||
{
|
|
||||||
static qPrefLocationService *self = new qPrefLocationService;
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
void qPrefLocationService::loadSync(bool doSync)
|
|
||||||
{
|
|
||||||
disk_distance_threshold(doSync);
|
|
||||||
disk_time_threshold(doSync);
|
|
||||||
}
|
|
||||||
|
|
||||||
HANDLE_PREFERENCE_INT(LocationService, "distance_threshold", distance_threshold);
|
|
||||||
|
|
||||||
HANDLE_PREFERENCE_INT(LocationService, "time_threshold", time_threshold);
|
|
|
@ -1,42 +0,0 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0
|
|
||||||
#ifndef QPREFLOCATIONSERVICE_H
|
|
||||||
#define QPREFLOCATIONSERVICE_H
|
|
||||||
#include "core/pref.h"
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
|
|
||||||
class qPrefLocationService : public QObject {
|
|
||||||
Q_OBJECT
|
|
||||||
Q_PROPERTY(int distance_threshold READ distance_threshold WRITE set_distance_threshold NOTIFY distance_thresholdChanged)
|
|
||||||
Q_PROPERTY(int time_threshold READ time_threshold WRITE set_time_threshold NOTIFY time_thresholdChanged)
|
|
||||||
|
|
||||||
public:
|
|
||||||
static qPrefLocationService *instance();
|
|
||||||
|
|
||||||
// Load/Sync local settings (disk) and struct preference
|
|
||||||
static void loadSync(bool doSync);
|
|
||||||
static void load() { loadSync(false); }
|
|
||||||
static void sync() { loadSync(true); }
|
|
||||||
|
|
||||||
public:
|
|
||||||
static int distance_threshold() { return prefs.distance_threshold; }
|
|
||||||
static int time_threshold() { return prefs.time_threshold; }
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
static void set_distance_threshold(int value);
|
|
||||||
static void set_time_threshold(int value);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void distance_thresholdChanged(int value);
|
|
||||||
void time_thresholdChanged(int value);
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
qPrefLocationService() {}
|
|
||||||
|
|
||||||
static void disk_distance_threshold(bool doSync);
|
|
||||||
static void disk_time_threshold(bool doSync);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -525,40 +525,9 @@ TemplatePage {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
|
||||||
GridLayout {
|
GridLayout {
|
||||||
id: gpsPrefs
|
|
||||||
visible: sectionAdvanced.isExpanded
|
visible: sectionAdvanced.isExpanded
|
||||||
width: parent.width
|
width: parent.width
|
||||||
columns: 2
|
columns: 2
|
||||||
TemplateLabel {
|
|
||||||
text: qsTr("GPS location service")
|
|
||||||
font.pointSize: subsurfaceTheme.headingPointSize
|
|
||||||
font.weight: Font.Light
|
|
||||||
Layout.topMargin: Kirigami.Units.largeSpacing
|
|
||||||
Layout.bottomMargin: Kirigami.Units.largeSpacing / 2
|
|
||||||
Layout.columnSpan: 2
|
|
||||||
}
|
|
||||||
TemplateLabel {
|
|
||||||
text: qsTr("Distance threshold (meters)")
|
|
||||||
}
|
|
||||||
TemplateTextField {
|
|
||||||
id: distanceThreshold
|
|
||||||
Layout.preferredWidth: Kirigami.Units.gridUnit * 2
|
|
||||||
text: PrefLocationService.distance_threshold
|
|
||||||
onEditingFinished: {
|
|
||||||
PrefLocationService.distance_threshold = distanceThreshold.text
|
|
||||||
}
|
|
||||||
}
|
|
||||||
TemplateLabel {
|
|
||||||
text: qsTr("Time threshold (minutes)")
|
|
||||||
}
|
|
||||||
TemplateTextField {
|
|
||||||
id: timeThreshold
|
|
||||||
Layout.preferredWidth: Kirigami.Units.gridUnit * 2
|
|
||||||
text: PrefLocationService.time_threshold / 60
|
|
||||||
onEditingFinished: {
|
|
||||||
PrefLocationService.time_threshold = timeThreshold.text * 60
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TemplateLine {
|
TemplateLine {
|
||||||
visible: sectionAdvanced.isExpanded
|
visible: sectionAdvanced.isExpanded
|
||||||
|
|
|
@ -42,7 +42,6 @@
|
||||||
#include "core/ssrf.h"
|
#include "core/ssrf.h"
|
||||||
#include "core/save-profiledata.h"
|
#include "core/save-profiledata.h"
|
||||||
#include "core/settings/qPrefLog.h"
|
#include "core/settings/qPrefLog.h"
|
||||||
#include "core/settings/qPrefLocationService.h"
|
|
||||||
#include "core/settings/qPrefTechnicalDetails.h"
|
#include "core/settings/qPrefTechnicalDetails.h"
|
||||||
#include "core/settings/qPrefPartialPressureGas.h"
|
#include "core/settings/qPrefPartialPressureGas.h"
|
||||||
#include "core/settings/qPrefUnit.h"
|
#include "core/settings/qPrefUnit.h"
|
||||||
|
|
|
@ -137,7 +137,6 @@ TEST(TestQPrefEquipment testqPrefEquipment.cpp)
|
||||||
TEST(TestQPrefMedia testqPrefMedia.cpp)
|
TEST(TestQPrefMedia testqPrefMedia.cpp)
|
||||||
TEST(TestQPrefGeocoding testqPrefGeocoding.cpp)
|
TEST(TestQPrefGeocoding testqPrefGeocoding.cpp)
|
||||||
TEST(TestQPrefLanguage testqPrefLanguage.cpp)
|
TEST(TestQPrefLanguage testqPrefLanguage.cpp)
|
||||||
TEST(TestQPrefLocationService testqPrefLocationService.cpp)
|
|
||||||
TEST(TestQPrefPartialPressureGas testqPrefPartialPressureGas.cpp)
|
TEST(TestQPrefPartialPressureGas testqPrefPartialPressureGas.cpp)
|
||||||
TEST(TestQPrefProxy testqPrefProxy.cpp)
|
TEST(TestQPrefProxy testqPrefProxy.cpp)
|
||||||
TEST(TestQPrefTechnicalDetails testqPrefTechnicalDetails.cpp)
|
TEST(TestQPrefTechnicalDetails testqPrefTechnicalDetails.cpp)
|
||||||
|
@ -174,7 +173,6 @@ add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}
|
||||||
TestQPrefMedia
|
TestQPrefMedia
|
||||||
TestQPrefGeocoding
|
TestQPrefGeocoding
|
||||||
TestQPrefLanguage
|
TestQPrefLanguage
|
||||||
TestQPrefLocationService
|
|
||||||
TestQPrefPartialPressureGas
|
TestQPrefPartialPressureGas
|
||||||
TestQPrefProxy
|
TestQPrefProxy
|
||||||
TestQPrefTechnicalDetails
|
TestQPrefTechnicalDetails
|
||||||
|
|
|
@ -1,132 +0,0 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0
|
|
||||||
#include "testqPrefLocationService.h"
|
|
||||||
|
|
||||||
#include "core/pref.h"
|
|
||||||
#include "core/qthelper.h"
|
|
||||||
#include "core/settings/qPrefLocationService.h"
|
|
||||||
|
|
||||||
#include <QTest>
|
|
||||||
#include <QSignalSpy>
|
|
||||||
|
|
||||||
void TestQPrefLocationService::initTestCase()
|
|
||||||
{
|
|
||||||
QCoreApplication::setOrganizationName("Subsurface");
|
|
||||||
QCoreApplication::setOrganizationDomain("subsurface.hohndel.org");
|
|
||||||
QCoreApplication::setApplicationName("SubsurfaceTestQPrefLocationService");
|
|
||||||
}
|
|
||||||
|
|
||||||
void TestQPrefLocationService::test_struct_get()
|
|
||||||
{
|
|
||||||
// Test struct pref -> get func.
|
|
||||||
|
|
||||||
auto tst = qPrefLocationService::instance();
|
|
||||||
|
|
||||||
prefs.distance_threshold = 1000;
|
|
||||||
prefs.time_threshold = 60;
|
|
||||||
|
|
||||||
QCOMPARE(tst->distance_threshold(), prefs.distance_threshold);
|
|
||||||
QCOMPARE(tst->time_threshold(), prefs.time_threshold);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TestQPrefLocationService::test_set_struct()
|
|
||||||
{
|
|
||||||
// Test set func -> struct pref
|
|
||||||
|
|
||||||
auto tst = qPrefLocationService::instance();
|
|
||||||
|
|
||||||
tst->set_distance_threshold(2000);
|
|
||||||
tst->set_time_threshold(90);
|
|
||||||
|
|
||||||
QCOMPARE(prefs.distance_threshold, 2000);
|
|
||||||
QCOMPARE(prefs.time_threshold, 90);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TestQPrefLocationService::test_set_load_struct()
|
|
||||||
{
|
|
||||||
// test set func -> load -> struct pref
|
|
||||||
|
|
||||||
auto tst = qPrefLocationService::instance();
|
|
||||||
|
|
||||||
tst->set_distance_threshold(2001);
|
|
||||||
tst->set_time_threshold(91);
|
|
||||||
|
|
||||||
prefs.distance_threshold = 1000;
|
|
||||||
prefs.time_threshold = 60;
|
|
||||||
|
|
||||||
tst->load();
|
|
||||||
QCOMPARE(tst->distance_threshold(), 2001);
|
|
||||||
QCOMPARE(tst->time_threshold(), 91);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TestQPrefLocationService::test_struct_disk()
|
|
||||||
{
|
|
||||||
// test struct prefs -> disk
|
|
||||||
|
|
||||||
auto tst = qPrefLocationService::instance();
|
|
||||||
|
|
||||||
prefs.distance_threshold = 1002;
|
|
||||||
prefs.time_threshold = 62;
|
|
||||||
|
|
||||||
tst->sync();
|
|
||||||
prefs.distance_threshold = 12;
|
|
||||||
prefs.time_threshold = 2;
|
|
||||||
|
|
||||||
tst->load();
|
|
||||||
QCOMPARE(tst->distance_threshold(), 1002);
|
|
||||||
QCOMPARE(tst->time_threshold(), 62);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TestQPrefLocationService::test_multiple()
|
|
||||||
{
|
|
||||||
// test multiple instances have the same information
|
|
||||||
|
|
||||||
prefs.distance_threshold = 52;
|
|
||||||
prefs.time_threshold = 62;
|
|
||||||
auto tst = qPrefLocationService::instance();
|
|
||||||
|
|
||||||
QCOMPARE(tst->distance_threshold(), qPrefLocationService::distance_threshold());
|
|
||||||
QCOMPARE(tst->time_threshold(), qPrefLocationService::time_threshold());
|
|
||||||
QCOMPARE(qPrefLocationService::distance_threshold(), 52);
|
|
||||||
QCOMPARE(qPrefLocationService::time_threshold(), 62);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define TEST(METHOD, VALUE) \
|
|
||||||
QCOMPARE(METHOD, VALUE); \
|
|
||||||
location->sync(); \
|
|
||||||
location->load(); \
|
|
||||||
QCOMPARE(METHOD, VALUE);
|
|
||||||
|
|
||||||
void TestQPrefLocationService::test_oldPreferences()
|
|
||||||
{
|
|
||||||
auto location = qPrefLocationService::instance();
|
|
||||||
|
|
||||||
location->set_time_threshold(10);
|
|
||||||
location->set_distance_threshold(20);
|
|
||||||
|
|
||||||
TEST(location->time_threshold(), 10);
|
|
||||||
TEST(location->distance_threshold(), 20);
|
|
||||||
|
|
||||||
location->set_time_threshold(30);
|
|
||||||
location->set_distance_threshold(40);
|
|
||||||
|
|
||||||
TEST(location->time_threshold(), 30);
|
|
||||||
TEST(location->distance_threshold(), 40);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TestQPrefLocationService::test_signals()
|
|
||||||
{
|
|
||||||
QSignalSpy spy1(qPrefLocationService::instance(), &qPrefLocationService::distance_thresholdChanged);
|
|
||||||
QSignalSpy spy2(qPrefLocationService::instance(), &qPrefLocationService::time_thresholdChanged);
|
|
||||||
|
|
||||||
qPrefLocationService::set_distance_threshold(-2000);
|
|
||||||
qPrefLocationService::set_time_threshold(-90);
|
|
||||||
|
|
||||||
QCOMPARE(spy1.count(), 1);
|
|
||||||
QCOMPARE(spy2.count(), 1);
|
|
||||||
|
|
||||||
QVERIFY(spy1.takeFirst().at(0).toInt() == -2000);
|
|
||||||
QVERIFY(spy2.takeFirst().at(0).toInt() == -90);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QTEST_MAIN(TestQPrefLocationService)
|
|
|
@ -1,21 +0,0 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0
|
|
||||||
#ifndef TESTQPREFLOCATIONSERVICE_H
|
|
||||||
#define TESTQPREFLOCATIONSERVICE_H
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
class TestQPrefLocationService : public QObject {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void initTestCase();
|
|
||||||
void test_struct_get();
|
|
||||||
void test_set_struct();
|
|
||||||
void test_set_load_struct();
|
|
||||||
void test_struct_disk();
|
|
||||||
void test_multiple();
|
|
||||||
void test_oldPreferences();
|
|
||||||
void test_signals();
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // TESTQPREFLOCATIONSERVICE_H
|
|
|
@ -1,38 +0,0 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0
|
|
||||||
import QtQuick 2.6
|
|
||||||
import QtTest 1.2
|
|
||||||
|
|
||||||
TestCase {
|
|
||||||
name: "qPrefLocationService"
|
|
||||||
|
|
||||||
function test_variables() {
|
|
||||||
var x1 = PrefLocationService.distance_threshold
|
|
||||||
PrefLocationService.distance_threshold = 123
|
|
||||||
compare(PrefLocationService.distance_threshold , 123)
|
|
||||||
|
|
||||||
var x2 = PrefLocationService.time_threshold
|
|
||||||
PrefLocationService.time_threshold = 12
|
|
||||||
compare(PrefLocationService.time_threshold , 12)
|
|
||||||
}
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: spyCatcher
|
|
||||||
|
|
||||||
property bool spy1 : false
|
|
||||||
property bool spy2 : false
|
|
||||||
|
|
||||||
Connections {
|
|
||||||
target: PrefLocationService
|
|
||||||
onDistance_thresholdChanged: {spyCatcher.spy1 = true }
|
|
||||||
onTime_thresholdChanged: {spyCatcher.spy2 = true }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function test_signals() {
|
|
||||||
PrefLocationService.distance_threshold = -123
|
|
||||||
PrefLocationService.time_threshold = -12
|
|
||||||
|
|
||||||
compare(spyCatcher.spy1, true)
|
|
||||||
compare(spyCatcher.spy2, true)
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Add table
Reference in a new issue