From 246fbd0333c53f55b7ff7e8165b4435163a8f350 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Mon, 20 May 2013 21:55:56 -0700 Subject: Implement rudimentary divecomputer download Small changes to the names of elements the divecomputer download UI and very simplistic first stab at populating the device_data_t structure. This is lacking lots of things - it should remember the last vendor / product used - it should figure out which device (mount point) to offer - it needs proper error handling But it's a step in the right direction. Signed-off-by: Dirk Hohndel --- qt-ui/downloadfromdivecomputer.cpp | 22 +++++++++++++++------- qt-ui/downloadfromdivecomputer.h | 6 +++++- qt-ui/downloadfromdivecomputer.ui | 4 ++-- 3 files changed, 22 insertions(+), 10 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/downloadfromdivecomputer.cpp b/qt-ui/downloadfromdivecomputer.cpp index 2a1d7f566..e621096ff 100644 --- a/qt-ui/downloadfromdivecomputer.cpp +++ b/qt-ui/downloadfromdivecomputer.cpp @@ -41,17 +41,17 @@ DownloadFromDCWidget::DownloadFromDCWidget(QWidget* parent, Qt::WindowFlags f) : vendorModel = new QStringListModel(vendorList); ui->vendor->setModel(vendorModel); - ui->diveComputerName->setModel(0); + ui->product->setModel(0); } void DownloadFromDCWidget::on_vendor_currentIndexChanged(const QString& vendor) { - QAbstractItemModel *currentModel = ui->diveComputerName->model(); + QAbstractItemModel *currentModel = ui->product->model(); if (!currentModel) return; productModel = new QStringListModel(productList[vendor]); - ui->diveComputerName->setModel(productModel); + ui->product->setModel(productModel); // Memleak - but deleting gives me a crash. //currentModel->deleteLater(); @@ -62,8 +62,6 @@ void DownloadFromDCWidget::fill_computer_list() dc_iterator_t *iterator = NULL; dc_descriptor_t *descriptor = NULL; struct mydescriptor *mydescriptor; - struct vendor *dcl; - struct product *pl; QStringList computer; dc_descriptor_iterator(&iterator); @@ -76,6 +74,8 @@ void DownloadFromDCWidget::fill_computer_list() if( !productList[vendor].contains( product )) productList[vendor].push_back( product ); + + descriptorLookup[QString(vendor) + QString(product)] = descriptor; } dc_iterator_free(iterator); @@ -96,6 +96,8 @@ void DownloadFromDCWidget::fill_computer_list() if( !productList["Uemis"].contains( "Zurich" )) productList["Uemis"].push_back( "Zurich" ); + + descriptorLookup[QString("UemisZurich")] = (dc_descriptor_t *)mydescriptor; } void DownloadFromDCWidget::on_cancel_clicked() @@ -121,8 +123,14 @@ void DownloadFromDCWidget::on_ok_clicked() thread->deleteLater(); } - device_data_t data; - // still need to fill the data info here. + data.devname = strdup(ui->device->text().toUtf8().data()); + data.vendor = strdup(ui->vendor->currentText().toUtf8().data()); + data.product = strdup(ui->product->currentText().toUtf8().data()); + data.descriptor = descriptorLookup[ui->vendor->currentText() + ui->product->currentText()]; + data.force_download = ui->forceDownload->isChecked(); + // still needs to be implemented + // set_default_dive_computer(data.vendor, data.product); + thread = new InterfaceThread(this, &data); connect(thread, SIGNAL(updateInterface(int)), ui->progressBar, SLOT(setValue(int)), Qt::QueuedConnection); // Qt::QueuedConnection == threadsafe. diff --git a/qt-ui/downloadfromdivecomputer.h b/qt-ui/downloadfromdivecomputer.h index eefcc4d29..eccea8ac7 100644 --- a/qt-ui/downloadfromdivecomputer.h +++ b/qt-ui/downloadfromdivecomputer.h @@ -4,6 +4,8 @@ #include #include #include +#include +#include "../libdivecomputer.h" namespace Ui{ class DownloadFromDiveComputer; @@ -49,10 +51,12 @@ private: QStringList vendorList; QHash productList; + QMap descriptorLookup; + device_data_t data; QStringListModel *vendorModel; QStringListModel *productModel; void fill_computer_list(); }; -#endif \ No newline at end of file +#endif diff --git a/qt-ui/downloadfromdivecomputer.ui b/qt-ui/downloadfromdivecomputer.ui index 924b886aa..4b46a6e43 100644 --- a/qt-ui/downloadfromdivecomputer.ui +++ b/qt-ui/downloadfromdivecomputer.ui @@ -32,7 +32,7 @@ - + @@ -42,7 +42,7 @@ - + -- cgit v1.2.3-70-g09d2