Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 04a59628 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

Add a way to un/check all updates

FEATURE: 398231
parent a24ececb
......@@ -89,8 +89,22 @@ DiscoverPage
anchors.fill: parent
enabled: page.currentAction.enabled
CheckBox {
Layout.leftMargin: Kirigami.Units.gridUnit + Kirigami.Units.largeSpacing
tristate: true
checkState: updateModel.toUpdateCount === 0 ? Qt.Unchecked
: updateModel.toUpdateCount === updateModel.totalUpdatesCount ? Qt.Checked
: Qt.PartiallyChecked
onClicked: {
if (updateModel.toUpdateCount === 0)
updateModel.checkAll()
else
updateModel.uncheckAll()
}
}
LabelBackground {
Layout.leftMargin: Kirigami.Units.gridUnit
text: updateModel.toUpdateCount + " (" + updateModel.updateSize+")"
}
Label {
......
......@@ -144,7 +144,7 @@ QVariant UpdateModel::data(const QModelIndex &index, int role) const
case AbstractResource::Addon: return addonsSection;
}
Q_UNREACHABLE();
}
}
case SectionResourceProgressRole:
return (100-item->progress()) + (101 * item->resource()->type());
default:
......@@ -338,3 +338,17 @@ void UpdateModel::resourceDataChanged(AbstractResource* res, const QVector<QByte
m_updateSizeTimer->start();
}
}
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);
}
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);
}
......@@ -79,6 +79,9 @@ public:
ResourcesUpdatesModel* backend() const;
public Q_SLOTS:
void checkAll();
void uncheckAll();
void setBackend(ResourcesUpdatesModel* updates);
Q_SIGNALS:
......
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