QGIS API Documentation 3.39.0-Master (3aed037ce22)
Loading...
Searching...
No Matches
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 "qgsexpression.h"
19
20#include <QSortFilterProxyModel>
21#include <QVariant>
22#include <QItemSelectionModel>
23#include <QPointer>
24
25#include "qgsfeaturemodel.h"
26#include "qgsfeature.h" // QgsFeatureId
28#include "qgsconditionalstyle.h"
29#include "qgis_gui.h"
30
34
39class GUI_EXPORT QgsFeatureListModel : public QSortFilterProxyModel, public QgsFeatureModel
40{
41 Q_OBJECT
42
43 public:
45 {
46 public:
47
48 FeatureInfo() = default;
49
51 bool isNew = false;
52
54 bool isEdited = false;
55 };
56
57 enum Role
58 {
59 FeatureInfoRole = 0x1000, // Make sure no collisions with roles on QgsAttributeTableModel
60 FeatureRole
61 };
62
63 public:
64
66 explicit QgsFeatureListModel( QgsAttributeTableFilterModel *sourceModel, QObject *parent SIP_TRANSFERTHIS = nullptr );
67
68#ifdef __clang__
69#pragma clang diagnostic push
70#pragma clang diagnostic ignored "-Woverloaded-virtual"
71#endif
72 virtual void setSourceModel( QgsAttributeTableFilterModel *sourceModel );
73#ifdef __clang__
74#pragma clang diagnostic pop
75#endif
76
80 QgsVectorLayerCache *layerCache();
81
82 QVariant data( const QModelIndex &index, int role ) const override;
83 Qt::ItemFlags flags( const QModelIndex &index ) const override;
84
90 void setInjectNull( bool injectNull );
91
96 bool injectNull();
97
98 QgsAttributeTableModel *masterModel();
99
106 bool setDisplayExpression( const QString &expression );
107
112 QString parserErrorString();
113
114 QString displayExpression() const;
115 bool featureByIndex( const QModelIndex &index, QgsFeature &feat );
116
121 QgsFeatureId idxToFid( const QModelIndex &index ) const;
122
127 QModelIndex fidToIdx( QgsFeatureId fid ) const;
128
129 QModelIndex mapToSource( const QModelIndex &proxyIndex ) const override;
130 QModelIndex mapFromSource( const QModelIndex &sourceIndex ) const override;
131
132 virtual QModelIndex mapToMaster( const QModelIndex &proxyIndex ) const;
133 virtual QModelIndex mapFromMaster( const QModelIndex &sourceIndex ) const;
134
135 virtual QItemSelection mapSelectionFromMaster( const QItemSelection &selection ) const;
136 virtual QItemSelection mapSelectionToMaster( const QItemSelection &selection ) const;
137
138 QModelIndex parent( const QModelIndex &child ) const override;
139 int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
140 int rowCount( const QModelIndex &parent = QModelIndex() ) const override;
141
142 QModelIndex fidToIndex( QgsFeatureId fid ) override;
143 QModelIndexList fidToIndexList( QgsFeatureId fid );
144
150 bool sortByDisplayExpression() const;
151
160 void setSortByDisplayExpression( bool sortByDisplayExpression, Qt::SortOrder order = Qt::AscendingOrder );
161
162 public slots:
163
169 Q_DECL_DEPRECATED void onBeginRemoveRows( const QModelIndex &parent, int first, int last );
170
176 Q_DECL_DEPRECATED void onEndRemoveRows( const QModelIndex &parent, int first, int last );
177
183 Q_DECL_DEPRECATED void onBeginInsertRows( const QModelIndex &parent, int first, int last );
184
190 Q_DECL_DEPRECATED void onEndInsertRows( const QModelIndex &parent, int first, int last );
191
192 private slots:
193
194 void conditionalStylesChanged();
195
196 private:
197 mutable QgsExpression mDisplayExpression;
198 QgsAttributeTableFilterModel *mFilterModel = nullptr;
199 QString mParserErrorString;
200 bool mInjectNull = false;
201 mutable QgsExpressionContext mExpressionContext;
202 mutable QMap< QgsFeatureId, QList<QgsConditionalStyle> > mRowStylesMap;
203 bool mSortByDisplayExpression = false;
204 QPointer< QgsVectorLayer > mSourceLayer;
205};
206
208
209#endif // QGSATTRIBUTEEDITORMODEL_H
A model backed by a QgsVectorLayerCache which is able to provide feature/attribute information to a Q...
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Class for parsing and evaluation of expressions (formerly called "search strings").
virtual QModelIndex fidToIndex(QgsFeatureId fid)=0
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:58
This class caches features of a given QgsVectorLayer.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
Q_DECLARE_METATYPE(QgsDatabaseQueryLogEntry)
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features