From 209570d3b25bd272bb929412b9c25e163eb5bbf2 Mon Sep 17 00:00:00 2001 From: Marco Allegretti Date: Sat, 18 Apr 2026 19:05:04 +0200 Subject: [PATCH] Fix app list model filter ordering and reset handling ApplicationListSearchModel: beginFilterChange() was called after mutating m_categoryFilter, inverting the documented before/after contract. Also add null checks for sourceModel() and favouritesModel() in filterAcceptsRow. CategoryPanel: add onModelReset to repopulate the category list when the underlying model is fully reloaded, not just on individual row insertions and removals. --- .../homescreens/folio/applicationlistmodel.cpp | 14 +++++++++++--- .../homescreens/folio/qml/CategoryPanel.qml | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/containments/homescreens/folio/applicationlistmodel.cpp b/containments/homescreens/folio/applicationlistmodel.cpp index 130e1a1c..cb901853 100644 --- a/containments/homescreens/folio/applicationlistmodel.cpp +++ b/containments/homescreens/folio/applicationlistmodel.cpp @@ -250,9 +250,9 @@ void ApplicationListSearchModel::setCategoryFilter(const QString &filter) { if (m_categoryFilter == filter) return; + beginFilterChange(); m_categoryFilter = filter; Q_EMIT categoryFilterChanged(); - beginFilterChange(); endFilterChange(QSortFilterProxyModel::Direction::Rows); } @@ -265,13 +265,21 @@ bool ApplicationListSearchModel::filterAcceptsRow(int sourceRow, const QModelInd return true; auto *src = static_cast(sourceModel()); + if (!src) + return false; const QModelIndex idx = src->index(sourceRow, 0, sourceParent); auto *del = src->data(idx, ApplicationListModel::DelegateRole).value(); if (!del || !del->application()) return false; - if (m_categoryFilter == QLatin1String("__favorites__")) - return m_homeScreen->favouritesModel()->containsApplication(del->application()->storageId()); + if (m_categoryFilter == QLatin1String("__favorites__")) { + if (!m_homeScreen) + return false; + auto *favModel = m_homeScreen->favouritesModel(); + if (!favModel) + return false; + return favModel->containsApplication(del->application()->storageId()); + } // Match both the canonical name and any raw aliases it absorbs. const QStringList &cats = del->application()->categories(); diff --git a/containments/homescreens/folio/qml/CategoryPanel.qml b/containments/homescreens/folio/qml/CategoryPanel.qml index 49ef6418..9ae3285e 100644 --- a/containments/homescreens/folio/qml/CategoryPanel.qml +++ b/containments/homescreens/folio/qml/CategoryPanel.qml @@ -80,6 +80,7 @@ Rectangle { target: folio.ApplicationListModel function onRowsInserted() { root.populate() } function onRowsRemoved() { root.populate() } + function onModelReset() { root.populate() } } // ---------- tile list ----------