QGIS API Documentation 3.41.0-Master (cea29feecf2)
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 QgsNumericFormatWidget *create( const QgsNumericFormat *format ) const
27 {
28 return new QgsBasicNumericFormatWidget( format );
29 }
30};
31
32class QgsBearingNumericFormatConfigurationWidgetFactory : public QgsNumericFormatConfigurationWidgetFactory
33{
34 public:
35 QgsNumericFormatWidget *create( const QgsNumericFormat *format ) const
36 {
37 return new QgsBearingNumericFormatWidget( format );
38 }
39};
40
41class QgsGeographicCoordinateNumericFormatConfigurationWidgetFactory : public QgsNumericFormatConfigurationWidgetFactory
42{
43 public:
44 QgsNumericFormatWidget *create( const QgsNumericFormat *format ) const
45 {
47 }
48};
49
50class QgsCurrencyNumericFormatConfigurationWidgetFactory : public QgsNumericFormatConfigurationWidgetFactory
51{
52 public:
53 QgsNumericFormatWidget *create( const QgsNumericFormat *format ) const
54 {
55 return new QgsCurrencyNumericFormatWidget( format );
56 }
57};
58
59class QgsPercentageNumericFormatConfigurationWidgetFactory : public QgsNumericFormatConfigurationWidgetFactory
60{
61 public:
62 QgsNumericFormatWidget *create( const QgsNumericFormat *format ) const
63 {
64 return new QgsPercentageNumericFormatWidget( format );
65 }
66};
67
68class QgsScientificNumericFormatConfigurationWidgetFactory : public QgsNumericFormatConfigurationWidgetFactory
69{
70 public:
71 QgsNumericFormatWidget *create( const QgsNumericFormat *format ) const
72 {
73 return new QgsScientificNumericFormatWidget( format );
74 }
75};
76
77class QgsFractionNumericFormatConfigurationWidgetFactory : public QgsNumericFormatConfigurationWidgetFactory
78{
79 public:
80 QgsNumericFormatWidget *create( const QgsNumericFormat *format ) const
81 {
82 return new QgsFractionNumericFormatWidget( format );
83 }
84};
85
86class QgsExpressionBasedNumericFormatConfigurationWidgetFactory : public QgsNumericFormatConfigurationWidgetFactory
87{
88 public:
89 QgsNumericFormatWidget *create( const QgsNumericFormat *format ) const
90 {
91 return new QgsExpressionBasedNumericFormatWidget( format );
92 }
93};
94
96
98{
99 addFormatConfigurationWidgetFactory( QStringLiteral( "basic" ), new QgsBasicNumericFormatConfigurationWidgetFactory() );
100 addFormatConfigurationWidgetFactory( QStringLiteral( "bearing" ), new QgsBearingNumericFormatConfigurationWidgetFactory() );
101 addFormatConfigurationWidgetFactory( QStringLiteral( "currency" ), new QgsCurrencyNumericFormatConfigurationWidgetFactory() );
102 addFormatConfigurationWidgetFactory( QStringLiteral( "percentage" ), new QgsPercentageNumericFormatConfigurationWidgetFactory() );
103 addFormatConfigurationWidgetFactory( QStringLiteral( "scientific" ), new QgsScientificNumericFormatConfigurationWidgetFactory() );
104 addFormatConfigurationWidgetFactory( QStringLiteral( "fraction" ), new QgsFractionNumericFormatConfigurationWidgetFactory() );
105 addFormatConfigurationWidgetFactory( QStringLiteral( "geographiccoordinate" ), new QgsGeographicCoordinateNumericFormatConfigurationWidgetFactory() );
106 addFormatConfigurationWidgetFactory( QStringLiteral( "expression" ), new QgsExpressionBasedNumericFormatConfigurationWidgetFactory() );
107}
108
110{
111 qDeleteAll( mFormatConfigurationWidgetFactories );
112}
113
115{
116 mFormatConfigurationWidgetFactories.insert( id, factory );
117}
118
120{
121 delete mFormatConfigurationWidgetFactories.value( id );
122 mFormatConfigurationWidgetFactories.remove( id );
123}
124
126{
127 if ( !format )
128 return nullptr;
129
130 if ( !mFormatConfigurationWidgetFactories.contains( format->id() ) )
131 return nullptr;
132
133 return mFormatConfigurationWidgetFactories.value( format->id() )->create( format );
134}
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.