Skip to content

Commit 1fb7855

Browse files
arnaud-morvan3nids
authored andcommittedMay 1, 2017
Sipifi QgsFieldFormatter
1 parent 84abf89 commit 1fb7855

File tree

2 files changed

+81
-20
lines changed

2 files changed

+81
-20
lines changed
 

‎python/auto_sip.blacklist

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ core/qgsfeaturefilterprovider.sip
1414
core/qgsfeatureiterator.sip
1515
core/qgsfeaturerequest.sip
1616
core/qgsfieldformatterregistry.sip
17-
core/qgsfieldformatter.sip
1817
core/qgsgeometrysimplifier.sip
1918
core/qgsgeometryvalidator.sip
2019
core/qgsgml.sip

‎python/core/qgsfieldformatter.sip

Lines changed: 81 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,30 @@
1-
/***************************************************************************
2-
qgsfieldformatter.sip - QgsFieldFormatter
3-
4-
---------------------
5-
begin : 2.12.2016
6-
copyright : (C) 2016 by Matthias Kuhn
7-
email : matthias@opengis.ch
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-
***************************************************************************/
1+
/************************************************************************
2+
* This file has been generated automatically from *
3+
* *
4+
* src/core/qgsfieldformatter.h *
5+
* *
6+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
7+
************************************************************************/
8+
9+
10+
11+
1612
class QgsFieldFormatter
1713
{
14+
%Docstring
15+
A field formatter helps to handle and display values for a field.
16+
17+
It allows for using a shared configuration with the editor widgets
18+
for representation of attribute values.
19+
Field kits normally have one single instance which is managed by the
20+
QgsFieldFormatterRegistry. Custom field formatters should be registered there and
21+
field formatters for use within code should normally be obtained from there.
22+
23+
This is an abstract base class and will always need to be subclassed.
24+
25+
.. versionadded:: 3.0
26+
%End
27+
1828
%TypeHeaderCode
1929
#include "qgsfieldformatter.h"
2030
%End
@@ -24,12 +34,64 @@ class QgsFieldFormatter
2434
virtual ~QgsFieldFormatter();
2535

2636
virtual QString id() const = 0;
37+
%Docstring
38+
Return a unique id for this field formatter.
39+
This id will later be used to identify this field formatter in the registry with QgsFieldFormatterRegistry.fieldFormatter().
40+
41+
This id matches the id of a QgsEditorWidgetFactory.
42+
:rtype: str
43+
%End
44+
45+
virtual QString representValue( QgsVectorLayer *layer, int fieldIndex, const QVariantMap &config, const QVariant &cache, const QVariant &value ) const;
46+
%Docstring
47+
Create a pretty String representation of the value.
2748

28-
virtual QString representValue( QgsVectorLayer* layer, int fieldIdx, const QVariantMap& config, const QVariant& cache, const QVariant& value ) const;
49+
:return: By default the string representation of the provided value as implied by the field definition is returned.
2950

30-
virtual QVariant sortValue( QgsVectorLayer* vl, int fieldIdx, const QVariantMap& config, const QVariant& cache, const QVariant& value ) const;
51+
.. versionadded:: 3.0
52+
:rtype: str
53+
%End
54+
55+
virtual QVariant sortValue( QgsVectorLayer *layer, int fieldIndex, const QVariantMap &config, const QVariant &cache, const QVariant &value ) const;
56+
%Docstring
57+
If the default sort order should be overwritten for this widget, you can transform the value in here.
58+
59+
:return: an unmodified value by default.
60+
61+
.. versionadded:: 3.0
62+
:rtype: QVariant
63+
%End
64+
65+
virtual Qt::AlignmentFlag alignmentFlag( QgsVectorLayer *layer, int fieldIndex, const QVariantMap &config ) const;
66+
%Docstring
67+
Return the alignment for a particular field. By default this will consider the field type but can be overwritten if mapped
68+
values are represented.
3169

32-
virtual Qt::AlignmentFlag alignmentFlag( QgsVectorLayer* vl, int fieldIdx, const QVariantMap& config ) const;
70+
.. versionadded:: 3.0
71+
:rtype: Qt.AlignmentFlag
72+
%End
73+
74+
virtual QVariant createCache( QgsVectorLayer *layer, int fieldIndex, const QVariantMap &config ) const;
75+
%Docstring
76+
Create a cache for a given field.
77+
78+
This will be used in situations where a field is being represented various times in a loop. And will be passed
79+
to other methods on QgsFieldKit and QgsEditorWidgetWrapper.
3380

34-
virtual QVariant createCache( QgsVectorLayer* vl, int fieldIdx, const QVariantMap& config ) const;
81+
For example, the attribute table will create a cache once for each field and then use this
82+
cache for representation. The QgsValueRelationFieldFormatter and QgsValueRelationEditorWidget
83+
implement this functionality to create a lookuptable once (a QVariantMap / dict) and are
84+
make use of a cache if present.
85+
86+
.. versionadded:: 3.0
87+
:rtype: QVariant
88+
%End
3589
};
90+
91+
/************************************************************************
92+
* This file has been generated automatically from *
93+
* *
94+
* src/core/qgsfieldformatter.h *
95+
* *
96+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
97+
************************************************************************/

0 commit comments

Comments
 (0)
Please sign in to comment.