mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 21:03:23 +00:00
Add the connections that we find to the model
So far this only deals with BT addresses. We also need to add other connections that we detect. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
c21845aa01
commit
a4f045abaa
3 changed files with 31 additions and 14 deletions
|
@ -192,25 +192,28 @@ void BTDiscovery::btDeviceDiscoveredMain(const btPairedDevice &device)
|
||||||
dc_descriptor_t *newDC = getDeviceType(device.name);
|
dc_descriptor_t *newDC = getDeviceType(device.name);
|
||||||
if (newDC)
|
if (newDC)
|
||||||
newDevice = dc_descriptor_get_product(newDC);
|
newDevice = dc_descriptor_get_product(newDC);
|
||||||
else
|
else
|
||||||
newDevice = device.name;
|
newDevice = device.name;
|
||||||
|
|
||||||
qDebug() << "Found new device:" << newDevice << device.address;
|
qDebug() << "Found new device:" << newDevice << device.address;
|
||||||
QString vendor;
|
QString vendor;
|
||||||
if (newDC) foreach (vendor, productList.keys()) {
|
if (newDC)
|
||||||
if (productList[vendor].contains(newDevice)) {
|
foreach (vendor, productList.keys()) {
|
||||||
qDebug() << "this could be a " + vendor + " " +
|
if (productList[vendor].contains(newDevice)) {
|
||||||
(newDevice == "OSTC 3" ? "OSTC family" : newDevice);
|
qDebug() << "this could be a " + vendor + " " +
|
||||||
btVP.btpdi = device;
|
(newDevice == "OSTC 3" ? "OSTC family" : newDevice);
|
||||||
btVP.dcDescriptor = newDC;
|
btVP.btpdi = device;
|
||||||
btVP.vendorIdx = vendorList.indexOf(vendor);
|
btVP.dcDescriptor = newDC;
|
||||||
btVP.productIdx = productList[vendor].indexOf(newDevice);
|
btVP.vendorIdx = vendorList.indexOf(vendor);
|
||||||
qDebug() << "adding new btDCs entry (detected DC)" << newDevice << btVP.vendorIdx << btVP.productIdx << btVP.btpdi.address;;
|
btVP.productIdx = productList[vendor].indexOf(newDevice);
|
||||||
btDCs << btVP;
|
qDebug() << "adding new btDCs entry (detected DC)" << newDevice << btVP.vendorIdx << btVP.productIdx << btVP.btpdi.address;;
|
||||||
productList[QObject::tr("Paired Bluetooth Devices")].append(device.name + " (" + device.address + ")");
|
btDCs << btVP;
|
||||||
return;
|
productList[QObject::tr("Paired Bluetooth Devices")].append(device.name + " (" + device.address + ")");
|
||||||
|
connectionListModel.addAddress(device.address + " (" + device.name + ")");
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
connectionListModel.addAddress(device.address);
|
||||||
qDebug() << "Not recognized as dive computer";
|
qDebug() << "Not recognized as dive computer";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ 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;
|
||||||
|
|
||||||
static QString str_error(const char *fmt, ...)
|
static QString str_error(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
|
@ -193,6 +194,16 @@ QStringList DCDeviceData::getProductListFromVendor(const QString &vendor)
|
||||||
return productList[vendor];
|
return productList[vendor];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int DCDeviceData::getMatchingAddress(const QString &vendor, const QString &product)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < connectionListModel.rowCount(); i++) {
|
||||||
|
QString address = connectionListModel.address(i);
|
||||||
|
if (address.contains(product))
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
DCDeviceData * DownloadThread::data()
|
DCDeviceData * DownloadThread::data()
|
||||||
{
|
{
|
||||||
return m_data;
|
return m_data;
|
||||||
|
|
|
@ -45,6 +45,8 @@ public:
|
||||||
device_data_t* internalData();
|
device_data_t* internalData();
|
||||||
|
|
||||||
Q_INVOKABLE QStringList getProductListFromVendor(const QString& vendor);
|
Q_INVOKABLE QStringList getProductListFromVendor(const QString& vendor);
|
||||||
|
Q_INVOKABLE int getMatchingAddress(const QString &vendor, const QString &product);
|
||||||
|
|
||||||
Q_INVOKABLE int getDetectedVendorIndex(const QString ¤tText);
|
Q_INVOKABLE int getDetectedVendorIndex(const QString ¤tText);
|
||||||
Q_INVOKABLE int getDetectedProductIndex(const QString ¤tVendorText,
|
Q_INVOKABLE int getDetectedProductIndex(const QString ¤tVendorText,
|
||||||
const QString ¤tProductText);
|
const QString ¤tProductText);
|
||||||
|
@ -102,5 +104,6 @@ void fill_computer_list();
|
||||||
extern QStringList vendorList;
|
extern QStringList vendorList;
|
||||||
extern QHash<QString, QStringList> productList;
|
extern QHash<QString, QStringList> productList;
|
||||||
extern QMap<QString, dc_descriptor_t *> descriptorLookup;
|
extern QMap<QString, dc_descriptor_t *> descriptorLookup;
|
||||||
|
extern ConnectionListModel connectionListModel;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue