QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
gui
attributetable
qgsfeaturelistmodel.h
Go to the documentation of this file.
1
/***************************************************************************
2
qgsfeaturelistmodel.h
3
---------------------
4
begin : February 2013
5
copyright : (C) 2013 by Matthias Kuhn
6
email : matthias at opengis dot ch
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
#ifndef QGSATTRIBUTEEDITORMODEL_H
16
#define QGSATTRIBUTEEDITORMODEL_H
17
18
#include "qgis_gui.h"
19
#include "
qgsconditionalstyle.h
"
20
#include "
qgsexpression.h
"
21
#include "
qgsexpressioncontext.h
"
22
#include "
qgsfeature.h
"
23
#include "
qgsfeaturemodel.h
"
24
25
#include <QItemSelectionModel>
26
#include <QPointer>
27
#include <QSortFilterProxyModel>
28
#include <QVariant>
29
30
class
QgsAttributeTableFilterModel
;
31
class
QgsAttributeTableModel
;
32
class
QgsVectorLayerCache
;
33
34
#define QGSFEATURELISTMODEL_CACHE_INDEX 1
35
41
class
GUI_EXPORT
QgsFeatureListModel
:
public
QSortFilterProxyModel,
public
QgsFeatureModel
42
{
43
Q_OBJECT
44
45
public
:
46
struct
FeatureInfo
47
{
48
public
:
49
FeatureInfo
() =
default
;
50
52
bool
isNew
=
false
;
53
55
bool
isEdited
=
false
;
56
};
57
58
enum
Role
59
{
60
FeatureInfoRole
= 0x1000,
// Make sure no collisions with roles on QgsAttributeTableModel
61
FeatureRole
,
62
FeatureWithGeometryRole
,
63
};
64
65
public
:
67
explicit
QgsFeatureListModel
(
QgsAttributeTableFilterModel
*sourceModel, QObject *parent
SIP_TRANSFERTHIS
=
nullptr
);
68
69
#ifdef __clang__
70
#pragma clang diagnostic push
71
#pragma clang diagnostic ignored "-Woverloaded-virtual"
72
#endif
73
virtual
void
setSourceModel(
QgsAttributeTableFilterModel
*sourceModel );
74
#ifdef __clang__
75
#pragma clang diagnostic pop
76
#endif
77
81
QgsVectorLayerCache
*layerCache();
82
83
QVariant data(
const
QModelIndex &index,
int
role )
const override
;
84
Qt::ItemFlags flags(
const
QModelIndex &index )
const override
;
85
91
void
setInjectNull(
bool
injectNull );
92
97
bool
injectNull();
98
99
QgsAttributeTableModel
*masterModel();
100
109
bool
setDisplayExpression(
const
QString &expression );
110
115
QString parserErrorString();
116
117
QString displayExpression()
const
;
118
bool
featureByIndex(
const
QModelIndex &index,
QgsFeature
&feat );
119
124
QgsFeatureId
idxToFid(
const
QModelIndex &index )
const
;
125
130
QModelIndex fidToIdx(
QgsFeatureId
fid )
const
;
131
132
QModelIndex mapToSource(
const
QModelIndex &proxyIndex )
const override
;
133
QModelIndex mapFromSource(
const
QModelIndex &sourceIndex )
const override
;
134
135
virtual
QModelIndex mapToMaster(
const
QModelIndex &proxyIndex )
const
;
136
virtual
QModelIndex mapFromMaster(
const
QModelIndex &sourceIndex )
const
;
137
138
virtual
QItemSelection mapSelectionFromMaster(
const
QItemSelection &selection )
const
;
139
virtual
QItemSelection mapSelectionToMaster(
const
QItemSelection &selection )
const
;
140
141
QModelIndex parent(
const
QModelIndex &child )
const override
;
142
int
columnCount(
const
QModelIndex &parent = QModelIndex() )
const override
;
143
int
rowCount(
const
QModelIndex &parent = QModelIndex() )
const override
;
144
145
QModelIndex
fidToIndex
(
QgsFeatureId
fid )
override
;
146
QModelIndexList fidToIndexList(
QgsFeatureId
fid );
147
153
bool
sortByDisplayExpression()
const
;
154
163
void
setSortByDisplayExpression(
bool
sortByDisplayExpression, Qt::SortOrder order = Qt::AscendingOrder );
164
165
public
slots:
166
172
Q_DECL_DEPRECATED
void
onBeginRemoveRows(
const
QModelIndex &parent,
int
first,
int
last );
173
179
Q_DECL_DEPRECATED
void
onEndRemoveRows(
const
QModelIndex &parent,
int
first,
int
last );
180
186
Q_DECL_DEPRECATED
void
onBeginInsertRows(
const
QModelIndex &parent,
int
first,
int
last );
187
193
Q_DECL_DEPRECATED
void
onEndInsertRows(
const
QModelIndex &parent,
int
first,
int
last );
194
195
private
slots:
196
197
void
conditionalStylesChanged();
198
199
private
:
200
mutable
QgsExpression
mDisplayExpression;
201
QgsAttributeTableFilterModel
*mFilterModel =
nullptr
;
202
QString mParserErrorString;
203
bool
mInjectNull =
false
;
204
mutable
QgsExpressionContext
mExpressionContext;
205
mutable
QMap<QgsFeatureId, QList<QgsConditionalStyle>> mRowStylesMap;
206
bool
mSortByDisplayExpression =
false
;
207
QPointer<QgsVectorLayer> mSourceLayer;
208
};
209
210
Q_DECLARE_METATYPE
(
QgsFeatureListModel::FeatureInfo
)
211
212
#endif
// QGSATTRIBUTEEDITORMODEL_H
QgsAttributeTableFilterModel
A proxy model for filtering an attribute table model.
Definition
qgsattributetablefiltermodel.h:39
QgsAttributeTableModel
A model backed by a QgsVectorLayerCache which is able to provide feature/attribute information to a Q...
Definition
qgsattributetablemodel.h:50
QgsExpressionContext
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Definition
qgsexpressioncontext.h:491
QgsExpression
Handles parsing and evaluation of expressions (formerly called "search strings").
Definition
qgsexpression.h:197
QgsFeatureListModel
A proxy model for feature lists.
Definition
qgsfeaturelistmodel.h:42
QgsFeatureListModel::QgsFeatureListModel
QgsFeatureListModel(QgsAttributeTableFilterModel *sourceModel, QObject *parent=nullptr)
Constructor for QgsFeatureListModel.
Definition
qgsfeaturelistmodel.cpp:30
QgsFeatureListModel::Role
Role
Definition
qgsfeaturelistmodel.h:59
QgsFeatureListModel::FeatureWithGeometryRole
@ FeatureWithGeometryRole
Feature with all attributes and geometry,.
Definition
qgsfeaturelistmodel.h:62
QgsFeatureListModel::FeatureInfoRole
@ FeatureInfoRole
Definition
qgsfeaturelistmodel.h:60
QgsFeatureListModel::FeatureRole
@ FeatureRole
Feature with all attributes and no geometry.
Definition
qgsfeaturelistmodel.h:61
QgsFeatureModel
Base class for feature models.
Definition
qgsfeaturemodel.h:29
QgsFeatureModel::fidToIndex
virtual QModelIndex fidToIndex(QgsFeatureId fid)=0
QgsFeature
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition
qgsfeature.h:60
QgsVectorLayerCache
Caches features for a given QgsVectorLayer.
Definition
qgsvectorlayercache.h:48
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition
qgis_sip.h:52
qgsconditionalstyle.h
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(QgsDatabaseQueryLogEntry)
qgsexpression.h
qgsexpressioncontext.h
qgsfeature.h
QgsFeatureId
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
Definition
qgsfeatureid.h:32
qgsfeaturemodel.h
QgsFeatureListModel::FeatureInfo
Definition
qgsfeaturelistmodel.h:47
QgsFeatureListModel::FeatureInfo::isEdited
bool isEdited
True if feature has been edited.
Definition
qgsfeaturelistmodel.h:55
QgsFeatureListModel::FeatureInfo::FeatureInfo
FeatureInfo()=default
QgsFeatureListModel::FeatureInfo::isNew
bool isNew
True if feature is a newly added feature.
Definition
qgsfeaturelistmodel.h:52
Generated on
for QGIS API Documentation by
1.17.0