Changeset a4f045a in subsurface


Ignore:
Timestamp:
Jul 16, 2017, 9:53:44 PM (3 days ago)
Author:
Dirk Hohndel <dirk@…>
Branches:
master
Children:
40223c8
Parents:
c21845aa
git-author:
Dirk Hohndel <dirk@…> (07/16/17 21:49:11)
git-committer:
Dirk Hohndel <dirk@…> (07/16/17 21:53:44)
Message:

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@…>

Location:
core
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • core/btdiscovery.cpp

    rc21845aa ra4f045a  
    193193        if (newDC)
    194194                newDevice = dc_descriptor_get_product(newDC);
    195          else
     195        else
    196196                newDevice = device.name;
    197197
    198198        qDebug() << "Found new device:" << newDevice << device.address;
    199199        QString vendor;
    200         if (newDC) foreach (vendor, productList.keys()) {
    201                 if (productList[vendor].contains(newDevice)) {
    202                         qDebug() << "this could be a " + vendor + " " +
    203                                         (newDevice == "OSTC 3" ? "OSTC family" : newDevice);
    204                         btVP.btpdi = device;
    205                         btVP.dcDescriptor = newDC;
    206                         btVP.vendorIdx = vendorList.indexOf(vendor);
    207                         btVP.productIdx = productList[vendor].indexOf(newDevice);
    208                         qDebug() << "adding new btDCs entry (detected DC)" << newDevice << btVP.vendorIdx << btVP.productIdx << btVP.btpdi.address;;
    209                         btDCs << btVP;
    210                         productList[QObject::tr("Paired Bluetooth Devices")].append(device.name + " (" + device.address + ")");
    211                         return;
    212                 }
    213         }
     200        if (newDC)
     201                foreach (vendor, productList.keys()) {
     202                        if (productList[vendor].contains(newDevice)) {
     203                                qDebug() << "this could be a " + vendor + " " +
     204                                            (newDevice == "OSTC 3" ? "OSTC family" : newDevice);
     205                                btVP.btpdi = device;
     206                                btVP.dcDescriptor = newDC;
     207                                btVP.vendorIdx = vendorList.indexOf(vendor);
     208                                btVP.productIdx = productList[vendor].indexOf(newDevice);
     209                                qDebug() << "adding new btDCs entry (detected DC)" << newDevice << btVP.vendorIdx << btVP.productIdx << btVP.btpdi.address;;
     210                                btDCs << btVP;
     211                                productList[QObject::tr("Paired Bluetooth Devices")].append(device.name + " (" + device.address + ")");
     212                                connectionListModel.addAddress(device.address + " (" + device.name + ")");
     213                                return;
     214                        }
     215                }
     216        connectionListModel.addAddress(device.address);
    214217        qDebug() << "Not recognized as dive computer";
    215218}
  • core/downloadfromdcthread.cpp

    r52d5172 ra4f045a  
    88static QHash<QString, QStringList> mobileProductList;   // BT, BLE or FTDI supported DCs for mobile
    99QMap<QString, dc_descriptor_t *> descriptorLookup;
     10ConnectionListModel connectionListModel;
    1011
    1112static QString str_error(const char *fmt, ...)
     
    194195}
    195196
     197int DCDeviceData::getMatchingAddress(const QString &vendor, const QString &product)
     198{
     199        for (int i = 0; i < connectionListModel.rowCount(); i++) {
     200                QString address = connectionListModel.address(i);
     201                if (address.contains(product))
     202                        return i;
     203        }
     204        return -1;
     205}
     206
    196207DCDeviceData * DownloadThread::data()
    197208{
  • core/downloadfromdcthread.h

    rdb39f1a ra4f045a  
    4646
    4747        Q_INVOKABLE QStringList getProductListFromVendor(const QString& vendor);
     48        Q_INVOKABLE int getMatchingAddress(const QString &vendor, const QString &product);
     49
    4850        Q_INVOKABLE int getDetectedVendorIndex(const QString &currentText);
    4951        Q_INVOKABLE int getDetectedProductIndex(const QString &currentVendorText,
     
    103105extern QHash<QString, QStringList> productList;
    104106extern QMap<QString, dc_descriptor_t *> descriptorLookup;
     107extern ConnectionListModel connectionListModel;
    105108
    106109#endif
Note: See TracChangeset for help on using the changeset viewer.