-
Notifications
You must be signed in to change notification settings - Fork 0
/
DraggableVideoItem.qml
67 lines (56 loc) · 1.67 KB
/
DraggableVideoItem.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import QtQuick 2.0
MouseArea {
property int itemHeight: 120
property int itemMargin: 12
id: mouseArea
height: itemHeight
function strFillWidth(s, width, fillChar) {
return (new Array( (width + 1) - ("%1".arg(s).length))).join(fillChar) + "%1".arg(s);
}
function secondsToTimeStr(s) {
return "%1:%2".arg(Math.floor(s/60)).arg(strFillWidth(Math.round(s%60), 2, '0'))
}
//drag.axis: Drag.YAxis
//drag.target: parent
drag.target: li
//hoverEnabled: true
//onHoveredChanged: {
// myView.currentIndex = index
//}
DropArea {
anchors.fill: parent
onEntered: {
console.log(drag.source);
console.log("from " + drag.source.visualIndex + " to " + index);
if( drag.source.visualIndex !== index)
myView.model.move(drag.source.visualIndex, index);
//drag.source.parent = parent;
}
onDropped: {
drag.source.parent = mouseArea.parent
}
}
VideoItem {
anchors.fill: parent
id: li
states: [
State {
when: li.Drag.active
ParentChange { target: li; parent: mouseArea.parent }
//AnchorChanges {
// target: li
//anchors.horizontalCenter: undefined
//anchors.verticalCenter: undefined
// }
}
]
Drag.active: mouseArea.drag.active
Drag.hotSpot.x: itemHeight / 2
Drag.hotSpot.y: 34
Drag.onDragStarted: console.log("Dragging")
}
}
/*##^## Designer {
D{i:0;autoSize:true;height:200;width:640}
}
##^##*/