diff options
author | Jonathan Bauer | 2011-05-04 13:24:24 +0200 |
---|---|---|
committer | Jonathan Bauer | 2011-05-04 13:24:24 +0200 |
commit | 0a8ab1c45108155434e22131ecc94989f564d58a (patch) | |
tree | 8902aa1940adbe6714dee3d096ae2018ea3073dc /src/downloadmanager.cpp | |
parent | minor (diff) | |
download | fbgui-0a8ab1c45108155434e22131ecc94989f564d58a.tar.gz fbgui-0a8ab1c45108155434e22131ecc94989f564d58a.tar.xz fbgui-0a8ab1c45108155434e22131ecc94989f564d58a.zip |
download manager constructor comments & typos fix
Diffstat (limited to 'src/downloadmanager.cpp')
-rw-r--r-- | src/downloadmanager.cpp | 19 |
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; |