src/download.h

changeset 431
ec1e2059319b
parent 430
8458cf2719d1
child 432
ef382b98a8af
equal deleted inserted replaced
430:8458cf2719d1 431:ec1e2059319b
21 21
22 #include <QDialog> 22 #include <QDialog>
23 #include "common.h" 23 #include "common.h"
24 #include "types.h" 24 #include "types.h"
25 25
26 class LDFile;
27 class QFile;
26 class PartDownloadRequest; 28 class PartDownloadRequest;
27 class Ui_DownloadFrom; 29 class Ui_DownloadFrom;
28 class QNetworkAccessManager; 30 class QNetworkAccessManager;
29 class QNetworkRequest; 31 class QNetworkRequest;
30 class QNetworkReply; 32 class QNetworkReply;
44 46
45 // ============================================================================= 47 // =============================================================================
46 // ----------------------------------------------------------------------------- 48 // -----------------------------------------------------------------------------
47 class PartDownloadPrompt : public QDialog { 49 class PartDownloadPrompt : public QDialog {
48 Q_OBJECT 50 Q_OBJECT
51 PROPERTY (LDFile*, primaryFile, setPrimaryFile)
49 52
50 public: 53 public:
51 enum Source { 54 enum Source {
52 /* OfficialLibrary, 55 PartsTracker,
53 */ PartsTracker,
54 CustomURL, 56 CustomURL,
55 }; 57 };
56 58
57 explicit PartDownloadPrompt (QWidget* parent = null); 59 explicit PartDownloadPrompt (QWidget* parent = null);
58 virtual ~PartDownloadPrompt(); 60 virtual ~PartDownloadPrompt();
59 str getURL() const; 61 str getURL() const;
60 str getDest(str fname) const;
61 Source getSource() const; 62 Source getSource() const;
62 void downloadFile (str dest, str url, bool primary); 63 void downloadFile (str dest, str url, bool primary);
63 void modifyDest (str& dest) const; 64 void modifyDest (str& dest) const;
64 65
65 public slots: 66 public slots:
91 enum State { 92 enum State {
92 Requesting, 93 Requesting,
93 Downloading, 94 Downloading,
94 Finished, 95 Finished,
95 Failed, 96 Failed,
96 Aborted,
97 }; 97 };
98 98
99 explicit PartDownloadRequest (str url, str dest, bool primary, PartDownloadPrompt* parent); 99 explicit PartDownloadRequest (str url, str dest, bool primary, PartDownloadPrompt* parent);
100 PartDownloadRequest (const PartDownloadRequest&) = delete; 100 PartDownloadRequest (const PartDownloadRequest&) = delete;
101 virtual ~PartDownloadRequest(); 101 virtual ~PartDownloadRequest();
102 void updateToTable(); 102 void updateToTable();
103 bool isFinished() const; 103 bool isFinished() const;
104 const State& state() const;
104 105
105 void operator= (const PartDownloadRequest&) = delete; 106 void operator= (const PartDownloadRequest&) = delete;
106 107
107 public slots: 108 public slots:
108 void downloadFinished(); 109 void downloadFinished();
117 QNetworkReply* m_reply; 118 QNetworkReply* m_reply;
118 bool m_firstUpdate; 119 bool m_firstUpdate;
119 State m_state; 120 State m_state;
120 int64 m_bytesRead, m_bytesTotal; 121 int64 m_bytesRead, m_bytesTotal;
121 bool m_primary; 122 bool m_primary;
123 QFile* m_fp;
122 }; 124 };
123 125
124 #endif // LDFORGE_DOWNLOAD_H 126 #endif // LDFORGE_DOWNLOAD_H

mercurial