QGIS API Documentation 3.38.0-Grenoble (exported)
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 <QString>
20#include <QVariant>
21
22#include "qgis_core.h"
23#include "qgsvectorlayerref.h"
24
25class QgsVectorLayer;
26
33class CORE_EXPORT QgsFieldFormatterContext
34{
35 public:
36
41
46 QgsProject *project() const { return mProject; }
47
52 void setProject( QgsProject *project ) { mProject = project; }
53
54 private:
55 QgsProject *mProject = nullptr;
56};
57
71class CORE_EXPORT QgsFieldFormatter
72{
73 public:
74
78 QgsFieldFormatter() = default;
79
80 virtual ~QgsFieldFormatter() = default;
81
87 enum Flag SIP_ENUM_BASETYPE( IntFlag )
88 {
89 CanProvideAvailableValues = 1
90 };
91 Q_DECLARE_FLAGS( Flags, Flag )
92
93
99 virtual QString id() const = 0;
100
107 virtual QString representValue( QgsVectorLayer *layer, int fieldIndex, const QVariantMap &config, const QVariant &cache, const QVariant &value ) const;
108
115 virtual QVariant sortValue( QgsVectorLayer *layer, int fieldIndex, const QVariantMap &config, const QVariant &cache, const QVariant &value ) const;
116
122 virtual Qt::AlignmentFlag alignmentFlag( QgsVectorLayer *layer, int fieldIndex, const QVariantMap &config ) const;
123
136 virtual QVariant createCache( QgsVectorLayer *layer, int fieldIndex, const QVariantMap &config ) const;
137
150 virtual QList< QgsVectorLayerRef > layerDependencies( const QVariantMap &config ) const SIP_SKIP;
151
158 virtual QVariantList availableValues( const QVariantMap &config, int countLimit, const QgsFieldFormatterContext &context ) const;
159
165 Flags flags() const { return mFlags; }
166
172 void setFlags( const Flags &flags );
173
174 private:
175 Flags mFlags;
176};
177
178#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
Constructor.
A field formatter helps to handle and display values for a field.
QgsFieldFormatter()=default
Default constructor.
virtual ~QgsFieldFormatter()=default
QFlags< Flag > Flags
enum Flag SIP_ENUM_BASETYPE(IntFlag)
Flags for the abilities of the formatter.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition qgsproject.h:107
Represents a vector layer which manages a vector based data sets.
#define SIP_SKIP
Definition qgis_sip.h:126