Commit 9e082f00 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

search: filter differently on the SourcesPage

Qt chokes on the QSortFilterProxyModel for some reason
parent 8d021962
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
#include <qqml.h> #include <qqml.h>
#include <QPointer> #include <QPointer>
#include <QGuiApplication> #include <QGuiApplication>
#include <QSortFilterProxyModel>
#include <QTimer> #include <QTimer>
#include <QSessionManager> #include <QSessionManager>
#include <QClipboard> #include <QClipboard>
...@@ -84,18 +83,6 @@ class CachedNetworkAccessManagerFactory : public QQmlNetworkAccessManagerFactory ...@@ -84,18 +83,6 @@ class CachedNetworkAccessManagerFactory : public QQmlNetworkAccessManagerFactory
} }
}; };
class OurSortFilterProxyModel : public QSortFilterProxyModel, public QQmlParserStatus
{
Q_OBJECT
Q_INTERFACES(QQmlParserStatus)
public:
void classBegin() override {}
void componentComplete() override {
if (dynamicSortFilter())
sort(0);
}
};
DiscoverObject::DiscoverObject(CompactMode mode, const QVariantMap &initialProperties) DiscoverObject::DiscoverObject(CompactMode mode, const QVariantMap &initialProperties)
: QObject() : QObject()
, m_engine(new QQmlApplicationEngine) , m_engine(new QQmlApplicationEngine)
...@@ -113,7 +100,6 @@ DiscoverObject::DiscoverObject(CompactMode mode, const QVariantMap &initialPrope ...@@ -113,7 +100,6 @@ DiscoverObject::DiscoverObject(CompactMode mode, const QVariantMap &initialPrope
qmlRegisterType<PaginateModel>("org.kde.discover.app", 1, 0, "PaginateModel"); qmlRegisterType<PaginateModel>("org.kde.discover.app", 1, 0, "PaginateModel");
qmlRegisterType<KConcatenateRowsProxyModel>("org.kde.discover.app", 1, 0, "KConcatenateRowsProxyModel"); qmlRegisterType<KConcatenateRowsProxyModel>("org.kde.discover.app", 1, 0, "KConcatenateRowsProxyModel");
qmlRegisterType<FeaturedModel>("org.kde.discover.app", 1, 0, "FeaturedModel"); qmlRegisterType<FeaturedModel>("org.kde.discover.app", 1, 0, "FeaturedModel");
qmlRegisterType<OurSortFilterProxyModel>("org.kde.discover.app", 1, 0, "QSortFilterProxyModel");
#ifdef WITH_FEEDBACK #ifdef WITH_FEEDBACK
qmlRegisterSingletonType<PlasmaUserFeedback>("org.kde.discover.app", 1, 0, "UserFeedbackSettings", [](QQmlEngine*, QJSEngine*) -> QObject* { return new PlasmaUserFeedback(KSharedConfig::openConfig(QStringLiteral("PlasmaUserFeedback"), KConfig::NoGlobals)); }); qmlRegisterSingletonType<PlasmaUserFeedback>("org.kde.discover.app", 1, 0, "UserFeedbackSettings", [](QQmlEngine*, QJSEngine*) -> QObject* { return new PlasmaUserFeedback(KSharedConfig::openConfig(QStringLiteral("PlasmaUserFeedback"), KConfig::NoGlobals)); });
#endif #endif
......
...@@ -22,11 +22,7 @@ DiscoverPage { ...@@ -22,11 +22,7 @@ DiscoverPage {
mainItem: ListView { mainItem: ListView {
id: sourcesView id: sourcesView
model: QSortFilterProxyModel { model: SourcesModel
filterRegExp: new RegExp(page.search, 'i')
dynamicSortFilter: false //We don't want to sort, as sorting can have some semantics on some backends
sourceModel: SourcesModel
}
currentIndex: -1 currentIndex: -1
section.property: "sourceName" section.property: "sourceName"
...@@ -159,6 +155,8 @@ DiscoverPage { ...@@ -159,6 +155,8 @@ DiscoverPage {
enabled: model.display.length>0 && model.enabled enabled: model.display.length>0 && model.enabled
highlighted: ListView.isCurrentItem highlighted: ListView.isCurrentItem
supportsMouseEvents: false supportsMouseEvents: false
visible: model.display.indexOf(page.search)>=0
height: visible ? implicitHeight : 0
Keys.onReturnPressed: clicked() Keys.onReturnPressed: clicked()
actions: [ actions: [
......
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