Commit b49b73de authored by Eike Hein's avatar Eike Hein
Browse files

Make Select/Deselect All operate on the filtered rows.

Summary: BUG:392264

Reviewers: #plasma, broulik

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D11665
parent 3fe4db6a
......@@ -36,7 +36,7 @@ Item {
property alias cfg_filterMimeTypes: mimeTypesModel.checkedTypes
PlasmaCore.SortFilterModel {
id: filderedMimeTypesModel
id: filteredMimeTypesModel
sourceModel: Folder.MimeTypesModel {
id: mimeTypesModel
......@@ -49,6 +49,27 @@ Item {
sortRole: mimeTypesView.getColumn(mimeTypesView.sortIndicatorColumn).role
sortOrder: mimeTypesView.sortIndicatorOrder
function checkFiltered() {
var types = [];
for (var i = 0; i < count; ++i) {
types.push(get(i).name);
}
mimeTypesModel.checkedTypes = types;
}
function uncheckFiltered() {
var types = [];
for (var i = 0; i < count; ++i) {
types.push(get(i).name);
}
mimeTypesModel.checkedTypes = mimeTypesModel.checkedTypes.filter(function(x) {
return types.indexOf(x) < 0; });
}
}
ColumnLayout {
......@@ -113,7 +134,7 @@ Item {
enabled: (filterMode.currentIndex > 0)
model: filderedMimeTypesModel
model: filteredMimeTypesModel
sortIndicatorVisible: true
sortIndicatorColumn: 2 // Default to sort by "File type".
......@@ -215,9 +236,7 @@ Item {
text: i18n("Select All")
onClicked: {
mimeTypesModel.checkAll();
}
onClicked: filteredMimeTypesModel.checkFiltered()
}
Button {
......@@ -228,9 +247,7 @@ Item {
text: i18n("Deselect All")
onClicked: {
mimeTypesModel.checkedTypes = "";
}
onClicked: filteredMimeTypesModel.uncheckFiltered()
}
}
}
......
......@@ -98,15 +98,6 @@ bool MimeTypesModel::setData(const QModelIndex &index, const QVariant &value, in
return false;
}
void MimeTypesModel::checkAll()
{
m_checkedRows = QVector<bool>(m_mimeTypesList.size(), true);
emit dataChanged(index(0, 0), index(m_mimeTypesList.size() - 1, 0), {Qt::CheckStateRole});
emit checkedTypesChanged();
}
int MimeTypesModel::indexOfType(const QString &name) const
{
for (int i = 0; i < m_mimeTypesList.size(); i++) {
......
......@@ -39,8 +39,6 @@ class MimeTypesModel : public QAbstractListModel
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
Q_INVOKABLE void checkAll();
int rowCount(const QModelIndex &parent = QModelIndex()) const override { Q_UNUSED(parent) return m_mimeTypesList.size(); }
QStringList checkedTypes() const;
......
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