mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
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:
parent
667efec483
commit
209570d3b2
2 changed files with 12 additions and 3 deletions
|
|
@ -250,9 +250,9 @@ void ApplicationListSearchModel::setCategoryFilter(const QString &filter)
|
||||||
{
|
{
|
||||||
if (m_categoryFilter == filter)
|
if (m_categoryFilter == filter)
|
||||||
return;
|
return;
|
||||||
|
beginFilterChange();
|
||||||
m_categoryFilter = filter;
|
m_categoryFilter = filter;
|
||||||
Q_EMIT categoryFilterChanged();
|
Q_EMIT categoryFilterChanged();
|
||||||
beginFilterChange();
|
|
||||||
endFilterChange(QSortFilterProxyModel::Direction::Rows);
|
endFilterChange(QSortFilterProxyModel::Direction::Rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -265,13 +265,21 @@ bool ApplicationListSearchModel::filterAcceptsRow(int sourceRow, const QModelInd
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
auto *src = static_cast<ApplicationListModel *>(sourceModel());
|
auto *src = static_cast<ApplicationListModel *>(sourceModel());
|
||||||
|
if (!src)
|
||||||
|
return false;
|
||||||
const QModelIndex idx = src->index(sourceRow, 0, sourceParent);
|
const QModelIndex idx = src->index(sourceRow, 0, sourceParent);
|
||||||
auto *del = src->data(idx, ApplicationListModel::DelegateRole).value<FolioDelegate *>();
|
auto *del = src->data(idx, ApplicationListModel::DelegateRole).value<FolioDelegate *>();
|
||||||
if (!del || !del->application())
|
if (!del || !del->application())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (m_categoryFilter == QLatin1String("__favorites__"))
|
if (m_categoryFilter == QLatin1String("__favorites__")) {
|
||||||
return m_homeScreen->favouritesModel()->containsApplication(del->application()->storageId());
|
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.
|
// Match both the canonical name and any raw aliases it absorbs.
|
||||||
const QStringList &cats = del->application()->categories();
|
const QStringList &cats = del->application()->categories();
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,7 @@ Rectangle {
|
||||||
target: folio.ApplicationListModel
|
target: folio.ApplicationListModel
|
||||||
function onRowsInserted() { root.populate() }
|
function onRowsInserted() { root.populate() }
|
||||||
function onRowsRemoved() { root.populate() }
|
function onRowsRemoved() { root.populate() }
|
||||||
|
function onModelReset() { root.populate() }
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------- tile list ----------
|
// ---------- tile list ----------
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue