DownloadManager starts robbing ContentManager

DownloadManager stole from ContentManager its two data members
mp_downloader and m_downloads.
This commit is contained in:
Veloman Yunkan 2024-05-23 12:19:20 +04:00 committed by Kelson
parent 16b89a54e3
commit bfad2291c8
4 changed files with 21 additions and 6 deletions

View File

@ -95,9 +95,9 @@ void openFileLocation(QString path, QWidget *parent = nullptr)
ContentManager::ContentManager(Library* library, kiwix::Downloader* downloader, QObject *parent)
: QObject(parent),
DownloadManager(downloader),
mp_library(library),
mp_remoteLibrary(kiwix::Library::create()),
mp_downloader(downloader),
m_remoteLibraryManager()
{
restoreDownloads();
@ -510,7 +510,7 @@ void ContentManager::openBook(const QString &id)
}
void ContentManager::openBookPreview(const QString &id)
{
{
try {
QMutexLocker locker(&remoteLibraryLocker);
const std::string &downloadUrl =

View File

@ -4,12 +4,12 @@
#include <QObject>
#include "library.h"
#include "contentmanagerview.h"
#include <kiwix/downloader.h>
#include "opdsrequestmanager.h"
#include "contenttypefilter.h"
#include "contentmanagermodel.h"
#include "downloadmanagement.h"
class ContentManager : public QObject
class ContentManager : public QObject, private DownloadManager
{
Q_OBJECT
Q_PROPERTY(bool isLocal MEMBER m_local READ isLocal WRITE setLocal NOTIFY localChanged)
@ -136,8 +136,6 @@ private: // functions
private: // data
Library* mp_library;
kiwix::LibraryPtr mp_remoteLibrary;
kiwix::Downloader* mp_downloader;
ContentManagerModel::Downloads m_downloads;
QThread* mp_downloadUpdaterThread = nullptr;
OpdsRequestManager m_remoteLibraryManager;
ContentManagerView* mp_view;

View File

@ -32,3 +32,11 @@ void DownloadState::update(const DownloadInfo& downloadInfos)
const bool paused = downloadInfos["status"] == "paused";
*this = {percent, completedLength, downloadSpeed, paused};
}
////////////////////////////////////////////////////////////////////////////////
// DowloadManager
////////////////////////////////////////////////////////////////////////////////
DownloadManager::DownloadManager(kiwix::Downloader *downloader)
: mp_downloader(downloader)
{}

View File

@ -9,6 +9,8 @@
#include <memory>
#include <kiwix/downloader.h>
typedef QMap<QString, QVariant> DownloadInfo;
class DownloadState
@ -59,6 +61,13 @@ public: // types
ImplType impl;
mutable QMutex mutex;
};
public: // functions
explicit DownloadManager(kiwix::Downloader *downloader);
protected: // data
kiwix::Downloader* const mp_downloader;
Downloads m_downloads;
};
#endif // DOWNLOADMANAGEMENT_H