QGIS API Documentation 4.1.0-Master (60fea48833c)
Loading...
Searching...
No Matches
qgsfieldformatter.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsfieldformatter.h - QgsFieldFormatter
3
4 ---------------------
5 begin : 2.12.2016
6 copyright : (C) 2016 by Matthias Kuhn
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#ifndef QGSFIELDKIT_H
17#define QGSFIELDKIT_H
18
19#include "qgis_core.h"
20#include "qgsvectorlayerref.h"
21
22#include <QString>
23#include <QVariant>
24
25class QgsVectorLayer;
26
33class CORE_EXPORT QgsFieldFormatterContext
34{
35 public:
37
42 QgsProject *project() const { return mProject; }
43
48 void setProject( QgsProject *project ) { mProject = project; }
49
50 private:
51 QgsProject *mProject = nullptr;
52};
53
67class CORE_EXPORT QgsFieldFormatter
68{
69 public:
70 QgsFieldFormatter() = default;
71
72 virtual ~QgsFieldFormatter() = default;
73
79 enum Flag SIP_ENUM_BASETYPE( IntFlag )
80 {
81 CanProvideAvailableValues = 1
82 };
83 Q_DECLARE_FLAGS( Flags, Flag )
84
85
91 virtual QString id() const = 0;
92
99 virtual QString representValue( QgsVectorLayer *layer, int fieldIndex, const QVariantMap &config, const QVariant &cache, const QVariant &value ) const;
100
107 virtual QVariant sortValue( QgsVectorLayer *layer, int fieldIndex, const QVariantMap &config, const QVariant &cache, const QVariant &value ) const;
108
114 virtual Qt::AlignmentFlag alignmentFlag( QgsVectorLayer *layer, int fieldIndex, const QVariantMap &config ) const;
115
128 virtual QVariant createCache( QgsVectorLayer *layer, int fieldIndex, const QVariantMap &config ) const;
129
142 virtual QList< QgsVectorLayerRef > layerDependencies( const QVariantMap &config ) const SIP_SKIP;
143
150 virtual QVariantList availableValues( const QVariantMap &config, int countLimit, const QgsFieldFormatterContext &context ) const;
151
157 Flags flags() const { return mFlags; }
158
164 void setFlags( const Flags &flags );
165
166 private:
167 Flags mFlags;
168};
169
170#endif // QGSFIELDKIT_H
A context for field formatter containing information like the project.
void setProject(QgsProject *project)
Sets the project used in field formatter.
QgsProject * project() const
Returns the project used in field formatter.
QgsFieldFormatterContext()=default
virtual QVariant createCache(QgsVectorLayer *layer, int fieldIndex, const QVariantMap &config) const
Create a cache for a given field.
Flags flags() const
Returns the flags.
virtual Qt::AlignmentFlag alignmentFlag(QgsVectorLayer *layer, int fieldIndex, const QVariantMap &config) const
Returns the alignment for a particular field.
QgsFieldFormatter()=default
virtual ~QgsFieldFormatter()=default
virtual QVariantList availableValues(const QVariantMap &config, int countLimit, const QgsFieldFormatterContext &context) const
Returns a list of the values that would be possible to select with this widget type On a RelationRefe...
QFlags< Flag > Flags
virtual QVariant sortValue(QgsVectorLayer *layer, int fieldIndex, const QVariantMap &config, const QVariant &cache, const QVariant &value) const
If the default sort order should be overwritten for this widget, you can transform the value in here.
enum Flag SIP_ENUM_BASETYPE(IntFlag)
Flags for the abilities of the formatter.
virtual QList< QgsVectorLayerRef > layerDependencies(const QVariantMap &config) const SIP_SKIP
Returns a list of weak layer references to other layers required by this formatter for the given conf...
virtual QString representValue(QgsVectorLayer *layer, int fieldIndex, const QVariantMap &config, const QVariant &cache, const QVariant &value) const
Create a pretty String representation of the value.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition qgsproject.h:113
Represents a vector layer which manages a vector based dataset.
#define SIP_SKIP
Definition qgis_sip.h:133
_LayerRef< QgsVectorLayer > QgsVectorLayerRef