summaryrefslogtreecommitdiffstats
path: root/src/downloadmanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/downloadmanager.cpp')
-rw-r--r--src/downloadmanager.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp
index 8f7d8bb..5bada3a 100644
--- a/src/downloadmanager.cpp
+++ b/src/downloadmanager.cpp
@@ -1,19 +1,30 @@
#include "downloadmanager.h"
+// static counter to save the number of successfully downloaded files.
int DownloadManager::_downloaded = 0;
// -------------------------------------------------------------------------------------------------------
+// Initialisation
+// -------------------------------------------------------------------------------------------------------
+// Constructor initialises a QNetworkAccessManager needed to create/received download requests/replies
+// This object is then moved to the thread for the download manager, to ensure that downloads
+// are done in a separate thread (to avoid GUI blocking.)
+// The flag "_dip" starts as false, since no download is in progress.
+// This flag is needed to control queueing functionality.
+// Lastly the given download directory's existance is checked. (see below)
+
DownloadManager::DownloadManager() {
qxtLog->debug() << "Initializing download manager...";
- check_downloadDirectory();
+ checkDownloadDirectory();
_qnam = new QNetworkAccessManager();
_qnam->moveToThread(&dmThread);
_dip = false;
}
+// Destructor
DownloadManager::~DownloadManager() {
delete _qnam;
}
// -------------------------------------------------------------------------------------------------------
-void DownloadManager::check_downloadDirectory() {
+void DownloadManager::checkDownloadDirectory() {
// check if downloadPath exists, if not create it.
_downloadDir = QDir(downloadPath);
if (!_downloadDir.exists()) {
@@ -188,9 +199,9 @@ void DownloadManager::downloadFinished() {
_outfile.close();
_downloaded++;
qxtLog->debug() << "[dm] Download of " << _currentDownload->url().toString()
- << " finished. (_downloaded = " << _downloaded << ")";
+ << " finished. (downloaded = " << _downloaded << ")";
emit
- notify(QString("Successfully _downloaded %1").arg(_currentDownload->url().toString()));
+ notify(QString("Successfully downloaded %1").arg(_currentDownload->url().toString()));
_currentDownload->deleteLater();
}
_dip = false;