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.
This commit is contained in:
Marco Allegretti 2026-04-18 19:05:04 +02:00
parent 667efec483
commit 209570d3b2
2 changed files with 12 additions and 3 deletions

View file

@ -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<ApplicationListModel *>(sourceModel());
if (!src)
return false;
const QModelIndex idx = src->index(sourceRow, 0, sourceParent);
auto *del = src->data(idx, ApplicationListModel::DelegateRole).value<FolioDelegate *>();
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();

View file

@ -80,6 +80,7 @@ Rectangle {
target: folio.ApplicationListModel
function onRowsInserted() { root.populate() }
function onRowsRemoved() { root.populate() }
function onModelReset() { root.populate() }
}
// ---------- tile list ----------