diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2017-07-22 15:54:42 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-07-22 16:15:00 -0700 |
commit | 587882c88bbcc6b95488f8c3fd9c5dd526a0712b (patch) | |
tree | d8be6e2a258b3bc60afbd69efd04cc1f26c273ff /core/downloadfromdcthread.cpp | |
parent | 686b87e903247d27a8dfc2ce27f9f665dc1fdac2 (diff) | |
download | subsurface-587882c88bbcc6b95488f8c3fd9c5dd526a0712b.tar.gz |
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>
Diffstat (limited to 'core/downloadfromdcthread.cpp')
-rw-r--r-- | core/downloadfromdcthread.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/core/downloadfromdcthread.cpp b/core/downloadfromdcthread.cpp index fe9da69fb..43861f035 100644 --- a/core/downloadfromdcthread.cpp +++ b/core/downloadfromdcthread.cpp @@ -1,5 +1,6 @@ #include "downloadfromdcthread.h" #include "core/libdivecomputer.h" +#include "core/subsurface-qt/SettingsObjectWrapper.h" #include <QDebug> #include <QRegularExpression> @@ -50,6 +51,10 @@ void DownloadThread::run() error = str_error(errorText, internalData->devname, internalData->vendor, internalData->product); 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() @@ -191,6 +196,17 @@ QStringList DCDeviceData::getProductListFromVendor(const QString &vendor) 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++) { QString address = connectionListModel.address(i); if (address.contains(product)) @@ -316,6 +332,15 @@ device_data_t* DCDeviceData::internalData() 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) QList<BTDiscovery::btVendorProduct> btDCs = BTDiscovery::instance()->getBtDcs(); @@ -329,6 +354,17 @@ int DCDeviceData::getDetectedVendorIndex(const QString ¤tText) int DCDeviceData::getDetectedProductIndex(const QString ¤tVendorText, 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) QList<BTDiscovery::btVendorProduct> btDCs = BTDiscovery::instance()->getBtDcs(); |