Commit c01a0cee authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

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.
parent c66e4647
......@@ -22,6 +22,7 @@
// Qt includes
#include <QFont>
#include <QTimer>
#include <QDebug>
// 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, this, &UpdateModel::activityChanged);
connect(ResourcesModel::global(), &ResourcesModel::updatesCountChanged, this, &UpdateModel::activityChanged);
connect(ResourcesModel::global(), &ResourcesModel::resourceDataChanged, this, &UpdateModel::resourceDataChanged);
connect(this, &UpdateModel::toUpdateChanged, this, &UpdateModel::updateSizeChanged);
connect(m_updateSizeTimer, &QTimer::timeout, this, &UpdateModel::updateSizeChanged);
UpdateModel::~UpdateModel() = default;
......@@ -310,6 +316,6 @@ void UpdateModel::resourceDataChanged(AbstractResource* res, const QVector<QByte
dataChanged(index, index, {SizeRole, VersionRole});
else if (properties.contains("size")) {
dataChanged(index, index, {SizeRole});
Q_EMIT updateSizeChanged();
......@@ -24,6 +24,7 @@
#include <QAbstractListModel>
#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<UpdateItem*> m_updateItems;
ResourcesUpdatesModel* m_updates;
QList<AbstractResource*> m_resources;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment