19 Commits

Author SHA1 Message Date
Nyall Dawson
31cdf131b3 Add equality operator for QgsNumericFormat 2020-01-14 19:08:20 +13:00
Nyall Dawson
1cd2e16fb1 Also expose setting for optionally overridding the decimal character 2020-01-09 19:51:50 +13:00
Nyall Dawson
1e82bbc417 Fix seealso link 2020-01-09 19:51:50 +13:00
Nyall Dawson
d3afd6d936 Allow users to override the default locale thousand separator within
specific numeric format objects

E.g. this allows users to set a specific thousand grouping character
to use for a particular scalebar number labels. Useful in the case of
creating maps for users outside of the current locale. Default is
always to use the QGIS locale character (this is an advanced setting!)
2020-01-09 19:51:50 +13:00
Nyall Dawson
ad6684bdb4 Add numeric formatting option to round to number of significant figures 2020-01-09 19:51:50 +13:00
Nyall Dawson
c0ad4303d2 [FEATURE] Add setting for format to show angular bearings to projects
and profile options

The Settings - Options - Map Tools tab contains a new setting for
controlling the default format to use for displaying angular bearings for
newly created projects. Whenever a new project is created, it will
inherit this default settings.

The Project Properties dialog also has a new setting for the project-specific
bearing format.

The intention is that whenever angular bearings are shown in QGIS,
they will be formatted using the current project's bearing format
settings.
2020-01-09 17:10:30 +13:00
Nyall Dawson
1f7140bfc5 New class QgsLocalDefaultSettings
This class contains a variety of default setting values. These values are local, profile
specific settings which may have been configured or tweaked by the user (as opposed to
global, fixed default settings).

The values encapsulated here should be inherited when creating new objects such as new
QGIS projects.

Typically, the QgsSettings backend is used to store and retrieve these local settings.

The intention here is to provide stable, structured and easily discoverable
methods for setting and retrieve these settings, rather than forcing raw QSetting
handling.
2020-01-09 17:10:30 +13:00
Nyall Dawson
664ba234da Also respect other locale specific characters 2020-01-08 16:20:43 +13:00
Nyall Dawson
545edcf148 Dox++ 2020-01-08 16:20:43 +13:00
Nyall Dawson
124df2d78d Add display of sample values to numeric format selector widget 2020-01-08 16:20:43 +13:00
Nyall Dawson
6b9cafb71f Nicer sorting of numeric format choices 2020-01-08 16:20:43 +13:00
Nyall Dawson
591e1a28e0 Start on GUI work 2020-01-08 16:20:43 +13:00
Nyall Dawson
90184a59eb Add methods to store/recreate formats from XML elements, and tweak
serialization API
2020-01-08 16:20:43 +13:00
Nyall Dawson
ec3763521a Avoid ambiguous test data, force minimum of 1 decimal place for scientific notation format to avoid undefined results 2020-01-08 16:20:43 +13:00
Nyall Dawson
a72d8faef5 Fix dox 2020-01-08 16:20:43 +13:00
Nyall Dawson
7affde6624 Add numeric formatter for currency values 2020-01-08 16:20:43 +13:00
Nyall Dawson
d445487c0d Add numeric formatter for scientific notation 2020-01-08 16:20:43 +13:00
Nyall Dawson
8bcba4780e Add percentage numeric formatter 2020-01-08 16:20:43 +13:00
Nyall Dawson
d0b5a01729 [api] Add registry and interface for QgsNumericFormats
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)
2020-01-08 16:20:43 +13:00