mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-24 04:32:15 -04:00
Moved DownloadManager code across .cpp files
This commit is contained in:
parent
8fbb867270
commit
fffe7586b4
@ -154,30 +154,6 @@ ContentManager::ContentManager(Library* library, kiwix::Downloader* downloader)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadManager::startDownloadUpdaterThread()
|
|
||||||
{
|
|
||||||
// so that DownloadInfo can be copied across threads
|
|
||||||
qRegisterMetaType<DownloadInfo>("DownloadInfo");
|
|
||||||
|
|
||||||
mp_downloadUpdaterThread = QThread::create([=]() {
|
|
||||||
while ( mp_downloadUpdaterThread != nullptr ) {
|
|
||||||
updateDownloads();
|
|
||||||
QThread::msleep(1000);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
mp_downloadUpdaterThread->start();
|
|
||||||
}
|
|
||||||
|
|
||||||
DownloadManager::~DownloadManager()
|
|
||||||
{
|
|
||||||
if ( mp_downloadUpdaterThread )
|
|
||||||
{
|
|
||||||
QThread* t = mp_downloadUpdaterThread;
|
|
||||||
mp_downloadUpdaterThread = nullptr; // tell the thread to terminate
|
|
||||||
t->wait();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ContentManager::updateModel()
|
void ContentManager::updateModel()
|
||||||
{
|
{
|
||||||
const auto bookIds = getBookIds();
|
const auto bookIds = getBookIds();
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#include "downloadmanagement.h"
|
#include "downloadmanagement.h"
|
||||||
|
|
||||||
|
#include <QThread>
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// DowloadState
|
// DowloadState
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -44,6 +46,30 @@ DownloadManager::DownloadManager(const Library* lib, kiwix::Downloader *download
|
|||||||
restoreDownloads();
|
restoreDownloads();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DownloadManager::~DownloadManager()
|
||||||
|
{
|
||||||
|
if ( mp_downloadUpdaterThread )
|
||||||
|
{
|
||||||
|
QThread* t = mp_downloadUpdaterThread;
|
||||||
|
mp_downloadUpdaterThread = nullptr; // tell the thread to terminate
|
||||||
|
t->wait();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DownloadManager::startDownloadUpdaterThread()
|
||||||
|
{
|
||||||
|
// so that DownloadInfo can be copied across threads
|
||||||
|
qRegisterMetaType<DownloadInfo>("DownloadInfo");
|
||||||
|
|
||||||
|
mp_downloadUpdaterThread = QThread::create([=]() {
|
||||||
|
while ( mp_downloadUpdaterThread != nullptr ) {
|
||||||
|
updateDownloads();
|
||||||
|
QThread::msleep(1000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mp_downloadUpdaterThread->start();
|
||||||
|
}
|
||||||
|
|
||||||
void DownloadManager::restoreDownloads()
|
void DownloadManager::restoreDownloads()
|
||||||
{
|
{
|
||||||
for ( const auto& bookId : mp_library->getBookIds() ) {
|
for ( const auto& bookId : mp_library->getBookIds() ) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user