54 ProgressColumn, |
54 ProgressColumn, |
55 }; |
55 }; |
56 |
56 |
57 using RequestList = QList<PartDownloadRequest*>; |
57 using RequestList = QList<PartDownloadRequest*>; |
58 |
58 |
59 properties: |
|
60 Q_OBJECT |
59 Q_OBJECT |
61 PROPERTY (public, LDDocument*, PrimaryFile, NO_OPS, STOCK_WRITE) |
60 PROPERTY (public, LDDocument*, primaryFile, setPrimaryFile, STOCK_WRITE) |
62 PROPERTY (public, bool, Aborted, BOOL_OPS, STOCK_WRITE) |
61 PROPERTY (public, bool, isAborted, setAborted, STOCK_WRITE) |
63 PROPERTY (private, Ui_DownloadFrom*, Interface, NO_OPS, STOCK_WRITE) |
62 PROPERTY (private, Ui_DownloadFrom*, interface, setInterface, STOCK_WRITE) |
64 PROPERTY (private, QStringList, FilesToDownload, LIST_OPS, STOCK_WRITE) |
63 PROPERTY (private, QStringList, filesToDownload, setFilesToDownload, STOCK_WRITE) |
65 PROPERTY (private, RequestList, Requests, LIST_OPS, STOCK_WRITE) |
64 PROPERTY (private, RequestList, requests, setRequests, STOCK_WRITE) |
66 PROPERTY (private, QPushButton*, DownloadButton, NO_OPS, STOCK_WRITE) |
65 PROPERTY (private, QPushButton*, downloadButton, setDownloadButton, STOCK_WRITE) |
67 |
66 |
68 public: |
67 public: |
69 explicit PartDownloader (QWidget* parent = null); |
68 explicit PartDownloader (QWidget* parent = null); |
70 virtual ~PartDownloader(); |
69 virtual ~PartDownloader(); |
71 |
70 |
72 void downloadFile (QString dest, QString url, bool primary); |
71 void downloadFile (QString dest, QString url, bool primary); |
73 QPushButton* getButton (Button i); |
72 QPushButton* getButton (Button i); |
74 QString getURL() const; |
73 QString getURL() const; |
75 Source getSource() const; |
74 Source getSource() const; |
76 void modifyDestination (QString& dest) const; |
75 void modifyDestination (QString& dest) const; |
77 |
76 |
78 static QString getDownloadPath(); |
77 static QString getDownloadPath(); |
79 static void staticBegin(); |
78 static void staticBegin(); |
80 |
79 |
81 public slots: |
80 public slots: |
82 void buttonClicked (QAbstractButton* btn); |
81 void buttonClicked (QAbstractButton* btn); |
83 void checkIfFinished(); |
82 void checkIfFinished(); |
86 |
85 |
87 // ============================================================================= |
86 // ============================================================================= |
88 // |
87 // |
89 class PartDownloadRequest : public QObject |
88 class PartDownloadRequest : public QObject |
90 { |
89 { |
91 typedefs: |
90 public: |
92 enum EState |
91 enum EState |
93 { |
92 { |
94 ERequesting, |
93 ERequesting, |
95 EDownloading, |
94 EDownloading, |
96 EFinished, |
95 EFinished, |
97 EFailed, |
96 EFailed, |
98 }; |
97 }; |
99 |
98 |
100 properties: |
|
101 Q_OBJECT |
99 Q_OBJECT |
102 PROPERTY (public, int, TableRow, NUM_OPS, STOCK_WRITE) |
100 PROPERTY (public, int, tableRow, setTableRow, STOCK_WRITE) |
103 PROPERTY (private, EState, State, NO_OPS, STOCK_WRITE) |
101 PROPERTY (private, EState, state, setState, STOCK_WRITE) |
104 PROPERTY (private, PartDownloader*, Prompt, NO_OPS, STOCK_WRITE) |
102 PROPERTY (private, PartDownloader*, prompt, setPrompt, STOCK_WRITE) |
105 PROPERTY (private, QString, URL, STR_OPS, STOCK_WRITE) |
103 PROPERTY (private, QString, url, setURL, STOCK_WRITE) |
106 PROPERTY (private, QString, Destinaton, STR_OPS, STOCK_WRITE) |
104 PROPERTY (private, QString, destinaton, setDestination, STOCK_WRITE) |
107 PROPERTY (private, QString, FilePath, STR_OPS, STOCK_WRITE) |
105 PROPERTY (private, QString, filePath, setFilePath, STOCK_WRITE) |
108 PROPERTY (private, QNetworkAccessManager*, NAM, NO_OPS, STOCK_WRITE) |
106 PROPERTY (private, QNetworkAccessManager*, networkManager, setNetworkManager, STOCK_WRITE) |
109 PROPERTY (private, QNetworkReply*, Reply, NO_OPS, STOCK_WRITE) |
107 PROPERTY (private, QNetworkReply*, networkReply, setNetworkReply, STOCK_WRITE) |
110 PROPERTY (private, bool, FirstUpdate, BOOL_OPS, STOCK_WRITE) |
108 PROPERTY (private, bool, isFirstUpdate, setFirstUpdate, STOCK_WRITE) |
111 PROPERTY (private, int64, BytesRead, NUM_OPS, STOCK_WRITE) |
109 PROPERTY (private, int64, numBytesRead, setNumBytesRead, STOCK_WRITE) |
112 PROPERTY (private, int64, BytesTotal, NUM_OPS, STOCK_WRITE) |
110 PROPERTY (private, int64, numBytesTotal, setNumBytesTotal, STOCK_WRITE) |
113 PROPERTY (private, bool, Primary, BOOL_OPS, STOCK_WRITE) |
111 PROPERTY (private, bool, isPrimary, setPrimary, STOCK_WRITE) |
114 PROPERTY (private, QFile*, FilePointer, NO_OPS, STOCK_WRITE) |
112 PROPERTY (private, QFile*, filePointer, setFilePointer, STOCK_WRITE) |
115 |
113 |
116 public: |
114 public: |
117 explicit PartDownloadRequest (QString url, QString dest, bool primary, PartDownloader* parent); |
115 explicit PartDownloadRequest (QString url, QString dest, bool primary, PartDownloader* parent); |
118 PartDownloadRequest (const PartDownloadRequest&) = delete; |
116 PartDownloadRequest (const PartDownloadRequest&) = delete; |
119 virtual ~PartDownloadRequest(); |
117 virtual ~PartDownloadRequest(); |
120 void updateToTable(); |
118 void updateToTable(); |
121 bool isFinished() const; |
119 bool isFinished() const; |
122 |
|
123 void operator= (const PartDownloadRequest&) = delete; |
120 void operator= (const PartDownloadRequest&) = delete; |
124 |
121 |
125 public slots: |
122 public slots: |
126 void downloadFinished(); |
123 void downloadFinished(); |
127 void readyRead(); |
124 void readyRead(); |