blob: 8e8344f2a1f677af1afc1217137d02a94e187e2c (
plain)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
|
// Copyright (C) 2025 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
pragma ComponentBehavior: Bound
import QtQuick
import QtQuick.Controls
import QtQuick.Controls.Basic
import qtgraphscsv
Item {
id: tableviewItem
property alias horizontalHeaderview: hHeaderView
property alias verticalalHeaderview: vHeaderView
property alias mainTableView: tv
property alias tableViewModel: tv.model
property alias horizontalHeaderViewModel: hHeaderView.model
property alias title: titleLabel.text
property alias dataSelectionModel: tv.dataSelectionModel
property color borderColor
property color primaryTextColor
property color secondaryTextColor
property color selectionColor: "#E3E3E3"
property color backgroundColor: "#FCFCFC"
property color scrollbarBackgroundColor: "#BEBEBE"
readonly property font titleFont: ({
family: "Inter",
weight: 700 * Units.px,
pixelSize: 16 * Units.px,
letterSpacing: 0 * Units.px,
bold: false
})
function extractBarSetGategories(first, count) {
var categories = [];
const last = first + count;
for (var i = first; i < last; ++i)
categories.push(tv.model.headerData(i, Qt.Horizontal, Qt.DisplayRole) + " medals");
return categories;
}
function fillHorizontalHeaderModel(rowLength) {
hHeaderView.model.clear();
for (var i = 0; i < rowLength; ++i) {
var h = tv.model.headerData(i, Qt.Horizontal, Qt.DisplayRole);
hHeaderView.model.append({
"display": h
});
}
}
Text {
id: titleLabel
text: ""
font: tableviewItem.titleFont
color: tableviewItem.primaryTextColor
width: 132 * Units.px
height: 16 * Units.px
anchors.top: tableviewItem.top
anchors.left: vHeaderView.left
anchors.right: tableviewItem.right
anchors.rightMargin: 236 * Units.px
anchors.leftMargin: 8 * Units.px
verticalAlignment: Text.AlignBottom
}
VerticalHeaderView {
id: vHeaderView
implicitWidth: 91 * Units.px
implicitHeight: 320 * Units.px
clip: true
anchors.top: hHeaderView.bottom
anchors.bottom: tv.bottom
boundsBehavior: Flickable.StopAtBounds
syncView: tv
delegate: VerticalHeaderDelegate {
textColor: tableviewItem.primaryTextColor
borderColor: tableviewItem.borderColor
}
}
HorizontalHeaderView {
id: hHeaderView
implicitWidth: 250 * Units.px
anchors.top: titleLabel.bottom
anchors.topMargin: 25 * Units.px
anchors.left: vHeaderView.right
interactive: false
columnWidthProvider: column => {
return (column ? tv.implicitColumnWidth(column) : 0);
}
delegate: HorizontalHeaderDelegate {
textColor: tableviewItem.secondaryTextColor
borderColor: tableviewItem.borderColor
}
}
TableView {
id: tv
property alias dataSelectionModel: dataSelectionModel
anchors.top: hHeaderView.bottom
anchors.left: vHeaderView.right
implicitWidth: 255 * Units.px
implicitHeight: 310 * Units.px
reuseItems: false
clip: true
selectionBehavior: TableView.SelectCells
selectionMode: TableView.ContiguousSelection
interactive: false
columnWidthProvider: column => {
if (column === 0)
return 0;
}
rowHeightProvider: row => {
if (row === 0)
return 0;
}
ScrollBar.vertical: MyScrollBar {
parent: tv.parent
anchors.top: tv.top
anchors.bottom: tv.bottom
anchors.left: tv.right
anchors.leftMargin: 16 * Units.px
}
keyNavigationEnabled: false
selectionModel: ItemSelectionModel {
id: dataSelectionModel
}
delegate: Rectangle {
id: delegateRectangle
implicitHeight: 31 * Units.px
implicitWidth: 63 * Units.px
required property bool selected
required property bool current
required property string display
border.width: 1 * Units.px
border.color: tableviewItem.borderColor
color: selected ? tableviewItem.selectionColor : tableviewItem.backgroundColor
Text {
leftPadding: 38
topPadding: 6
bottomPadding: 5
rightPadding: 11
color: tableviewItem.primaryTextColor
text: delegateRectangle.display
}
}
}
component MyScrollBar: ScrollBar {
id: scrollBar
background: Rectangle {
implicitWidth: 8 * Units.px
implicitHeight: 320 * Units.px
radius: 8 * Units.px
color: tableviewItem.selectionColor
}
contentItem: Rectangle {
implicitWidth: 8 * Units.px
implicitHeight: 91 * Units.px
color: tableviewItem.scrollbarBackgroundColor
radius: 8 * Units.px
}
}
}
|