-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Initialize Fact QVariant as invalid #13642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -321,14 +321,18 @@ QStringList Fact::selectedBitmaskStrings() const | |
|
|
||
| QString Fact::_variantToString(const QVariant &variant, int decimalPlaces) const | ||
| { | ||
| if (!variant.isValid()) { | ||
| return placeholderString(decimalPlaces); | ||
| } | ||
|
|
||
| QString valueString; | ||
|
|
||
| switch (type()) { | ||
| case FactMetaData::valueTypeFloat: | ||
| { | ||
| const float fValue = variant.toFloat(); | ||
| if (qIsNaN(fValue)) { | ||
| valueString = QStringLiteral("--.--"); | ||
| valueString = placeholderString(decimalPlaces); | ||
| } else { | ||
| valueString = QStringLiteral("%1").arg(fValue, 0, 'f', decimalPlaces); | ||
| } | ||
|
|
@@ -338,7 +342,7 @@ QString Fact::_variantToString(const QVariant &variant, int decimalPlaces) const | |
| { | ||
| const double dValue = variant.toDouble(); | ||
| if (qIsNaN(dValue)) { | ||
| valueString = QStringLiteral("--.--"); | ||
| valueString = placeholderString(decimalPlaces); | ||
| } else { | ||
| valueString = QStringLiteral("%1").arg(dValue, 0, 'f', decimalPlaces); | ||
| } | ||
|
|
@@ -351,7 +355,7 @@ QString Fact::_variantToString(const QVariant &variant, int decimalPlaces) const | |
| { | ||
| const double dValue = variant.toDouble(); | ||
| if (qIsNaN(dValue)) { | ||
| valueString = QStringLiteral("--:--:--"); | ||
| valueString = placeholderString(decimalPlaces); | ||
| } else { | ||
| QTime time(0, 0, 0, 0); | ||
| time = time.addSecs(dValue); | ||
|
|
@@ -367,6 +371,22 @@ QString Fact::_variantToString(const QVariant &variant, int decimalPlaces) const | |
| return valueString; | ||
| } | ||
|
|
||
| QString Fact::placeholderString(int decimalPlaces) const { | ||
| switch (type()) { | ||
| case FactMetaData::valueTypeFloat: | ||
| case FactMetaData::valueTypeDouble: | ||
| if (decimalPlaces <= 0) { | ||
| return QStringLiteral("-"); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would say that using '--' for this would make it clearer this is a missing value. Given the fact that '-' can kinda mean negative and may confuse folks. |
||
| } | ||
| return QStringLiteral("-.") + | ||
| QString(decimalPlaces, QLatin1Char('-')); | ||
| case FactMetaData::valueTypeElapsedTimeInSeconds: | ||
| return QStringLiteral("--:--:--"); | ||
| default: | ||
| return QStringLiteral("-"); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same thing here '--' is clearer. |
||
| } | ||
| } | ||
|
|
||
| QString Fact::rawValueStringFullPrecision() const | ||
| { | ||
| return _variantToString(rawValue(), 18); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,7 +40,7 @@ QtObject { | |
| property var rgRotationValueStrings: [ rotationNoneValueString, rotationYaw45ValueString, rotationYaw90ValueString, rotationYaw135ValueString, rotationYaw180ValueString, rotationYaw225ValueString, rotationYaw270ValueString, rotationYaw315ValueString ] | ||
|
|
||
| property var _distanceSensors: vehicle ? vehicle.distanceSensors : null | ||
| property string _noValueStr: qsTr("--.--") | ||
| property string _noValueStr: qsTr("-") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These values are shown with decimal places in the ui when available. So I would keep the |
||
|
|
||
| onRotationNoneValueChanged: rotationValueChanged() | ||
| onRotationYaw45ValueChanged: rotationValueChanged() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,7 +21,7 @@ ToolIndicatorPage { | |
|
|
||
| property var activeVehicle: QGroundControl.multiVehicleManager.activeVehicle | ||
| property string na: qsTr("N/A", "No data to display") | ||
| property string valueNA: qsTr("--.--", "No data to display") | ||
| property string valueNA: qsTr("-", "No data to display") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are also shown normally with decimal places. So I would keep it as is to make it more clear. That said, given the way the control works this string is never shown since that sections of values is hidden when no vehicle is available. |
||
| property var rtkSettings: QGroundControl.settingsManager.rtkSettings | ||
| property var useFixedPosition: rtkSettings.useFixedBasePosition.rawValue | ||
| property var manufacturer: rtkSettings.baseReceiverManufacturers.rawValue | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be better named
invalidValueString. What do you think?