QGIS API Documentation
3.2.0-Bonn (bc43194)
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 "
qgsfallbackfieldformatter.h
"
27
28
29
QgsFieldFormatterRegistry::QgsFieldFormatterRegistry
( QObject *parent )
30
: QObject( parent )
31
{
32
addFieldFormatter
(
new
QgsValueRelationFieldFormatter
() );
33
addFieldFormatter
(
new
QgsValueMapFieldFormatter
() );
34
addFieldFormatter
(
new
QgsRelationReferenceFieldFormatter
() );
35
addFieldFormatter
(
new
QgsKeyValueFieldFormatter
() );
36
addFieldFormatter
(
new
QgsListFieldFormatter
() );
37
addFieldFormatter
(
new
QgsDateTimeFieldFormatter
() );
38
addFieldFormatter
(
new
QgsRangeFieldFormatter
() );
39
40
mFallbackFieldFormatter =
new
QgsFallbackFieldFormatter
();
41
}
42
43
QgsFieldFormatterRegistry::~QgsFieldFormatterRegistry
()
44
{
45
qDeleteAll( mFieldFormatters );
46
delete
mFallbackFieldFormatter;
47
}
48
49
void
QgsFieldFormatterRegistry::addFieldFormatter
(
QgsFieldFormatter
*formatter )
50
{
51
mFieldFormatters.insert( formatter->
id
(), formatter );
52
emit
fieldFormatterAdded
( formatter );
53
}
54
55
void
QgsFieldFormatterRegistry::removeFieldFormatter
(
QgsFieldFormatter
*formatter )
56
{
57
removeFieldFormatter
( formatter->
id
() );
58
}
59
60
void
QgsFieldFormatterRegistry::removeFieldFormatter
(
const
QString &
id
)
61
{
62
if
(
QgsFieldFormatter
*formatter = mFieldFormatters.take(
id
) )
63
{
64
emit
fieldFormatterRemoved
( formatter );
65
delete
formatter;
66
}
67
}
68
69
QgsFieldFormatter
*
QgsFieldFormatterRegistry::fieldFormatter
(
const
QString &
id
)
const
70
{
71
return
mFieldFormatters.value(
id
, mFallbackFieldFormatter );
72
}
73
74
QgsFieldFormatter
*
QgsFieldFormatterRegistry::fallbackFieldFormatter
()
const
75
{
76
return
mFallbackFieldFormatter;
77
}
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:55
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
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:49
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
QgsFieldFormatterRegistry::fieldFormatter
QgsFieldFormatter * fieldFormatter(const QString &id) const
Gets a field formatter by its id.
Definition:
qgsfieldformatterregistry.cpp:69
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:29
qgsrelationreferencefieldformatter.h
QgsRelationReferenceFieldFormatter
Field formatter for a relation reference field.
Definition:
qgsrelationreferencefieldformatter.h:30
QgsFieldFormatterRegistry::~QgsFieldFormatterRegistry
~QgsFieldFormatterRegistry() override
Definition:
qgsfieldformatterregistry.cpp:43
QgsDateTimeFieldFormatter
Field formatter for a date time field.
Definition:
qgsdatetimefieldformatter.h:30
qgslistfieldformatter.h
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:74
qgsdatetimefieldformatter.h
qgsrangefieldformatter.h
QgsRangeFieldFormatter
Field formatter for a range (double) field with precision and locale.
Definition:
qgsrangefieldformatter.h:28
Generated on Sat Jun 23 2018 20:58:15 for QGIS API Documentation by
1.8.13