mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-22 03:26:05 -04:00
DownloadManager starts robbing ContentManager
DownloadManager stole from ContentManager its two data members mp_downloader and m_downloads.
This commit is contained in:
parent
16b89a54e3
commit
bfad2291c8
@ -95,9 +95,9 @@ void openFileLocation(QString path, QWidget *parent = nullptr)
|
|||||||
|
|
||||||
ContentManager::ContentManager(Library* library, kiwix::Downloader* downloader, QObject *parent)
|
ContentManager::ContentManager(Library* library, kiwix::Downloader* downloader, QObject *parent)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
|
DownloadManager(downloader),
|
||||||
mp_library(library),
|
mp_library(library),
|
||||||
mp_remoteLibrary(kiwix::Library::create()),
|
mp_remoteLibrary(kiwix::Library::create()),
|
||||||
mp_downloader(downloader),
|
|
||||||
m_remoteLibraryManager()
|
m_remoteLibraryManager()
|
||||||
{
|
{
|
||||||
restoreDownloads();
|
restoreDownloads();
|
||||||
@ -510,7 +510,7 @@ void ContentManager::openBook(const QString &id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ContentManager::openBookPreview(const QString &id)
|
void ContentManager::openBookPreview(const QString &id)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
QMutexLocker locker(&remoteLibraryLocker);
|
QMutexLocker locker(&remoteLibraryLocker);
|
||||||
const std::string &downloadUrl =
|
const std::string &downloadUrl =
|
||||||
|
@ -4,12 +4,12 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include "library.h"
|
#include "library.h"
|
||||||
#include "contentmanagerview.h"
|
#include "contentmanagerview.h"
|
||||||
#include <kiwix/downloader.h>
|
|
||||||
#include "opdsrequestmanager.h"
|
#include "opdsrequestmanager.h"
|
||||||
#include "contenttypefilter.h"
|
#include "contenttypefilter.h"
|
||||||
#include "contentmanagermodel.h"
|
#include "contentmanagermodel.h"
|
||||||
|
#include "downloadmanagement.h"
|
||||||
|
|
||||||
class ContentManager : public QObject
|
class ContentManager : public QObject, private DownloadManager
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(bool isLocal MEMBER m_local READ isLocal WRITE setLocal NOTIFY localChanged)
|
Q_PROPERTY(bool isLocal MEMBER m_local READ isLocal WRITE setLocal NOTIFY localChanged)
|
||||||
@ -136,8 +136,6 @@ private: // functions
|
|||||||
private: // data
|
private: // data
|
||||||
Library* mp_library;
|
Library* mp_library;
|
||||||
kiwix::LibraryPtr mp_remoteLibrary;
|
kiwix::LibraryPtr mp_remoteLibrary;
|
||||||
kiwix::Downloader* mp_downloader;
|
|
||||||
ContentManagerModel::Downloads m_downloads;
|
|
||||||
QThread* mp_downloadUpdaterThread = nullptr;
|
QThread* mp_downloadUpdaterThread = nullptr;
|
||||||
OpdsRequestManager m_remoteLibraryManager;
|
OpdsRequestManager m_remoteLibraryManager;
|
||||||
ContentManagerView* mp_view;
|
ContentManagerView* mp_view;
|
||||||
|
@ -32,3 +32,11 @@ void DownloadState::update(const DownloadInfo& downloadInfos)
|
|||||||
const bool paused = downloadInfos["status"] == "paused";
|
const bool paused = downloadInfos["status"] == "paused";
|
||||||
*this = {percent, completedLength, downloadSpeed, paused};
|
*this = {percent, completedLength, downloadSpeed, paused};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// DowloadManager
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
DownloadManager::DownloadManager(kiwix::Downloader *downloader)
|
||||||
|
: mp_downloader(downloader)
|
||||||
|
{}
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include <kiwix/downloader.h>
|
||||||
|
|
||||||
typedef QMap<QString, QVariant> DownloadInfo;
|
typedef QMap<QString, QVariant> DownloadInfo;
|
||||||
|
|
||||||
class DownloadState
|
class DownloadState
|
||||||
@ -59,6 +61,13 @@ public: // types
|
|||||||
ImplType impl;
|
ImplType impl;
|
||||||
mutable QMutex mutex;
|
mutable QMutex mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public: // functions
|
||||||
|
explicit DownloadManager(kiwix::Downloader *downloader);
|
||||||
|
|
||||||
|
protected: // data
|
||||||
|
kiwix::Downloader* const mp_downloader;
|
||||||
|
Downloads m_downloads;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DOWNLOADMANAGEMENT_H
|
#endif // DOWNLOADMANAGEMENT_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user