@@ -274,17 +274,35 @@ Popup {
274274
275275 MultipageSortFilterProxyModel {
276276 id: folderProxyModel
277+ filterOnlyMode: true
277278 sourceModel: ItemArrangementProxyModel
278279 pageId: modelData
279280 folderId: folderLoader .currentFolderId
280281 }
282+
283+ SortProxyModel {
284+ id: sortProxyModel
285+ sourceModel: folderProxyModel
286+ sortRole: ItemArrangementProxyModel .IndexInPageRole
287+ Component .onCompleted : {
288+ sortProxyModel .sort (0 )
289+ }
290+ }
281291
282292 // gridViewContainer
283293 Loader {
284294 id: gridViewContainerLoader
285295 anchors .fill : parent
286-
287296 sourceComponent: isWindowedMode ? listViewGridViewContainer : fullScreenGridViewContainer
297+
298+ // Define common itemMove transition to avoid duplication
299+ property Transition itemMove: Transition {
300+ NumberAnimation {
301+ properties: " x,y"
302+ duration: 200
303+ easing .type : Easing .OutQuad
304+ }
305+ }
288306 }
289307
290308 Component {
@@ -295,13 +313,13 @@ Popup {
295313 anchors .fill : parent
296314 rows: 3
297315 columns: 4
298- model: folderProxyModel
316+ model: sortProxyModel
299317 padding: 10
300318 interactive: false
301319 focus: true
302320 gridViewClip: false // TODO it maybe a bug for dtk, https://github.com/linuxdeepin/developer-center/issues/8468
303321 activeGridViewFocusOnTab: folderGridViewLoader .SwipeView .isCurrentItem
304- itemMove: Transition { NumberAnimation { properties : " x,y " ; duration : 250 } }
322+ itemMove: parent . itemMove
305323 delegate: DelegateDropArea {
306324 width: folderGridViewContainer .cellWidth
307325 height: folderGridViewContainer .cellHeight
@@ -316,14 +334,15 @@ Popup {
316334 anchors .fill : parent
317335 rows: 3
318336 columns: 4
319- model: folderProxyModel
337+ model: sortProxyModel
320338 paddingRows: 6
321339 cellHeight: 86
322340 paddingColumns: 2
323341 interactive: false
324342 focus: true
325343 gridViewClip: false
326344 activeGridViewFocusOnTab: folderGridViewLoader .SwipeView .isCurrentItem
345+ itemMove: parent .itemMove
327346 delegate: DelegateDropArea {
328347 width: folderGridViewContainer .cellWidth
329348 height: folderGridViewContainer .cellHeight
@@ -332,7 +351,28 @@ Popup {
332351 }
333352
334353 component DelegateDropArea: DropArea {
354+ onEntered : function (drag ) {
355+ folderDragApplyTimer .dragId = drag .getDataAsString (" text/x-dde-launcher-dnd-desktopId" )
356+ folderDragApplyTimer .restart ()
357+ }
358+ onPositionChanged : function (drag ) {
359+ let dragId = drag .getDataAsString (" text/x-dde-launcher-dnd-desktopId" )
360+ if (dragId === model .desktopId ) {
361+ return
362+ }
363+ folderDragApplyTimer .dragId = dragId
364+ folderDragApplyTimer .currentDropX = drag .x
365+ if (! folderDragApplyTimer .running ) {
366+ folderDragApplyTimer .restart ()
367+ }
368+ }
369+ onExited: {
370+ folderDragApplyTimer .stop ()
371+ folderDragApplyTimer .dragId = " "
372+ }
335373 onDropped : function (drop ) {
374+ folderDragApplyTimer .stop ()
375+ folderDragApplyTimer .dragId = " "
336376 let dragId = drop .getDataAsString (" text/x-dde-launcher-dnd-desktopId" )
337377 if (dragId === model .desktopId ) {
338378 return
@@ -345,6 +385,29 @@ Popup {
345385 }
346386
347387 dropOnItem (dragId, model .desktopId , op)
388+ sortProxyModel .sort (0 )
389+ }
390+
391+ Timer {
392+ id: folderDragApplyTimer
393+ interval: 500
394+ property string dragId: " "
395+ property real currentDropX: 0
396+ onTriggered : function () {
397+ if (dragId === " " ) return
398+ let op = 0
399+ let sideOpPadding = parent .width / 4
400+ if (currentDropX < sideOpPadding) {
401+ op = - 1
402+ } else if (currentDropX > (parent .width - sideOpPadding)) {
403+ op = 1
404+ }
405+ // 只有在需要插入操作时才执行预览移动
406+ if (op !== 0 ) {
407+ dropOnItem (dragId, model .desktopId , op)
408+ sortProxyModel .sort (0 )
409+ }
410+ }
348411 }
349412 Keys .forwardTo : [innerItem]
350413
0 commit comments