From 1a1dcfc5c779202f66282a2ecd544256c7e22b7c Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 4 Oct 2023 16:15:43 +0200 Subject: [PATCH] Core: Un-export and hide only locally used ProgressTimer Change-Id: If67b0d55972620a59a38a811fda6238d9cd4ab56 Reviewed-by: Reviewed-by: Eike Ziller --- .../progressmanager/progressmanager.cpp | 60 +++++++++++-------- .../progressmanager/progressmanager.h | 17 ------ 2 files changed, 34 insertions(+), 43 deletions(-) diff --git a/src/plugins/coreplugin/progressmanager/progressmanager.cpp b/src/plugins/coreplugin/progressmanager/progressmanager.cpp index bbad151c032..a2d61902b1c 100644 --- a/src/plugins/coreplugin/progressmanager/progressmanager.cpp +++ b/src/plugins/coreplugin/progressmanager/progressmanager.cpp @@ -24,7 +24,8 @@ #include #include -#include +#include +#include #include #include #include @@ -42,6 +43,38 @@ using namespace Core::Internal; using namespace Utils; namespace Core { + +class ProgressTimer : public QObject +{ +public: + ProgressTimer(const QFutureInterfaceBase &futureInterface, int expectedSeconds, QObject *parent) + : QObject(parent), + m_futureInterface(futureInterface), + m_expectedTime(expectedSeconds) + { + m_futureInterface.setProgressRange(0, 100); + m_futureInterface.setProgressValue(0); + + m_timer.setInterval(TimerInterval); + connect(&m_timer, &QTimer::timeout, this, &ProgressTimer::handleTimeout); + m_timer.start(); + } + +private: + void handleTimeout() + { + ++m_currentTime; + const int halfLife = qRound(1000.0 * m_expectedTime / TimerInterval); + const int progress = MathUtils::interpolateTangential(m_currentTime, halfLife, 0, 100); + m_futureInterface.setProgressValue(progress); + } + + QFutureInterfaceBase m_futureInterface; + int m_expectedTime; + int m_currentTime = 0; + QTimer m_timer; +}; + /*! \class Core::ProgressManager \inheaderfile coreplugin/progressmanager/progressmanager.h @@ -789,29 +822,4 @@ void ProgressManager::cancelTasks(Id type) m_instance->doCancelTasks(type); } - -ProgressTimer::ProgressTimer(const QFutureInterfaceBase &futureInterface, - int expectedSeconds, - QObject *parent) - : QObject(parent), - m_futureInterface(futureInterface), - m_expectedTime(expectedSeconds) -{ - m_futureInterface.setProgressRange(0, 100); - m_futureInterface.setProgressValue(0); - - m_timer = new QTimer(this); - m_timer->setInterval(TimerInterval); - connect(m_timer, &QTimer::timeout, this, &ProgressTimer::handleTimeout); - m_timer->start(); -} - -void ProgressTimer::handleTimeout() -{ - ++m_currentTime; - const int halfLife = qRound(1000.0 * m_expectedTime / TimerInterval); - const int progress = MathUtils::interpolateTangential(m_currentTime, halfLife, 0, 100); - m_futureInterface.setProgressValue(progress); -} - } // Core diff --git a/src/plugins/coreplugin/progressmanager/progressmanager.h b/src/plugins/coreplugin/progressmanager/progressmanager.h index 99580436ca2..f59fb0562fd 100644 --- a/src/plugins/coreplugin/progressmanager/progressmanager.h +++ b/src/plugins/coreplugin/progressmanager/progressmanager.h @@ -11,8 +11,6 @@ #include #include -QT_FORWARD_DECLARE_CLASS(QTimer) - namespace Core { class FutureProgress; @@ -58,21 +56,6 @@ private: friend class Core::Internal::ProgressManagerPrivate; }; -class CORE_EXPORT ProgressTimer : public QObject -{ -public: - ProgressTimer(const QFutureInterfaceBase &futureInterface, int expectedSeconds, - QObject *parent = nullptr); - -private: - void handleTimeout(); - - QFutureInterfaceBase m_futureInterface; - int m_expectedTime; - int m_currentTime = 0; - QTimer *m_timer; -}; - } // namespace Core Q_DECLARE_OPERATORS_FOR_FLAGS(Core::ProgressManager::ProgressFlags)