2013-05-20 16:43:33 -03:00
|
|
|
#ifndef DOWNLOADFROMDIVECOMPUTER_H
|
|
|
|
#define DOWNLOADFROMDIVECOMPUTER_H
|
2013-05-20 17:58:06 -03:00
|
|
|
|
2013-05-20 16:43:33 -03:00
|
|
|
#include <QDialog>
|
|
|
|
#include <QThread>
|
2013-05-20 17:58:06 -03:00
|
|
|
#include <QHash>
|
2013-05-20 21:55:56 -07:00
|
|
|
#include <QMap>
|
2015-01-08 10:12:11 -02:00
|
|
|
#include <QAbstractTableModel>
|
2014-06-26 14:01:31 -03:00
|
|
|
|
2014-12-27 08:31:51 -08:00
|
|
|
#include "libdivecomputer.h"
|
|
|
|
#include "configuredivecomputerdialog.h"
|
2013-10-03 11:54:24 -07:00
|
|
|
#include "ui_downloadfromdivecomputer.h"
|
2015-07-06 16:35:13 +03:00
|
|
|
#include "btdeviceselectiondialog.h"
|
2013-05-20 16:43:33 -03:00
|
|
|
|
2014-06-26 14:01:31 -03:00
|
|
|
class QStringListModel;
|
|
|
|
|
2014-02-27 20:09:57 -08:00
|
|
|
class DownloadThread : public QThread {
|
2013-05-20 16:43:33 -03:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2014-02-27 20:09:57 -08:00
|
|
|
DownloadThread(QObject *parent, device_data_t *data);
|
2013-05-22 21:25:05 -07:00
|
|
|
virtual void run();
|
2013-09-01 11:14:54 -03:00
|
|
|
|
|
|
|
QString error;
|
2014-02-27 20:09:57 -08:00
|
|
|
|
2013-05-20 16:43:33 -03:00
|
|
|
private:
|
|
|
|
device_data_t *data;
|
|
|
|
};
|
|
|
|
|
2015-01-08 10:12:11 -02: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 10:12:43 -08:00
|
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
2015-01-08 10:12:11 -02:00
|
|
|
void setImportedDivesIndexes(int first, int last);
|
2015-01-08 11:00:42 -02:00
|
|
|
Qt::ItemFlags flags(const QModelIndex &index) const;
|
2015-01-11 07:46:21 -08:00
|
|
|
void clearTable();
|
2015-01-08 11:39:34 -08:00
|
|
|
|
|
|
|
public
|
|
|
|
slots:
|
2015-01-09 12:17:02 -08:00
|
|
|
void changeSelected(QModelIndex clickedIndex);
|
2015-01-08 12:54:53 -08:00
|
|
|
void selectAll();
|
|
|
|
void selectNone();
|
2015-01-08 11:39:34 -08:00
|
|
|
|
2015-01-08 10:12:11 -02:00
|
|
|
private:
|
|
|
|
int firstIndex;
|
|
|
|
int lastIndex;
|
2015-01-08 10:52:54 -02:00
|
|
|
bool *checkStates;
|
2015-01-08 10:12:11 -02:00
|
|
|
};
|
|
|
|
|
2014-02-27 20:09:57 -08:00
|
|
|
class DownloadFromDCWidget : public QDialog {
|
2013-05-20 16:43:33 -03:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2014-02-27 20:09:57 -08:00
|
|
|
explicit DownloadFromDCWidget(QWidget *parent = 0, Qt::WindowFlags f = 0);
|
2013-08-25 10:01:59 -03:00
|
|
|
void reject();
|
|
|
|
|
2013-08-25 19:02:30 -03:00
|
|
|
enum states {
|
|
|
|
INITIAL,
|
|
|
|
DOWNLOADING,
|
|
|
|
CANCELLING,
|
2013-09-01 11:14:54 -03:00
|
|
|
ERROR,
|
2013-08-25 19:02:30 -03:00
|
|
|
DONE,
|
|
|
|
};
|
|
|
|
|
2014-02-27 20:09:57 -08:00
|
|
|
public
|
|
|
|
slots:
|
2015-01-09 15:01:48 -08:00
|
|
|
void on_downloadCancelRetryButton_clicked();
|
2015-01-08 11:31:05 -02:00
|
|
|
void on_ok_clicked();
|
2013-05-20 16:43:33 -03:00
|
|
|
void on_cancel_clicked();
|
2014-02-18 17:20:35 -08:00
|
|
|
void on_search_clicked();
|
2014-02-27 20:09:57 -08:00
|
|
|
void on_vendor_currentIndexChanged(const QString &vendor);
|
2014-05-26 00:06:56 +02:00
|
|
|
void on_product_currentIndexChanged(const QString &product);
|
2013-08-25 10:01:59 -03:00
|
|
|
|
2013-08-25 19:02:30 -03:00
|
|
|
void onDownloadThreadFinished();
|
|
|
|
void updateProgressBar();
|
2013-12-24 16:26:00 -08:00
|
|
|
void checkLogFile(int state);
|
|
|
|
void checkDumpFile(int state);
|
2015-07-06 16:18:06 +03:00
|
|
|
void enableBluetoothMode(int state);
|
2013-12-24 16:26:00 -08:00
|
|
|
void pickDumpFile();
|
|
|
|
void pickLogFile();
|
2015-07-06 16:18:06 +03:00
|
|
|
void selectRemoteBluetoothDevice();
|
2015-07-06 16:35:13 +03:00
|
|
|
void bluetoothSelectionDialogIsFinished(int result);
|
2013-08-25 19:02:30 -03:00
|
|
|
|
2013-05-20 16:43:33 -03:00
|
|
|
private:
|
2013-08-25 19:02:30 -03:00
|
|
|
void markChildrenAsDisabled();
|
|
|
|
void markChildrenAsEnabled();
|
2013-08-25 10:01:59 -03:00
|
|
|
|
2013-10-03 11:54:25 -07:00
|
|
|
Ui::DownloadFromDiveComputer ui;
|
2013-08-25 19:02:30 -03:00
|
|
|
DownloadThread *thread;
|
2013-05-20 17:02:17 -03:00
|
|
|
bool downloading;
|
2013-05-20 17:58:06 -03:00
|
|
|
|
|
|
|
QStringList vendorList;
|
|
|
|
QHash<QString, QStringList> productList;
|
2013-05-20 21:55:56 -07:00
|
|
|
QMap<QString, dc_descriptor_t *> descriptorLookup;
|
|
|
|
device_data_t data;
|
2013-12-08 06:33:46 +01:00
|
|
|
int previousLast;
|
2013-05-20 17:58:06 -03:00
|
|
|
|
|
|
|
QStringListModel *vendorModel;
|
|
|
|
QStringListModel *productModel;
|
|
|
|
void fill_computer_list();
|
2014-05-18 13:29:40 +09:00
|
|
|
void fill_device_list(int dc_type);
|
2013-12-24 16:26:00 -08:00
|
|
|
QString logFile;
|
|
|
|
QString dumpFile;
|
2013-08-25 19:02:30 -03:00
|
|
|
QTimer *timer;
|
2013-12-26 09:18:57 -08:00
|
|
|
bool dumpWarningShown;
|
2014-12-27 08:31:51 -08:00
|
|
|
OstcFirmwareCheck *ostcFirmwareCheck;
|
2015-01-08 10:12:11 -02:00
|
|
|
DiveImportedModel *diveImportedModel;
|
2015-07-06 16:35:13 +03:00
|
|
|
BtDeviceSelectionDialog *btDeviceSelectionDialog;
|
2013-08-25 19:02:30 -03:00
|
|
|
|
2013-05-30 17:58:59 +09:00
|
|
|
public:
|
|
|
|
bool preferDownloaded();
|
2013-08-25 19:02:30 -03:00
|
|
|
void updateState(states state);
|
|
|
|
states currentState;
|
2013-05-20 16:43:33 -03:00
|
|
|
};
|
|
|
|
|
2014-02-11 19:14:46 +01:00
|
|
|
#endif // DOWNLOADFROMDIVECOMPUTER_H
|