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>
|
2014-02-11 17:50:44 +00:00
|
|
|
#include <QStringListModel>
|
2013-05-21 04:55:56 +00:00
|
|
|
#include "../libdivecomputer.h"
|
2013-10-03 18:54:24 +00:00
|
|
|
#include "ui_downloadfromdivecomputer.h"
|
2013-05-20 19:43:33 +00:00
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
class DownloadThread : public QThread {
|
2013-05-20 19:43:33 +00:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2014-02-28 04:09:57 +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;
|
2014-02-28 04:09:57 +00:00
|
|
|
|
2013-05-20 19:43:33 +00:00
|
|
|
private:
|
|
|
|
device_data_t *data;
|
|
|
|
};
|
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
class DownloadFromDCWidget : public QDialog {
|
2013-05-20 19:43:33 +00:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2014-02-28 04:09:57 +00:00
|
|
|
explicit DownloadFromDCWidget(QWidget *parent = 0, Qt::WindowFlags f = 0);
|
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,
|
|
|
|
};
|
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
public
|
|
|
|
slots:
|
2013-05-20 19:43:33 +00:00
|
|
|
void on_ok_clicked();
|
|
|
|
void on_cancel_clicked();
|
2014-02-19 01:20:35 +00:00
|
|
|
void on_search_clicked();
|
2014-02-28 04:09:57 +00:00
|
|
|
void on_vendor_currentIndexChanged(const QString &vendor);
|
2014-05-25 22:06:56 +00:00
|
|
|
void on_product_currentIndexChanged(const QString &product);
|
2013-08-25 13:01:59 +00:00
|
|
|
|
2013-08-25 22:02:30 +00:00
|
|
|
void onDownloadThreadFinished();
|
|
|
|
void updateProgressBar();
|
2013-12-25 00:26:00 +00:00
|
|
|
void checkLogFile(int state);
|
|
|
|
void checkDumpFile(int state);
|
|
|
|
void pickDumpFile();
|
|
|
|
void pickLogFile();
|
2013-08-25 22:02:30 +00:00
|
|
|
|
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-10-03 18:54:25 +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-12-08 05:33:46 +00:00
|
|
|
int previousLast;
|
2013-05-20 20:58:06 +00:00
|
|
|
|
|
|
|
QStringListModel *vendorModel;
|
|
|
|
QStringListModel *productModel;
|
|
|
|
void fill_computer_list();
|
2014-05-18 04:29:40 +00:00
|
|
|
void fill_device_list(int dc_type);
|
2013-12-25 00:26:00 +00:00
|
|
|
QString logFile;
|
|
|
|
QString dumpFile;
|
2013-08-25 22:02:30 +00:00
|
|
|
QTimer *timer;
|
2013-12-26 17:18:57 +00:00
|
|
|
bool dumpWarningShown;
|
2013-08-25 22:02:30 +00:00
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2014-02-11 18:14:46 +00:00
|
|
|
#endif // DOWNLOADFROMDIVECOMPUTER_H
|