From 49e3951327002bcee46c3c38e3195247b32f215f Mon Sep 17 00:00:00 2001 From: Jacob Walser Date: Wed, 10 May 2017 12:39:11 -0400 Subject: [PATCH] Handle null facts in Values Widget --- src/FlightMap/Widgets/ValuesWidget.qml | 114 ++++++++++++++----------- 1 file changed, 63 insertions(+), 51 deletions(-) diff --git a/src/FlightMap/Widgets/ValuesWidget.qml b/src/FlightMap/Widgets/ValuesWidget.qml index f9495390a..1d8733363 100644 --- a/src/FlightMap/Widgets/ValuesWidget.qml +++ b/src/FlightMap/Widgets/ValuesWidget.qml @@ -65,33 +65,39 @@ QGCFlickable { Repeater { model: _activeVehicle ? controller.largeValues : 0 - - Column { - width: _largeColumn.width - + Loader { + sourceComponent: fact ? largeValue : undefined property Fact fact: _activeVehicle.getFact(modelData.replace("Vehicle.", "")) - property bool largeValue: _root.listContains(controller.altitudeProperties, fact.name) - - QGCLabel { - width: parent.width - horizontalAlignment: Text.AlignHCenter - color: textColor - fontSizeMode: Text.HorizontalFit - text: fact.shortDescription + (fact.units ? " (" + fact.units + ")" : "") - } - QGCLabel { - width: parent.width - horizontalAlignment: Text.AlignHCenter - font.pointSize: ScreenTools.mediumFontPointSize * (largeValue ? 1.3 : 1.0) - font.family: largeValue ? ScreenTools.demiboldFontFamily : ScreenTools.normalFontFamily - fontSizeMode: Text.HorizontalFit - color: textColor - text: fact.valueString - } } } // Repeater - Large } // Column - Large + Component { + id: largeValue + + Column { + width: _largeColumn.width + property bool largeValue: _root.listContains(controller.altitudeProperties, fact.name) + + QGCLabel { + width: parent.width + horizontalAlignment: Text.AlignHCenter + color: textColor + fontSizeMode: Text.HorizontalFit + text: fact.shortDescription + (fact.units ? " (" + fact.units + ")" : "") + } + QGCLabel { + width: parent.width + horizontalAlignment: Text.AlignHCenter + font.pointSize: ScreenTools.mediumFontPointSize * (largeValue ? 1.3 : 1.0) + font.family: largeValue ? ScreenTools.demiboldFontFamily : ScreenTools.normalFontFamily + fontSizeMode: Text.HorizontalFit + color: textColor + text: fact.valueString + } + } + } + Flow { id: _smallFlow width: parent.width @@ -102,40 +108,46 @@ QGCFlickable { Repeater { model: _activeVehicle ? controller.smallValues : 0 - - Column { - width: (_root.width / 2) - (_margins / 2) - 0.1 - clip: true - + Loader { + sourceComponent: fact ? smallValue : undefined property Fact fact: _activeVehicle.getFact(modelData.replace("Vehicle.", "")) - - QGCLabel { - width: parent.width - horizontalAlignment: Text.AlignHCenter - font.pointSize: ScreenTools.isTinyScreen ? ScreenTools.smallFontPointSize * 0.75 : ScreenTools.smallFontPointSize - fontSizeMode: Text.HorizontalFit - color: textColor - text: fact.shortDescription - } - QGCLabel { - width: parent.width - horizontalAlignment: Text.AlignHCenter - color: textColor - fontSizeMode: Text.HorizontalFit - text: fact.enumOrValueString - } - QGCLabel { - width: parent.width - horizontalAlignment: Text.AlignHCenter - font.pointSize: ScreenTools.isTinyScreen ? ScreenTools.smallFontPointSize * 0.75 : ScreenTools.smallFontPointSize - fontSizeMode: Text.HorizontalFit - color: textColor - text: fact.units - } } } // Repeater - Small } // Flow + Component { + id: smallValue + + Column { + width: (_root.width / 2) - (_margins / 2) - 0.1 + clip: true + + QGCLabel { + width: parent.width + horizontalAlignment: Text.AlignHCenter + font.pointSize: ScreenTools.isTinyScreen ? ScreenTools.smallFontPointSize * 0.75 : ScreenTools.smallFontPointSize + fontSizeMode: Text.HorizontalFit + color: textColor + text: fact.shortDescription + } + QGCLabel { + width: parent.width + horizontalAlignment: Text.AlignHCenter + color: textColor + fontSizeMode: Text.HorizontalFit + text: fact.enumOrValueString + } + QGCLabel { + width: parent.width + horizontalAlignment: Text.AlignHCenter + font.pointSize: ScreenTools.isTinyScreen ? ScreenTools.smallFontPointSize * 0.75 : ScreenTools.smallFontPointSize + fontSizeMode: Text.HorizontalFit + color: textColor + text: fact.units + } + } + } + Component { id: propertyPicker -- 2.22.0