|
|
|
|
@ -21,6 +21,7 @@ import QtQuick.Controls 2.12
|
|
|
|
|
import QtQuick.Layouts 1.12
|
|
|
|
|
|
|
|
|
|
import Cutefish.FileManager 1.0
|
|
|
|
|
import Cutefish.DragDrop 1.0 as DragDrop
|
|
|
|
|
import FishUI 1.0 as FishUI
|
|
|
|
|
|
|
|
|
|
GridView {
|
|
|
|
|
@ -147,6 +148,38 @@ GridView {
|
|
|
|
|
cPress = null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function drop(target, event, pos) {
|
|
|
|
|
var dropPos = mapToItem(control.contentItem, pos.x, pos.y)
|
|
|
|
|
var dropIndex = control.indexAt(dropPos.x, dropPos.y)
|
|
|
|
|
var dragPos = mapToItem(control.contentItem, control.dragX, control.dragY)
|
|
|
|
|
var dragIndex = control.indexAt(dragPos.x, dragPos.y)
|
|
|
|
|
|
|
|
|
|
if (control.dragX === -1 || dragIndex !== dropIndex) {
|
|
|
|
|
dirModel.drop(control, event, dropItemAt(dropPos))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function dropItemAt(pos) {
|
|
|
|
|
var item = control.itemAt(pos.x, pos.y)
|
|
|
|
|
|
|
|
|
|
if (item) {
|
|
|
|
|
if (item.blank) {
|
|
|
|
|
return -1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var hOffset = Math.abs(Math.min(control.contentX, control.originX))
|
|
|
|
|
var hPos = mapToItem(item, pos.x + hOffset, pos.y)
|
|
|
|
|
|
|
|
|
|
if ((hPos.x < 0 || hPos.y < 0 || hPos.x > item.width || hPos.y > item.height)) {
|
|
|
|
|
return -1
|
|
|
|
|
} else {
|
|
|
|
|
return positioner.map(item.index)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return -1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
highlightMoveDuration: 0
|
|
|
|
|
keyNavigationEnabled : true
|
|
|
|
|
keyNavigationWraps : true
|
|
|
|
|
@ -205,7 +238,7 @@ GridView {
|
|
|
|
|
var newIndex = positioner.nearestItem(currentIndex,
|
|
|
|
|
effectiveNavDirection(control.flow, control.effectiveLayoutDirection, Qt.LeftArrow))
|
|
|
|
|
if (newIndex !== -1) {
|
|
|
|
|
currentIndex = newIndex;
|
|
|
|
|
currentIndex = newIndex
|
|
|
|
|
updateSelection(event.modifiers)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -215,7 +248,7 @@ GridView {
|
|
|
|
|
var newIndex = positioner.nearestItem(currentIndex,
|
|
|
|
|
effectiveNavDirection(control.flow, control.effectiveLayoutDirection, Qt.RightArrow))
|
|
|
|
|
if (newIndex !== -1) {
|
|
|
|
|
currentIndex = newIndex;
|
|
|
|
|
currentIndex = newIndex
|
|
|
|
|
updateSelection(event.modifiers)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -276,22 +309,14 @@ GridView {
|
|
|
|
|
folderModel: dirModel
|
|
|
|
|
perStripe: Math.floor(((control.flow == GridView.FlowLeftToRight)
|
|
|
|
|
? control.width : control.height) / ((control.flow == GridView.FlowLeftToRight)
|
|
|
|
|
? control.cellWidth : control.cellHeight));
|
|
|
|
|
? control.cellWidth : control.cellHeight))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DropArea {
|
|
|
|
|
id: _dropArea
|
|
|
|
|
DragDrop.DropArea {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
|
|
onDropped: {
|
|
|
|
|
var dropPos = mapToItem(control.contentItem, drop.x, drop.y)
|
|
|
|
|
var dropIndex = control.indexAt(drop.x, drop.y)
|
|
|
|
|
var dragPos = mapToItem(control.contentItem, control.dragX, control.dragY)
|
|
|
|
|
var dragIndex = control.indexAt(dragPos.x, dragPos.y)
|
|
|
|
|
|
|
|
|
|
if (control.dragX == -1 || dragIndex !== dropIndex) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
onDrop: {
|
|
|
|
|
control.drop(control, event, mapToItem(control, event.x, event.y))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -429,7 +454,7 @@ GridView {
|
|
|
|
|
clearPressState()
|
|
|
|
|
} else {
|
|
|
|
|
if (control.editor && control.editor.targetItem)
|
|
|
|
|
return;
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
dirModel.pinSelection()
|
|
|
|
|
control.rubberBand = rubberBandObject.createObject(control.contentItem, {x: cPress.x, y: cPress.y})
|
|
|
|
|
|