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 Kirigami.Theme.colorSet: Kirigami.Theme.Header
36 Kirigami.Theme.inherit: false
38 readonly property bool containsDrag: delegate.enabled &&
39 delegate.headerComponent.draggable &&
40 dropArea.containsDrag &&
41 dropArea.drag.source.index !== delegate.index
43 border.color: containsDrag ? Kirigami.Theme.highlightColor : "Transparent"
45 if (!delegate.enabled) {
49 if (delegate.hovered && !
Kirigami.Settings.isMobile) {
50 return Qt.alpha(
Kirigami.Theme.hoverColor, 0.3)
53 return Kirigami.Theme.backgroundColor
58 anchors.right: parent.right
59 visible: !parent.containsDrag && !delegate.Drag.active
64 anchors.bottom: parent.bottom
65 visible: !parent.containsDrag && !delegate.Drag.active
69 contentItem: DropArea {
73 onTapped: delegate.clicked()
74 onDoubleTapped: delegate.doubleClicked()
80 enabled: delegate.headerComponent.draggable
82 cursorShape:
Qt.DragMoveCursor
85 property real startX: -1
100 spacing: delegate.spacing
104 Layout.alignment:
Qt.AlignVCenter
105 visible: delegate.headerComponent.leading
106 sourceComponent: delegate.headerComponent.leading
111 Layout.alignment:
Qt.AlignVCenter
112 Layout.fillWidth:
true
113 sourceComponent: delegate.headerComponent.headerDelegate
114 readonly
property string modelData: delegate.headerComponent.title
115 readonly
property int index: delegate.index
119 id: sortIndicatorLoader
120 Layout.alignment:
Qt.AlignVCenter
121 visible: delegate.sortEnabled
122 sourceComponent: delegate.sortEnabled ? delegate.sortIndicator : null
126 onDropped: function(drop) {
127 const currentItemIndex = delegate.index
128 const dropItemIndex =
drop.source.index
130 if (!delegate.headerComponent.draggable)
133 if (currentItemIndex === -1 || dropItemIndex === -1)
136 if (currentItemIndex === dropItemIndex)
139 __columnModel.move(dropItemIndex, currentItemIndex, 1)
143 property Component sortIndicator:
Kirigami.Icon {
146 source:
"arrow-up-symbolic"
148 implicitWidth:
Kirigami.Units.iconSizes.small
149 implicitHeight:
Kirigami.Units.iconSizes.small
152 when: delegate.sortEnabled && delegate.sortOrder ===
Qt.DescendingOrder
153 PropertyChanges { target: sortIndicator; rotation: 180 }
156 transitions: Transition {
158 duration:
Kirigami.Units.longDuration
159 direction: RotationAnimation.Counterclockwise
KIOWIDGETS_EXPORT DropJob * drop(const QDropEvent *dropEvent, const QUrl &destUrl, DropJobFlags dropjobFlags, JobFlags flags=DefaultFlags)