Commit 103c1911 authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇

[Folder View Config] Replace FilterableMimeTypesModel by Plasma SortFilterModel

We already have a ready-to-use filter model for that.
While at it, make the filter case-insensitive.

Differential Revision: https://phabricator.kde.org/D7064
parent 76af2694
......@@ -35,10 +35,17 @@ Item {
property alias cfg_filterPattern: filterPattern.text
property alias cfg_filterMimeTypes: mimeTypesModel.checkedTypes
Folder.FilterableMimeTypesModel {
id: mimeTypesModel
PlasmaCore.SortFilterModel {
id: filderedMimeTypesModel
filter: mimeFilter.text
sourceModel: Folder.MimeTypesModel {
id: mimeTypesModel
}
// SortFilterModel doesn't have a case-sensitivity option
// but filterRegExp always causes case-insensitive sorting.
filterRegExp: mimeFilter.text
filterRole: "display"
}
ColumnLayout {
......@@ -96,7 +103,7 @@ Item {
enabled: (filterMode.currentIndex > 0)
ListView {
model: mimeTypesModel
model: filderedMimeTypesModel
delegate: RowLayout {
CheckBox {
......
......@@ -43,7 +43,7 @@ void FolderPlugin::registerTypes(const char *uri)
qmlRegisterType<ItemViewAdapter>(uri, 0, 1, "ItemViewAdapter");
qmlRegisterType<LabelGenerator>(uri, 0, 1, "LabelGenerator");
qmlRegisterType<MenuHelper>(uri, 0, 1, "MenuHelper");
qmlRegisterType<FilterableMimeTypesModel>(uri, 0, 1, "FilterableMimeTypesModel");
qmlRegisterType<MimeTypesModel>(uri, 0, 1, "MimeTypesModel");
qmlRegisterType<PlacesModel>(uri, 0, 1, "PlacesModel");
qmlRegisterType<Positioner>(uri, 0, 1, "Positioner");
qmlRegisterType<PreviewPluginsModel>(uri, 0, 1, "PreviewPluginsModel");
......
......@@ -147,48 +147,3 @@ void MimeTypesModel::setCheckedTypes(const QStringList &list)
emit checkedTypesChanged();
}
FilterableMimeTypesModel::FilterableMimeTypesModel(QObject *parent) : QSortFilterProxyModel(parent),
m_sourceModel(new MimeTypesModel(this))
{
setSourceModel(m_sourceModel);
setDynamicSortFilter(true);
connect(m_sourceModel, &MimeTypesModel::checkedTypesChanged, this, &FilterableMimeTypesModel::checkedTypesChanged);
}
FilterableMimeTypesModel::~FilterableMimeTypesModel()
{
}
void FilterableMimeTypesModel::checkAll()
{
m_sourceModel->checkAll();
}
QStringList FilterableMimeTypesModel::checkedTypes() const
{
return m_sourceModel->checkedTypes();
}
void FilterableMimeTypesModel::setCheckedTypes(const QStringList &list)
{
m_sourceModel->setCheckedTypes(list);
}
QString FilterableMimeTypesModel::filter() const
{
return m_filter;
}
void FilterableMimeTypesModel::setFilter(const QString &filter)
{
if (m_filter != filter) {
m_filter = filter;
setFilterFixedString(m_filter);
emit filterChanged();
}
}
......@@ -57,32 +57,4 @@ class MimeTypesModel : public QAbstractListModel
QVector<bool> checkedRows;
};
class FilterableMimeTypesModel : public QSortFilterProxyModel
{
Q_OBJECT
Q_PROPERTY(QStringList checkedTypes READ checkedTypes WRITE setCheckedTypes NOTIFY checkedTypesChanged)
Q_PROPERTY(QString filter READ filter WRITE setFilter NOTIFY filterChanged)
public:
FilterableMimeTypesModel(QObject *parent = 0);
~FilterableMimeTypesModel();
Q_INVOKABLE void checkAll();
QStringList checkedTypes() const;
void setCheckedTypes(const QStringList &list);
QString filter() const;
void setFilter(const QString &filter);
Q_SIGNALS:
void checkedTypesChanged() const;
void filterChanged() const;
private:
MimeTypesModel *m_sourceModel;
QString m_filter;
};
#endif
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