@@ -8,52 +8,56 @@ import Controls 1.0
88import "common.js" as Common
99
1010/**
11- * ChunkListView
11+ * NodeEditorElementsListView
1212 */
1313ColumnLayout {
1414 id: root
15- property variant chunks
15+ property variant elements
1616 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"
1819
19- onChunksChanged: {
20+ // TODO : change to currentElement
21+ property variant currentElement: (elements && currentIndex >= 0 ) ? elements .at (currentIndex) : undefined
22+
23+ onElementsChanged: {
2024 // 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
2327 }
2428
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 )
2731
28- width: 60
32+ width: 75
2933
3034 ListView {
31- id: chunksLV
35+ id: elementsLV
3236 Layout .fillWidth : true
3337 Layout .fillHeight : true
3438
35- model: root .chunks
39+ model: root .elements
3640
37- highlightFollowsCurrentItem: (root .chunksSummary === false )
41+ highlightFollowsCurrentItem: (root .elementsSummary === false )
3842 keyNavigationEnabled: true
3943 focus: true
4044 currentIndex: root .currentIndex
4145 onCurrentIndexChanged: {
42- if (chunksLV .currentIndex !== root .currentIndex ) {
46+ if (elementsLV .currentIndex !== root .currentIndex ) {
4347 // When the list is resized, the currentIndex is reset to 0.
4448 // 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 })
4650 }
4751 }
4852
4953 header: Component {
5054 Button {
51- id: allChunks
52- text: " Chunks "
55+ id: allElements
56+ text: title
5357 width: parent .width
5458 flat: true
5559 checkable: true
56- property bool summaryEnabled: root .chunksSummary
60+ property bool summaryEnabled: root .elementsSummary
5761 checked: summaryEnabled
5862 onSummaryEnabledChanged: {
5963 checked = summaryEnabled
@@ -66,7 +70,7 @@ ColumnLayout {
6670 }
6771 highlight: Component {
6872 Rectangle {
69- visible: true // !root.chunksSummary
73+ visible: true // !root.elementsSummary
7074 color: activePalette .highlight
7175 opacity: 0.3
7276 z: 2
@@ -76,19 +80,19 @@ ColumnLayout {
7680 highlightResizeDuration: 0
7781
7882 delegate: ItemDelegate {
79- id: chunkDelegate
80- property var chunk : object
83+ id: elementDelegate
84+ property var element : object
8185 text: index
8286 width: parent ? parent .width : 0
8387 leftPadding: 8
8488 onClicked: {
85- chunksLV .forceActiveFocus ()
89+ elementsLV .forceActiveFocus ()
8690 root .currentIndex = index
8791 }
8892 Rectangle {
8993 width: 4
9094 height: parent .height
91- color: Common .getChunkColor (parent .chunk )
95+ color: isChunk ? Common .getChunkColor (parent .element ) : palette . mid
9296 }
9397 }
9498 }
0 commit comments