/*SPDX-FileCopyrightText: 2013-2015 Eike Hein <hein@kde.org>SPDX-License-Identifier: GPL-2.0-or-later*/import QtQuickimport QtQuick.Layoutsimport org.kde.kirigami as Kirigamiimport org.kde.ksvg as KSvgimport org.kde.plasma.components as PlasmaComponents3ItemAbstractDelegate {id: itemrequired property bool showIconsreadonly property bool iconAndLabelsShouldlookSelected: pressed && !hasChildrenwidth: ListView.view.widthheight: isSeparator && !showSeparators ? 0 : implicitHeight// if it's not disabled and is either a leaf node or a node with childrenenabled: !isSeparator && !disabled && (!isParent || (isParent && hasChildren))favoritesModel: ListView.view.model.favoritesModelbaseModel: ListView.view.modelAccessible.role: isSeparator ? Accessible.Separator : Accessible.ListItemAccessible.description: isParent? i18nc("@action:inmenu accessible description for opening submenu", "Open category"): i18nc("@action:inmenu accessible description for opening app or file", "Launch")onHasChildrenChanged: {if (!hasChildren && ListView.view.currentItem === item) {ListView.view.currentIndex = -1;}}onClicked: {if (!item.hasChildren && !dragHandler.active) {item.baseModel.trigger(index, "", null);item.interactionConcluded()}}Keys.onReturnPressed: event => {if (!item.hasChildren) {item.clicked()} else {event.accepted = false}}Keys.onEnterPressed: event => item.Keys.returnPressed(event)contentItem: RowLayout {id: rowspacing: Kirigami.Units.smallSpacing * 2LayoutMirroring.enabled: (Application.layoutDirection === Qt.RightToLeft)Kirigami.Icon {id: iconLayout.alignment: Qt.AlignVCenterimplicitWidth: Kirigami.Units.iconSizes.smallimplicitHeight: implicitWidthvisible: item.showIcons & !item.isSeparatoranimated: falseselected: item.iconAndLabelsShouldlookSelectedsource: item.icon.name}PlasmaComponents3.Label {id: labelenabled: !item.isParent || (item.isParent && item.hasChildren)LayoutMirroring.enabled: (Application.layoutDirection === Qt.RightToLeft)visible: !item.isSeparatorLayout.fillWidth: trueLayout.alignment: Qt.AlignVCenterverticalAlignment: Text.AlignVCentertextFormat: Text.PlainTextwrapMode: Text.NoWrapelide: Text.ElideRightcolor: item.iconAndLabelsShouldlookSelected ? Kirigami.Theme.highlightedTextColor : Kirigami.Theme.textColortext: item.model.display ?? ""}Kirigami.Icon {id: arrowLayout.alignment: Qt.AlignVCenterimplicitWidth: visible ? Kirigami.Units.iconSizes.small : 0implicitHeight: implicitWidthvisible: item.hasChildren && !item.isSeparatoropacity: (item.ListView.view.currentIndex === item.index) ? 1.0 : 0.4selected: item.iconAndLabelsShouldlookSelectedsource: item.dialogDefaultRight? "go-next-symbolic": "go-next-rtl-symbolic"}Loader {id: separatorLoaderLayout.alignment: Qt.AlignVCenterLayout.fillWidth: true// Separator positions don't make sense when sorting everything alphabeticallyactive: item.isSeparator && item.showSeparatorsvisible: activeasynchronous: falsesourceComponent: separatorComponent}}DragHandler {id: dragHandlertarget: nullonActiveChanged: {if (active && item.url) {// we need dragHelper and can't use attached Drag; submenus are destroyed too soon and Plasma crashesdragHelper.startDrag(kicker, item.url, item.decoration)}}}Component {id: separatorComponentKSvg.SvgItem {width: parent.widthimagePath: "widgets/line"elementId: "horizontal-line"}}}