Warning, /plasma/kdeplasma-addons/applets/dict/package/contents/ui/DictItemDelegate.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2020 Ismael Asensio <isma.af@gmail.com>
0003     SPDX-FileCopyrightText: 2022 Fushan Wen <qydwhotmail@gmail.com>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 import QtQuick 2.15
0009 import QtQuick.Controls 2.15 as QQC2
0010 import QtQuick.Layouts 1.15
0011 
0012 import org.kde.kirigami 2.20 as Kirigami
0013 import org.kde.kirigami.delegates as KD
0014 
0015 // External item required to make Kirigami.ListItemDragHandle work
0016 Item {
0017     id: delegate
0018 
0019     property ListView view
0020 
0021     implicitHeight : dictItem.implicitHeight
0022 
0023     signal removed(int index)
0024     signal moveRequested(int oldIndex, int newIndex)
0025 
0026     Kirigami.SwipeListItem {
0027         id: dictItem
0028 
0029         // Don't need highlight, hover, or pressed effects
0030         highlighted: false
0031         hoverEnabled: false
0032         down: false
0033 
0034         text: model.id
0035         Accessible.description: model.description
0036 
0037         contentItem: RowLayout {
0038             Kirigami.ListItemDragHandle {
0039                 listItem: dictItem
0040                 listView: delegate.view
0041                 onMoveRequested: (oldIndex, newIndex) => {
0042                     delegate.moveRequested(oldIndex, newIndex);
0043                 }
0044             }
0045 
0046             KD.TitleSubtitle {
0047                 Layout.fillWidth: true
0048 
0049                 selected: dictItem.highlighted
0050 
0051                 title: dictItem.text
0052                 subtitle: dictItem.Accessible.description
0053             }
0054         }
0055 
0056         actions: [
0057             Kirigami.Action {
0058                 text: i18n("Delete")
0059                 icon.name: "entry-delete"
0060                 onTriggered: {
0061                     delegate.removed(index);
0062                 }
0063             }
0064         ]
0065     }
0066 }