7import QtQuick.Controls as QQC2
10import org.kde.kirigami as Kirigami
12import org.kde.kirigamiaddons.tableview as Tables
17 Accessible.role: Accessible.ColumnHeader
18 padding: Kirigami.Units.smallSpacing
20 z: Drag.active ? 2 : 0
21 Drag.active: dragHandler.active && delegate.headerComponent.draggable
22 Drag.hotSpot.x: width / 2
23 Drag.hotSpot.y: height / 2
25 required property int index
26 required property var headerComponent
28 property bool sortEnabled
29 property int sortOrder
32 signal doubleClicked()
34 background: Rectangle {
35 readonly property bool containsDrag: delegate.enabled &&
36 delegate.headerComponent.draggable &&
37 dropArea.containsDrag &&
38 dropArea.drag.source.index !== delegate.index
40 border.color: containsDrag ? Kirigami.Theme.highlightColor : "Transparent"
42 if (!delegate.enabled) {
46 if (delegate.hovered && !
Kirigami.Settings.isMobile) {
47 return Qt.alpha(
Kirigami.Theme.hoverColor, 0.3)
50 return Kirigami.Theme.backgroundColor
55 anchors.right: parent.right
56 visible: !parent.containsDrag && !delegate.Drag.active
61 anchors.bottom: parent.bottom
62 visible: !parent.containsDrag && !delegate.Drag.active
66 contentItem: DropArea {
70 onTapped: delegate.clicked()
71 onDoubleTapped: delegate.doubleClicked()
77 enabled: delegate.headerComponent.draggable
79 cursorShape:
Qt.DragMoveCursor
82 property real startX: -1
97 spacing: delegate.spacing
101 Layout.alignment:
Qt.AlignVCenter
102 visible: delegate.headerComponent.leading
103 sourceComponent: delegate.headerComponent.leading
108 Layout.alignment:
Qt.AlignVCenter
109 Layout.fillWidth:
true
110 sourceComponent: delegate.headerComponent.headerDelegate
111 readonly
property string modelData: delegate.headerComponent.title
112 readonly
property int index: delegate.index
116 id: sortIndicatorLoader
117 Layout.alignment:
Qt.AlignVCenter
118 visible: delegate.sortEnabled
119 sourceComponent: delegate.sortEnabled ? delegate.sortIndicator : null
123 onDropped: function(drop) {
124 const currentItemIndex = delegate.index
125 const dropItemIndex =
drop.source.index
127 if (!delegate.headerComponent.draggable)
130 if (currentItemIndex === -1 || dropItemIndex === -1)
133 if (currentItemIndex === dropItemIndex)
136 __columnModel.move(dropItemIndex, currentItemIndex, 1)
140 property Component sortIndicator:
Kirigami.Icon {
143 source:
"arrow-up-symbolic"
145 implicitWidth:
Kirigami.Units.iconSizes.small
146 implicitHeight:
Kirigami.Units.iconSizes.small
149 when: delegate.sortEnabled && delegate.sortOrder ===
Qt.DescendingOrder
150 PropertyChanges { target: sortIndicator; rotation: 180 }
153 transitions: Transition {
155 duration:
Kirigami.Units.longDuration
156 direction: RotationAnimation.Counterclockwise
KIOWIDGETS_EXPORT DropJob * drop(const QDropEvent *dropEvent, const QUrl &destUrl, DropJobFlags dropjobFlags, JobFlags flags=DefaultFlags)