From 0a8ab1c45108155434e22131ecc94989f564d58a Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Wed, 4 May 2011 13:24:24 +0200 Subject: download manager constructor comments & typos fix --- src/downloadmanager.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/downloadmanager.cpp') 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; -- cgit v1.2.3-55-g7522