summaryrefslogtreecommitdiffstats
path: root/qt-ui/downloadfromdivecomputer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qt-ui/downloadfromdivecomputer.cpp')
-rw-r--r--qt-ui/downloadfromdivecomputer.cpp34
1 files changed, 23 insertions, 11 deletions
diff --git a/qt-ui/downloadfromdivecomputer.cpp b/qt-ui/downloadfromdivecomputer.cpp
index 17c2a4eaa..71f428b14 100644
--- a/qt-ui/downloadfromdivecomputer.cpp
+++ b/qt-ui/downloadfromdivecomputer.cpp
@@ -34,8 +34,7 @@ struct mydescriptor {
unsigned int model;
};
-namespace DownloadFromDcGlobal
-{
+namespace DownloadFromDcGlobal {
const char *err_string;
};
@@ -56,7 +55,6 @@ DownloadFromDCWidget::DownloadFromDCWidget(QWidget *parent, Qt::WindowFlags f) :
progress_bar_text = "";
- fill_device_list();
fill_computer_list();
ui.chooseDumpFile->setEnabled(ui.dumpToFile->isChecked());
@@ -74,7 +72,6 @@ DownloadFromDCWidget::DownloadFromDCWidget(QWidget *parent, Qt::WindowFlags f) :
if (default_dive_computer_product)
ui.product->setCurrentIndex(ui.product->findText(default_dive_computer_product));
}
- connect(ui.product, SIGNAL(currentIndexChanged(int)), this, SLOT(on_product_currentIndexChanged()), Qt::UniqueConnection);
if (default_dive_computer_device)
ui.device->setEditText(default_dive_computer_device);
@@ -104,7 +101,7 @@ void DownloadFromDCWidget::updateState(states state)
return;
if (state == INITIAL) {
- fill_device_list();
+ fill_device_list(DC_TYPE_OTHER);
ui.progressBar->hide();
markChildrenAsEnabled();
timer->stop();
@@ -176,6 +173,7 @@ void DownloadFromDCWidget::updateState(states state)
void DownloadFromDCWidget::on_vendor_currentIndexChanged(const QString &vendor)
{
+ int dcType = DC_TYPE_SERIAL;
QAbstractItemModel *currentModel = ui.product->model();
if (!currentModel)
return;
@@ -183,15 +181,19 @@ void DownloadFromDCWidget::on_vendor_currentIndexChanged(const QString &vendor)
productModel = new QStringListModel(productList[vendor]);
ui.product->setModel(productModel);
+ if (vendor == QString("Uemis"))
+ dcType = DC_TYPE_UEMIS;
+ fill_device_list(dcType);
+
// Memleak - but deleting gives me a crash.
//currentModel->deleteLater();
}
-void DownloadFromDCWidget::on_product_currentIndexChanged()
+void DownloadFromDCWidget::on_product_currentIndexChanged(const QString &product)
{
// Set up the DC descriptor
dc_descriptor_t *descriptor = NULL;
- descriptor = descriptorLookup[ui.vendor->currentText() + ui.product->currentText()];
+ descriptor = descriptorLookup[ui.vendor->currentText() + product];
// call dc_descriptor_get_transport to see if the dc_transport_t is DC_TRANSPORT_SERIAL
if (dc_descriptor_get_transport(descriptor) == DC_TRANSPORT_SERIAL) {
@@ -378,10 +380,20 @@ void DownloadFromDCWidget::onDownloadThreadFinished()
// down in the dive_table
for (int i = dive_table.nr - 1; i >= previousLast; i--)
delete_single_dive(i);
- } else {
+ } else if (dive_table.nr) {
+ int uniqId, idx;
+ // remember the last downloaded dive (on most dive computers this will be the chronologically
+ // first new dive) and select it again after processing all the dives
+ MainWindow::instance()->dive_list()->unselectDives();
+ uniqId = get_dive(dive_table.nr - 1)->id;
process_dives(true, preferDownloaded());
+ // after process_dives does any merging or resorting needed, we need
+ // to recreate the model for the dive list so we can select the newest dive
+ MainWindow::instance()->recreateDiveList();
+ idx = get_idx_by_uniq_id(uniqId);
+ MainWindow::instance()->dive_list()->selectDive(idx, true);
}
- } else if (currentState == CANCELLING || currentState == CANCELLED){
+ } else if (currentState == CANCELLING || currentState == CANCELLED) {
if (import_thread_cancelled) {
// walk backwards so we don't keep moving the dives
// down in the dive_table
@@ -429,11 +441,11 @@ static void fillDeviceList(const char *name, void *data)
comboBox->addItem(name);
}
-void DownloadFromDCWidget::fill_device_list()
+void DownloadFromDCWidget::fill_device_list(int dc_type)
{
int deviceIndex;
ui.device->clear();
- deviceIndex = enumerate_devices(fillDeviceList, ui.device);
+ deviceIndex = enumerate_devices(fillDeviceList, ui.device, dc_type);
if (deviceIndex >= 0)
ui.device->setCurrentIndex(deviceIndex);
}