mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Cleanup[5/6]: remove unused preferences
Remove all the code to handle the preferences itself. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
This commit is contained in:
parent
bb0ac5f778
commit
19e8fa4eaf
3 changed files with 0 additions and 63 deletions
|
@ -24,8 +24,6 @@ void qPrefCloudStorage::loadSync(bool doSync)
|
|||
disk_cloud_timeout(doSync);
|
||||
disk_cloud_verification_status(doSync);
|
||||
disk_save_password_local(doSync);
|
||||
disk_save_userid_local(doSync);
|
||||
disk_userid(doSync);
|
||||
}
|
||||
|
||||
void qPrefCloudStorage::set_cloud_base_url(const QString &value)
|
||||
|
@ -81,22 +79,3 @@ HANDLE_PREFERENCE_INT(CloudStorage, "timeout", cloud_timeout);
|
|||
HANDLE_PREFERENCE_INT(CloudStorage, "cloud_verification_status", cloud_verification_status);
|
||||
|
||||
HANDLE_PREFERENCE_BOOL(CloudStorage, "save_password_local", save_password_local);
|
||||
|
||||
HANDLE_PREFERENCE_BOOL(CloudStorage, "save_userid_local", save_userid_local);
|
||||
|
||||
SET_PREFERENCE_TXT(CloudStorage, userid);
|
||||
void qPrefCloudStorage::disk_userid(bool doSync)
|
||||
{
|
||||
if (doSync) {
|
||||
// always save in new position (part of cloud storage group)
|
||||
qPrefPrivate::propSetValue(keyFromGroupAndName(group, "subsurface_webservice_uid"), prefs.userid, default_prefs.userid);
|
||||
} else {
|
||||
//WARNING: UserId was stored outside of any group.
|
||||
// try to read from new location, if it fails read from old location
|
||||
prefs.userid = copy_qstring(qPrefPrivate::propValue(keyFromGroupAndName(group, "subsurface_webservice_uid"), "NoUserIdHere").toString());
|
||||
if (QString(prefs.userid) == "NoUserIdHere") {
|
||||
const QString group = QStringLiteral("");
|
||||
prefs.userid = copy_qstring(qPrefPrivate::propValue(keyFromGroupAndName(group,"subsurface_webservice_uid"), default_prefs.userid).toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,8 +16,6 @@ class qPrefCloudStorage : public QObject {
|
|||
Q_PROPERTY(int cloud_verification_status READ cloud_verification_status WRITE set_cloud_verification_status NOTIFY cloud_verification_status_changed);
|
||||
Q_PROPERTY(int cloud_timeout READ cloud_timeout WRITE set_cloud_timeout NOTIFY cloud_timeout_changed);
|
||||
Q_PROPERTY(bool save_password_local READ save_password_local WRITE set_save_password_local NOTIFY save_password_local_changed);
|
||||
Q_PROPERTY(bool save_userid_local READ save_userid_local WRITE set_save_userid_local NOTIFY save_userid_local_changed);
|
||||
Q_PROPERTY(QString userid READ userid WRITE set_userid NOTIFY userid_changed);
|
||||
|
||||
public:
|
||||
qPrefCloudStorage(QObject *parent = NULL);
|
||||
|
@ -38,8 +36,6 @@ public:
|
|||
static int cloud_timeout() { return prefs.cloud_timeout; }
|
||||
static int cloud_verification_status() { return prefs.cloud_verification_status; }
|
||||
static bool save_password_local() { return prefs.save_password_local; }
|
||||
static bool save_userid_local() { return prefs.save_userid_local; }
|
||||
static QString userid() { return prefs.userid; }
|
||||
|
||||
public slots:
|
||||
static void set_cloud_base_url(const QString &value);
|
||||
|
@ -50,8 +46,6 @@ public slots:
|
|||
static void set_cloud_timeout(int value);
|
||||
static void set_cloud_verification_status(int value);
|
||||
static void set_save_password_local(bool value);
|
||||
static void set_save_userid_local(bool value);
|
||||
static void set_userid(const QString &value);
|
||||
|
||||
signals:
|
||||
void cloud_base_url_changed(const QString &value);
|
||||
|
@ -62,8 +56,6 @@ signals:
|
|||
void cloud_timeout_changed(int value);
|
||||
void cloud_verification_status_changed(int value);
|
||||
void save_password_local_changed(bool value);
|
||||
void save_userid_local_changed(bool value);
|
||||
void userid_changed(const QString &value);
|
||||
|
||||
private:
|
||||
// functions to load/sync variable with disk
|
||||
|
@ -75,8 +67,6 @@ private:
|
|||
static void disk_cloud_timeout(bool doSync);
|
||||
static void disk_cloud_verification_status(bool doSync);
|
||||
static void disk_save_password_local(bool doSync);
|
||||
static void disk_save_userid_local(bool doSync);
|
||||
static void disk_userid(bool doSync);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -29,8 +29,6 @@ void TestQPrefCloudStorage::test_struct_get()
|
|||
prefs.cloud_timeout = 117;
|
||||
prefs.cloud_verification_status = qPref::CS_NOCLOUD;
|
||||
prefs.save_password_local = true;
|
||||
prefs.save_userid_local = true;
|
||||
prefs.userid = copy_qstring("my user");
|
||||
|
||||
QCOMPARE(tst->cloud_base_url(), QString(prefs.cloud_base_url));
|
||||
QCOMPARE(tst->cloud_git_url(), QString(prefs.cloud_git_url));
|
||||
|
@ -41,8 +39,6 @@ void TestQPrefCloudStorage::test_struct_get()
|
|||
QCOMPARE(tst->cloud_timeout(), (int)prefs.cloud_timeout);
|
||||
QCOMPARE(tst->cloud_verification_status(), (int)prefs.cloud_verification_status);
|
||||
QCOMPARE(tst->save_password_local(), prefs.save_password_local);
|
||||
QCOMPARE(tst->save_userid_local(), prefs.save_userid_local);
|
||||
QCOMPARE(tst->userid(), QString(prefs.userid));
|
||||
}
|
||||
|
||||
void TestQPrefCloudStorage::test_set_struct()
|
||||
|
@ -59,8 +55,6 @@ void TestQPrefCloudStorage::test_set_struct()
|
|||
tst->set_cloud_timeout(123);
|
||||
tst->set_cloud_verification_status(qPref::CS_VERIFIED);
|
||||
tst->set_save_password_local(false);
|
||||
tst->set_save_userid_local(false);
|
||||
tst->set_userid("t2 user");
|
||||
|
||||
QCOMPARE(QString(prefs.cloud_base_url), QString("t2 base"));
|
||||
QCOMPARE(QString(prefs.cloud_storage_email), QString("t2 email"));
|
||||
|
@ -70,8 +64,6 @@ void TestQPrefCloudStorage::test_set_struct()
|
|||
QCOMPARE((int)prefs.cloud_timeout, 123);
|
||||
QCOMPARE((int)prefs.cloud_verification_status, (int)qPref::CS_VERIFIED);
|
||||
QCOMPARE(prefs.save_password_local, false);
|
||||
QCOMPARE(prefs.save_userid_local, false);
|
||||
QCOMPARE(QString(prefs.userid), QString("t2 user"));
|
||||
|
||||
// remark is set with set_base_url
|
||||
QCOMPARE(QString(prefs.cloud_git_url), QString("t2 base/git"));
|
||||
|
@ -91,8 +83,6 @@ void TestQPrefCloudStorage::test_set_load_struct()
|
|||
tst->set_cloud_storage_pin("t3 pin");
|
||||
tst->set_cloud_timeout(321);
|
||||
tst->set_cloud_verification_status(qPref::CS_NOCLOUD);
|
||||
tst->set_save_userid_local(true);
|
||||
tst->set_userid("t3 user");
|
||||
|
||||
prefs.cloud_base_url = copy_qstring("error1");
|
||||
prefs.cloud_git_url = copy_qstring("error1");
|
||||
|
@ -103,8 +93,6 @@ void TestQPrefCloudStorage::test_set_load_struct()
|
|||
prefs.cloud_timeout = 324;
|
||||
prefs.cloud_verification_status = qPref::CS_VERIFIED;
|
||||
prefs.save_password_local = false;
|
||||
prefs.save_userid_local = false;
|
||||
prefs.userid = copy_qstring("error1");
|
||||
|
||||
tst->load();
|
||||
QCOMPARE(QString(prefs.cloud_base_url), QString("t3 base"));
|
||||
|
@ -115,8 +103,6 @@ void TestQPrefCloudStorage::test_set_load_struct()
|
|||
QCOMPARE((int)prefs.cloud_timeout, 321);
|
||||
QCOMPARE((int)prefs.cloud_verification_status, (int)qPref::CS_NOCLOUD);
|
||||
QCOMPARE(prefs.save_password_local, true);
|
||||
QCOMPARE(prefs.save_userid_local, true);
|
||||
QCOMPARE(QString(prefs.userid), QString("t3 user"));
|
||||
|
||||
// remark is set with set_base_url
|
||||
QCOMPARE(QString(prefs.cloud_git_url), QString("t3 base/git"));
|
||||
|
@ -136,8 +122,6 @@ void TestQPrefCloudStorage::test_struct_disk()
|
|||
prefs.cloud_storage_pin = copy_qstring("t4 pin");
|
||||
prefs.cloud_timeout = 123;
|
||||
prefs.cloud_verification_status = qPref::CS_VERIFIED;
|
||||
prefs.save_userid_local = true;
|
||||
prefs.userid = copy_qstring("t4 user");
|
||||
|
||||
tst->sync();
|
||||
|
||||
|
@ -150,8 +134,6 @@ void TestQPrefCloudStorage::test_struct_disk()
|
|||
prefs.cloud_timeout = 324;
|
||||
prefs.cloud_verification_status = qPref::CS_VERIFIED;
|
||||
prefs.save_password_local = false;
|
||||
prefs.save_userid_local = false;
|
||||
prefs.userid = copy_qstring("error1");
|
||||
|
||||
tst->load();
|
||||
|
||||
|
@ -163,8 +145,6 @@ void TestQPrefCloudStorage::test_struct_disk()
|
|||
QCOMPARE((int)prefs.cloud_timeout, 123);
|
||||
QCOMPARE((int)prefs.cloud_verification_status, (int)qPref::CS_VERIFIED);
|
||||
QCOMPARE(prefs.save_password_local, true);
|
||||
QCOMPARE(prefs.save_userid_local, true);
|
||||
QCOMPARE(QString(prefs.userid), QString("t4 user"));
|
||||
|
||||
// remark is set with set_base_url
|
||||
QCOMPARE(QString(prefs.cloud_git_url), QString("t4 base/git"));
|
||||
|
@ -174,14 +154,12 @@ void TestQPrefCloudStorage::test_multiple()
|
|||
{
|
||||
// test multiple instances have the same information
|
||||
|
||||
prefs.userid = copy_qstring("my user");
|
||||
auto tst_direct = new qPrefCloudStorage;
|
||||
|
||||
prefs.cloud_timeout = 25;
|
||||
auto tst = qPrefCloudStorage::instance();
|
||||
|
||||
QCOMPARE(tst->cloud_timeout(), tst_direct->cloud_timeout());
|
||||
QCOMPARE(tst->userid(), tst_direct->userid());
|
||||
QCOMPARE(tst_direct->cloud_timeout(), 25);
|
||||
}
|
||||
|
||||
|
@ -215,16 +193,6 @@ void TestQPrefCloudStorage::test_oldPreferences()
|
|||
cloud->set_save_password_local(false);
|
||||
TEST(cloud->save_password_local(), false);
|
||||
|
||||
cloud->set_save_userid_local(1);
|
||||
TEST(cloud->save_userid_local(), true);
|
||||
cloud->set_save_userid_local(0);
|
||||
TEST(cloud->save_userid_local(), false);
|
||||
|
||||
cloud->set_userid("Tomaz");
|
||||
TEST(cloud->userid(), QStringLiteral("Tomaz"));
|
||||
cloud->set_userid("Zamot");
|
||||
TEST(cloud->userid(), QStringLiteral("Zamot"));
|
||||
|
||||
cloud->set_cloud_verification_status(0);
|
||||
TEST(cloud->cloud_verification_status(), 0);
|
||||
cloud->set_cloud_verification_status(1);
|
||||
|
|
Loading…
Add table
Reference in a new issue