mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
ae2c132a26
commit
f32e86eb32
4 changed files with 38 additions and 5 deletions
|
@ -4,6 +4,8 @@
|
||||||
#include "../libdivecomputer.h"
|
#include "../libdivecomputer.h"
|
||||||
#include "../helpers.h"
|
#include "../helpers.h"
|
||||||
#include "../display.h"
|
#include "../display.h"
|
||||||
|
#include "../divelist.h"
|
||||||
|
#include "mainwindow.h"
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
@ -32,6 +34,12 @@ namespace DownloadFromDcGlobal{
|
||||||
const char *err_string;
|
const char *err_string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
DownloadFromDCWidget *DownloadFromDCWidget::instance()
|
||||||
|
{
|
||||||
|
static DownloadFromDCWidget *dialog = new DownloadFromDCWidget();
|
||||||
|
return dialog;
|
||||||
|
}
|
||||||
|
|
||||||
DownloadFromDCWidget::DownloadFromDCWidget(QWidget* parent, Qt::WindowFlags f) :
|
DownloadFromDCWidget::DownloadFromDCWidget(QWidget* parent, Qt::WindowFlags f) :
|
||||||
QDialog(parent, f), ui(new Ui::DownloadFromDiveComputer), thread(0), downloading(false)
|
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);
|
ui->device->setText(default_dive_computer_device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DownloadFromDCWidget::runDialog()
|
||||||
|
{
|
||||||
|
ui->progressBar->hide();
|
||||||
|
show();
|
||||||
|
}
|
||||||
|
|
||||||
void DownloadFromDCWidget::on_vendor_currentIndexChanged(const QString& vendor)
|
void DownloadFromDCWidget::on_vendor_currentIndexChanged(const QString& vendor)
|
||||||
{
|
{
|
||||||
QAbstractItemModel *currentModel = ui->product->model();
|
QAbstractItemModel *currentModel = ui->product->model();
|
||||||
|
@ -151,13 +165,20 @@ void DownloadFromDCWidget::on_ok_clicked()
|
||||||
downloading = true;
|
downloading = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DownloadFromDCWidget::preferDownloaded()
|
||||||
|
{
|
||||||
|
return ui->preferDownloaded->isChecked();
|
||||||
|
}
|
||||||
|
|
||||||
DownloadThread::DownloadThread(device_data_t* data): data(data)
|
DownloadThread::DownloadThread(device_data_t* data): data(data)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadThread::run()
|
void DownloadThread::run()
|
||||||
{
|
{
|
||||||
|
DownloadFromDCWidget *dfdcw = DownloadFromDCWidget::instance();
|
||||||
do_libdivecomputer_import(data);
|
do_libdivecomputer_import(data);
|
||||||
|
process_dives(TRUE, dfdcw->preferDownloaded());
|
||||||
}
|
}
|
||||||
|
|
||||||
InterfaceThread::InterfaceThread(QObject* parent, device_data_t* data): QThread(parent), data(data)
|
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()
|
void InterfaceThread::run()
|
||||||
{
|
{
|
||||||
DownloadThread *download = new DownloadThread(data);
|
DownloadThread *download = new DownloadThread(data);
|
||||||
|
MainWindow *w = mainWindow();
|
||||||
|
connect(download, SIGNAL(finished()), w, SLOT(refreshDisplay()));
|
||||||
download->start();
|
download->start();
|
||||||
while (download->isRunning()) {
|
while (download->isRunning()) {
|
||||||
msleep(200);
|
msleep(200);
|
||||||
|
|
|
@ -38,11 +38,11 @@ class DownloadFromDCWidget : public QDialog{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit DownloadFromDCWidget(QWidget* parent = 0, Qt::WindowFlags f = 0);
|
explicit DownloadFromDCWidget(QWidget* parent = 0, Qt::WindowFlags f = 0);
|
||||||
|
static DownloadFromDCWidget *instance();
|
||||||
public slots:
|
public slots:
|
||||||
void on_ok_clicked();
|
void on_ok_clicked();
|
||||||
void on_cancel_clicked();
|
void on_cancel_clicked();
|
||||||
|
void runDialog();
|
||||||
void on_vendor_currentIndexChanged(const QString& vendor);
|
void on_vendor_currentIndexChanged(const QString& vendor);
|
||||||
private:
|
private:
|
||||||
Ui::DownloadFromDiveComputer *ui;
|
Ui::DownloadFromDiveComputer *ui;
|
||||||
|
@ -57,6 +57,8 @@ private:
|
||||||
QStringListModel *vendorModel;
|
QStringListModel *vendorModel;
|
||||||
QStringListModel *productModel;
|
QStringListModel *productModel;
|
||||||
void fill_computer_list();
|
void fill_computer_list();
|
||||||
|
public:
|
||||||
|
bool preferDownloaded();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -52,6 +52,14 @@ MainWindow::MainWindow() : ui(new Ui::MainWindow())
|
||||||
instance = this;
|
instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// this gets called after we download dives from a divecomputer
|
||||||
|
void MainWindow::refreshDisplay()
|
||||||
|
{
|
||||||
|
if (!selected_dive)
|
||||||
|
current_dive_changed(dive_table.nr - 1);
|
||||||
|
ui->ListWidget->reload();
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::current_dive_changed(int divenr)
|
void MainWindow::current_dive_changed(int divenr)
|
||||||
{
|
{
|
||||||
select_dive(divenr);
|
select_dive(divenr);
|
||||||
|
@ -162,8 +170,8 @@ void MainWindow::on_actionQuit_triggered()
|
||||||
|
|
||||||
void MainWindow::on_actionDownloadDC_triggered()
|
void MainWindow::on_actionDownloadDC_triggered()
|
||||||
{
|
{
|
||||||
DownloadFromDCWidget* downloadWidget = new DownloadFromDCWidget();
|
DownloadFromDCWidget* downloadWidget = DownloadFromDCWidget::instance();
|
||||||
downloadWidget->show();
|
downloadWidget->runDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionDownloadWeb_triggered()
|
void MainWindow::on_actionDownloadWeb_triggered()
|
||||||
|
|
|
@ -87,6 +87,7 @@ protected:
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void readSettings();
|
void readSettings();
|
||||||
|
void refreshDisplay();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
|
|
Loading…
Add table
Reference in a new issue