mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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 <dirk@hohndel.org>
This commit is contained in:
parent
f4acbb02e4
commit
246fbd0333
3 changed files with 22 additions and 10 deletions
|
@ -41,17 +41,17 @@ DownloadFromDCWidget::DownloadFromDCWidget(QWidget* parent, Qt::WindowFlags f) :
|
||||||
|
|
||||||
vendorModel = new QStringListModel(vendorList);
|
vendorModel = new QStringListModel(vendorList);
|
||||||
ui->vendor->setModel(vendorModel);
|
ui->vendor->setModel(vendorModel);
|
||||||
ui->diveComputerName->setModel(0);
|
ui->product->setModel(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadFromDCWidget::on_vendor_currentIndexChanged(const QString& vendor)
|
void DownloadFromDCWidget::on_vendor_currentIndexChanged(const QString& vendor)
|
||||||
{
|
{
|
||||||
QAbstractItemModel *currentModel = ui->diveComputerName->model();
|
QAbstractItemModel *currentModel = ui->product->model();
|
||||||
if (!currentModel)
|
if (!currentModel)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
productModel = new QStringListModel(productList[vendor]);
|
productModel = new QStringListModel(productList[vendor]);
|
||||||
ui->diveComputerName->setModel(productModel);
|
ui->product->setModel(productModel);
|
||||||
|
|
||||||
// Memleak - but deleting gives me a crash.
|
// Memleak - but deleting gives me a crash.
|
||||||
//currentModel->deleteLater();
|
//currentModel->deleteLater();
|
||||||
|
@ -62,8 +62,6 @@ void DownloadFromDCWidget::fill_computer_list()
|
||||||
dc_iterator_t *iterator = NULL;
|
dc_iterator_t *iterator = NULL;
|
||||||
dc_descriptor_t *descriptor = NULL;
|
dc_descriptor_t *descriptor = NULL;
|
||||||
struct mydescriptor *mydescriptor;
|
struct mydescriptor *mydescriptor;
|
||||||
struct vendor *dcl;
|
|
||||||
struct product *pl;
|
|
||||||
|
|
||||||
QStringList computer;
|
QStringList computer;
|
||||||
dc_descriptor_iterator(&iterator);
|
dc_descriptor_iterator(&iterator);
|
||||||
|
@ -76,6 +74,8 @@ void DownloadFromDCWidget::fill_computer_list()
|
||||||
|
|
||||||
if( !productList[vendor].contains( product ))
|
if( !productList[vendor].contains( product ))
|
||||||
productList[vendor].push_back( product );
|
productList[vendor].push_back( product );
|
||||||
|
|
||||||
|
descriptorLookup[QString(vendor) + QString(product)] = descriptor;
|
||||||
}
|
}
|
||||||
dc_iterator_free(iterator);
|
dc_iterator_free(iterator);
|
||||||
|
|
||||||
|
@ -96,6 +96,8 @@ void DownloadFromDCWidget::fill_computer_list()
|
||||||
|
|
||||||
if( !productList["Uemis"].contains( "Zurich" ))
|
if( !productList["Uemis"].contains( "Zurich" ))
|
||||||
productList["Uemis"].push_back( "Zurich" );
|
productList["Uemis"].push_back( "Zurich" );
|
||||||
|
|
||||||
|
descriptorLookup[QString("UemisZurich")] = (dc_descriptor_t *)mydescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadFromDCWidget::on_cancel_clicked()
|
void DownloadFromDCWidget::on_cancel_clicked()
|
||||||
|
@ -121,8 +123,14 @@ void DownloadFromDCWidget::on_ok_clicked()
|
||||||
thread->deleteLater();
|
thread->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
device_data_t data;
|
data.devname = strdup(ui->device->text().toUtf8().data());
|
||||||
// still need to fill the data info here.
|
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);
|
thread = new InterfaceThread(this, &data);
|
||||||
connect(thread, SIGNAL(updateInterface(int)),
|
connect(thread, SIGNAL(updateInterface(int)),
|
||||||
ui->progressBar, SLOT(setValue(int)), Qt::QueuedConnection); // Qt::QueuedConnection == threadsafe.
|
ui->progressBar, SLOT(setValue(int)), Qt::QueuedConnection); // Qt::QueuedConnection == threadsafe.
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
|
#include <QMap>
|
||||||
|
#include "../libdivecomputer.h"
|
||||||
|
|
||||||
namespace Ui{
|
namespace Ui{
|
||||||
class DownloadFromDiveComputer;
|
class DownloadFromDiveComputer;
|
||||||
|
@ -49,6 +51,8 @@ private:
|
||||||
|
|
||||||
QStringList vendorList;
|
QStringList vendorList;
|
||||||
QHash<QString, QStringList> productList;
|
QHash<QString, QStringList> productList;
|
||||||
|
QMap<QString, dc_descriptor_t *> descriptorLookup;
|
||||||
|
device_data_t data;
|
||||||
|
|
||||||
QStringListModel *vendorModel;
|
QStringListModel *vendorModel;
|
||||||
QStringListModel *productModel;
|
QStringListModel *productModel;
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
<widget class="QComboBox" name="vendor"/>
|
<widget class="QComboBox" name="vendor"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1" colspan="2">
|
<item row="1" column="1" colspan="2">
|
||||||
<widget class="QComboBox" name="diveComputerName"/>
|
<widget class="QComboBox" name="product"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0" colspan="3">
|
<item row="2" column="0" colspan="3">
|
||||||
<widget class="QLabel" name="label_3">
|
<widget class="QLabel" name="label_3">
|
||||||
|
@ -42,7 +42,7 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0" colspan="2">
|
<item row="3" column="0" colspan="2">
|
||||||
<widget class="QLineEdit" name="mountPoint"/>
|
<widget class="QLineEdit" name="device"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="2">
|
<item row="3" column="2">
|
||||||
<widget class="QToolButton" name="search">
|
<widget class="QToolButton" name="search">
|
||||||
|
|
Loading…
Add table
Reference in a new issue