diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-05-30 17:58:59 +0900 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-05-30 18:02:29 +0900 |
commit | f32e86eb32ee3697f255d01a61f6aa2e1cff5a8b (patch) | |
tree | 4f3db6fbaef45d931fb9dfda0286d445da2f9102 /qt-ui/downloadfromdivecomputer.cpp | |
parent | ae2c132a267932892d5c3f7965517194d38d962a (diff) | |
download | subsurface-f32e86eb32ee3697f255d01a61f6aa2e1cff5a8b.tar.gz |
Hook up the Download dialog
The download already worked, but we didn't display the new dives. This
introduces a new slot for MainWindow that updates what is displayed in
Subsurface after files were imported.
With this change we can successfully download ONCE - but when trying to
download a second dive the dialog doesn't appear to get refreshed the
right way - the OK button doesn't appear to work anymore (Cancel however
does).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/downloadfromdivecomputer.cpp')
-rw-r--r-- | qt-ui/downloadfromdivecomputer.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/qt-ui/downloadfromdivecomputer.cpp b/qt-ui/downloadfromdivecomputer.cpp index 9411ddd88..c1d74fb3a 100644 --- a/qt-ui/downloadfromdivecomputer.cpp +++ b/qt-ui/downloadfromdivecomputer.cpp @@ -4,6 +4,8 @@ #include "../libdivecomputer.h" #include "../helpers.h" #include "../display.h" +#include "../divelist.h" +#include "mainwindow.h" #include <cstdlib> #include <QThread> #include <QDebug> @@ -32,6 +34,12 @@ namespace DownloadFromDcGlobal{ const char *err_string; }; +DownloadFromDCWidget *DownloadFromDCWidget::instance() +{ + static DownloadFromDCWidget *dialog = new DownloadFromDCWidget(); + return dialog; +} + DownloadFromDCWidget::DownloadFromDCWidget(QWidget* parent, Qt::WindowFlags f) : QDialog(parent, f), ui(new Ui::DownloadFromDiveComputer), thread(0), downloading(false) { @@ -54,6 +62,12 @@ DownloadFromDCWidget::DownloadFromDCWidget(QWidget* parent, Qt::WindowFlags f) : ui->device->setText(default_dive_computer_device); } +void DownloadFromDCWidget::runDialog() +{ + ui->progressBar->hide(); + show(); +} + void DownloadFromDCWidget::on_vendor_currentIndexChanged(const QString& vendor) { QAbstractItemModel *currentModel = ui->product->model(); @@ -151,13 +165,20 @@ void DownloadFromDCWidget::on_ok_clicked() downloading = true; } +bool DownloadFromDCWidget::preferDownloaded() +{ + return ui->preferDownloaded->isChecked(); +} + DownloadThread::DownloadThread(device_data_t* data): data(data) { } void DownloadThread::run() { + DownloadFromDCWidget *dfdcw = DownloadFromDCWidget::instance(); do_libdivecomputer_import(data); + process_dives(TRUE, dfdcw->preferDownloaded()); } InterfaceThread::InterfaceThread(QObject* parent, device_data_t* data): QThread(parent), data(data) @@ -167,7 +188,8 @@ InterfaceThread::InterfaceThread(QObject* parent, device_data_t* data): QThread( void InterfaceThread::run() { DownloadThread *download = new DownloadThread(data); - + MainWindow *w = mainWindow(); + connect(download, SIGNAL(finished()), w, SLOT(refreshDisplay())); download->start(); while (download->isRunning()) { msleep(200); |