mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-07 20:53:25 +00:00
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:
parent
94fd758607
commit
4b2071728d
3 changed files with 17 additions and 23 deletions
|
@ -1,7 +1,7 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0
|
// SPDX-License-Identifier: GPL-2.0
|
||||||
#include "divecomputer.h"
|
#include "divecomputer.h"
|
||||||
#include "dive.h"
|
#include "dive.h"
|
||||||
#include "subsurface-qt/SettingsObjectWrapper.h"
|
#include "core/settings/qPrefDiveComputer.h"
|
||||||
#include "subsurface-string.h"
|
#include "subsurface-string.h"
|
||||||
|
|
||||||
DiveComputerList dcList;
|
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)
|
extern "C" int is_default_dive_computer(const char *vendor, const char *product)
|
||||||
{
|
{
|
||||||
auto dc = SettingsObjectWrapper::instance()->dive_computer_settings;
|
return qPrefDiveComputer::vendor() == vendor && qPrefDiveComputer::product() == product;
|
||||||
return dc->vendor() == vendor && dc->product() == product;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" int is_default_dive_computer_device(const char *name)
|
extern "C" int is_default_dive_computer_device(const char *name)
|
||||||
{
|
{
|
||||||
auto dc = SettingsObjectWrapper::instance()->dive_computer_settings;
|
return qPrefDiveComputer::device() == name;
|
||||||
return dc->device() == name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void set_dc_nickname(struct dive *dive)
|
extern "C" void set_dc_nickname(struct dive *dive)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "downloadfromdcthread.h"
|
#include "downloadfromdcthread.h"
|
||||||
#include "core/libdivecomputer.h"
|
#include "core/libdivecomputer.h"
|
||||||
#include "core/qthelper.h"
|
#include "core/qthelper.h"
|
||||||
#include "core/subsurface-qt/SettingsObjectWrapper.h"
|
#include "core/settings/qPrefDiveComputer.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#if defined(Q_OS_ANDROID)
|
#if defined(Q_OS_ANDROID)
|
||||||
|
@ -57,11 +57,10 @@ void DownloadThread::run()
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Finishing download thread:" << downloadTable.nr << "dives downloaded";
|
qDebug() << "Finishing download thread:" << downloadTable.nr << "dives downloaded";
|
||||||
}
|
}
|
||||||
auto dcs = SettingsObjectWrapper::instance()->dive_computer_settings;
|
qPrefDiveComputer::set_vendor(internalData->vendor);
|
||||||
dcs->set_vendor(internalData->vendor);
|
qPrefDiveComputer::set_product(internalData->product);
|
||||||
dcs->set_product(internalData->product);
|
qPrefDiveComputer::set_device(internalData->devname);
|
||||||
dcs->set_device(internalData->devname);
|
qPrefDiveComputer::set_device_name(m_data->devBluetoothName());
|
||||||
dcs->set_device_name(m_data->devBluetoothName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fill_supported_mobile_list()
|
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)
|
int DCDeviceData::getMatchingAddress(const QString &vendor, const QString &product)
|
||||||
{
|
{
|
||||||
auto dcs = SettingsObjectWrapper::instance()->dive_computer_settings;
|
if (qPrefDiveComputer::vendor() == vendor &&
|
||||||
if (dcs->vendor() == vendor &&
|
qPrefDiveComputer::product() == product) {
|
||||||
dcs->product() == product) {
|
|
||||||
// we are trying to show the last dive computer selected
|
// we are trying to show the last dive computer selected
|
||||||
for (int i = 0; i < connectionListModel.rowCount(); i++) {
|
for (int i = 0; i < connectionListModel.rowCount(); i++) {
|
||||||
QString address = connectionListModel.address(i);
|
QString address = connectionListModel.address(i);
|
||||||
if (address.contains(dcs->device()))
|
if (address.contains(qPrefDiveComputer::device()))
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -415,11 +413,10 @@ device_data_t *DCDeviceData::internalData()
|
||||||
|
|
||||||
int DCDeviceData::getDetectedVendorIndex()
|
int DCDeviceData::getDetectedVendorIndex()
|
||||||
{
|
{
|
||||||
auto dcs = SettingsObjectWrapper::instance()->dive_computer_settings;
|
if (!qPrefDiveComputer::vendor().isEmpty()) {
|
||||||
if (!dcs->vendor().isEmpty()) {
|
|
||||||
// use the last one
|
// use the last one
|
||||||
for (int i = 0; i < vendorList.length(); i++) {
|
for (int i = 0; i < vendorList.length(); i++) {
|
||||||
if (vendorList[i] == dcs->vendor())
|
if (vendorList[i] == qPrefDiveComputer::vendor())
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -436,12 +433,11 @@ int DCDeviceData::getDetectedVendorIndex()
|
||||||
|
|
||||||
int DCDeviceData::getDetectedProductIndex(const QString ¤tVendorText)
|
int DCDeviceData::getDetectedProductIndex(const QString ¤tVendorText)
|
||||||
{
|
{
|
||||||
auto dcs = SettingsObjectWrapper::instance()->dive_computer_settings;
|
if (!qPrefDiveComputer::vendor().isEmpty()) {
|
||||||
if (!dcs->vendor().isEmpty()) {
|
if (qPrefDiveComputer::vendor() == currentVendorText) {
|
||||||
if (dcs->vendor() == currentVendorText) {
|
|
||||||
// we are trying to show the last dive computer selected
|
// we are trying to show the last dive computer selected
|
||||||
for (int i = 0; i < productList[currentVendorText].length(); i++) {
|
for (int i = 0; i < productList[currentVendorText].length(); i++) {
|
||||||
if (productList[currentVendorText][i] == dcs->product())
|
if (productList[currentVendorText][i] == qPrefDiveComputer::product())
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include <QLibraryInfo>
|
#include <QLibraryInfo>
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
#include "qthelper.h"
|
#include "qthelper.h"
|
||||||
#include "core/subsurface-qt/SettingsObjectWrapper.h"
|
#include "core/settings/qPref.h"
|
||||||
|
|
||||||
char *settings_suffix = NULL;
|
char *settings_suffix = NULL;
|
||||||
static QTranslator *qtTranslator, *ssrfTranslator;
|
static QTranslator *qtTranslator, *ssrfTranslator;
|
||||||
|
|
Loading…
Add table
Reference in a new issue