Changeset 7858376 in subsurface


Ignore:
Timestamp:
May 27, 2017, 11:07:20 AM (3 months ago)
Author:
Dirk Hohndel <dirk@…>
Branches:
master
Children:
38e24512
Parents:
85e9259
git-author:
Tomaz Canabrava <tcanabrava@…> (05/26/17 07:40:50)
git-committer:
Dirk Hohndel <dirk@…> (05/27/17 11:07:20)
Message:

QML UI: add the DownloadThread?

For this I had to also make the DCDeviceData accessible,
and for that it needed to be a pointer.

Signed-off-by: Tomaz Canabrava <tcanabrava@…>
Signed-off-by: Dirk Hohndel <dirk@…>

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • core/downloadfromdcthread.cpp

    r85e9259 r7858376  
    1717}
    1818
    19 DownloadThread::DownloadThread()
    20 {
    21 }
    22 
    23 void DownloadThread::setDiveTable(struct dive_table* table)
    24 {
    25         m_data.setDiveTable(table);
    26 }
     19DownloadThread::DownloadThread() : m_data(new DCDeviceData())
     20{
     21}
     22
    2723
    2824void DownloadThread::run()
    2925{
    30         auto internalData = m_data.internalData();
    31         internalData->descriptor = descriptorLookup[m_data.vendor() + m_data.product()];
     26        auto internalData = m_data->internalData();
     27        internalData->descriptor = descriptorLookup[m_data->vendor() + m_data->product()];
     28        internalData->download_table =  &downloadTable;
     29
     30        downloadTable.nr = 0;
     31        qDebug() << "Starting the thread" << downloadTable.nr;
     32
    3233        Q_ASSERT(internalData->download_table != nullptr);
    3334        const char *errorText;
     
    3940        if (errorText)
    4041                error = str_error(errorText, internalData->devname, internalData->vendor, internalData->product);
     42
     43        qDebug() << "Finishing the thread" << errorText << "dives downloaded" << downloadTable.nr;
    4144}
    4245
     
    97100}
    98101
    99 DCDeviceData & DownloadThread::data()
     102DCDeviceData * DownloadThread::data()
    100103{
    101104        return m_data;
     
    211214        return &data;
    212215}
    213 
    214 void DCDeviceData::setDiveTable(struct dive_table* downloadTable)
    215 {
    216         data.download_table = downloadTable;
    217 }
  • core/downloadfromdcthread.h

    r85e9259 r7858376  
    3939        int diveId() const;
    4040
    41         void setDiveTable(struct dive_table* downloadTable);
    42 
    4341        /* this needs to be a pointer to make the C-API happy */
    4442        device_data_t* internalData();
     
    6159class DownloadThread : public QThread {
    6260        Q_OBJECT
     61        Q_PROPERTY(DCDeviceData* deviceData MEMBER m_data)
     62
    6363public:
    6464        DownloadThread();
    65         void setDiveTable(struct dive_table *table);
    6665        void run() override;
    6766
    68         DCDeviceData& data();
     67        DCDeviceData *data();
    6968        QString error;
    7069
    7170private:
    72         DCDeviceData m_data;
     71        DCDeviceData *m_data;
    7372};
    7473
  • desktop-widgets/downloadfromdivecomputer.cpp

    rc370b87 r7858376  
    262262        ui.downloadCancelRetryButton->setText(tr("Cancel download"));
    263263
    264         auto& data = thread.data();
    265         data.setVendor(ui.vendor->currentText());
    266         data.setProduct(ui.product->currentText());
     264        auto data = thread.data();
     265        data->setVendor(ui.vendor->currentText());
     266        data->setProduct(ui.product->currentText());
    267267#if defined(BT_SUPPORT)
    268         data.setBluetoothMode(ui.bluetoothMode->isChecked());
    269         if (data.bluetoothMode() && btDeviceSelectionDialog != NULL) {
     268        data->setBluetoothMode(ui.bluetoothMode->isChecked());
     269        if (data->bluetoothMode() && btDeviceSelectionDialog != NULL) {
    270270                // Get the selected device address
    271                 data.setDevName(btDeviceSelectionDialog->getSelectedDeviceAddress());
     271                data->setDevName(btDeviceSelectionDialog->getSelectedDeviceAddress());
    272272        } else
    273273                // this breaks an "else if" across lines... not happy...
    274274#endif
    275         if (data.vendor() == "Uemis") {
     275        if (data->vendor() == "Uemis") {
    276276                char *colon;
    277277                char *devname = strdup(ui.device->currentText().toUtf8().data());
     
    281281                        fprintf(stderr, "shortened devname to \"%s\"", devname);
    282282                }
    283                 data.setDevName(devname);
     283                data->setDevName(devname);
    284284        } else {
    285                 data.setDevName(ui.device->currentText());
    286         }
    287         //TODO: Add the descriptor function.
    288         // data.descriptor = descriptorLookup[ui.vendor->currentText() + ui.product->currentText()];
    289         data.setForceDownload(ui.forceDownload->isChecked());
    290         data.setCreateNewTrip(ui.createNewTrip->isChecked());
    291         data.setSaveLog(ui.chooseLogFile->isChecked());
    292         data.setSaveDump(ui.chooseDumpFile->isChecked());
     285                data->setDevName(ui.device->currentText());
     286        }
     287
     288        data->setForceDownload(ui.forceDownload->isChecked());
     289        data->setCreateNewTrip(ui.createNewTrip->isChecked());
     290        data->setSaveLog(ui.chooseLogFile->isChecked());
     291        data->setSaveDump(ui.chooseDumpFile->isChecked());
    293292
    294293        auto dc = SettingsObjectWrapper::instance()->dive_computer_settings;
    295         dc->setVendor(data.vendor());
    296         dc->setProduct(data.product());
    297         dc->setDevice(data.devName());
     294        dc->setVendor(data->vendor());
     295        dc->setProduct(data->product());
     296        dc->setDevice(data->devName());
    298297
    299298#if defined(BT_SUPPORT) && defined(SSRF_CUSTOM_SERIAL)
     
    310309        // before we start, remember where the dive_table ended
    311310        previousLast = dive_table.nr;
    312 
    313         // TODO: the downloadTable should something inside the thrad or should be something from outside?
    314         thread.setDiveTable(&downloadTable);
    315311        thread.start();
    316312
     
    324320        if ((product == "OSTC 3" || product == "OSTC 3+" ||
    325321                        product == "OSTC Cr" || product == "OSTC Sport" ||
    326                         product == "OSTC 4") && ! data.saveDump())
     322                        product == "OSTC 4") && ! data->saveDump())
    327323        ostcFirmwareCheck = new OstcFirmwareCheck(product);
    328324}
     
    452448
    453449        if (ostcFirmwareCheck && currentState == DONE) {
    454                 ostcFirmwareCheck->checkLatest(this, thread.data().internalData());
     450                ostcFirmwareCheck->checkLatest(this, thread.data()->internalData());
    455451        }
    456452        accept();
  • mobile-widgets/qml/DownloadFromDiveComputer.qml

    r0e4c996 r7858376  
    2929        ]
    3030 */
     31        DCDownloadThread {
     32                id: downlodaThread
     33                deviceData.vendor : comboVendor.currentText
     34                deviceData.product : comboProduct.currentText
     35
     36                //TODO: make this dynamic?
     37                deviceData.devName : "/tmp/ttyS1"
     38
     39                //TODO: Make this the default on the C++
     40                deviceData.bluetoothMode : false
     41                deviceData.forceDownload : false
     42                deviceData.createNewTrip : false
     43                deviceData.deviceId : 0
     44                deviceData.diveId : 0
     45                deviceData.saveDump : false
     46                deviceData.saveLog : false
     47        }
     48
    3149        ColumnLayout {
    3250                anchors.top: parent.top
     
    6078                                onClicked: {
    6179                                        text: qsTr("Retry")
    62                                         stackView.pop();
     80                                        downlodaThread.start()
    6381                                }
    6482                        }
  • subsurface-mobile-helper.cpp

    rf78fdf3 r7858376  
    3737        qmlRegisterType<QMLManager>("org.subsurfacedivelog.mobile", 1, 0, "QMLManager");
    3838        qmlRegisterType<QMLProfile>("org.subsurfacedivelog.mobile", 1, 0, "QMLProfile");
     39
     40        qmlRegisterType<DCDeviceData>("org.subsurfacedivelog.mobile", 1, 0, "DCDeviceData");
     41        qmlRegisterType<DownloadThread>("org.subsurfacedivelog.mobile", 1, 0, "DCDownloadThread");
    3942
    4043        QQmlApplicationEngine engine;
Note: See TracChangeset for help on using the changeset viewer.