summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleix Pol <[email protected]>2018-10-30 16:43:39 +0100
committerAleix Pol <[email protected]>2018-10-30 16:43:39 +0100
commit04a59628a6d97667b628e69742af94b2aa22ea64 (patch)
treefcef52b25daaf35addac08f5e2df40bde908f3ee
parenta24ececbe953e06e5b484a553e955467abc17bd6 (diff)
Add a way to un/check all updates
FEATURE: 398231
-rw-r--r--discover/qml/UpdatesPage.qml16
-rw-r--r--libdiscover/UpdateModel/UpdateModel.cpp16
-rw-r--r--libdiscover/UpdateModel/UpdateModel.h3
3 files changed, 33 insertions, 2 deletions
diff --git a/discover/qml/UpdatesPage.qml b/discover/qml/UpdatesPage.qml
index 1078897..14fe6c6 100644
--- a/discover/qml/UpdatesPage.qml
+++ b/discover/qml/UpdatesPage.qml
@@ -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 {
diff --git a/libdiscover/UpdateModel/UpdateModel.cpp b/libdiscover/UpdateModel/UpdateModel.cpp
index 80a1aef..b21e6ab 100644
--- a/libdiscover/UpdateModel/UpdateModel.cpp
+++ b/libdiscover/UpdateModel/UpdateModel.cpp
@@ -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);
+}
diff --git a/libdiscover/UpdateModel/UpdateModel.h b/libdiscover/UpdateModel/UpdateModel.h
index 29142ba..2c7d495 100644
--- a/libdiscover/UpdateModel/UpdateModel.h
+++ b/libdiscover/UpdateModel/UpdateModel.h
@@ -79,6 +79,9 @@ public:
ResourcesUpdatesModel* backend() const;
public Q_SLOTS:
+ void checkAll();
+ void uncheckAll();
+
void setBackend(ResourcesUpdatesModel* updates);
Q_SIGNALS: