mirror of
https://invent.kde.org/plasma/plasma-desktop.git
synced 2026-11-03 22:59:45 -09:00
Suggested by Luis Büchi, making this a separate commit to keep the refactoring of those files clean commits. Signed-off-by: Sebastian Kügler <sebas@kde.org>
37 lines
1,015 B
QML
37 lines
1,015 B
QML
/*
|
|
SPDX-FileCopyrightText: 2024 Evgeny Chesnokov <echesnokov@astralinux.ru>
|
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
*/
|
|
|
|
import QtQuick
|
|
|
|
import org.kde.kitemmodels as KItemModels
|
|
|
|
KItemModels.KSortFilterProxyModel {
|
|
id: variantProxy
|
|
sourceModel: layoutSearchProxy
|
|
sortRoleName: "searchScore"
|
|
sortOrder: Qt.DescendingOrder
|
|
|
|
filterRowCallback: function (row, parent): bool {
|
|
if (!layoutsView.currentItem) {
|
|
return false;
|
|
}
|
|
|
|
const modelIndex = sourceModel.index(row, 0, parent);
|
|
const currentName = sourceModel.data(modelIndex, KItemModels.KRoleNames.role("shortName"));
|
|
const selectedName = layoutsView.currentItem.shortName;
|
|
|
|
if (currentName !== selectedName) {
|
|
return false;
|
|
}
|
|
|
|
if (searchField.text.length > 0) {
|
|
const searchScore = sourceModel.data(modelIndex, KItemModels.KRoleNames.role("searchScore"));
|
|
return searchScore > 100;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|