13import org.kde.kirigami as Kirigami
15import org.kde.ksysguard.faces.private
16import org.kde.ksysguard.formatter
17import org.kde.ksysguard.sensors
19import org.kde.quickcharts as Charts
20import org.kde.quickcharts.controls as ChartsControls
30ChartsControls.Legend {
37 property alias sensorIds: sensorsRepeater.model
41 property SensorDataModel sourceModel
46 property var colorSource
48 property int updateRateLimit
50 Layout.maximumHeight: implicitHeight
51 Layout.maximumWidth: parent.width
53 horizontalSpacing: Kirigami.Units.gridUnit
54 verticalSpacing: Kirigami.Units.smallSpacing
56 maximumDelegateWidth: Kirigami.Units.gridUnit * 15
58 formatValue: function(input, index) {
63 return Formatter.formatValueShowNull(input, sourceModel.headerData(index, Qt.Horiztonal, SensorDataModel.Unit))
68 value: QTransposeProxyModel {
69 sourceModel: legend.sourceModel
72 Binding on valueRole {
80 Binding on shortNameRole {
84 Binding on colorRole {
89 maximumValueWidth: function(input, index) {
94 var unit = sourceModel.headerData(index,
Qt.Horiztonal, SensorDataModel.Unit)
95 return Formatter.maximumLength(unit, legend.font)
100 delegate: ChartsControls.LegendDelegate {
101 name: legend.sourceModel.sensorLabels[sensor.sensorId] || sensor.name
102 shortName: legend.sourceModel.sensorLabels[sensor.sensorId] || sensor.shortName
103 value: sensor.formattedValue ||
""
107 maximumValueWidth: legend.maximumValueWidth(sensor.value, index)
109 ChartsControls.LegendLayout.minimumWidth: minimumWidth
110 ChartsControls.LegendLayout.preferredWidth: preferredWidth
111 ChartsControls.LegendLayout.maximumWidth: Math.max(legend.maximumDelegateWidth, preferredWidth)
116 updateRateLimit: legend.updateRateLimit
QString name(StandardShortcut id)