8import org.kde.kirigami as Kirigami
83 property Item listItem
88 property ListView listView
102 signal moveRequested(int oldIndex, int newIndex)
110 implicitWidth: Kirigami.Units.iconSizes.smallMedium
111 implicitHeight: Kirigami.Units.iconSizes.smallMedium
124 cursorShape: pressed ? Qt.ClosedHandCursor : Qt.OpenHandCursor
125 preventStealing: true
132 source: "handle-sort"
133 opacity: mouseArea.pressed || (!Kirigami.Settings.tabletMode && listItem.hovered) ? 1 : 0.6
136 property int mouseDownY
137 property Item originalParent
138 property int listItemLastY
139 property bool draggingUp
141 function arrangeItem() {
142 const newIndex = listView.indexAt(1, listView.contentItem.mapFromItem(mouseArea, 0, internal.mouseDownY).y);
144 if (newIndex > -1 && ((internal.draggingUp && newIndex < index) || (!internal.draggingUp && newIndex > index))) {
145 root.moveRequested(index, newIndex);
150 onPressed: mouse => {
151 internal.originalParent = listItem.parent;
152 listItem.parent = listView;
153 listItem.y = internal.originalParent.mapToItem(listItem.parent, listItem.x, listItem.y).y;
154 internal.originalParent.z = 99;
155 internal.startY = listItem.y;
156 internal.listItemLastY = listItem.y;
157 internal.mouseDownY = mouse.y;
160 mouseArea.drag.maximumY = listView.height - listItem.height;
163 onPositionChanged: mouse => {
164 if (!pressed || listItem.y === internal.listItemLastY) {
168 internal.draggingUp = listItem.y < internal.listItemLastY
169 internal.listItemLastY = listItem.y;
171 internal.arrangeItem();
174 scrollTimer.running = (listView.contentHeight > listView.height)
175 && ((listItem.y === 0 && !listView.atYBeginning)
176 || (listItem.y === mouseArea.drag.maximumY && !listView.atYEnd));
179 onReleased: mouse => dropped()
180 onCanceled: dropped()
183 listItem.y = internal.originalParent.mapFromItem(listItem, 0, 0).y;
184 listItem.parent = internal.originalParent;
185 dropAnimation.running =
true;
186 scrollTimer.running =
false;
190 SequentialAnimation {
196 duration: Kirigami.Units.longDuration
197 easing.type: Easing.InOutQuad
200 target: listItem.parent
213 if (internal.draggingUp) {
214 listView.contentY -= Kirigami.Units.gridUnit;
215 if (listView.atYBeginning) {
216 listView.positionViewAtBeginning();
220 listView.contentY += Kirigami.Units.gridUnit;
221 if (listView.atYEnd) {
222 listView.positionViewAtEnd();
226 internal.arrangeItem();
void stop(Ekos::AlignState mode)
QAction * repeat(const QObject *recvr, const char *slot, QObject *parent)