2013-05-20 19:43:33 +00:00
|
|
|
#ifndef DOWNLOADFROMDIVECOMPUTER_H
|
|
|
|
#define DOWNLOADFROMDIVECOMPUTER_H
|
2013-05-20 20:58:06 +00:00
|
|
|
|
2013-05-20 19:43:33 +00:00
|
|
|
#include <QDialog>
|
|
|
|
#include <QThread>
|
2013-05-20 20:58:06 +00:00
|
|
|
#include <QHash>
|
2013-05-21 04:55:56 +00:00
|
|
|
#include <QMap>
|
|
|
|
#include "../libdivecomputer.h"
|
2013-05-20 19:43:33 +00:00
|
|
|
|
|
|
|
namespace Ui{
|
|
|
|
class DownloadFromDiveComputer;
|
|
|
|
}
|
|
|
|
struct device_data_t;
|
|
|
|
|
|
|
|
class DownloadThread : public QThread{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2013-09-01 14:14:54 +00:00
|
|
|
DownloadThread(QObject* parent, device_data_t* data);
|
2013-05-23 04:25:05 +00:00
|
|
|
virtual void run();
|
2013-09-01 14:14:54 +00:00
|
|
|
|
|
|
|
QString error;
|
2013-05-20 19:43:33 +00:00
|
|
|
private:
|
|
|
|
device_data_t *data;
|
|
|
|
};
|
|
|
|
|
2013-05-20 20:58:06 +00:00
|
|
|
class QStringListModel;
|
2013-05-20 19:43:33 +00:00
|
|
|
class DownloadFromDCWidget : public QDialog{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2013-05-23 04:25:05 +00:00
|
|
|
explicit DownloadFromDCWidget(QWidget* parent = 0, Qt::WindowFlags f = 0);
|
2013-05-30 08:58:59 +00:00
|
|
|
static DownloadFromDCWidget *instance();
|
2013-08-25 13:01:59 +00:00
|
|
|
void reject();
|
|
|
|
|
2013-08-25 22:02:30 +00:00
|
|
|
enum states {
|
|
|
|
INITIAL,
|
|
|
|
DOWNLOADING,
|
|
|
|
CANCELLING,
|
|
|
|
CANCELLED,
|
2013-09-01 14:14:54 +00:00
|
|
|
ERROR,
|
2013-08-25 22:02:30 +00:00
|
|
|
DONE,
|
|
|
|
};
|
|
|
|
|
2013-05-20 19:43:33 +00:00
|
|
|
public slots:
|
|
|
|
void on_ok_clicked();
|
|
|
|
void on_cancel_clicked();
|
2013-05-20 20:58:06 +00:00
|
|
|
void on_vendor_currentIndexChanged(const QString& vendor);
|
2013-08-25 13:01:59 +00:00
|
|
|
|
2013-08-25 22:02:30 +00:00
|
|
|
void onDownloadThreadFinished();
|
|
|
|
void updateProgressBar();
|
|
|
|
void runDialog();
|
|
|
|
|
2013-05-20 19:43:33 +00:00
|
|
|
private:
|
2013-08-25 22:02:30 +00:00
|
|
|
void markChildrenAsDisabled();
|
|
|
|
void markChildrenAsEnabled();
|
2013-08-25 13:01:59 +00:00
|
|
|
|
2013-05-20 19:43:33 +00:00
|
|
|
Ui::DownloadFromDiveComputer *ui;
|
2013-08-25 22:02:30 +00:00
|
|
|
DownloadThread *thread;
|
2013-05-20 20:02:17 +00:00
|
|
|
bool downloading;
|
2013-05-20 20:58:06 +00:00
|
|
|
|
|
|
|
QStringList vendorList;
|
|
|
|
QHash<QString, QStringList> productList;
|
2013-05-21 04:55:56 +00:00
|
|
|
QMap<QString, dc_descriptor_t *> descriptorLookup;
|
|
|
|
device_data_t data;
|
2013-05-20 20:58:06 +00:00
|
|
|
|
|
|
|
QStringListModel *vendorModel;
|
|
|
|
QStringListModel *productModel;
|
|
|
|
void fill_computer_list();
|
2013-08-25 13:01:59 +00:00
|
|
|
|
2013-08-25 22:02:30 +00:00
|
|
|
QTimer *timer;
|
|
|
|
|
2013-05-30 08:58:59 +00:00
|
|
|
public:
|
|
|
|
bool preferDownloaded();
|
2013-08-25 22:02:30 +00:00
|
|
|
void updateState(states state);
|
|
|
|
states currentState;
|
|
|
|
|
2013-05-20 19:43:33 +00:00
|
|
|
};
|
|
|
|
|
2013-05-21 04:55:56 +00:00
|
|
|
#endif
|