mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Whitespace cleanup core divecomputer handling
Not entirely script based because of two odd issues where the script creates bogus indentation. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
0e6c3db24c
commit
c7f0e65b12
2 changed files with 19 additions and 20 deletions
|
@ -1,8 +1,8 @@
|
||||||
// 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-string.h"
|
|
||||||
#include "subsurface-qt/SettingsObjectWrapper.h"
|
#include "subsurface-qt/SettingsObjectWrapper.h"
|
||||||
|
#include "subsurface-string.h"
|
||||||
|
|
||||||
DiveComputerList dcList;
|
DiveComputerList dcList;
|
||||||
|
|
||||||
|
@ -38,13 +38,13 @@ bool DiveComputerNode::changesValues(const DiveComputerNode &b) const
|
||||||
|
|
||||||
const DiveComputerNode *DiveComputerList::getExact(const QString &m, uint32_t d)
|
const DiveComputerNode *DiveComputerList::getExact(const QString &m, uint32_t d)
|
||||||
{
|
{
|
||||||
auto it = std::lower_bound(dcs.begin(), dcs.end(), DiveComputerNode { m, d , {}, {}, {} } );
|
auto it = std::lower_bound(dcs.begin(), dcs.end(), DiveComputerNode{m, d, {}, {}, {}});
|
||||||
return it != dcs.end() && it->model == m && it->deviceId == d ? &*it : NULL;
|
return it != dcs.end() && it->model == m && it->deviceId == d ? &*it : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DiveComputerNode *DiveComputerList::get(const QString &m)
|
const DiveComputerNode *DiveComputerList::get(const QString &m)
|
||||||
{
|
{
|
||||||
auto it = std::lower_bound(dcs.begin(), dcs.end(), DiveComputerNode { m, 0 , {}, {}, {} } );
|
auto it = std::lower_bound(dcs.begin(), dcs.end(), DiveComputerNode{m, 0, {}, {}, {}});
|
||||||
return it != dcs.end() && it->model == m ? &*it : NULL;
|
return it != dcs.end() && it->model == m ? &*it : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ void DiveComputerList::addDC(QString m, uint32_t d, QString n, QString s, QStrin
|
||||||
{
|
{
|
||||||
if (m.isEmpty() || d == 0)
|
if (m.isEmpty() || d == 0)
|
||||||
return;
|
return;
|
||||||
auto it = std::lower_bound(dcs.begin(), dcs.end(), DiveComputerNode { m, d , {}, {}, {} } );
|
auto it = std::lower_bound(dcs.begin(), dcs.end(), DiveComputerNode{m, d, {}, {}, {}});
|
||||||
if (it != dcs.end() && it->model == m && it->deviceId == d) {
|
if (it != dcs.end() && it->model == m && it->deviceId == d) {
|
||||||
// debugging: show changes
|
// debugging: show changes
|
||||||
if (verbose)
|
if (verbose)
|
||||||
|
@ -75,7 +75,7 @@ void DiveComputerList::addDC(QString m, uint32_t d, QString n, QString s, QStrin
|
||||||
if (!f.isEmpty())
|
if (!f.isEmpty())
|
||||||
it->firmware = f;
|
it->firmware = f;
|
||||||
} else {
|
} else {
|
||||||
dcs.insert(it, DiveComputerNode { m, d, s, f, n });
|
dcs.insert(it, DiveComputerNode{m, d, s, f, n});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,13 +89,12 @@ static bool compareDCById(const DiveComputerNode &a, const DiveComputerNode &b)
|
||||||
return a.deviceId < b.deviceId;
|
return a.deviceId < b.deviceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void call_for_each_dc (void *f, void (*callback)(void *, const char *, uint32_t,
|
extern "C" void call_for_each_dc (void *f, void (*callback)(void *, const char *, uint32_t, const char *, const char *, const char *),
|
||||||
const char *, const char *, const char *),
|
bool select_only)
|
||||||
bool select_only)
|
|
||||||
{
|
{
|
||||||
QVector<DiveComputerNode> values = dcList.dcs;
|
QVector<DiveComputerNode> values = dcList.dcs;
|
||||||
std::sort(values.begin(), values.end(), compareDCById);
|
std::sort(values.begin(), values.end(), compareDCById);
|
||||||
for (const DiveComputerNode &node: values) {
|
for (const DiveComputerNode &node : values) {
|
||||||
bool found = false;
|
bool found = false;
|
||||||
if (select_only) {
|
if (select_only) {
|
||||||
int j;
|
int j;
|
||||||
|
@ -104,7 +103,7 @@ extern "C" void call_for_each_dc (void *f, void (*callback)(void *, const char *
|
||||||
struct divecomputer *dc;
|
struct divecomputer *dc;
|
||||||
if (!d->selected)
|
if (!d->selected)
|
||||||
continue;
|
continue;
|
||||||
for_each_dc(d, dc) {
|
for_each_dc (d, dc) {
|
||||||
if (dc->deviceid == node.deviceId) {
|
if (dc->deviceid == node.deviceId) {
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
|
@ -117,7 +116,7 @@ extern "C" void call_for_each_dc (void *f, void (*callback)(void *, const char *
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
if (found)
|
if (found)
|
||||||
callback(f, qPrintable(node.model), node.deviceId, qPrintable(node.nickName),
|
callback(f, qPrintable(node.model), node.deviceId, qPrintable(node.nickName),
|
||||||
qPrintable(node.serialNumber), qPrintable(node.firmware));
|
qPrintable(node.serialNumber), qPrintable(node.firmware));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
QStringList vendorList;
|
QStringList vendorList;
|
||||||
QHash<QString, QStringList> productList;
|
QHash<QString, QStringList> productList;
|
||||||
static QHash<QString, QStringList> mobileProductList; // BT, BLE or FTDI supported DCs for mobile
|
static QHash<QString, QStringList> mobileProductList; // BT, BLE or FTDI supported DCs for mobile
|
||||||
QMap<QString, dc_descriptor_t *> descriptorLookup;
|
QMap<QString, dc_descriptor_t *> descriptorLookup;
|
||||||
ConnectionListModel connectionListModel;
|
ConnectionListModel connectionListModel;
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ void DownloadThread::run()
|
||||||
{
|
{
|
||||||
auto internalData = m_data->internalData();
|
auto internalData = m_data->internalData();
|
||||||
internalData->descriptor = descriptorLookup[m_data->vendor() + m_data->product()];
|
internalData->descriptor = descriptorLookup[m_data->vendor() + m_data->product()];
|
||||||
internalData->download_table = &downloadTable;
|
internalData->download_table = &downloadTable;
|
||||||
#if defined(Q_OS_ANDROID)
|
#if defined(Q_OS_ANDROID)
|
||||||
// on Android we either use BT or we download via FTDI cable
|
// on Android we either use BT or we download via FTDI cable
|
||||||
if (!internalData->bluetooth_mode)
|
if (!internalData->bluetooth_mode)
|
||||||
|
@ -201,7 +201,7 @@ void show_computer_list()
|
||||||
dc_descriptor_t *descriptor = descriptorLookup[vendor + product];
|
dc_descriptor_t *descriptor = descriptorLookup[vendor + product];
|
||||||
unsigned int transport = dc_descriptor_get_transports(descriptor) & transportMask;
|
unsigned int transport = dc_descriptor_get_transports(descriptor) & transportMask;
|
||||||
QString transportString = getTransportString(transport);
|
QString transportString = getTransportString(transport);
|
||||||
msg += product + " (" + transportString +"), ";
|
msg += product + " (" + transportString + "), ";
|
||||||
}
|
}
|
||||||
msg.chop(2);
|
msg.chop(2);
|
||||||
qDebug() << msg;
|
qDebug() << msg;
|
||||||
|
@ -265,7 +265,7 @@ int DCDeviceData::getMatchingAddress(const QString &vendor, const QString &produ
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
DCDeviceData * DownloadThread::data()
|
DCDeviceData *DownloadThread::data()
|
||||||
{
|
{
|
||||||
return m_data;
|
return m_data;
|
||||||
}
|
}
|
||||||
|
@ -320,17 +320,17 @@ int DCDeviceData::diveId() const
|
||||||
return data.diveid;
|
return data.diveid;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DCDeviceData::setVendor(const QString& vendor)
|
void DCDeviceData::setVendor(const QString &vendor)
|
||||||
{
|
{
|
||||||
data.vendor = copy_qstring(vendor);
|
data.vendor = copy_qstring(vendor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DCDeviceData::setProduct(const QString& product)
|
void DCDeviceData::setProduct(const QString &product)
|
||||||
{
|
{
|
||||||
data.product = copy_qstring(product);
|
data.product = copy_qstring(product);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DCDeviceData::setDevName(const QString& devName)
|
void DCDeviceData::setDevName(const QString &devName)
|
||||||
{
|
{
|
||||||
// This is a workaround for bug #1002. A string of the form "devicename (deviceaddress)"
|
// This is a workaround for bug #1002. A string of the form "devicename (deviceaddress)"
|
||||||
// or "deviceaddress (devicename)" may have found its way into the preferences.
|
// or "deviceaddress (devicename)" may have found its way into the preferences.
|
||||||
|
@ -351,7 +351,7 @@ void DCDeviceData::setDevName(const QString& devName)
|
||||||
data.devname = copy_qstring(devName);
|
data.devname = copy_qstring(devName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DCDeviceData::setDevBluetoothName(const QString& name)
|
void DCDeviceData::setDevBluetoothName(const QString &name)
|
||||||
{
|
{
|
||||||
m_devBluetoothName = name;
|
m_devBluetoothName = name;
|
||||||
}
|
}
|
||||||
|
@ -402,7 +402,7 @@ bool DCDeviceData::saveLog() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
device_data_t* DCDeviceData::internalData()
|
device_data_t *DCDeviceData::internalData()
|
||||||
{
|
{
|
||||||
return &data;
|
return &data;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue