Skip to content

Commit 7a25b8a

Browse files
committed
Refactor PathView
1 parent 5d1ec04 commit 7a25b8a

File tree

2 files changed

+63
-54
lines changed

2 files changed

+63
-54
lines changed

src/qml/PathView.qml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import QtQuick
2+
import QtQuick.Controls
3+
import QtQuick.Controls.Material
4+
5+
import Backend
6+
7+
ListView {
8+
id: pathView
9+
model: PathModel
10+
visible: count
11+
spacing: 2
12+
header: Rectangle {
13+
width: parent.width
14+
height: pathView.count ? 32 : 0
15+
Behavior on height { NumberAnimation { duration: 300; easing.type: Easing.InOutSine }}
16+
visible: pathView.count
17+
color: Material.accent
18+
Text {
19+
anchors.centerIn: parent
20+
text: "Drag all " + pathView.count + " items"
21+
}
22+
DragArea {
23+
anchors.fill: parent
24+
target: parent
25+
dragUri: PathModel.foldedUriList
26+
onPreDragStarted: {
27+
PathModel.refresh_folded_paths();
28+
}
29+
onDragFinished: (dropAction) => {
30+
PathModel.taint_all_used();
31+
}
32+
}
33+
}
34+
delegate: Item {
35+
height: 64
36+
width: ListView.view.width
37+
Rectangle {
38+
id: rectangle
39+
anchors.fill: parent
40+
color: !exists ? Material.color(Material.Red) : used ? Material.primary : Material.color(Material.Grey)
41+
Behavior on color { ColorAnimation { duration: 200; easing.type: Easing.InOutSine }}
42+
Text {
43+
anchors.centerIn: parent
44+
text: path
45+
ToolTip.text: path
46+
ToolTip.visible: dragArea.containsMouse
47+
ToolTip.delay: 1500
48+
ToolTip.timeout: 2000
49+
}
50+
}
51+
DragArea {
52+
id: dragArea
53+
anchors.fill: parent
54+
target: rectangle
55+
dragUri: uri
56+
hoverEnabled: true
57+
onDragFinished: (dropAction) => {
58+
PathModel.taint_used(index)
59+
}
60+
}
61+
}
62+
}

src/qml/main.qml

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -39,61 +39,8 @@ ApplicationWindow {
3939
anchors { left: parent.left; right: parent.right; margins: 48; verticalCenter: parent.verticalCenter }
4040
visible: !pathView.count
4141
}
42-
ListView {
42+
PathView {
4343
id: pathView
4444
anchors.fill: parent
45-
model: PathModel
46-
visible: count
47-
spacing: 2
48-
header: Rectangle {
49-
width: parent.width
50-
height: pathView.count ? 32 : 0
51-
Behavior on height { NumberAnimation { duration: 300; easing.type: Easing.InOutSine }}
52-
visible: pathView.count
53-
color: Material.accent
54-
Text {
55-
anchors.centerIn: parent
56-
text: "Drag all " + pathView.count + " items"
57-
}
58-
DragArea {
59-
anchors.fill: parent
60-
target: parent
61-
dragUri: PathModel.foldedUriList
62-
onPreDragStarted: {
63-
PathModel.refresh_folded_paths();
64-
}
65-
onDragFinished: (dropAction) => {
66-
PathModel.taint_all_used();
67-
}
68-
}
69-
}
70-
delegate: Item {
71-
height: 64
72-
width: ListView.view.width
73-
Rectangle {
74-
id: rectangle
75-
anchors.fill: parent
76-
color: !exists ? Material.color(Material.Red) : used ? Material.primary : Material.color(Material.Grey)
77-
Behavior on color { ColorAnimation { duration: 200; easing.type: Easing.InOutSine }}
78-
Text {
79-
anchors.centerIn: parent
80-
text: path
81-
ToolTip.text: path
82-
ToolTip.visible: dragArea.containsMouse
83-
ToolTip.delay: 1500
84-
ToolTip.timeout: 2000
85-
}
86-
}
87-
DragArea {
88-
id: dragArea
89-
anchors.fill: parent
90-
target: rectangle
91-
dragUri: uri
92-
hoverEnabled: true
93-
onDragFinished: (dropAction) => {
94-
PathModel.taint_used(index)
95-
}
96-
}
97-
}
9845
}
9946
}

0 commit comments

Comments
 (0)