mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-01 00:03:42 -05:00
QgsNumericFormat subclasses provide a means to format a numeric value as a string, applying various formatting options. E.g. a default string to value formatter (included here) includes settings for controlling the number of decimal places, whether a thousands separator should be shown, whether a leading + sign should be shown, whether trailing zeros should be shown. This PR also includes a formatter for bearings, allowing various formats of numeric bearings to be applied (e.g. control over decimal places, etc + control over whether direction E/W suffixes are shown, or whether values should be limited to either the +/- 180 range or 0-360 degree range) When formatting values, a QgsNumericFormatContext class is used to provide context. Currently, this includes the thousands and decimal separators to apply when formatting (which are taken by default from the user's locale). A registry of formatters is included to allow easy addition of other formats in future (e.g. currencies, percentages, scientific notation, etc...) and to allow plugin based formats. The intention is to follow this up with gui configuration widgets for the formats, and then expose them in various places through the qgis ui (e.g. in the range editor widget for fields, in scalebar numbers, as an option for formatting numeric labels, etc)