@@ -11,31 +11,90 @@ ListView {
1111
1212 property var targetNode: null
1313
14+ // Pre/Post process chunk objects (single items)
15+ property var preprocessChunk: null
16+ property var postprocessChunk: null
17+
1418 property color defaultColor: Qt .darker (activePalette .window , 1.1 )
1519 property real chunkHeight: height
1620 property int modelSize: model ? model .count : 0
17- property bool modelIsBig: (3 * modelSize >= width)
21+
22+ // Account for header/footer in width calculations
23+ property bool hasHeader: preprocessChunk !== null
24+ property bool hasFooter: postprocessChunk !== null
25+ property int totalChunks: modelSize + (hasHeader ? 1 : 0 ) + (hasFooter ? 1 : 0 )
26+
27+ property bool modelIsBig: (3 * totalChunks >= width)
1828 property real chunkWidth: {
19- if (modelSize == 0 ) return 0
20- return (width / modelSize ) - spacing
29+ if (totalChunks == 0 ) return 0
30+ return (width / totalChunks ) - spacing
2131 }
2232
2333 orientation: ListView .Horizontal
2434
2535 // If we have enough space, add one pixel margin between chunks
2636 spacing: modelIsBig ? 0 : 1
37+
38+ // Header: Preprocess chunk
39+ header: Loader {
40+ active: root .hasHeader
41+ visible: active
42+
43+ sourceComponent: Rectangle {
44+ height: root .chunkHeight
45+ width: root .chunkWidth
46+
47+ property var chunkColor: Colors .getChunkColor (root .preprocessChunk , { " NONE" : root .defaultColor })
48+ color: {
49+ if (! root .highlightChunks || root .totalChunks == 1 )
50+ return chunkColor
51+ // Index 0 for header
52+ return Qt .lighter (chunkColor, 1.1 )
53+ }
54+ }
55+ }
56+
57+ // Main delegate for chunks list
2758 delegate: Rectangle {
2859 id: chunkDelegate
2960 height: root .chunkHeight
3061 width: root .chunkWidth
62+
3163 property var chunkColor: Colors .getChunkColor (object, { " NONE" : root .defaultColor })
3264 color: {
33- if (! highlightChunks || modelSize == 1 )
65+ if (! root . highlightChunks || root . totalChunks == 1 )
3466 return chunkColor
35- if (index % 2 == 0 )
67+
68+ // Offset index by 1 if we have a header for alternating colors
69+ var effectiveIndex = root .hasHeader ? index + 1 : index
70+ if (effectiveIndex % 2 == 0 )
3671 return Qt .lighter (chunkColor, 1.1 )
3772 else
3873 return Qt .darker (chunkColor, 1.1 )
3974 }
4075 }
41- }
76+
77+ // Footer: Postprocess chunk
78+ footer: Loader {
79+ active: root .hasFooter
80+ visible: active
81+
82+ sourceComponent: Rectangle {
83+ height: root .chunkHeight
84+ width: root .chunkWidth
85+
86+ property var chunkColor: Colors .getChunkColor (root .postprocessChunk , { " NONE" : root .defaultColor })
87+ color: {
88+ if (! root .highlightChunks || root .totalChunks == 1 )
89+ return chunkColor
90+
91+ // Calculate effective index for alternating colors
92+ var effectiveIndex = root .modelSize + (root .hasHeader ? 1 : 0 )
93+ if (effectiveIndex % 2 == 0 )
94+ return Qt .lighter (chunkColor, 1.1 )
95+ else
96+ return Qt .darker (chunkColor, 1.1 )
97+ }
98+ }
99+ }
100+ }
0 commit comments