core: remove SettingsObjectWrapper and update qPref calls

remove use of SettingsObjectWrapper::
remove include of SettingsObjectWrapper.h
use qPrefFoo:: for setters and getters
replace prefs.foo with qPrefXYZ::foo() where feasible
(this expands to the same code, but gives us more control
over the variable).

Signed-off-by: Jan Iversen <jani@apache.org>
This commit is contained in:
jan Iversen 2018-08-15 11:54:37 +02:00 committed by Dirk Hohndel
parent 94fd758607
commit 4b2071728d
3 changed files with 17 additions and 23 deletions

View file

@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
#include "divecomputer.h"
#include "dive.h"
#include "subsurface-qt/SettingsObjectWrapper.h"
#include "core/settings/qPrefDiveComputer.h"
#include "subsurface-string.h"
DiveComputerList dcList;
@ -123,14 +123,12 @@ extern "C" void call_for_each_dc (void *f, void (*callback)(void *, const char *
extern "C" int is_default_dive_computer(const char *vendor, const char *product)
{
auto dc = SettingsObjectWrapper::instance()->dive_computer_settings;
return dc->vendor() == vendor && dc->product() == product;
return qPrefDiveComputer::vendor() == vendor && qPrefDiveComputer::product() == product;
}
extern "C" int is_default_dive_computer_device(const char *name)
{
auto dc = SettingsObjectWrapper::instance()->dive_computer_settings;
return dc->device() == name;
return qPrefDiveComputer::device() == name;
}
extern "C" void set_dc_nickname(struct dive *dive)

View file

@ -1,7 +1,7 @@
#include "downloadfromdcthread.h"
#include "core/libdivecomputer.h"
#include "core/qthelper.h"
#include "core/subsurface-qt/SettingsObjectWrapper.h"
#include "core/settings/qPrefDiveComputer.h"
#include <QDebug>
#include <QRegularExpression>
#if defined(Q_OS_ANDROID)
@ -57,11 +57,10 @@ void DownloadThread::run()
} else {
qDebug() << "Finishing download thread:" << downloadTable.nr << "dives downloaded";
}
auto dcs = SettingsObjectWrapper::instance()->dive_computer_settings;
dcs->set_vendor(internalData->vendor);
dcs->set_product(internalData->product);
dcs->set_device(internalData->devname);
dcs->set_device_name(m_data->devBluetoothName());
qPrefDiveComputer::set_vendor(internalData->vendor);
qPrefDiveComputer::set_product(internalData->product);
qPrefDiveComputer::set_device(internalData->devname);
qPrefDiveComputer::set_device_name(m_data->devBluetoothName());
}
static void fill_supported_mobile_list()
@ -252,13 +251,12 @@ QStringList DCDeviceData::getProductListFromVendor(const QString &vendor)
int DCDeviceData::getMatchingAddress(const QString &vendor, const QString &product)
{
auto dcs = SettingsObjectWrapper::instance()->dive_computer_settings;
if (dcs->vendor() == vendor &&
dcs->product() == product) {
if (qPrefDiveComputer::vendor() == vendor &&
qPrefDiveComputer::product() == product) {
// we are trying to show the last dive computer selected
for (int i = 0; i < connectionListModel.rowCount(); i++) {
QString address = connectionListModel.address(i);
if (address.contains(dcs->device()))
if (address.contains(qPrefDiveComputer::device()))
return i;
}
}
@ -415,11 +413,10 @@ device_data_t *DCDeviceData::internalData()
int DCDeviceData::getDetectedVendorIndex()
{
auto dcs = SettingsObjectWrapper::instance()->dive_computer_settings;
if (!dcs->vendor().isEmpty()) {
if (!qPrefDiveComputer::vendor().isEmpty()) {
// use the last one
for (int i = 0; i < vendorList.length(); i++) {
if (vendorList[i] == dcs->vendor())
if (vendorList[i] == qPrefDiveComputer::vendor())
return i;
}
}
@ -436,12 +433,11 @@ int DCDeviceData::getDetectedVendorIndex()
int DCDeviceData::getDetectedProductIndex(const QString &currentVendorText)
{
auto dcs = SettingsObjectWrapper::instance()->dive_computer_settings;
if (!dcs->vendor().isEmpty()) {
if (dcs->vendor() == currentVendorText) {
if (!qPrefDiveComputer::vendor().isEmpty()) {
if (qPrefDiveComputer::vendor() == currentVendorText) {
// we are trying to show the last dive computer selected
for (int i = 0; i < productList[currentVendorText].length(); i++) {
if (productList[currentVendorText][i] == dcs->product())
if (productList[currentVendorText][i] == qPrefDiveComputer::product())
return i;
}
}

View file

@ -5,7 +5,7 @@
#include <QLibraryInfo>
#include <QTextCodec>
#include "qthelper.h"
#include "core/subsurface-qt/SettingsObjectWrapper.h"
#include "core/settings/qPref.h"
char *settings_suffix = NULL;
static QTranslator *qtTranslator, *ssrfTranslator;