19 #ifndef LDFORGE_DOWNLOAD_H |
19 #ifndef LDFORGE_DOWNLOAD_H |
20 #define LDFORGE_DOWNLOAD_H |
20 #define LDFORGE_DOWNLOAD_H |
21 |
21 |
22 #include <QDialog> |
22 #include <QDialog> |
23 #include "common.h" |
23 #include "common.h" |
|
24 #include "types.h" |
24 |
25 |
25 class Ui_DownloadFrom; |
26 class Ui_DownloadFrom; |
26 class QNetworkAccessManager; |
27 class QNetworkAccessManager; |
27 class QNetworkRequest; |
28 class QNetworkRequest; |
28 class QNetworkReply; |
29 class QNetworkReply; |
65 }; |
69 }; |
66 |
70 |
67 // ============================================================================= |
71 // ============================================================================= |
68 // ----------------------------------------------------------------------------- |
72 // ----------------------------------------------------------------------------- |
69 class PartDownloadRequest : public QObject { |
73 class PartDownloadRequest : public QObject { |
|
74 Q_OBJECT |
70 PROPERTY (int, tableRow, setTableRow) |
75 PROPERTY (int, tableRow, setTableRow) |
71 |
76 |
72 public: |
77 public: |
73 explicit PartDownloadRequest (str url, PartDownloadPrompt* parent); |
78 enum TableColumn { |
|
79 PartLabelColumn, |
|
80 ProgressColumn, |
|
81 }; |
|
82 |
|
83 enum State { |
|
84 Requesting, |
|
85 Downloading, |
|
86 Finished, |
|
87 Aborted, |
|
88 }; |
|
89 |
|
90 explicit PartDownloadRequest (str url, str dest, PartDownloadPrompt* parent); |
|
91 PartDownloadRequest (const PartDownloadRequest&) = delete; |
|
92 virtual ~PartDownloadRequest(); |
74 void updateToTable(); |
93 void updateToTable(); |
|
94 |
|
95 void operator= (const PartDownloadRequest&) = delete; |
|
96 |
|
97 public slots: |
|
98 void downloadFinished(); |
|
99 void readyRead(); |
|
100 void downloadProgress (qint64 recv, qint64 total); |
75 |
101 |
76 private: |
102 private: |
77 PartDownloadPrompt* m_prompt; |
103 PartDownloadPrompt* m_prompt; |
78 str m_url; |
104 str m_url, m_dest, m_fpath; |
79 QNetworkAccessManager* m_nam; |
105 QNetworkAccessManager* m_nam; |
80 QNetworkReply* m_reply; |
106 QNetworkReply* m_reply; |
|
107 bool m_firstUpdate; |
|
108 State m_state; |
|
109 int64 m_bytesRead, m_bytesTotal; |
81 }; |
110 }; |
82 |
111 |
83 #endif // LDFORGE_DOWNLOAD_H |
112 #endif // LDFORGE_DOWNLOAD_H |