From 05d01e39fa15bfd3395ac89ea6a1f2acb9a4dea6 Mon Sep 17 00:00:00 2001 From: Jeremy Rimpo Date: Thu, 16 Dec 2021 22:04:41 -0600 Subject: Download status improvements - Better speed calculation - Add download time estimate --- src/downloadmanager.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/downloadmanager.h') diff --git a/src/downloadmanager.h b/src/downloadmanager.h index ba9f4b5c..86dc17b9 100644 --- a/src/downloadmanager.h +++ b/src/downloadmanager.h @@ -38,6 +38,10 @@ along with Mod Organizer. If not, see . #include #include #include +#include +#include +#include +using namespace boost::accumulators; namespace MOBase { class IPluginGame; } @@ -75,6 +79,10 @@ private: struct DownloadInfo { ~DownloadInfo() { delete m_FileInfo; } + accumulator_set> m_DownloadAcc; + accumulator_set> m_DownloadTimeAcc; + int m_DownloadLast; + int m_DownloadTimeLast; unsigned int m_DownloadID; QString m_FileName; QFile m_Output; @@ -82,7 +90,6 @@ private: QElapsedTimer m_StartTime; qint64 m_PreResumeSize; std::pair m_Progress; - std::tuple m_SpeedDiff; bool m_HasData; DownloadState m_State; int m_CurrentUrl; @@ -126,7 +133,10 @@ private: private: static unsigned int s_NextDownloadID; private: - DownloadInfo() : m_TotalSize(0), m_ReQueried(false), m_Hidden(false), m_SpeedDiff(std::tuple(0,0,0,0,0)), m_HasData(false) {} + DownloadInfo() : m_TotalSize(0), m_ReQueried(false), m_Hidden(false), m_HasData(false), + m_DownloadTimeLast(0), m_DownloadLast(0), + m_DownloadAcc(tag::rolling_window::window_size = 500), + m_DownloadTimeAcc(tag::rolling_window::window_size = 500) {} }; friend class DownloadManagerProxy; -- cgit v1.3.1