Commit eef96968 authored by Tobias Rautenkranz's avatar Tobias Rautenkranz
Browse files

Speedup (un-)checking all packages by not updating per item

Tested with 548 packages in the list to update. From ~ 6000 ms to 25 ms
for uncheckAll() and 70 ms for checkAll().

BUG: 442402
parent cd2b9b05
Pipeline #208663 passed with stage
in 2 minutes and 50 seconds
......@@ -350,16 +350,36 @@ void UpdateModel::resourceDataChanged(AbstractResource *res, const QVector<QByte
void UpdateModel::checkAll()
{
for (int i = 0, c = rowCount(); i < c; ++i)
if (index(i, 0).data(Qt::CheckStateRole) != Qt::Checked)
setData(index(i, 0), Qt::Checked, Qt::CheckStateRole);
QList<AbstractResource *> updatedItems;
for (int i = 0, c = rowCount(); i < c; ++i) {
auto idx = index(i);
if (idx.data(Qt::CheckStateRole) != Qt::Checked) {
updatedItems.append(itemFromIndex(idx)->app());
}
}
checkResources(updatedItems, true);
Q_EMIT dataChanged(index(0), index(rowCount() - 1), {Qt::CheckStateRole});
Q_EMIT toUpdateChanged();
}
void UpdateModel::uncheckAll()
{
for (int i = 0, c = rowCount(); i < c; ++i)
if (index(i, 0).data(Qt::CheckStateRole) != Qt::Unchecked)
setData(index(i, 0), Qt::Unchecked, Qt::CheckStateRole);
QList<AbstractResource *> updatedItems;
for (int i = 0, c = rowCount(); i < c; ++i) {
auto idx = index(i);
if (idx.data(Qt::CheckStateRole) != Qt::Unchecked) {
updatedItems.append(itemFromIndex(idx)->app());
}
}
checkResources(updatedItems, false);
Q_EMIT dataChanged(index(0), index(rowCount() - 1), {Qt::CheckStateRole});
Q_EMIT toUpdateChanged();
}
#include "moc_UpdateModel.cpp"
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