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 highlightEnabled: sourceModel.sensors.length > 1
60 formatValue: function(input, index) {
65 return Formatter.formatValueShowNull(input, sourceModel.headerData(index, Qt.Horiztonal, SensorDataModel.Unit))
70 value: QTransposeProxyModel {
71 sourceModel: legend.sourceModel
74 Binding on valueRole {
82 Binding on shortNameRole {
86 Binding on colorRole {
91 maximumValueWidth: function(input, index) {
96 var unit = sourceModel.headerData(index,
Qt.Horiztonal, SensorDataModel.Unit)
97 return Formatter.maximumLength(unit, legend.font)
102 delegate: ChartsControls.LegendDelegate {
103 name: legend.sourceModel.sensorLabels[sensor.sensorId] || sensor.name
104 shortName: legend.sourceModel.sensorLabels[sensor.sensorId] || sensor.shortName
105 value: sensor.formattedValue ||
""
109 maximumValueWidth: legend.maximumValueWidth(sensor.value, index)
111 ChartsControls.LegendLayout.minimumWidth: minimumWidth
112 ChartsControls.LegendLayout.preferredWidth: preferredWidth
113 ChartsControls.LegendLayout.maximumWidth: Math.max(legend.maximumDelegateWidth, preferredWidth)
118 updateRateLimit: legend.updateRateLimit
QString name(StandardAction id)