QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
qgsnumericformatguiregistry.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsnumericformatguiregistry.cpp
3 -------------------------------
4 begin : January 2020
5 copyright : (C) 2020 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
19#include "qgis.h"
21
23class QgsBasicNumericFormatConfigurationWidgetFactory : public QgsNumericFormatConfigurationWidgetFactory
24{
25 public:
26
27 QgsNumericFormatWidget *create( const QgsNumericFormat *format ) const
28 {
29 return new QgsBasicNumericFormatWidget( format );
30 }
31};
32
33class QgsBearingNumericFormatConfigurationWidgetFactory : public QgsNumericFormatConfigurationWidgetFactory
34{
35 public:
36
37 QgsNumericFormatWidget *create( const QgsNumericFormat *format ) const
38 {
39 return new QgsBearingNumericFormatWidget( format );
40 }
41};
42
43class QgsGeographicCoordinateNumericFormatConfigurationWidgetFactory : public QgsNumericFormatConfigurationWidgetFactory
44{
45 public:
46
47 QgsNumericFormatWidget *create( const QgsNumericFormat *format ) const
48 {
50 }
51};
52
53class QgsCurrencyNumericFormatConfigurationWidgetFactory : public QgsNumericFormatConfigurationWidgetFactory
54{
55 public:
56
57 QgsNumericFormatWidget *create( const QgsNumericFormat *format ) const
58 {
59 return new QgsCurrencyNumericFormatWidget( format );
60 }
61};
62
63class QgsPercentageNumericFormatConfigurationWidgetFactory : public QgsNumericFormatConfigurationWidgetFactory
64{
65 public:
66
67 QgsNumericFormatWidget *create( const QgsNumericFormat *format ) const
68 {
69 return new QgsPercentageNumericFormatWidget( format );
70 }
71};
72
73class QgsScientificNumericFormatConfigurationWidgetFactory : public QgsNumericFormatConfigurationWidgetFactory
74{
75 public:
76
77 QgsNumericFormatWidget *create( const QgsNumericFormat *format ) const
78 {
79 return new QgsScientificNumericFormatWidget( format );
80 }
81};
82
83class QgsFractionNumericFormatConfigurationWidgetFactory : public QgsNumericFormatConfigurationWidgetFactory
84{
85 public:
86
87 QgsNumericFormatWidget *create( const QgsNumericFormat *format ) const
88 {
89 return new QgsFractionNumericFormatWidget( format );
90 }
91};
92
93class QgsExpressionBasedNumericFormatConfigurationWidgetFactory : public QgsNumericFormatConfigurationWidgetFactory
94{
95 public:
96
97 QgsNumericFormatWidget *create( const QgsNumericFormat *format ) const
98 {
99 return new QgsExpressionBasedNumericFormatWidget( format );
100 }
101};
102
104
106{
107 addFormatConfigurationWidgetFactory( QStringLiteral( "basic" ), new QgsBasicNumericFormatConfigurationWidgetFactory() );
108 addFormatConfigurationWidgetFactory( QStringLiteral( "bearing" ), new QgsBearingNumericFormatConfigurationWidgetFactory() );
109 addFormatConfigurationWidgetFactory( QStringLiteral( "currency" ), new QgsCurrencyNumericFormatConfigurationWidgetFactory() );
110 addFormatConfigurationWidgetFactory( QStringLiteral( "percentage" ), new QgsPercentageNumericFormatConfigurationWidgetFactory() );
111 addFormatConfigurationWidgetFactory( QStringLiteral( "scientific" ), new QgsScientificNumericFormatConfigurationWidgetFactory() );
112 addFormatConfigurationWidgetFactory( QStringLiteral( "fraction" ), new QgsFractionNumericFormatConfigurationWidgetFactory() );
113 addFormatConfigurationWidgetFactory( QStringLiteral( "geographiccoordinate" ), new QgsGeographicCoordinateNumericFormatConfigurationWidgetFactory() );
114 addFormatConfigurationWidgetFactory( QStringLiteral( "expression" ), new QgsExpressionBasedNumericFormatConfigurationWidgetFactory() );
115}
116
118{
119 qDeleteAll( mFormatConfigurationWidgetFactories );
120}
121
123{
124 mFormatConfigurationWidgetFactories.insert( id, factory );
125}
126
128{
129 delete mFormatConfigurationWidgetFactories.value( id );
130 mFormatConfigurationWidgetFactories.remove( id );
131}
132
134{
135 if ( !format )
136 return nullptr;
137
138 if ( !mFormatConfigurationWidgetFactories.contains( format->id() ) )
139 return nullptr;
140
141 return mFormatConfigurationWidgetFactories.value( format->id() )->create( format );
142}
A widget which allow control over the properties of a QgsBasicNumericFormat.
A widget which allow control over the properties of a QgsBearingNumericFormat.
A widget which allow control over the properties of a QgsCurrencyNumericFormat.
A widget which allow control over the properties of a QgsExpressionBasedNumericFormat.
A widget which allow control over the properties of a QgsFractionNumericFormat.
A widget which allow control over the properties of a QgsGeographicCoordinateNumericFormat.
Interface base class for factories for numeric format configuration widgets.
virtual QgsNumericFormatWidget * create(const QgsNumericFormat *format) const =0
Create a new configuration widget for a format.
QgsNumericFormatWidget * formatConfigurationWidget(const QgsNumericFormat *format) const
Returns a new configuration widget for an format.
void addFormatConfigurationWidgetFactory(const QString &id, QgsNumericFormatConfigurationWidgetFactory *factory)
Add a new configuration widget factory for customizing a numeric format with the specified id.
void removeFormatConfigurationWidgetFactory(const QString &id)
Removes the configuration widget factory for customizing numeric formats with the specified id.
Base class for widgets which allow control over the properties of QgsNumericFormat subclasses.
A numeric formatter allows for formatting a numeric value for display, using a variety of different f...
virtual QString id() const =0
Returns a unique id for this numeric format.
A widget which allow control over the properties of a QgsPercentageNumericFormat.
A widget which allow control over the properties of a QgsScientificNumericFormat.