QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgsnumericformatregistry.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsnumericformatregistry.h
3 --------------------------
4 begin : January 2020
5 copyright : (C) 2020 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15#ifndef QGSNUMERICFORMATREGISTRY_H
16#define QGSNUMERICFORMATREGISTRY_H
17
18#include "qgis_core.h"
19#include "qgis_sip.h"
20
21#include <QHash>
22#include <QObject>
23#include <QString>
24
26class QDomElement;
28
38class CORE_EXPORT QgsNumericFormatRegistry
39{
40
41 public:
42
48 explicit QgsNumericFormatRegistry();
50
54 QStringList formats() const;
55
62
66 void removeFormat( const QString &id );
67
74 QgsNumericFormat *format( const QString &id ) const SIP_TRANSFERBACK;
75
82 QgsNumericFormat *create( const QString &id, const QVariantMap &configuration, const QgsReadWriteContext &context ) const SIP_TRANSFERBACK;
83
90 QgsNumericFormat *createFromXml( const QDomElement &element, const QgsReadWriteContext &context ) const SIP_TRANSFERBACK;
91
99
103 QString visibleName( const QString &id ) const;
104
108 int sortKey( const QString &id ) const;
109
110 private:
111 QHash<QString, QgsNumericFormat *> mFormats;
112};
113
114#endif // QGSNUMERICFORMATREGISTRY_H
int sortKey(const QString &id) const
Returns the sorting key for the format with matching id.
QgsNumericFormat * fallbackFormat() const
Returns a basic numeric formatter which can be used to represent any number in an default manner.
void removeFormat(const QString &id)
Removes the format with matching id from the registry.
QString visibleName(const QString &id) const
Returns the translated, user-visible name for the format with matching id.
QgsNumericFormat * format(const QString &id) const
Creates a new numeric format by id.
QStringList formats() const
Returns a list of the format IDs currently contained in the registry.
QgsNumericFormat * createFromXml(const QDomElement &element, const QgsReadWriteContext &context) const
Creates a new numeric format from an XML element.
QgsNumericFormatRegistry()
You should not normally need to create your own numeric format registry.
void addFormat(QgsNumericFormat *format)
Adds a new format to the registry.
QgsNumericFormat * create(const QString &id, const QVariantMap &configuration, const QgsReadWriteContext &context) const
Creates a new numeric format by id, using the supplied configuration.
Abstract base class for numeric formatters, which allow for formatting a numeric value for display.
A container for the context for various read/write operations on objects.
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_TRANSFERBACK
Definition qgis_sip.h:48
#define SIP_FACTORY
Definition qgis_sip.h:84