summaryrefslogtreecommitdiffstats
path: root/qt-ui/downloadfromdivecomputer.h
diff options
context:
space:
mode:
authorGravatar Danilo Cesar Lemes de Paula <danilo.eu@gmail.com>2013-08-25 19:02:30 -0300
committerGravatar Danilo Cesar Lemes de Paula <danilo.eu@gmail.com>2013-09-10 14:45:25 -0300
commit59da382613280b14b34df0921d308b910a36ce32 (patch)
treedf54613b8e331aab68b457b31530fdcc6fdd86a5 /qt-ui/downloadfromdivecomputer.h
parent923b4cd9b1932c13ef52567ea095740887345b38 (diff)
downloadsubsurface-59da382613280b14b34df0921d308b910a36ce32.tar.gz
improve DownloadDialog UI control
* Removes the InterfaceThread which is basically an unecessary proxy between the MainThread and the DownloadThread. * Use a state machine to control the DownloadWidget UI logic. Signed-off-by: Danilo Cesar Lemes de Paula <danilo.eu@gmail.com>
Diffstat (limited to 'qt-ui/downloadfromdivecomputer.h')
-rw-r--r--qt-ui/downloadfromdivecomputer.h39
1 files changed, 21 insertions, 18 deletions
diff --git a/qt-ui/downloadfromdivecomputer.h b/qt-ui/downloadfromdivecomputer.h
index 26216c1e0..f092314c0 100644
--- a/qt-ui/downloadfromdivecomputer.h
+++ b/qt-ui/downloadfromdivecomputer.h
@@ -15,24 +15,12 @@ struct device_data_t;
class DownloadThread : public QThread{
Q_OBJECT
public:
- explicit DownloadThread(device_data_t* data);
+ explicit DownloadThread(QObject* parent, device_data_t* data);
virtual void run();
private:
device_data_t *data;
};
-class InterfaceThread : public QThread{
- Q_OBJECT
-public:
- InterfaceThread(QObject *parent, device_data_t *data);
- virtual void run();
-
-signals:
- void updateInterface(int value);
-private:
- device_data_t *data;
-};
-
class QStringListModel;
class DownloadFromDCWidget : public QDialog{
Q_OBJECT
@@ -41,19 +29,29 @@ public:
static DownloadFromDCWidget *instance();
void reject();
+ enum states {
+ INITIAL,
+ DOWNLOADING,
+ CANCELLING,
+ CANCELLED,
+ DONE,
+ };
+
public slots:
void on_ok_clicked();
void on_cancel_clicked();
- void runDialog();
- void stoppedDownloading();
void on_vendor_currentIndexChanged(const QString& vendor);
+ void onDownloadThreadFinished();
+ void updateProgressBar();
+ void runDialog();
+
private:
- void markChildrenAsDisabled();
- void markChildrenAsEnabled();
+ void markChildrenAsDisabled();
+ void markChildrenAsEnabled();
Ui::DownloadFromDiveComputer *ui;
- InterfaceThread *thread;
+ DownloadThread *thread;
bool downloading;
QStringList vendorList;
@@ -65,8 +63,13 @@ private:
QStringListModel *productModel;
void fill_computer_list();
+ QTimer *timer;
+
public:
bool preferDownloaded();
+ void updateState(states state);
+ states currentState;
+
};
#endif