diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2017-07-17 07:43:31 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-07-18 00:49:31 -0700 |
commit | 025efc12d469017b068bdb14a78f664c47be5ac1 (patch) | |
tree | fdc01a93ce4eb145c29c3c1a70ca86b2033dd513 /core | |
parent | cec3c256e71a979d0f97c472829e74693c1d2b84 (diff) | |
download | subsurface-025efc12d469017b068bdb14a78f664c47be5ac1.tar.gz |
QML UI: remove the Paired Bluetooth Devices virtual vendor
We now actually handle connections in a sane manner and don't need
that workaround anymore.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core')
-rw-r--r-- | core/downloadfromdcthread.cpp | 73 | ||||
-rw-r--r-- | core/downloadfromdcthread.h | 4 |
2 files changed, 6 insertions, 71 deletions
diff --git a/core/downloadfromdcthread.cpp b/core/downloadfromdcthread.cpp index 8abc46bcd..b544b8c61 100644 --- a/core/downloadfromdcthread.cpp +++ b/core/downloadfromdcthread.cpp @@ -324,12 +324,9 @@ int DCDeviceData::getDetectedVendorIndex(const QString ¤tText) #if defined(BT_SUPPORT) QList<BTDiscovery::btVendorProduct> btDCs = BTDiscovery::instance()->getBtDcs(); - // Pick the vendor of the first confirmed find of a DC (if any), but - // only return a true vendor, and not our virtual one - if (!btDCs.isEmpty() && currentText != QObject::tr("Paired Bluetooth Devices")) { - qDebug() << "getDetectedVendorIndex" << currentText << btDCs.first().vendorIdx; + // Pick the vendor of the first confirmed find of a DC (if any) + if (!btDCs.isEmpty()) return btDCs.first().vendorIdx; - } #endif return -1; } @@ -342,17 +339,9 @@ int DCDeviceData::getDetectedProductIndex(const QString ¤tVendorText, // Display in the QML UI, the first found dive computer that is been // detected as a possible real dive computer (and not some other paired - // BT device - if (currentVendorText != QObject::tr("Paired Bluetooth Devices") && !btDCs.isEmpty()) { - qDebug() << "getDetectedProductIndex" << btDCs.first().productIdx; + // BT device) + if (!btDCs.isEmpty()) return btDCs.first().productIdx; - } - - // if the above fails, display the selected paired device - if (currentVendorText == QObject::tr("Paired Bluetooth Devices")) { - qDebug() << "getDetectedProductIndex" << productList[currentVendorText].indexOf(currentProductText); - return productList[currentVendorText].indexOf(currentProductText); - } #endif return -1; } @@ -361,19 +350,9 @@ QString DCDeviceData::getDetectedDeviceAddress(const QString ¤tVendorText, const QString ¤tProductText) { #if defined(BT_SUPPORT) - if (currentVendorText == QObject::tr("Paired Bluetooth Devices")) { - // simply get the address from the product text - QRegularExpression extractAddr(".*\\(([0-9A-FL:]*)\\)"); - QRegularExpressionMatch m = extractAddr.match(currentProductText); - if (m.hasMatch()) { - qDebug() << "matched" << m.captured(1); - return m.captured(1); - } - } - // Otherwise, pull the vendor from the found devices that are possible real dive computers + // Pull the vendor from the found devices that are possible real dive computers // HACK: this assumes that dive computer names are unique across vendors - // and will only give you the first of multiple identically named dive computers - use - // the Paired Bluetooth Devices vendor in cases like that + // and will only give you the first of multiple identically named dive computers QList<BTDiscovery::btVendorProduct> btDCs = BTDiscovery::instance()->getBtDcs(); BTDiscovery::btVendorProduct btDC; Q_FOREACH(btDC, btDCs) { @@ -383,43 +362,3 @@ QString DCDeviceData::getDetectedDeviceAddress(const QString ¤tVendorText, #endif return QStringLiteral("cannot determine address of dive computer"); } - -QString DCDeviceData::getDeviceDescriptorVendor(const QString ¤tVendorText, - const QString ¤tProductText) -{ -#if defined(BT_SUPPORT) - if (currentVendorText != QObject::tr("Paired Bluetooth Devices")) - return currentVendorText; - - QList<BTDiscovery::btVendorProduct> btDCs = BTDiscovery::instance()->getBtDcs(); - - // Pull the vendor from the found devices that are possible real dive computers - // HACK: this assumes that dive computer names are unique across vendors - BTDiscovery::btVendorProduct btDC; - Q_FOREACH(btDC, btDCs) { - if (currentProductText.startsWith(dc_descriptor_get_product(btDC.dcDescriptor))) - return dc_descriptor_get_vendor(btDC.dcDescriptor); - } -#endif - return QStringLiteral("failed to detect vendor"); -} - -QString DCDeviceData::getDeviceDescriptorProduct(const QString ¤tVendorText, - const QString ¤tProductText) -{ -#if defined(BT_SUPPORT) - if (currentVendorText != QObject::tr("Paired Bluetooth Devices")) - return currentProductText; - - QList<BTDiscovery::btVendorProduct> btDCs = BTDiscovery::instance()->getBtDcs(); - - // Pull the canonical product from the found devices that are possible real dive computers - // HACK: this assumes that dive computer names are unique across vendors - BTDiscovery::btVendorProduct btDC; - Q_FOREACH(btDC, btDCs) { - if (currentProductText.startsWith(dc_descriptor_get_product(btDC.dcDescriptor))) - return dc_descriptor_get_product(btDC.dcDescriptor); - } -#endif - return QStringLiteral("failed to detect product"); -} diff --git a/core/downloadfromdcthread.h b/core/downloadfromdcthread.h index 51b2a825f..0760363d5 100644 --- a/core/downloadfromdcthread.h +++ b/core/downloadfromdcthread.h @@ -52,10 +52,6 @@ public: const QString ¤tProductText); Q_INVOKABLE QString getDetectedDeviceAddress(const QString ¤tVendorText, const QString ¤tProductText); - Q_INVOKABLE QString getDeviceDescriptorVendor(const QString ¤tVendorText, - const QString ¤tProductText); - Q_INVOKABLE QString getDeviceDescriptorProduct(const QString ¤tVendorText, - const QString ¤tProductText); public slots: void setVendor(const QString& vendor); |