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>
|
2015-01-08 12:12:11 +00:00
|
|
|
#include <QAbstractTableModel>
|
2014-06-26 17:01:31 +00:00
|
|
|
|
2014-12-27 16:31:51 +00:00
|
|
|
#include "libdivecomputer.h"
|
|
|
|
#include "configuredivecomputerdialog.h"
|
2013-10-03 18:54:24 +00:00
|
|
|
#include "ui_downloadfromdivecomputer.h"
|
2013-05-20 19:43:33 +00:00
|
|
|
|
2014-06-26 17:01:31 +00:00
|
|
|
class QStringListModel;
|
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2015-01-08 12:12:11 +00:00
|
|
|
class DiveImportedModel : public QAbstractTableModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
DiveImportedModel(QObject *o);
|
|
|
|
int columnCount(const QModelIndex& index = QModelIndex()) const;
|
|
|
|
int rowCount(const QModelIndex& index = QModelIndex()) const;
|
|
|
|
QVariant data(const QModelIndex& index, int role) const;
|
2015-01-08 18:12:43 +00:00
|
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
2015-01-08 12:55:38 +00:00
|
|
|
bool setData(const QModelIndex &index, const QVariant &value, int role);
|
2015-01-08 12:12:11 +00:00
|
|
|
void setImportedDivesIndexes(int first, int last);
|
2015-01-08 13:00:42 +00:00
|
|
|
Qt::ItemFlags flags(const QModelIndex &index) const;
|
2015-01-08 13:52:12 +00:00
|
|
|
void removeUnused();
|
2015-01-08 19:39:34 +00:00
|
|
|
|
|
|
|
public
|
|
|
|
slots:
|
2015-01-09 20:17:02 +00:00
|
|
|
void changeSelected(QModelIndex clickedIndex);
|
2015-01-08 20:54:53 +00:00
|
|
|
void selectAll();
|
|
|
|
void selectNone();
|
2015-01-08 19:39:34 +00:00
|
|
|
|
2015-01-08 12:12:11 +00:00
|
|
|
private:
|
|
|
|
int firstIndex;
|
|
|
|
int lastIndex;
|
2015-01-08 12:52:54 +00:00
|
|
|
bool *checkStates;
|
2015-01-08 12:12:11 +00:00
|
|
|
};
|
|
|
|
|
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:
|
2015-01-08 13:29:28 +00:00
|
|
|
void on_startDownload_clicked();
|
2015-01-08 13:31:05 +00:00
|
|
|
void on_ok_clicked();
|
2013-05-20 19:43:33 +00:00
|
|
|
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;
|
2014-12-27 16:31:51 +00:00
|
|
|
OstcFirmwareCheck *ostcFirmwareCheck;
|
2015-01-08 12:12:11 +00:00
|
|
|
DiveImportedModel *diveImportedModel;
|
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
|