Skip to content

Clean up: refactor handling and display decimal places#2850

Open
ybott-qinetic wants to merge 4 commits intottomkins/unit-refactorfrom
ttomkins/change-to-decimals
Open

Clean up: refactor handling and display decimal places#2850
ybott-qinetic wants to merge 4 commits intottomkins/unit-refactorfrom
ttomkins/change-to-decimals

Conversation

@ybott-qinetic
Copy link
Contributor

Move truncating digits after the decimal point to FormatHints mechanism. Also change to decimals nameclature everywhere.

Contributes to #2791

Move truncating digits after the decimal point to FormatHints
mechanism. Also change to decimals nameclature everywhere.

Contributes to #2791
@ybott-qinetic ybott-qinetic requested a review from chriadam March 2, 2026 06:29
precision: 2
precisionAdjustmentAllowed: false
decimals: 2
formatHints: Units.DecimalsAdjustmentAllowed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the flag supposed to be DecimalsAdjustmentDisallowed? If not, this change inverts the current behaviour.

enum FormatHint {
CompactUnitFormat = 0x1
CompactUnitFormat = 0x1,
DecimalsAdjustmentAllowed = 0x4,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not 0x2?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, maybe this flag should be DecimalsAdjustmentDisallowed, so that the "default" value can be just zero. I am not sure, though...

Q_INVOKABLE QString formatLongitude(qreal longitude, VenusOS::Enums::GpsData_Format format) const;

Q_INVOKABLE int defaultUnitPrecision(VenusOS::Enums::Units_Type unit) const;
Q_INVOKABLE int defaultUnitDecimalPlaces(VenusOS::Enums::Units_Type unit) const;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just defaultUnitDecimals() since the property name is decimals not decimalPlaces etc.

bool precisionAdjustmentAllowed = true,
int decimals = 0,
qreal unitMatchValue = qQNaN(),
int formatHints = 0) const;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this be VenusOS::Units::FormatHints instead of int?

@chriadam
Copy link
Contributor

chriadam commented Mar 2, 2026

Please separate this into two commits, the first doing the renaming from precision to decimals, and the second doing the formatHints stuff.

@ybott-qinetic ybott-qinetic force-pushed the ttomkins/unit-refactor branch from 5bf6768 to f1ce8d8 Compare March 10, 2026 02:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants