Skip to content

Commit 552e1b2

Browse files
committed
Add doxymentation for field formatters
1 parent f7ae653 commit 552e1b2

10 files changed

Lines changed: 82 additions & 9 deletions

‎src/core/fieldformatter/qgsdatetimefieldformatter.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ QString QgsDateTimeFieldFormatter::representValue( QgsVectorLayer* layer, int fi
6060
return result;
6161
}
6262

63-
QString QgsDateTimeFieldFormatter::defaultFormat( const QVariant::Type type )
63+
QString QgsDateTimeFieldFormatter::defaultFormat( QVariant::Type type )
6464
{
6565
switch ( type )
6666
{

‎src/core/fieldformatter/qgsdatetimefieldformatter.h‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@
1919
#include "qgis_core.h"
2020
#include "qgsfieldformatter.h"
2121

22+
/**
23+
* \ingroup core
24+
* Field formatter for a date time field.
25+
* This represents a date, time or datetime value based on
26+
* the field configuration.
27+
*
28+
* \note Added in QGIS 3.0
29+
*/
2230
class CORE_EXPORT QgsDateTimeFieldFormatter : public QgsFieldFormatter
2331
{
2432
public:
@@ -38,7 +46,7 @@ class CORE_EXPORT QgsDateTimeFieldFormatter : public QgsFieldFormatter
3846
* - QVariant::Date
3947
* - QVariant::Time
4048
*/
41-
static QString defaultFormat( const QVariant::Type type );
49+
static QString defaultFormat( QVariant::Type type );
4250
};
4351

4452
#endif // QGSDATETIMEFIELDKIT_H

‎src/core/fieldformatter/qgsfallbackfieldformatter.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@
1919
#include "qgis_core.h"
2020
#include "qgsfieldformatter.h"
2121

22+
/**
23+
* \ingroup core
24+
* A default fallback field formatter in case no specialized field formatter is defined.
25+
* The values will be returned unmodified.
26+
*
27+
* \note Added in QGIS 3.0
28+
*/
2229
class CORE_EXPORT QgsFallbackFieldFormatter : public QgsFieldFormatter
2330
{
2431
public:

‎src/core/fieldformatter/qgskeyvaluefieldformatter.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ QString QgsKeyValueFieldFormatter::representValue( QgsVectorLayer* layer, int fi
3232

3333
if ( value.isNull() )
3434
{
35-
QSettings settings;
3635
return QgsApplication::nullRepresentation();
3736
}
3837

3938
QString result;
4039
const QVariantMap map = value.toMap();
4140
for ( QVariantMap::const_iterator i = map.constBegin(); i != map.constEnd(); ++i )
4241
{
43-
if ( !result.isEmpty() ) result.append( ", " );
42+
if ( !result.isEmpty() )
43+
result.append( ", " );
4444
result.append( i.key() ).append( ": " ).append( i.value().toString() );
4545
}
4646
return result;

‎src/core/fieldformatter/qgskeyvaluefieldformatter.h‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@
1919
#include "qgis_core.h"
2020
#include "qgsfieldformatter.h"
2121

22+
/**
23+
* \ingroup core
24+
* Field formatter for a key value field.
25+
* This represents a list type value.
26+
* Values will be represented as a colon-delimited and
27+
* comma-separated list.
28+
*
29+
* E.g. "color: yellow, amount: 5"
30+
*
31+
* \note Added in QGIS 3.0
32+
*/
2233
class CORE_EXPORT QgsKeyValueFieldFormatter : public QgsFieldFormatter
2334
{
2435
public:

‎src/core/fieldformatter/qgslistfieldformatter.cpp‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,15 @@ QString QgsListFieldFormatter::representValue( QgsVectorLayer* layer, int fieldI
3131

3232
if ( value.isNull() )
3333
{
34-
QSettings settings;
3534
return QgsApplication::nullRepresentation();
3635
}
3736

3837
QString result;
39-
const QVariantList list = value.toList();
40-
for ( QVariantList::const_iterator i = list.constBegin(); i != list.constEnd(); ++i )
38+
Q_FOREACH ( const QVariant& val, value.toList() )
4139
{
42-
if ( !result.isEmpty() ) result.append( ", " );
43-
result.append( i->toString() );
40+
if ( !result.isEmpty() )
41+
result.append( ", " );
42+
result.append( val.toString() );
4443
}
4544
return result;
4645
}

‎src/core/fieldformatter/qgslistfieldformatter.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@
1919
#include "qgis_core.h"
2020
#include "qgsfieldformatter.h"
2121

22+
/**
23+
* \ingroup core
24+
* Field formatter for a list field.
25+
* This represents a list type value.
26+
* Values will be represented as a comma-separated list.
27+
*
28+
* \note Added in QGIS 3.0
29+
*/
2230
class CORE_EXPORT QgsListFieldFormatter : public QgsFieldFormatter
2331
{
2432
public:

‎src/core/fieldformatter/qgsrelationreferencefieldformatter.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@
1919
#include "qgis_core.h"
2020
#include "qgsfieldformatter.h"
2121

22+
/**
23+
* \ingroup core
24+
* Field formatter for a relation reference field.
25+
* A value relation field formatter looks up the values from
26+
* features on another layer.
27+
*
28+
* \note Added in QGIS 3.0
29+
*/
2230
class CORE_EXPORT QgsRelationReferenceFieldFormatter : public QgsFieldFormatter
2331
{
2432
public:

‎src/core/fieldformatter/qgsvaluemapfieldformatter.h‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,23 @@
1919
#include "qgis_core.h"
2020
#include "qgsfieldformatter.h"
2121

22+
/**
23+
* \ingroup core
24+
* Field formatter for a ValueMap field.
25+
* A value relation field formatter looks up the values a map.
26+
*
27+
* The map is defined in the configuration as dictionary under the key "map".
28+
*
29+
* { "map": { 1: "one", 2: "two", 3: "three" } }
30+
*
31+
* Values that are not on the map will be wrapped in parantheses. So with the above
32+
* configuration:
33+
*
34+
* - 3 => "three"
35+
* - 5 => "(5)"
36+
*
37+
* \note Added in QGIS 3.0
38+
*/
2239
class CORE_EXPORT QgsValueMapFieldFormatter : public QgsFieldFormatter
2340
{
2441
public:

‎src/core/fieldformatter/qgsvaluerelationfieldformatter.h‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@
2222
#include <QVector>
2323
#include <QVariant>
2424

25+
/**
26+
* \ingroup core
27+
* Field formatter for a value relation field.
28+
* A value relation field formatter looks up the values from
29+
* features on another layer.
30+
*
31+
* \note Added in QGIS 3.0
32+
*/
2533
class CORE_EXPORT QgsValueRelationFieldFormatter : public QgsFieldFormatter
2634
{
2735
public:
@@ -50,6 +58,13 @@ class CORE_EXPORT QgsValueRelationFieldFormatter : public QgsFieldFormatter
5058

5159
QVariant createCache( QgsVectorLayer *layer, int fieldIndex, const QVariantMap &config ) const override;
5260

61+
/**
62+
* Create a cache for a value relation field.
63+
* This can be used to keep the value map in the local memory
64+
* if doing multiple lookups in a loop.
65+
*
66+
* \note Added in QGIS 3.0
67+
*/
5368
static ValueRelationCache createCache( const QVariantMap& config );
5469
};
5570

0 commit comments

Comments
 (0)