QGIS API Documentation
3.4.15-Madeira (e83d02e274)
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
src
core
qgsfieldformatterregistry.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgsfieldformatterregistry.cpp - QgsFieldFormatterRegistry
3
4
---------------------
5
begin : 2.12.2016
6
copyright : (C) 2016 by Matthias Kuhn
7
email :
[email protected]
8
***************************************************************************
9
* *
10
* This program is free software; you can redistribute it and/or modify *
11
* it under the terms of the GNU General Public License as published by *
12
* the Free Software Foundation; either version 2 of the License, or *
13
* (at your option) any later version. *
14
* *
15
***************************************************************************/
16
#include "
qgsfieldformatterregistry.h
"
17
#include "
qgsfieldformatter.h
"
18
19
#include "
qgsvaluerelationfieldformatter.h
"
20
#include "
qgsvaluemapfieldformatter.h
"
21
#include "
qgsdatetimefieldformatter.h
"
22
#include "
qgsrelationreferencefieldformatter.h
"
23
#include "
qgskeyvaluefieldformatter.h
"
24
#include "
qgslistfieldformatter.h
"
25
#include "
qgsrangefieldformatter.h
"
26
#include "
qgscheckboxfieldformatter.h
"
27
#include "
qgsfallbackfieldformatter.h
"
28
29
30
QgsFieldFormatterRegistry::QgsFieldFormatterRegistry
( QObject *parent )
31
: QObject( parent )
32
{
33
addFieldFormatter
(
new
QgsValueRelationFieldFormatter
() );
34
addFieldFormatter
(
new
QgsValueMapFieldFormatter
() );
35
addFieldFormatter
(
new
QgsRelationReferenceFieldFormatter
() );
36
addFieldFormatter
(
new
QgsKeyValueFieldFormatter
() );
37
addFieldFormatter
(
new
QgsListFieldFormatter
() );
38
addFieldFormatter
(
new
QgsDateTimeFieldFormatter
() );
39
addFieldFormatter
(
new
QgsRangeFieldFormatter
() );
40
addFieldFormatter
(
new
QgsCheckBoxFieldFormatter
() );
41
42
mFallbackFieldFormatter =
new
QgsFallbackFieldFormatter
();
43
}
44
45
QgsFieldFormatterRegistry::~QgsFieldFormatterRegistry
()
46
{
47
qDeleteAll( mFieldFormatters );
48
delete
mFallbackFieldFormatter;
49
}
50
51
void
QgsFieldFormatterRegistry::addFieldFormatter
(
QgsFieldFormatter
*formatter )
52
{
53
mFieldFormatters.insert( formatter->
id
(), formatter );
54
emit
fieldFormatterAdded
( formatter );
55
}
56
57
void
QgsFieldFormatterRegistry::removeFieldFormatter
(
QgsFieldFormatter
*formatter )
58
{
59
removeFieldFormatter
( formatter->
id
() );
60
}
61
62
void
QgsFieldFormatterRegistry::removeFieldFormatter
(
const
QString &
id
)
63
{
64
if
(
QgsFieldFormatter
*formatter = mFieldFormatters.take(
id
) )
65
{
66
emit
fieldFormatterRemoved
( formatter );
67
delete
formatter;
68
}
69
}
70
71
QgsFieldFormatter
*
QgsFieldFormatterRegistry::fieldFormatter
(
const
QString &
id
)
const
72
{
73
return
mFieldFormatters.value(
id
, mFallbackFieldFormatter );
74
}
75
76
QgsFieldFormatter
*
QgsFieldFormatterRegistry::fallbackFieldFormatter
()
const
77
{
78
return
mFallbackFieldFormatter;
79
}
qgsfieldformatterregistry.h
QgsKeyValueFieldFormatter
Field formatter for a key value field.
Definition:
qgskeyvaluefieldformatter.h:33
QgsValueMapFieldFormatter
Field formatter for a ValueMap field.
Definition:
qgsvaluemapfieldformatter.h:39
QgsFieldFormatterRegistry::removeFieldFormatter
void removeFieldFormatter(QgsFieldFormatter *formatter)
Remove a field formatter from the registry.
Definition:
qgsfieldformatterregistry.cpp:57
QgsFieldFormatterRegistry::fieldFormatter
QgsFieldFormatter * fieldFormatter(const QString &id) const
Gets a field formatter by its id.
Definition:
qgsfieldformatterregistry.cpp:71
QgsListFieldFormatter
Field formatter for a list field.
Definition:
qgslistfieldformatter.h:30
QgsFallbackFieldFormatter
A default fallback field formatter in case no specialized field formatter is defined.
Definition:
qgsfallbackfieldformatter.h:29
QgsFieldFormatterRegistry::fallbackFieldFormatter
QgsFieldFormatter * fallbackFieldFormatter() const
Returns a basic fallback field formatter which can be used to represent any field in an unspectacular...
Definition:
qgsfieldformatterregistry.cpp:76
QgsFieldFormatter::id
virtual QString id() const =0
Returns a unique id for this field formatter.
qgsvaluemapfieldformatter.h
QgsFieldFormatterRegistry::addFieldFormatter
void addFieldFormatter(QgsFieldFormatter *formatter)
They will take precedence in order of adding them.
Definition:
qgsfieldformatterregistry.cpp:51
QgsCheckBoxFieldFormatter
Field formatter for a checkbox field.
Definition:
qgscheckboxfieldformatter.h:29
QgsFieldFormatterRegistry::fieldFormatterAdded
void fieldFormatterAdded(QgsFieldFormatter *formatter)
Will be emitted after a new field formatter has been added.
qgsvaluerelationfieldformatter.h
qgsfieldformatter.h
QgsValueRelationFieldFormatter
Field formatter for a value relation field.
Definition:
qgsvaluerelationfieldformatter.h:36
qgskeyvaluefieldformatter.h
QgsFieldFormatterRegistry::fieldFormatterRemoved
void fieldFormatterRemoved(QgsFieldFormatter *formatter)
Will be emitted just before a field formatter is removed and deleted.
QgsFieldFormatter
A field formatter helps to handle and display values for a field.
Definition:
qgsfieldformatter.h:40
qgsfallbackfieldformatter.h
QgsFieldFormatterRegistry::QgsFieldFormatterRegistry
QgsFieldFormatterRegistry(QObject *parent=nullptr)
You should not normally need to create your own field formatter registry.
Definition:
qgsfieldformatterregistry.cpp:30
qgsrelationreferencefieldformatter.h
QgsRelationReferenceFieldFormatter
Field formatter for a relation reference field.
Definition:
qgsrelationreferencefieldformatter.h:30
QgsFieldFormatterRegistry::~QgsFieldFormatterRegistry
~QgsFieldFormatterRegistry() override
Definition:
qgsfieldformatterregistry.cpp:45
qgscheckboxfieldformatter.h
QgsDateTimeFieldFormatter
Field formatter for a date time field.
Definition:
qgsdatetimefieldformatter.h:30
qgslistfieldformatter.h
qgsdatetimefieldformatter.h
qgsrangefieldformatter.h
QgsRangeFieldFormatter
Field formatter for a range (double) field with precision and locale.
Definition:
qgsrangefieldformatter.h:28
Generated on Sun Jan 19 2020 15:27:13 for QGIS API Documentation by
1.8.11