mirror-kde-plasma-desktop/kcms/keyboard/ui/KeyboardVariantsModel.qml
Sebastian Kügler af90e58865 keyboard kcm: return value in function signature
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>
2025-10-30 09:35:21 +01:00

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;
}
}