@@ -274,10 +274,20 @@ 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 {
@@ -295,13 +305,19 @@ Popup {
295305 anchors .fill : parent
296306 rows: 3
297307 columns: 4
298- model: folderProxyModel
308+ model: sortProxyModel
299309 padding: 10
300310 interactive: false
301311 focus: true
302312 gridViewClip: false // TODO it maybe a bug for dtk, https://github.com/linuxdeepin/developer-center/issues/8468
303313 activeGridViewFocusOnTab: folderGridViewLoader .SwipeView .isCurrentItem
304- itemMove: Transition { NumberAnimation { properties: " x,y" ; duration: 250 } }
314+ itemMove: Transition {
315+ NumberAnimation {
316+ properties: " x,y"
317+ duration: 200
318+ easing .type : Easing .OutQuad
319+ }
320+ }
305321 delegate: DelegateDropArea {
306322 width: folderGridViewContainer .cellWidth
307323 height: folderGridViewContainer .cellHeight
@@ -316,14 +332,21 @@ Popup {
316332 anchors .fill : parent
317333 rows: 3
318334 columns: 4
319- model: folderProxyModel
335+ model: sortProxyModel
320336 paddingRows: 6
321337 cellHeight: 86
322338 paddingColumns: 2
323339 interactive: false
324340 focus: true
325341 gridViewClip: false
326342 activeGridViewFocusOnTab: folderGridViewLoader .SwipeView .isCurrentItem
343+ itemMove: Transition {
344+ NumberAnimation {
345+ properties: " x,y"
346+ duration: 200
347+ easing .type : Easing .OutQuad
348+ }
349+ }
327350 delegate: DelegateDropArea {
328351 width: folderGridViewContainer .cellWidth
329352 height: folderGridViewContainer .cellHeight
@@ -332,7 +355,28 @@ Popup {
332355 }
333356
334357 component DelegateDropArea: DropArea {
358+ onEntered : function (drag ) {
359+ folderDragApplyTimer .dragId = drag .getDataAsString (" text/x-dde-launcher-dnd-desktopId" )
360+ folderDragApplyTimer .restart ()
361+ }
362+ onPositionChanged : function (drag ) {
363+ let dragId = drag .getDataAsString (" text/x-dde-launcher-dnd-desktopId" )
364+ if (dragId === model .desktopId ) {
365+ return
366+ }
367+ folderDragApplyTimer .dragId = dragId
368+ folderDragApplyTimer .currentDropX = drag .x
369+ if (! folderDragApplyTimer .running ) {
370+ folderDragApplyTimer .restart ()
371+ }
372+ }
373+ onExited: {
374+ folderDragApplyTimer .stop ()
375+ folderDragApplyTimer .dragId = " "
376+ }
335377 onDropped : function (drop ) {
378+ folderDragApplyTimer .stop ()
379+ folderDragApplyTimer .dragId = " "
336380 let dragId = drop .getDataAsString (" text/x-dde-launcher-dnd-desktopId" )
337381 if (dragId === model .desktopId ) {
338382 return
@@ -345,6 +389,29 @@ Popup {
345389 }
346390
347391 dropOnItem (dragId, model .desktopId , op)
392+ sortProxyModel .sort (0 )
393+ }
394+
395+ Timer {
396+ id: folderDragApplyTimer
397+ interval: 500
398+ property string dragId: " "
399+ property real currentDropX: 0
400+ onTriggered : function () {
401+ if (dragId === " " ) return
402+ let op = 0
403+ let sideOpPadding = parent .width / 4
404+ if (currentDropX < sideOpPadding) {
405+ op = - 1
406+ } else if (currentDropX > (parent .width - sideOpPadding)) {
407+ op = 1
408+ }
409+ // 只有在需要插入操作时才执行预览移动
410+ if (op !== 0 ) {
411+ dropOnItem (dragId, model .desktopId , op)
412+ sortProxyModel .sort (0 )
413+ }
414+ }
348415 }
349416 Keys .forwardTo : [innerItem]
350417
0 commit comments