mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
QML UI: remember the last dive computer
We already have the infrastructure to do so, all we needed to do was hook it all up. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
686b87e903
commit
587882c88b
1 changed files with 36 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
||||||
#include "downloadfromdcthread.h"
|
#include "downloadfromdcthread.h"
|
||||||
#include "core/libdivecomputer.h"
|
#include "core/libdivecomputer.h"
|
||||||
|
#include "core/subsurface-qt/SettingsObjectWrapper.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
|
|
||||||
|
@ -50,6 +51,10 @@ void DownloadThread::run()
|
||||||
error = str_error(errorText, internalData->devname, internalData->vendor, internalData->product);
|
error = str_error(errorText, internalData->devname, internalData->vendor, internalData->product);
|
||||||
|
|
||||||
qDebug() << "Finishing the thread" << errorText << "dives downloaded" << downloadTable.nr;
|
qDebug() << "Finishing the thread" << errorText << "dives downloaded" << downloadTable.nr;
|
||||||
|
auto dcs = SettingsObjectWrapper::instance()->dive_computer_settings;
|
||||||
|
dcs->setVendor(internalData->vendor);
|
||||||
|
dcs->setProduct(internalData->product);
|
||||||
|
dcs->setDevice(internalData->devname);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fill_supported_mobile_list()
|
static void fill_supported_mobile_list()
|
||||||
|
@ -191,6 +196,17 @@ 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 (dcs->dc_vendor() == vendor &&
|
||||||
|
dcs->dc_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->dc_device()))
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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(product))
|
if (address.contains(product))
|
||||||
|
@ -316,6 +332,15 @@ device_data_t* DCDeviceData::internalData()
|
||||||
|
|
||||||
int DCDeviceData::getDetectedVendorIndex(const QString ¤tText)
|
int DCDeviceData::getDetectedVendorIndex(const QString ¤tText)
|
||||||
{
|
{
|
||||||
|
auto dcs = SettingsObjectWrapper::instance()->dive_computer_settings;
|
||||||
|
if (!dcs->dc_vendor().isEmpty()) {
|
||||||
|
// use the last one
|
||||||
|
for (int i = 0; i < vendorList.length(); i++) {
|
||||||
|
if (vendorList[i] == dcs->dc_vendor())
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(BT_SUPPORT)
|
#if defined(BT_SUPPORT)
|
||||||
QList<BTDiscovery::btVendorProduct> btDCs = BTDiscovery::instance()->getBtDcs();
|
QList<BTDiscovery::btVendorProduct> btDCs = BTDiscovery::instance()->getBtDcs();
|
||||||
|
|
||||||
|
@ -329,6 +354,17 @@ int DCDeviceData::getDetectedVendorIndex(const QString ¤tText)
|
||||||
int DCDeviceData::getDetectedProductIndex(const QString ¤tVendorText,
|
int DCDeviceData::getDetectedProductIndex(const QString ¤tVendorText,
|
||||||
const QString ¤tProductText)
|
const QString ¤tProductText)
|
||||||
{
|
{
|
||||||
|
auto dcs = SettingsObjectWrapper::instance()->dive_computer_settings;
|
||||||
|
if (!dcs->dc_vendor().isEmpty()) {
|
||||||
|
if (dcs->dc_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->dc_product())
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(BT_SUPPORT)
|
#if defined(BT_SUPPORT)
|
||||||
QList<BTDiscovery::btVendorProduct> btDCs = BTDiscovery::instance()->getBtDcs();
|
QList<BTDiscovery::btVendorProduct> btDCs = BTDiscovery::instance()->getBtDcs();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue