@@ -8,52 +8,56 @@ import Controls 1.0
8
8
import "common.js" as Common
9
9
10
10
/**
11
- * ChunkListView
11
+ * NodeEditorElementsListView
12
12
*/
13
13
ColumnLayout {
14
14
id: root
15
- property variant chunks
15
+ property variant elements
16
16
property int currentIndex: 0
17
- property variant currentChunk: (chunks && currentIndex >= 0 ) ? chunks .at (currentIndex) : undefined
17
+ property bool isChunk: true
18
+ property string title: " Chunks"
18
19
19
- onChunksChanged: {
20
+ // TODO : change to currentElement
21
+ property variant currentElement: (elements && currentIndex >= 0 ) ? elements .at (currentIndex) : undefined
22
+
23
+ onElementsChanged: {
20
24
// When the list changes, ensure the current index is in the new range
21
- if (currentIndex >= chunks .count )
22
- currentIndex = chunks .count - 1
25
+ if (currentIndex >= elements .count )
26
+ currentIndex = elements .count - 1
23
27
}
24
28
25
- // chunksSummary is in sync with allChunks button (but not directly accessible as it is in a Component)
26
- property bool chunksSummary : (currentIndex === - 1 )
29
+ // elementsSummary is in sync with allElements button (but not directly accessible as it is in a Component)
30
+ property bool elementsSummary : (currentIndex === - 1 )
27
31
28
- width: 60
32
+ width: 75
29
33
30
34
ListView {
31
- id: chunksLV
35
+ id: elementsLV
32
36
Layout .fillWidth : true
33
37
Layout .fillHeight : true
34
38
35
- model: root .chunks
39
+ model: root .elements
36
40
37
- highlightFollowsCurrentItem: (root .chunksSummary === false )
41
+ highlightFollowsCurrentItem: (root .elementsSummary === false )
38
42
keyNavigationEnabled: true
39
43
focus: true
40
44
currentIndex: root .currentIndex
41
45
onCurrentIndexChanged: {
42
- if (chunksLV .currentIndex !== root .currentIndex ) {
46
+ if (elementsLV .currentIndex !== root .currentIndex ) {
43
47
// When the list is resized, the currentIndex is reset to 0.
44
48
// So here we force it to keep the binding.
45
- chunksLV .currentIndex = Qt .binding (function () { return root .currentIndex })
49
+ elementsLV .currentIndex = Qt .binding (function () { return root .currentIndex })
46
50
}
47
51
}
48
52
49
53
header: Component {
50
54
Button {
51
- id: allChunks
52
- text: " Chunks "
55
+ id: allElements
56
+ text: title
53
57
width: parent .width
54
58
flat: true
55
59
checkable: true
56
- property bool summaryEnabled: root .chunksSummary
60
+ property bool summaryEnabled: root .elementsSummary
57
61
checked: summaryEnabled
58
62
onSummaryEnabledChanged: {
59
63
checked = summaryEnabled
@@ -66,7 +70,7 @@ ColumnLayout {
66
70
}
67
71
highlight: Component {
68
72
Rectangle {
69
- visible: true // !root.chunksSummary
73
+ visible: true // !root.elementsSummary
70
74
color: activePalette .highlight
71
75
opacity: 0.3
72
76
z: 2
@@ -76,19 +80,19 @@ ColumnLayout {
76
80
highlightResizeDuration: 0
77
81
78
82
delegate: ItemDelegate {
79
- id: chunkDelegate
80
- property var chunk : object
83
+ id: elementDelegate
84
+ property var element : object
81
85
text: index
82
86
width: parent ? parent .width : 0
83
87
leftPadding: 8
84
88
onClicked: {
85
- chunksLV .forceActiveFocus ()
89
+ elementsLV .forceActiveFocus ()
86
90
root .currentIndex = index
87
91
}
88
92
Rectangle {
89
93
width: 4
90
94
height: parent .height
91
- color: Common .getChunkColor (parent .chunk )
95
+ color: isChunk ? Common .getChunkColor (parent .element ) : palette . mid
92
96
}
93
97
}
94
98
}
0 commit comments