QGIS API Documentation
3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
src
core
qgsfieldmodel.h
Go to the documentation of this file.
1
/***************************************************************************
2
qgsfieldmodel.h
3
--------------------------------------
4
Date : 01.04.2014
5
Copyright : (C) 2014 Denis Rouzaud
6
Email : denis.rouzaud@gmail.com
7
***************************************************************************
8
* *
9
* This program is free software; you can redistribute it and/or modify *
10
* it under the terms of the GNU General Public License as published by *
11
* the Free Software Foundation; either version 2 of the License, or *
12
* (at your option) any later version. *
13
* *
14
***************************************************************************/
15
16
#ifndef QGSFIELDMODEL_H
17
#define QGSFIELDMODEL_H
18
19
#include <QAbstractItemModel>
20
#include <QComboBox>
21
#include <QItemSelectionModel>
22
23
#include "
qgsfields.h
"
24
#include "qgis_core.h"
25
26
#include "
qgis_sip.h
"
27
28
class
QgsVectorLayer
;
29
38
class
CORE_EXPORT
QgsFieldModel
:
public
QAbstractItemModel
39
{
40
Q_OBJECT
41
42
Q_PROPERTY(
bool
allowExpression READ allowExpression WRITE setAllowExpression )
43
Q_PROPERTY(
bool
allowEmptyFieldName READ allowEmptyFieldName WRITE setAllowEmptyFieldName )
44
Q_PROPERTY(
QgsVectorLayer
*layer READ layer WRITE setLayer )
45
46
public:
47
48
// *INDENT-OFF*
49
56
enum class
CustomRole
SIP_MONKEYPATCH_SCOPEENUM_UNNEST
(
QgsFieldModel
, FieldRoles ) :
int
57
{
58
FieldName
SIP_MONKEYPATCH_COMPAT_NAME
(FieldNameRole) = Qt::UserRole + 1,
59
FieldIndex
SIP_MONKEYPATCH_COMPAT_NAME
(FieldIndexRole) = Qt::UserRole + 2,
60
Expression
SIP_MONKEYPATCH_COMPAT_NAME
(ExpressionRole) = Qt::UserRole + 3,
61
IsExpression
SIP_MONKEYPATCH_COMPAT_NAME
(IsExpressionRole) = Qt::UserRole + 4,
62
ExpressionValidity
SIP_MONKEYPATCH_COMPAT_NAME
(ExpressionValidityRole) = Qt::UserRole + 5,
63
FieldType
SIP_MONKEYPATCH_COMPAT_NAME
(FieldTypeRole) = Qt::UserRole + 6,
64
FieldOrigin
SIP_MONKEYPATCH_COMPAT_NAME
(FieldOriginRole) = Qt::UserRole + 7,
65
IsEmpty
SIP_MONKEYPATCH_COMPAT_NAME
(IsEmptyRole) = Qt::UserRole + 8,
66
EditorWidgetType = Qt::UserRole + 9,
67
JoinedFieldIsEditable = Qt::UserRole + 10,
68
FieldIsWidgetEditable = Qt::UserRole + 11,
69
};
70
Q_ENUM( CustomRole )
71
// *INDENT-ON*
72
73
76
explicit
QgsFieldModel
( QObject *parent
SIP_TRANSFERTHIS
=
nullptr
);
77
81
QModelIndex indexFromName(
const
QString &fieldName );
82
88
void
setAllowExpression(
bool
allowExpression );
89
94
bool
allowExpression
() {
return
mAllowExpression; }
95
100
void
setAllowEmptyFieldName(
bool
allowEmpty );
101
106
bool
allowEmptyFieldName
()
const
{
return
mAllowEmpty; }
107
112
bool
isField(
const
QString &expression )
const
;
113
120
void
setExpression(
const
QString &expression );
121
127
void
removeExpression();
128
133
QgsVectorLayer
*
layer
() {
return
mLayer; }
134
135
// QAbstractItemModel interface
136
QModelIndex index(
int
row,
int
column,
const
QModelIndex &parent = QModelIndex() )
const override
;
137
QModelIndex parent(
const
QModelIndex &child )
const override
;
138
int
rowCount(
const
QModelIndex &parent = QModelIndex() )
const override
;
139
int
columnCount(
const
QModelIndex &parent )
const override
;
140
QVariant data(
const
QModelIndex &index,
int
role )
const override
;
141
146
static
QString fieldToolTip(
const
QgsField
&field );
147
153
static
QString fieldToolTipExtended(
const
QgsField
&field,
const
QgsVectorLayer
*layer );
154
165
void
setFields(
const
QgsFields
&fields );
166
175
QgsFields
fields()
const
;
176
177
public
slots:
178
183
void
setLayer(
QgsVectorLayer
*layer );
184
185
protected
slots:
186
190
virtual
void
updateModel();
191
192
private
slots:
193
void
layerDeleted();
194
195
protected
:
196
QgsFields
mFields
;
197
QList<QString>
mExpression
;
198
199
QgsVectorLayer
*mLayer =
nullptr
;
200
bool
mAllowExpression =
false
;
201
bool
mAllowEmpty =
false
;
202
203
private
:
204
void
fetchFeature();
205
};
206
207
#endif
// QGSFIELDMODEL_H
QgsFieldModel
The QgsFieldModel class is a model to display the list of fields in widgets (optionally associated wi...
Definition
qgsfieldmodel.h:39
QgsFieldModel::allowEmptyFieldName
bool allowEmptyFieldName() const
Returns true if the model allows the empty field ("not set") choice.
Definition
qgsfieldmodel.h:106
QgsFieldModel::CustomRole
CustomRole
Custom model roles.
Definition
qgsfieldmodel.h:57
QgsFieldModel::layer
QgsVectorLayer * layer()
Returns the layer associated with the model.
Definition
qgsfieldmodel.h:133
QgsFieldModel::mFields
QgsFields mFields
Definition
qgsfieldmodel.h:196
QgsFieldModel::allowExpression
bool allowExpression()
Returns true if the model allows custom expressions to be created and displayed.
Definition
qgsfieldmodel.h:94
QgsFieldModel::mExpression
QList< QString > mExpression
Definition
qgsfieldmodel.h:197
QgsField
Encapsulate a field in an attribute table or data source.
Definition
qgsfield.h:53
QgsFields
Container of fields for a vector layer.
Definition
qgsfields.h:46
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition
qgsvectorlayer.h:401
qgis_sip.h
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition
qgis_sip.h:53
SIP_MONKEYPATCH_SCOPEENUM_UNNEST
#define SIP_MONKEYPATCH_SCOPEENUM_UNNEST(OUTSIDE_CLASS, FORMERNAME)
Definition
qgis_sip.h:271
SIP_MONKEYPATCH_COMPAT_NAME
#define SIP_MONKEYPATCH_COMPAT_NAME(FORMERNAME)
Definition
qgis_sip.h:273
qgsfields.h
Generated on Tue Nov 19 2024 18:20:01 for QGIS API Documentation by
1.9.8