QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
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};
93
95{
96 addFormatConfigurationWidgetFactory( QStringLiteral( "basic" ), new QgsBasicNumericFormatConfigurationWidgetFactory() );
97 addFormatConfigurationWidgetFactory( QStringLiteral( "bearing" ), new QgsBearingNumericFormatConfigurationWidgetFactory() );
98 addFormatConfigurationWidgetFactory( QStringLiteral( "currency" ), new QgsCurrencyNumericFormatConfigurationWidgetFactory() );
99 addFormatConfigurationWidgetFactory( QStringLiteral( "percentage" ), new QgsPercentageNumericFormatConfigurationWidgetFactory() );
100 addFormatConfigurationWidgetFactory( QStringLiteral( "scientific" ), new QgsScientificNumericFormatConfigurationWidgetFactory() );
101 addFormatConfigurationWidgetFactory( QStringLiteral( "fraction" ), new QgsFractionNumericFormatConfigurationWidgetFactory() );
102 addFormatConfigurationWidgetFactory( QStringLiteral( "geographiccoordinate" ), new QgsGeographicCoordinateNumericFormatConfigurationWidgetFactory() );
103}
104
106{
107 qDeleteAll( mFormatConfigurationWidgetFactories );
108}
109
111{
112 mFormatConfigurationWidgetFactories.insert( id, factory );
113}
114
116{
117 delete mFormatConfigurationWidgetFactories.value( id );
118 mFormatConfigurationWidgetFactories.remove( id );
119}
120
122{
123 if ( !format )
124 return nullptr;
125
126 if ( !mFormatConfigurationWidgetFactories.contains( format->id() ) )
127 return nullptr;
128
129 return mFormatConfigurationWidgetFactories.value( format->id() )->create( format );
130}
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 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.