From 149328dcb2ff716f56937bd9ca705ad79c5d1f81 Mon Sep 17 00:00:00 2001 From: Mikaƫl Capelle Date: Sun, 11 Oct 2020 21:15:12 +0200 Subject: Switch from Qt signals to boost::signals for DownloadManager. --- src/downloadmanager.h | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'src/downloadmanager.h') diff --git a/src/downloadmanager.h b/src/downloadmanager.h index 90def927..8a0d8eed 100644 --- a/src/downloadmanager.h +++ b/src/downloadmanager.h @@ -37,6 +37,7 @@ along with Mod Organizer. If not, see . #include #include #include +#include namespace MOBase { class IPluginGame; } @@ -126,6 +127,8 @@ private: DownloadInfo() : m_TotalSize(0), m_ReQueried(false), m_Hidden(false), m_SpeedDiff(std::tuple(0,0,0,0,0)), m_HasData(false) {} }; + using SignalDownloadCallback = boost::signals2::signal; + public: /** @@ -367,11 +370,16 @@ public: */ void refreshList(); - virtual int startDownloadURLs(const QStringList &urls); +public: // IDownloadManager interface: - virtual int startDownloadNexusFile(int modID, int fileID); + int startDownloadURLs(const QStringList &urls) override; + int startDownloadNexusFile(int modID, int fileID) override; + QString downloadPath(int id) override; - virtual QString downloadPath(int id); + bool onDownloadComplete(const std::function& callback) override; + bool onDownloadPaused(const std::function& callback) override; + bool onDownloadFailed(const std::function& callback) override; + bool onDownloadRemoved(const std::function& callback) override; /** * @brief retrieve a download index from the filename @@ -383,7 +391,7 @@ public: void pauseAll(); -signals: +Q_SIGNALS: void aboutToUpdate(); @@ -556,6 +564,11 @@ private: QFileSystemWatcher m_DirWatcher; + SignalDownloadCallback m_DownloadComplete; + SignalDownloadCallback m_DownloadPaused; + SignalDownloadCallback m_DownloadFailed; + SignalDownloadCallback m_DownloadRemoved; + //The dirWatcher is actually triggering off normal Mo operations such as deleting downloads or editing .meta files //so it needs to be disabled during operations that are known to cause the creation or deletion of files in the Downloads folder. //Notably using QSettings to edit a file creates a temporarily .lock file that causes the Watcher to trigger multiple listRefreshes freezing the ui. -- cgit v1.3.1