From kde-commits Wed May 30 23:44:35 2018 From: Aleix Pol Date: Wed, 30 May 2018 23:44:35 +0000 To: kde-commits Subject: [discover/Plasma/5.12] libdiscover/UpdateModel: Limit how often we refresh the size of the updates s Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=152772388605855 Git commit c01a0cee7ac60f7ec26e0710df6bbb1bcfddd889 by Aleix Pol. Committed on 30/05/2018 at 23:44. Pushed by apol into branch 'Plasma/5.12'. Limit how often we refresh the size of the updates set PackageKit will update every resource separately after the initial fetch and this would recompute the update size for each. Now its done once per update, saving some freeze time. M +7 -1 libdiscover/UpdateModel/UpdateModel.cpp M +2 -0 libdiscover/UpdateModel/UpdateModel.h https://commits.kde.org/discover/c01a0cee7ac60f7ec26e0710df6bbb1bcfddd889 diff --git a/libdiscover/UpdateModel/UpdateModel.cpp b/libdiscover/UpdateMo= del/UpdateModel.cpp index 1f229133..8b04a966 100644 --- a/libdiscover/UpdateModel/UpdateModel.cpp +++ b/libdiscover/UpdateModel/UpdateModel.cpp @@ -22,6 +22,7 @@ = // Qt includes #include +#include #include = // KDE includes @@ -36,12 +37,17 @@ = UpdateModel::UpdateModel(QObject *parent) : QAbstractListModel(parent) + , m_updateSizeTimer(new QTimer(this)) , m_updates(nullptr) { connect(ResourcesModel::global(), &ResourcesModel::fetchingChanged, th= is, &UpdateModel::activityChanged); connect(ResourcesModel::global(), &ResourcesModel::updatesCountChanged= , this, &UpdateModel::activityChanged); connect(ResourcesModel::global(), &ResourcesModel::resourceDataChanged= , this, &UpdateModel::resourceDataChanged); connect(this, &UpdateModel::toUpdateChanged, this, &UpdateModel::updat= eSizeChanged); + + m_updateSizeTimer->setInterval(100); + m_updateSizeTimer->setSingleShot(true); + connect(m_updateSizeTimer, &QTimer::timeout, this, &UpdateModel::updat= eSizeChanged); } = UpdateModel::~UpdateModel() =3D default; @@ -310,6 +316,6 @@ void UpdateModel::resourceDataChanged(AbstractResource*= res, const QVectorstart(); } } diff --git a/libdiscover/UpdateModel/UpdateModel.h b/libdiscover/UpdateMode= l/UpdateModel.h index fc5dd1a4..4df37b85 100644 --- a/libdiscover/UpdateModel/UpdateModel.h +++ b/libdiscover/UpdateModel/UpdateModel.h @@ -24,6 +24,7 @@ #include #include "discovercommon_export.h" = +class QTimer; class ResourcesUpdatesModel; class AbstractResource; class UpdateItem; @@ -91,6 +92,7 @@ private: void resourceHasProgressed(AbstractResource* res, qreal progress); void activityChanged(); = + QTimer* const m_updateSizeTimer; QVector m_updateItems; ResourcesUpdatesModel* m_updates; QList m_resources;