/*SPDX-FileCopyrightText: 2013-2014 Eike Hein <hein@kde.org>SPDX-License-Identifier: GPL-2.0-or-later*/import QtQuickimport org.kde.kirigami as Kirigamiimport org.kde.plasma.core as PlasmaCoreimport org.kde.plasma.plasmoidimport org.kde.plasma.private.kicker as KickerKicker.SubMenu {id: itemDialogproperty alias focusParent: itemListView.focusParentproperty alias model: funnelModel.sourceModelproperty bool aboutToBeDestroyed: falseproperty alias mainSearchField: itemListView.mainSearchFieldvisible: falsehideOnWindowDeactivate: kicker.hideOnWindowDeactivatelocation: PlasmaCore.Types.Floatingoffset: Kirigami.Units.smallSpacingonWindowDeactivated: {if (!aboutToBeDestroyed) {kicker.expanded = false;}}mainItem: ItemListView {id: itemListViewheight: {const m = funnelModel.sourceModel;if (m === null || m === undefined) {// TODO: setting height to 0 triggers a warning in PlasmaQuick::Dialogreturn 0;}return Math.min(// either fit in screen boundaries (cut to the nearest item/separator boundary), ...__subFloorMultipleOf(itemDialog.availableScreenRectForItem(itemListView).height- itemDialog.margins.top- itemDialog.margins.bottom,itemHeight) + m.separatorCount * (separatorHeight - itemHeight),// ...or fit the content itself -- whichever is shorter.((m.count - m.separatorCount) * itemHeight)+ (m.separatorCount * separatorHeight));}// get x rounded down to the multiple of y, minus extra y.function __subFloorMultipleOf(x : real, y : real) : real {return (Math.floor(x / y) - 1) * y;}iconsEnabled: trueLayoutMirroring.enabled: itemDialog.LayoutMirroring.enableddialog: itemDialogmodel: funnelModelKicker.FunnelModel {id: funnelModelproperty bool sorted: sourceModel?.sorted ?? falseComponent.onCompleted: {kicker.reset.connect(funnelModel.reset);}onCountChanged: {if (sourceModel && count === 0) {itemDialog.delayedDestroy();}}onSourceModelChanged: {itemListView.currentIndex = -1;}}}function delayedDestroy() {aboutToBeDestroyed = true;Plasmoid.hideOnWindowDeactivate = false;Qt.callLater(() => itemDialog.destroy());}}