QGIS API Documentation 3.41.0-Master (cea29feecf2)
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 FeatureInfo() = default;
48
50 bool isNew = false;
51
53 bool isEdited = false;
54 };
55
56 enum Role
57 {
58 FeatureInfoRole = 0x1000, // Make sure no collisions with roles on QgsAttributeTableModel
59 FeatureRole
60 };
61
62 public:
64 explicit QgsFeatureListModel( QgsAttributeTableFilterModel *sourceModel, QObject *parent SIP_TRANSFERTHIS = nullptr );
65
66#ifdef __clang__
67#pragma clang diagnostic push
68#pragma clang diagnostic ignored "-Woverloaded-virtual"
69#endif
70 virtual void setSourceModel( QgsAttributeTableFilterModel *sourceModel );
71#ifdef __clang__
72#pragma clang diagnostic pop
73#endif
74
78 QgsVectorLayerCache *layerCache();
79
80 QVariant data( const QModelIndex &index, int role ) const override;
81 Qt::ItemFlags flags( const QModelIndex &index ) const override;
82
88 void setInjectNull( bool injectNull );
89
94 bool injectNull();
95
96 QgsAttributeTableModel *masterModel();
97
104 bool setDisplayExpression( const QString &expression );
105
110 QString parserErrorString();
111
112 QString displayExpression() const;
113 bool featureByIndex( const QModelIndex &index, QgsFeature &feat );
114
119 QgsFeatureId idxToFid( const QModelIndex &index ) const;
120
125 QModelIndex fidToIdx( QgsFeatureId fid ) const;
126
127 QModelIndex mapToSource( const QModelIndex &proxyIndex ) const override;
128 QModelIndex mapFromSource( const QModelIndex &sourceIndex ) const override;
129
130 virtual QModelIndex mapToMaster( const QModelIndex &proxyIndex ) const;
131 virtual QModelIndex mapFromMaster( const QModelIndex &sourceIndex ) const;
132
133 virtual QItemSelection mapSelectionFromMaster( const QItemSelection &selection ) const;
134 virtual QItemSelection mapSelectionToMaster( const QItemSelection &selection ) const;
135
136 QModelIndex parent( const QModelIndex &child ) const override;
137 int columnCount( const QModelIndex &parent = QModelIndex() ) const override;
138 int rowCount( const QModelIndex &parent = QModelIndex() ) const override;
139
140 QModelIndex fidToIndex( QgsFeatureId fid ) override;
141 QModelIndexList fidToIndexList( QgsFeatureId fid );
142
148 bool sortByDisplayExpression() const;
149
158 void setSortByDisplayExpression( bool sortByDisplayExpression, Qt::SortOrder order = Qt::AscendingOrder );
159
160 public slots:
161
167 Q_DECL_DEPRECATED void onBeginRemoveRows( const QModelIndex &parent, int first, int last );
168
174 Q_DECL_DEPRECATED void onEndRemoveRows( const QModelIndex &parent, int first, int last );
175
181 Q_DECL_DEPRECATED void onBeginInsertRows( const QModelIndex &parent, int first, int last );
182
188 Q_DECL_DEPRECATED void onEndInsertRows( const QModelIndex &parent, int first, int last );
189
190 private slots:
191
192 void conditionalStylesChanged();
193
194 private:
195 mutable QgsExpression mDisplayExpression;
196 QgsAttributeTableFilterModel *mFilterModel = nullptr;
197 QString mParserErrorString;
198 bool mInjectNull = false;
199 mutable QgsExpressionContext mExpressionContext;
200 mutable QMap<QgsFeatureId, QList<QgsConditionalStyle>> mRowStylesMap;
201 bool mSortByDisplayExpression = false;
202 QPointer<QgsVectorLayer> mSourceLayer;
203};
204
206
207#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