QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgsfeaturelistmodel.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsfeaturelistmodel.cpp
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 #include "qgsexception.h"
16 #include "qgsvectordataprovider.h"
17 #include "qgsfeaturelistmodel.h"
18 #include "qgsattributetablemodel.h"
21 #include "qgsapplication.h"
22 #include "qgsvectorlayercache.h"
23 
24 #include <QItemSelection>
25 #include <QSettings>
26 
28  : QSortFilterProxyModel( parent )
29 {
30  setSourceModel( sourceModel );
31 }
32 
34 {
35  if ( mSourceLayer )
36  disconnect( mSourceLayer->conditionalStyles(), &QgsConditionalLayerStyles::changed, this, &QgsFeatureListModel::conditionalStylesChanged );
37 
38  QSortFilterProxyModel::setSourceModel( sourceModel );
39  mExpressionContext = sourceModel->layer()->createExpressionContext();
40  mFilterModel = sourceModel;
41 
42  mSourceLayer = sourceModel->layer();
43  connect( mSourceLayer->conditionalStyles(), &QgsConditionalLayerStyles::changed, this, &QgsFeatureListModel::conditionalStylesChanged );
44 }
45 
47 {
48  return mFilterModel->layerCache();
49 }
50 
51 QgsFeatureId QgsFeatureListModel::idxToFid( const QModelIndex &index ) const
52 {
53  return mFilterModel->masterModel()->rowToId( mapToMaster( index ).row() );
54 }
55 
56 QModelIndex QgsFeatureListModel::fidToIdx( const QgsFeatureId fid ) const
57 {
58  return mapFromMaster( mFilterModel->masterModel()->idToIndex( fid ) );
59 }
60 
61 QVariant QgsFeatureListModel::data( const QModelIndex &index, int role ) const
62 {
63  if ( mInjectNull && index.row() == 0 )
64  {
65  if ( role == Qt::DisplayRole )
66  {
68  }
69  else
70  {
71  return QVariant( QVariant::Invalid );
72  }
73  }
74 
75  if ( role == Qt::DisplayRole || role == Qt::EditRole )
76  {
77  QgsFeature feat;
78 
79  mFilterModel->layerCache()->featureAtId( idxToFid( index ), feat );
80 
81  mExpressionContext.setFeature( feat );
82  return mDisplayExpression.evaluate( &mExpressionContext );
83  }
84 
85  if ( role == FeatureInfoRole )
86  {
87  FeatureInfo featInfo;
88 
89  QgsFeature feat;
90 
91  mFilterModel->layerCache()->featureAtId( idxToFid( index ), feat );
92 
93  QgsVectorLayerEditBuffer *editBuffer = mFilterModel->layer()->editBuffer();
94 
95  if ( editBuffer )
96  {
97  if ( editBuffer->isFeatureAdded( feat.id() ) )
98  {
99  featInfo.isNew = true;
100  }
101  if ( editBuffer->isFeatureAttributesChanged( feat.id() ) )
102  {
103  featInfo.isEdited = true;
104  }
105  }
106 
107  return QVariant::fromValue( featInfo );
108  }
109  else if ( role == FeatureRole )
110  {
111  QgsFeature feat;
112 
113  mFilterModel->layerCache()->featureAtId( idxToFid( index ), feat );
114 
115  return QVariant::fromValue( feat );
116  }
117  else if ( role == Qt::TextAlignmentRole )
118  {
119  return static_cast<Qt::Alignment::Int>( Qt::AlignLeft );
120  }
121 
122 #if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
123  if ( role == Qt::BackgroundColorRole
124  || role == Qt::TextColorRole
125 #else
126  if ( role == Qt::BackgroundRole
127  || role == Qt::ForegroundRole
128 #endif
129  || role == Qt::DecorationRole
130  || role == Qt::FontRole )
131  {
132  QgsVectorLayer *layer = mFilterModel->layer();
133  QgsFeature feat;
134  const QgsFeatureId fid = idxToFid( index );
135  mFilterModel->layerCache()->featureAtId( fid, feat );
136  mExpressionContext.setFeature( feat );
137  QList<QgsConditionalStyle> styles;
138 
139  if ( mRowStylesMap.contains( fid ) )
140  {
141  styles = mRowStylesMap.value( fid );
142  }
143  else
144  {
145  styles = QgsConditionalStyle::matchingConditionalStyles( layer->conditionalStyles()->rowStyles(), QVariant(), mExpressionContext );
146  mRowStylesMap.insert( fid, styles );
147  }
148 
149  const QgsConditionalStyle rowstyle = QgsConditionalStyle::compressStyles( styles );
150 
151  if ( mDisplayExpression.isField() )
152  {
153  const QString fieldName = *mDisplayExpression.referencedColumns().constBegin();
154  styles = layer->conditionalStyles()->fieldStyles( fieldName );
155  styles = QgsConditionalStyle::matchingConditionalStyles( styles, feat.attribute( fieldName ), mExpressionContext );
156  }
157 
158  styles.insert( 0, rowstyle );
159 
161 
162  if ( style.isValid() )
163  {
164 #if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
165  if ( role == Qt::BackgroundColorRole && style.validBackgroundColor() )
166 #else
167  if ( role == Qt::BackgroundRole && style.validBackgroundColor() )
168 #endif
169  return style.backgroundColor().isValid() ? style.backgroundColor() : QVariant();
170 #if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
171  if ( role == Qt::TextColorRole && style.validTextColor() )
172 #else
173  if ( role == Qt::ForegroundRole && style.validTextColor() )
174 #endif
175  return style.textColor().isValid() ? style.textColor() : QVariant();
176  if ( role == Qt::DecorationRole )
177  return style.icon().isNull() ? QVariant() : style.icon();
178  if ( role == Qt::FontRole )
179  return style.font();
180  }
181 
182  return QVariant();
183  }
184 
185  return sourceModel()->data( mapToSource( index ), role );
186 }
187 
188 Qt::ItemFlags QgsFeatureListModel::flags( const QModelIndex &index ) const
189 {
190  if ( mInjectNull && index.row() == 0 )
191  {
192  return Qt::ItemIsSelectable | Qt::ItemIsEnabled;
193  }
194  else
195  {
196  return sourceModel()->flags( mapToSource( index ) ) & ~Qt::ItemIsEditable;
197  }
198 }
199 
200 void QgsFeatureListModel::setInjectNull( bool injectNull )
201 {
202  if ( mInjectNull == injectNull )
203  return;
204 
205  if ( injectNull )
207 
208  beginResetModel();
209  mInjectNull = injectNull;
210  endResetModel();
211 }
212 
214 {
215  return mInjectNull;
216 }
217 
219 {
220  return mFilterModel->masterModel();
221 }
222 
223 bool QgsFeatureListModel::setDisplayExpression( const QString &expression )
224 {
225  QgsExpression exp = QgsExpression( expression );
226 
227  exp.prepare( &mExpressionContext );
228 
229  if ( exp.hasParserError() )
230  {
231  mParserErrorString = exp.parserErrorString();
232  return false;
233  }
234 
235  mDisplayExpression = exp;
236 
237  if ( mSortByDisplayExpression )
238  masterModel()->prefetchSortData( expression, 1 );
239 
240  emit dataChanged( index( 0, 0 ), index( rowCount() - 1, 0 ) );
241 
242  invalidate();
243  return true;
244 }
245 
247 {
248  return mParserErrorString;
249 }
250 
252 {
253  return mDisplayExpression.expression();
254 }
255 
256 bool QgsFeatureListModel::featureByIndex( const QModelIndex &index, QgsFeature &feat )
257 {
258  return mFilterModel->layerCache()->featureAtId( idxToFid( index ), feat );
259 }
260 
261 void QgsFeatureListModel::onBeginRemoveRows( const QModelIndex &parent, int first, int last )
262 {
263  beginRemoveRows( parent, first, last );
264 }
265 
266 void QgsFeatureListModel::onEndRemoveRows( const QModelIndex &parent, int first, int last )
267 {
268  Q_UNUSED( parent )
269  Q_UNUSED( first )
270  Q_UNUSED( last )
271  endRemoveRows();
272 }
273 
274 void QgsFeatureListModel::onBeginInsertRows( const QModelIndex &parent, int first, int last )
275 {
276  beginInsertRows( parent, first, last );
277 }
278 
279 void QgsFeatureListModel::onEndInsertRows( const QModelIndex &parent, int first, int last )
280 {
281  Q_UNUSED( parent )
282  Q_UNUSED( first )
283  Q_UNUSED( last )
284  endInsertRows();
285 }
286 
287 void QgsFeatureListModel::conditionalStylesChanged()
288 {
289  mRowStylesMap.clear();
290  emit dataChanged( index( 0, 0 ), index( rowCount() - 1, columnCount() - 1 ) );
291 }
292 
294 {
295  return mSortByDisplayExpression;
296 }
297 
298 void QgsFeatureListModel::setSortByDisplayExpression( bool sortByDisplayExpression, Qt::SortOrder order )
299 {
300  mSortByDisplayExpression = sortByDisplayExpression;
301 
302  // If we are sorting by display expression, we do not support injected null
303  if ( mSortByDisplayExpression )
304  setInjectNull( false );
305 
306  setSortRole( QgsAttributeTableModel::SortRole + 1 );
307  setDynamicSortFilter( mSortByDisplayExpression );
308  sort( 0, order );
309 }
310 
311 QModelIndex QgsFeatureListModel::mapToMaster( const QModelIndex &proxyIndex ) const
312 {
313  QModelIndex masterIndex;
314 
315  if ( proxyIndex.isValid() )
316  {
317  if ( mSortByDisplayExpression )
318  {
319  masterIndex = mFilterModel->mapToMaster( mapToSource( proxyIndex ) );
320  }
321  else
322  {
323  const int offset = mInjectNull ? 1 : 0;
324 
325  masterIndex = mFilterModel->mapToMaster( mFilterModel->index( proxyIndex.row() - offset, proxyIndex.column() ) );
326  }
327  }
328  return masterIndex;
329 }
330 
331 QModelIndex QgsFeatureListModel::mapFromMaster( const QModelIndex &masterIndex ) const
332 {
333  QModelIndex proxyIndex;
334 
335  if ( masterIndex.isValid() )
336  {
337  if ( mSortByDisplayExpression )
338  {
339  proxyIndex = mapFromSource( mFilterModel->mapFromMaster( masterIndex ) );
340  }
341  else
342  {
343  const int offset = mInjectNull ? 1 : 0;
344 
345  return createIndex( mFilterModel->mapFromMaster( masterIndex ).row() + offset, 0 );
346  }
347  }
348 
349  return proxyIndex;
350 }
351 
352 QItemSelection QgsFeatureListModel::mapSelectionFromMaster( const QItemSelection &selection ) const
353 {
354  return mapSelectionFromSource( mFilterModel->mapSelectionFromSource( selection ) );
355 }
356 
357 QItemSelection QgsFeatureListModel::mapSelectionToMaster( const QItemSelection &selection ) const
358 {
359  return mFilterModel->mapSelectionToSource( mapSelectionToSource( selection ) );
360 }
361 
362 // Override some methods from QAbstractProxyModel, not that interesting
363 
364 QModelIndex QgsFeatureListModel::mapToSource( const QModelIndex &proxyIndex ) const
365 {
366  QModelIndex sourceIndex;
367 
368  if ( mSortByDisplayExpression )
369  {
370  sourceIndex = QSortFilterProxyModel::mapToSource( proxyIndex );
371  }
372  else
373  {
374  if ( !proxyIndex.isValid() )
375  return QModelIndex();
376 
377  const int offset = mInjectNull ? 1 : 0;
378 
379  sourceIndex = sourceModel()->index( proxyIndex.row() - offset, proxyIndex.column() );
380  }
381 
382  return sourceIndex;
383 }
384 
385 QModelIndex QgsFeatureListModel::mapFromSource( const QModelIndex &sourceIndex ) const
386 {
387  QModelIndex proxyIndex;
388 
389  if ( mSortByDisplayExpression )
390  {
391  proxyIndex = QSortFilterProxyModel::mapFromSource( sourceIndex );
392  }
393  else
394  {
395  if ( sourceIndex.isValid() )
396  proxyIndex = createIndex( sourceIndex.row(), 0 );
397  }
398 
399  return proxyIndex;
400 }
401 
402 QModelIndex QgsFeatureListModel::parent( const QModelIndex &child ) const
403 {
404  Q_UNUSED( child )
405  return QModelIndex();
406 }
407 
408 int QgsFeatureListModel::columnCount( const QModelIndex &parent ) const
409 {
410  Q_UNUSED( parent )
411  return 1;
412 }
413 
414 int QgsFeatureListModel::rowCount( const QModelIndex &parent ) const
415 {
416  Q_UNUSED( parent )
417 
418  const int offset = mInjectNull ? 1 : 0;
419 
420  return sourceModel()->rowCount() + offset;
421 }
422 
424 {
425  return mapFromMaster( masterModel()->idToIndex( fid ) );
426 }
427 
429 {
430  return QModelIndexList() << fidToIndex( fid );
431 }
QgsFeatureListModel::setDisplayExpression
bool setDisplayExpression(const QString &expression)
Definition: qgsfeaturelistmodel.cpp:223
QgsVectorLayer::editBuffer
Q_INVOKABLE QgsVectorLayerEditBuffer * editBuffer()
Buffer with uncommitted editing operations. Only valid after editing has been turned on.
Definition: qgsvectorlayer.h:2014
QgsVectorLayerEditBuffer::isFeatureAttributesChanged
bool isFeatureAttributesChanged(QgsFeatureId id) const
Returns true if the specified feature ID has had an attribute changed but not committed.
Definition: qgsvectorlayereditbuffer.h:146
QgsFeatureListModel::columnCount
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Definition: qgsfeaturelistmodel.cpp:408
QgsConditionalStyle::isValid
bool isValid() const
isValid Check if this rule is valid.
Definition: qgsconditionalstyle.h:252
qgsvectorlayercache.h
QgsVectorLayerCache
This class caches features of a given QgsVectorLayer.
Definition: qgsvectorlayercache.h:46
QgsFeatureListModel::featureByIndex
bool featureByIndex(const QModelIndex &index, QgsFeature &feat)
Definition: qgsfeaturelistmodel.cpp:256
QgsFeatureListModel::mapToSource
QModelIndex mapToSource(const QModelIndex &proxyIndex) const override
Definition: qgsfeaturelistmodel.cpp:364
QgsExpression::referencedColumns
QSet< QString > referencedColumns() const
Gets list of columns referenced by the expression.
Definition: qgsexpression.cpp:221
QgsFeatureListModel::setInjectNull
void setInjectNull(bool injectNull)
If true is specified, a NULL value will be injected.
Definition: qgsfeaturelistmodel.cpp:200
QgsFeatureListModel::mapToMaster
virtual QModelIndex mapToMaster(const QModelIndex &proxyIndex) const
Definition: qgsfeaturelistmodel.cpp:311
QgsFeatureListModel::fidToIndexList
QModelIndexList fidToIndexList(QgsFeatureId fid)
Definition: qgsfeaturelistmodel.cpp:428
qgsfeaturelistmodel.h
QgsConditionalStyle
Conditional styling for a rule.
Definition: qgsconditionalstyle.h:120
QgsFeatureListModel::data
QVariant data(const QModelIndex &index, int role) const override
Definition: qgsfeaturelistmodel.cpp:61
QgsFeatureListModel::rowCount
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Definition: qgsfeaturelistmodel.cpp:414
QgsFeatureListModel::sortByDisplayExpression
bool sortByDisplayExpression() const
Sort this model by its display expression.
Definition: qgsfeaturelistmodel.cpp:293
QgsConditionalStyle::compressStyles
static QgsConditionalStyle compressStyles(const QList< QgsConditionalStyle > &styles)
Compress a list of styles into a single style.
Definition: qgsconditionalstyle.cpp:276
qgsapplication.h
QgsFeatureListModel::FeatureRole
@ FeatureRole
Definition: qgsfeaturelistmodel.h:63
QgsFeatureListModel::FeatureInfo::isEdited
bool isEdited
True if feature has been edited.
Definition: qgsfeaturelistmodel.h:57
QgsFeature::id
QgsFeatureId id
Definition: qgsfeature.h:68
QgsFeatureListModel::mapFromMaster
virtual QModelIndex mapFromMaster(const QModelIndex &sourceIndex) const
Definition: qgsfeaturelistmodel.cpp:331
QgsConditionalStyle::icon
QPixmap icon() const
The icon set for style generated from the set symbol.
Definition: qgsconditionalstyle.h:200
QgsFeatureListModel::onBeginInsertRows
Q_DECL_DEPRECATED void onBeginInsertRows(const QModelIndex &parent, int first, int last)
Does nothing except for calling beginInsertRows()
Definition: qgsfeaturelistmodel.cpp:274
QgsFeatureListModel::idxToFid
QgsFeatureId idxToFid(const QModelIndex &index) const
Returns the feature ID corresponding to an index from the model.
Definition: qgsfeaturelistmodel.cpp:51
QgsFeatureListModel::flags
Qt::ItemFlags flags(const QModelIndex &index) const override
Definition: qgsfeaturelistmodel.cpp:188
QgsFeatureListModel::parserErrorString
QString parserErrorString()
Returns a detailed message about errors while parsing a QgsExpression.
Definition: qgsfeaturelistmodel.cpp:246
QgsExpression::parserErrorString
QString parserErrorString() const
Returns parser error.
Definition: qgsexpression.cpp:211
QgsFeatureListModel::displayExpression
QString displayExpression() const
Definition: qgsfeaturelistmodel.cpp:251
QgsFeatureListModel::onEndInsertRows
Q_DECL_DEPRECATED void onEndInsertRows(const QModelIndex &parent, int first, int last)
Does nothing except for calling endInsertRows()
Definition: qgsfeaturelistmodel.cpp:279
QgsApplication::nullRepresentation
static QString nullRepresentation()
This string is used to represent the value NULL throughout QGIS.
Definition: qgsapplication.cpp:2018
QgsAttributeTableModel::rowToId
QgsFeatureId rowToId(int row) const
Maps row to feature id.
Definition: qgsattributetablemodel.cpp:587
QgsConditionalStyle::validBackgroundColor
bool validBackgroundColor() const
Check if the background color is valid for render.
Definition: qgsconditionalstyle.cpp:243
QgsAttributeTableFilterModel::layer
QgsVectorLayer * layer() const
Returns the layer this filter acts on.
Definition: qgsattributetablefiltermodel.h:160
QgsConditionalStyle::backgroundColor
QColor backgroundColor() const
The background color for style.
Definition: qgsconditionalstyle.h:225
QgsAttributeTableModel
A model backed by a QgsVectorLayerCache which is able to provide feature/attribute information to a Q...
Definition: qgsattributetablemodel.h:49
qgsattributetablefiltermodel.h
QgsAttributeTableFilterModel::layerCache
QgsVectorLayerCache * layerCache() const
Returns the layerCache this filter acts on.
Definition: qgsattributetablefiltermodel.h:167
qgsvectordataprovider.h
QgsAttributeTableFilterModel::masterModel
QgsAttributeTableModel * masterModel() const
Returns the table model this filter is using.
Definition: qgsattributetablefiltermodel.h:174
QgsFeatureListModel::FeatureInfo::isNew
bool isNew
True if feature is a newly added feature.
Definition: qgsfeaturelistmodel.h:54
QgsAttributeTableFilterModel::mapToMaster
QModelIndex mapToMaster(const QModelIndex &proxyIndex) const
Definition: qgsattributetablefiltermodel.h:189
QgsFeatureListModel::FeatureInfoRole
@ FeatureInfoRole
Definition: qgsfeaturelistmodel.h:62
QgsAttributeTableModel::prefetchSortData
void prefetchSortData(const QString &expression, unsigned long cacheIndex=0)
Prefetches the entire data for an expression.
Definition: qgsattributetablemodel.cpp:956
QgsFeatureListModel::fidToIdx
QModelIndex fidToIdx(QgsFeatureId fid) const
Returns the model index corresponding to a feature ID.
Definition: qgsfeaturelistmodel.cpp:56
QgsFeature::attribute
QVariant attribute(const QString &name) const
Lookup attribute value by attribute name.
Definition: qgsfeature.cpp:327
QgsFeatureListModel::parent
QModelIndex parent(const QModelIndex &child) const override
Definition: qgsfeaturelistmodel.cpp:402
qgsattributetablemodel.h
QgsFeatureListModel::FeatureInfo
Definition: qgsfeaturelistmodel.h:44
QgsExpression::prepare
bool prepare(const QgsExpressionContext *context)
Gets the expression ready for evaluation - find out column indexes.
Definition: qgsexpression.cpp:327
QgsConditionalStyle::matchingConditionalStyles
static QList< QgsConditionalStyle > matchingConditionalStyles(const QList< QgsConditionalStyle > &styles, const QVariant &value, QgsExpressionContext &context)
Find and return the matching styles for the value and feature.
Definition: qgsconditionalstyle.cpp:253
QgsVectorLayerCache::featureAtId
bool featureAtId(QgsFeatureId featureId, QgsFeature &feature, bool skipCache=false)
Gets the feature at the given feature id.
Definition: qgsvectorlayercache.cpp:147
QgsFeatureListModel::mapSelectionToMaster
virtual QItemSelection mapSelectionToMaster(const QItemSelection &selection) const
Definition: qgsfeaturelistmodel.cpp:357
QgsExpression::evaluate
QVariant evaluate()
Evaluate the feature and return the result.
Definition: qgsexpression.cpp:350
QgsConditionalStyle::font
QFont font() const
The font for the style.
Definition: qgsconditionalstyle.h:238
QgsFeatureListModel::masterModel
QgsAttributeTableModel * masterModel()
Definition: qgsfeaturelistmodel.cpp:218
QgsAttributeTableFilterModel
Definition: qgsattributetablefiltermodel.h:36
QgsConditionalLayerStyles::rowStyles
QgsConditionalStyles rowStyles() const
Returns a list of row styles associated with the layer.
Definition: qgsconditionalstyle.cpp:28
QgsVectorLayerEditBuffer::isFeatureAdded
bool isFeatureAdded(QgsFeatureId id) const
Returns true if the specified feature ID has been added but not committed.
Definition: qgsvectorlayereditbuffer.h:132
QgsFeatureListModel::injectNull
bool injectNull()
Returns the current state of null value injection.
Definition: qgsfeaturelistmodel.cpp:213
QgsAttributeTableFilterModel::mapFromMaster
QModelIndex mapFromMaster(const QModelIndex &sourceIndex) const
Definition: qgsattributetablefiltermodel.h:191
QgsFeatureListModel::layerCache
QgsVectorLayerCache * layerCache()
Returns the vector layer cache which is being used to populate the model.
Definition: qgsfeaturelistmodel.cpp:46
QgsFeatureListModel::onEndRemoveRows
Q_DECL_DEPRECATED void onEndRemoveRows(const QModelIndex &parent, int first, int last)
Does nothing except for calling endRemoveRows()
Definition: qgsfeaturelistmodel.cpp:266
QgsVectorLayerEditBuffer
Definition: qgsvectorlayereditbuffer.h:37
QgsConditionalStyle::textColor
QColor textColor() const
The text color set for style.
Definition: qgsconditionalstyle.h:212
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:391
QgsFeatureListModel::onBeginRemoveRows
Q_DECL_DEPRECATED void onBeginRemoveRows(const QModelIndex &parent, int first, int last)
Does nothing except for calling beginRemoveRows()
Definition: qgsfeaturelistmodel.cpp:261
QgsVectorLayer::conditionalStyles
QgsConditionalLayerStyles * conditionalStyles() const
Returns the conditional styles that are set for this layer.
Definition: qgsvectorlayer.cpp:1047
QgsFeatureListModel::QgsFeatureListModel
QgsFeatureListModel(QgsAttributeTableFilterModel *sourceModel, QObject *parent=nullptr)
Constructor for QgsFeatureListModel.
Definition: qgsfeaturelistmodel.cpp:27
QgsConditionalLayerStyles::fieldStyles
QList< QgsConditionalStyle > fieldStyles(const QString &fieldName) const
Returns the conditional styles set for the field with matching fieldName.
Definition: qgsconditionalstyle.cpp:51
qgsexception.h
QgsFeature
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition: qgsfeature.h:55
QgsFeatureListModel::setSortByDisplayExpression
void setSortByDisplayExpression(bool sortByDisplayExpression, Qt::SortOrder order=Qt::AscendingOrder)
Sort this model by its display expression.
Definition: qgsfeaturelistmodel.cpp:298
QgsExpression::isField
bool isField() const
Checks whether an expression consists only of a single field reference.
Definition: qgsexpression.cpp:1360
QgsExpression::hasParserError
bool hasParserError() const
Returns true if an error occurred when parsing the input expression.
Definition: qgsexpression.cpp:206
QgsAttributeTableModel::SortRole
@ SortRole
Role used for sorting start here.
Definition: qgsattributetablemodel.h:60
QgsFeatureListModel::mapSelectionFromMaster
virtual QItemSelection mapSelectionFromMaster(const QItemSelection &selection) const
Definition: qgsfeaturelistmodel.cpp:352
QgsVectorLayer::createExpressionContext
QgsExpressionContext createExpressionContext() const FINAL
This method needs to be reimplemented in all classes which implement this interface and return an exp...
Definition: qgsvectorlayer.cpp:5203
QgsAttributeTableModel::idToIndex
QModelIndex idToIndex(QgsFeatureId id) const
Definition: qgsattributetablemodel.cpp:567
QgsExpression
Class for parsing and evaluation of expressions (formerly called "search strings")....
Definition: qgsexpression.h:102
QgsConditionalStyle::validTextColor
bool validTextColor() const
Check if the text color is valid for render.
Definition: qgsconditionalstyle.cpp:248
QgsExpression::expression
QString expression() const
Returns the original, unmodified expression string.
Definition: qgsexpression.cpp:60
QgsConditionalLayerStyles::changed
void changed()
Emitted when the conditional styles are changed.
QgsFeatureListModel::fidToIndex
QModelIndex fidToIndex(QgsFeatureId fid) override
Definition: qgsfeaturelistmodel.cpp:423
QgsFeatureListModel::mapFromSource
QModelIndex mapFromSource(const QModelIndex &sourceIndex) const override
Definition: qgsfeaturelistmodel.cpp:385
qgsvectorlayereditbuffer.h
QgsFeatureId
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
Definition: qgsfeatureid.h:28
QgsExpressionContext::setFeature
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
Definition: qgsexpressioncontext.cpp:525
QgsFeatureListModel::setSourceModel
virtual void setSourceModel(QgsAttributeTableFilterModel *sourceModel)
Definition: qgsfeaturelistmodel.cpp:33