Commit 7f9bd37a authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

Recalculate update size when a package's size changes

parent 8b884363
......@@ -41,6 +41,7 @@ UpdateModel::UpdateModel(QObject *parent)
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);
}
UpdateModel::~UpdateModel() = default;
......@@ -275,4 +276,8 @@ void UpdateModel::resourceDataChanged(AbstractResource* res, const QVector<QByte
const auto index = indexFromItem(item);
if (properties.contains("state"))
dataChanged(index, index, {SizeRole, VersionRole});
else if (properties.contains("size")) {
dataChanged(index, index, {SizeRole});
Q_EMIT updateSizeChanged();
}
}
......@@ -35,7 +35,7 @@ class DISCOVERCOMMON_EXPORT UpdateModel : public QAbstractListModel
Q_PROPERTY(bool hasUpdates READ hasUpdates NOTIFY hasUpdatesChanged)
Q_PROPERTY(int toUpdateCount READ toUpdateCount NOTIFY toUpdateChanged)
Q_PROPERTY(int totalUpdatesCount READ totalUpdatesCount NOTIFY hasUpdatesChanged)
Q_PROPERTY(QString updateSize READ updateSize NOTIFY toUpdateChanged)
Q_PROPERTY(QString updateSize READ updateSize NOTIFY updateSizeChanged)
public:
enum Roles {
......@@ -81,6 +81,7 @@ public Q_SLOTS:
Q_SIGNALS:
void hasUpdatesChanged(bool hasUpdates);
void toUpdateChanged();
void updateSizeChanged();
private:
void resourceDataChanged(AbstractResource* res, const QVector<QByteArray> &properties);
......
Markdown is supported
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