QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgsfeaturepickermodelbase.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsfeaturepickermodelbase.cpp - QgsFeaturePickerModelBase
3  ---------------------
4  begin : 10.3.2017
5  copyright : (C) 2017 by Matthias Kuhn
6  email : [email protected]
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 
18 
19 #include "qgsvectorlayer.h"
20 #include "qgsconditionalstyle.h"
21 #include "qgsapplication.h"
22 #include "qgssettings.h"
23 
24 
26  : QAbstractItemModel( parent )
27 {
28  mReloadTimer.setInterval( 100 );
29  mReloadTimer.setSingleShot( true );
30  connect( &mReloadTimer, &QTimer::timeout, this, &QgsFeaturePickerModelBase::scheduledReload );
31 }
32 
33 
35 {
36  if ( mGatherer )
37  connect( mGatherer, &QgsFeatureExpressionValuesGatherer::finished, mGatherer, &QgsFeatureExpressionValuesGatherer::deleteLater );
38 }
39 
40 
42 {
43  return mSourceLayer;
44 }
45 
46 
48 {
49  if ( mSourceLayer == sourceLayer )
50  return;
51 
52  mSourceLayer = sourceLayer;
53  mExpressionContext = sourceLayer->createExpressionContext();
54  reload();
55  emit sourceLayerChanged();
56 
58 }
59 
60 
62 {
63  return mDisplayExpression.expression();
64 }
65 
66 
67 void QgsFeaturePickerModelBase::setDisplayExpression( const QString &displayExpression )
68 {
69  if ( mDisplayExpression.expression() == displayExpression )
70  return;
71 
72  mDisplayExpression = QgsExpression( displayExpression );
73  reload();
75 }
76 
77 
79 {
80  return mFilterValue;
81 }
82 
83 
84 void QgsFeaturePickerModelBase::setFilterValue( const QString &filterValue )
85 {
86  if ( mFilterValue == filterValue )
87  return;
88 
89  mFilterValue = filterValue;
90  reload();
91  emit filterValueChanged();
92 }
93 
94 
96 {
97  return mFilterExpression;
98 }
99 
100 
101 void QgsFeaturePickerModelBase::setFilterExpression( const QString &filterExpression )
102 {
103  if ( mFilterExpression == filterExpression )
104  return;
105 
106  mFilterExpression = filterExpression;
107  reload();
109 }
110 
111 
113 {
114  return mGatherer;
115 }
116 
118 {
119  return mExtraIdentifierValue;
120 }
121 
122 
123 QModelIndex QgsFeaturePickerModelBase::index( int row, int column, const QModelIndex &parent ) const
124 {
125  Q_UNUSED( parent )
126  return createIndex( row, column, nullptr );
127 }
128 
129 
130 QModelIndex QgsFeaturePickerModelBase::parent( const QModelIndex &child ) const
131 {
132  Q_UNUSED( child )
133  return QModelIndex();
134 }
135 
136 
137 int QgsFeaturePickerModelBase::rowCount( const QModelIndex &parent ) const
138 {
139  Q_UNUSED( parent )
140  return mEntries.size();
141 }
142 
143 
144 
145 QVariant QgsFeaturePickerModelBase::data( const QModelIndex &index, int role ) const
146 {
147  if ( !index.isValid() )
148  return QVariant();
149 
150  switch ( role )
151  {
152  case Qt::DisplayRole:
153  case Qt::EditRole:
154  case ValueRole:
155  return mEntries.value( index.row() ).value;
156 
157  case FeatureIdRole:
158  return mEntries.value( index.row() ).featureId;
159 
160  case FeatureRole:
161  return mEntries.value( index.row() ).feature;
162 
163  case IdentifierValueRole:
164  {
165  const QVariantList values = mEntries.value( index.row() ).identifierFields;
166  return values.value( 0 );
167  }
168 
170  return mEntries.value( index.row() ).identifierFields;
171 
172 #if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
173  case Qt::BackgroundColorRole:
174  case Qt::TextColorRole:
175 #else
176  case Qt::BackgroundRole:
177  case Qt::ForegroundRole:
178 #endif
179  case Qt::DecorationRole:
180  case Qt::FontRole:
181  {
182  bool isNull = identifierIsNull( entryIdentifier( mEntries.value( index.row() ) ) );
183  if ( isNull )
184  {
185  // Representation for NULL value
186 #if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
187  if ( role == Qt::TextColorRole )
188 #else
189  if ( role == Qt::ForegroundRole )
190 #endif
191  {
192  return QBrush( QColor( Qt::gray ) );
193  }
194  if ( role == Qt::FontRole )
195  {
196  QFont font = QFont();
197  if ( index.row() == mExtraValueIndex )
198  font.setBold( true );
199  else
200  font.setItalic( true );
201  return font;
202  }
203  }
204  else
205  {
206  // Respect conditional style
207  const QgsConditionalStyle style = featureStyle( mEntries.value( index.row() ).feature );
208 
209  if ( style.isValid() )
210  {
211 #if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
212  if ( role == Qt::BackgroundColorRole && style.validBackgroundColor() )
213 #else
214  if ( role == Qt::BackgroundRole && style.validBackgroundColor() )
215 #endif
216  return style.backgroundColor();
217 #if QT_VERSION < QT_VERSION_CHECK(5, 13, 0)
218  if ( role == Qt::TextColorRole && style.validTextColor() )
219 #else
220  if ( role == Qt::ForegroundRole && style.validTextColor() )
221 #endif
222  return style.textColor();
223  if ( role == Qt::DecorationRole )
224  return style.icon();
225  if ( role == Qt::FontRole )
226  return style.font();
227  }
228  }
229  break;
230  }
231  }
232 
233  return QVariant();
234 }
235 
236 
237 void QgsFeaturePickerModelBase::updateCompleter()
238 {
239  emit beginUpdate();
240 
241  QgsFeatureExpressionValuesGatherer *gatherer = qobject_cast<QgsFeatureExpressionValuesGatherer *>( sender() );
242  if ( gatherer->wasCanceled() )
243  {
244  delete gatherer;
245  return;
246  }
247 
248  QVector<QgsFeatureExpressionValuesGatherer::Entry> entries = mGatherer->entries();
249 
250  if ( mExtraValueIndex == -1 )
251  {
253  }
254 
255  // Only reloading the current entry?
256  bool reloadCurrentFeatureOnly = mGatherer->data().toBool();
257  if ( reloadCurrentFeatureOnly )
258  {
259  if ( !entries.isEmpty() )
260  {
261  mEntries.replace( mExtraValueIndex, entries.at( 0 ) );
262  emit dataChanged( index( mExtraValueIndex, 0, QModelIndex() ), index( mExtraValueIndex, 0, QModelIndex() ) );
263  mShouldReloadCurrentFeature = false;
264  setExtraValueDoesNotExist( false );
265  }
266  else
267  {
268  setExtraValueDoesNotExist( true );
269  }
270 
271  mKeepCurrentEntry = true;
272  mShouldReloadCurrentFeature = false;
273 
274  if ( mFilterValue.isEmpty() )
275  reload();
276  }
277  else
278  {
279  // We got strings for a filter selection
280  std::sort( entries.begin(), entries.end(), []( const QgsFeatureExpressionValuesGatherer::Entry & a, const QgsFeatureExpressionValuesGatherer::Entry & b ) { return a.value.localeAwareCompare( b.value ) < 0; } );
281 
282  if ( mAllowNull )
283  {
284  entries.prepend( QgsFeatureExpressionValuesGatherer::nullEntry( mSourceLayer ) );
285  }
286 
287  const int newEntriesSize = entries.size();
288 
289  // fixed entry is either NULL or extra value
290  const int nbFixedEntry = ( mKeepCurrentEntry ? 1 : 0 ) + ( mAllowNull ? 1 : 0 );
291 
292  // Find the index of the current entry in the new list
293  int currentEntryInNewList = -1;
294  if ( mExtraValueIndex != -1 && mExtraValueIndex < mEntries.count() )
295  {
296  for ( int i = 0; i < newEntriesSize; ++i )
297  {
298  if ( compareEntries( entries.at( i ), mEntries.at( mExtraValueIndex ) ) )
299  {
300  mEntries.replace( mExtraValueIndex, entries.at( i ) );
301  currentEntryInNewList = i;
302  setExtraValueDoesNotExist( false );
303  break;
304  }
305  }
306  }
307 
308  int firstRow = 0;
309 
310  // Move current entry to the first position if this is a fixed entry or because
311  // the entry exists in the new list
312  if ( mExtraValueIndex > -1 && ( mExtraValueIndex < nbFixedEntry || currentEntryInNewList != -1 ) )
313  {
314  if ( mExtraValueIndex != 0 )
315  {
316  beginMoveRows( QModelIndex(), mExtraValueIndex, mExtraValueIndex, QModelIndex(), 0 );
317  mEntries.move( mExtraValueIndex, 0 );
318  endMoveRows();
319  }
320  firstRow = 1;
321  }
322 
323  // Remove all entries (except for extra entry if existent)
324  beginRemoveRows( QModelIndex(), firstRow, mEntries.size() - firstRow );
325  mEntries.remove( firstRow, mEntries.size() - firstRow );
326 
327  // if we remove all rows before endRemoveRows, setExtraIdentifierValuesUnguarded will be called
328  // and a null value will be added to mEntries, so we block setExtraIdentifierValuesUnguarded call
329 
330  mIsSettingExtraIdentifierValue = true;
331  endRemoveRows();
332  mIsSettingExtraIdentifierValue = false;
333 
334  if ( currentEntryInNewList == -1 )
335  {
336  beginInsertRows( QModelIndex(), firstRow, entries.size() + 1 );
337  mEntries += entries;
338  endInsertRows();
339 
340  // if all entries have been cleaned (firstRow == 0)
341  // and there is a value in entries, prefer this value over NULL
342  // else chose the first one (the previous one)
343  setExtraIdentifierValueIndex( firstRow == 0 && mAllowNull && !entries.isEmpty() ? 1 : 0, firstRow == 0 );
344  }
345  else
346  {
347  if ( currentEntryInNewList != 0 )
348  {
349  beginInsertRows( QModelIndex(), 0, currentEntryInNewList - 1 );
350  mEntries = entries.mid( 0, currentEntryInNewList ) + mEntries;
351  endInsertRows();
352  }
353  else
354  {
355  mEntries.replace( 0, entries.at( 0 ) );
356  }
357 
358  // don't notify for a change if it's a fixed entry
359  if ( currentEntryInNewList >= nbFixedEntry )
360  {
361  emit dataChanged( index( currentEntryInNewList, 0, QModelIndex() ), index( currentEntryInNewList, 0, QModelIndex() ) );
362  }
363 
364  beginInsertRows( QModelIndex(), currentEntryInNewList + 1, newEntriesSize - currentEntryInNewList - 1 );
365  mEntries += entries.mid( currentEntryInNewList + 1 );
366  endInsertRows();
367  setExtraIdentifierValueIndex( currentEntryInNewList );
368  }
369 
370  emit filterJobCompleted();
371 
372  mKeepCurrentEntry = false;
373  }
374  emit endUpdate();
375 
376  // scheduleReload and updateCompleter lives in the same thread so if the gatherer hasn't been stopped
377  // (checked before), mGatherer still references the current gatherer
378  Q_ASSERT( gatherer == mGatherer );
379  delete mGatherer;
380  mGatherer = nullptr;
381  emit isLoadingChanged();
382 }
383 
384 
385 void QgsFeaturePickerModelBase::scheduledReload()
386 {
387  if ( !mSourceLayer )
388  return;
389 
390  bool wasLoading = false;
391 
392  if ( mGatherer )
393  {
394  mGatherer->stop();
395  wasLoading = true;
396  }
397 
398  QgsFeatureRequest request;
399 
400  if ( mShouldReloadCurrentFeature )
401  {
403  }
404  else
405  {
406  QString filterClause;
407 
408  if ( mFilterValue.isEmpty() && !mFilterExpression.isEmpty() )
409  filterClause = mFilterExpression;
410  else if ( mFilterExpression.isEmpty() && !mFilterValue.isEmpty() )
411  filterClause = QStringLiteral( "(%1) ILIKE '%%2%'" ).arg( mDisplayExpression, mFilterValue );
412  else if ( !mFilterExpression.isEmpty() && !mFilterValue.isEmpty() )
413  filterClause = QStringLiteral( "(%1) AND ((%2) ILIKE '%%3%')" ).arg( mFilterExpression, mDisplayExpression, mFilterValue );
414 
415  if ( !filterClause.isEmpty() )
416  request.setFilterExpression( filterClause );
417  }
418  QSet<QString> attributes = requestedAttributes();
419  if ( !attributes.isEmpty() )
420  {
421  if ( auto *lFilterExpression = request.filterExpression() )
422  attributes += lFilterExpression->referencedColumns();
423  attributes += requestedAttributesForStyle();
424 
425  request.setSubsetOfAttributes( attributes, mSourceLayer->fields() );
426  }
427 
428  if ( !mFetchGeometry )
430  if ( mFetchLimit > 0 )
431  request.setLimit( mFetchLimit );
432 
433  mGatherer = createValuesGatherer( request );
434  mGatherer->setData( mShouldReloadCurrentFeature );
435  connect( mGatherer, &QgsFeatureExpressionValuesGatherer::finished, this, &QgsFeaturePickerModelBase::updateCompleter );
436 
437  mGatherer->start();
438  if ( !wasLoading )
439  emit isLoadingChanged();
440 }
441 
442 
443 QSet<QString> QgsFeaturePickerModelBase::requestedAttributesForStyle() const
444 {
445  QSet<QString> requestedAttrs;
446 
447  const auto rowStyles = mSourceLayer->conditionalStyles()->rowStyles();
448 
449  for ( const QgsConditionalStyle &style : rowStyles )
450  {
451  QgsExpression exp( style.rule() );
452  requestedAttrs += exp.referencedColumns();
453  }
454 
455  if ( mDisplayExpression.isField() )
456  {
457  QString fieldName = *mDisplayExpression.referencedColumns().constBegin();
458  const auto constFieldStyles = mSourceLayer->conditionalStyles()->fieldStyles( fieldName );
459  for ( const QgsConditionalStyle &style : constFieldStyles )
460  {
461  QgsExpression exp( style.rule() );
462  requestedAttrs += exp.referencedColumns();
463  }
464  }
465 
466  return requestedAttrs;
467 }
468 
469 
470 void QgsFeaturePickerModelBase::setExtraIdentifierValueIndex( int index, bool force )
471 {
472  if ( mExtraValueIndex == index && !force )
473  return;
474 
477 }
478 
479 
480 void QgsFeaturePickerModelBase::reloadCurrentFeature()
481 {
482  mShouldReloadCurrentFeature = true;
483  mReloadTimer.start();
484 }
485 
486 
487 void QgsFeaturePickerModelBase::setExtraIdentifierValueUnguarded( const QVariant &identifierValue )
488 {
489  const QVector<QgsFeatureExpressionValuesGatherer::Entry> entries = mEntries;
490 
491  int index = 0;
492  for ( const QgsFeatureExpressionValuesGatherer::Entry &entry : entries )
493  {
494  if ( compareEntries( entry, createEntry( identifierValue ) ) )
495  {
496  setExtraIdentifierValueIndex( index );
497  break;
498  }
499 
500  index++;
501  }
502 
503  // Value not found in current entries
504  if ( mExtraValueIndex != index )
505  {
506  bool isNull = identifierIsNull( identifierValue );
507  if ( !isNull || mAllowNull )
508  {
509  beginInsertRows( QModelIndex(), 0, 0 );
510  if ( !isNull )
511  {
512  mEntries.prepend( createEntry( identifierValue ) );
513  reloadCurrentFeature();
514  }
515  else
516  {
517  mEntries.prepend( QgsFeatureExpressionValuesGatherer::nullEntry( mSourceLayer ) );
518  }
519  endInsertRows();
520 
521  setExtraIdentifierValueIndex( 0, true );
522  }
523  }
524 }
525 
526 
527 QgsConditionalStyle QgsFeaturePickerModelBase::featureStyle( const QgsFeature &feature ) const
528 {
529  if ( !mSourceLayer )
530  return QgsConditionalStyle();
531 
532  QgsVectorLayer *layer = mSourceLayer;
533  QgsFeatureId fid = feature.id();
534  mExpressionContext.setFeature( feature );
535 
536  auto styles = QgsConditionalStyle::matchingConditionalStyles( layer->conditionalStyles()->rowStyles(), QVariant(), mExpressionContext );
537 
538  if ( mDisplayExpression.referencedColumns().count() == 1 )
539  {
540  // Style specific for this field
541  QString fieldName = *mDisplayExpression.referencedColumns().constBegin();
542  const auto allStyles = layer->conditionalStyles()->fieldStyles( fieldName );
543  const auto matchingFieldStyles = QgsConditionalStyle::matchingConditionalStyles( allStyles, feature.attribute( fieldName ), mExpressionContext );
544 
545  styles += matchingFieldStyles;
546  }
547 
548  QgsConditionalStyle style;
549  style = QgsConditionalStyle::compressStyles( styles );
550  mEntryStylesMap.insert( fid, style );
551 
552  return style;
553 }
554 
555 
557 {
558  return mAllowNull;
559 }
560 
561 
563 {
564  if ( mAllowNull == allowNull )
565  return;
566 
567  mAllowNull = allowNull;
568  emit allowNullChanged();
569 
570  reload();
571 }
572 
574 {
575  return mFetchGeometry;
576 }
577 
579 {
580  if ( mFetchGeometry == fetchGeometry )
581  return;
582 
583  mFetchGeometry = fetchGeometry;
584  reload();
585 }
586 
588 {
589  return mFetchLimit;
590 }
591 
593 {
594  if ( fetchLimit == mFetchLimit )
595  return;
596 
597  mFetchLimit = fetchLimit;
598  emit fetchLimitChanged();
599 }
600 
601 
603 {
604  return mExtraValueDoesNotExist;
605 }
606 
607 
608 void QgsFeaturePickerModelBase::setExtraValueDoesNotExist( bool extraValueDoesNotExist )
609 {
610  if ( mExtraValueDoesNotExist == extraValueDoesNotExist )
611  return;
612 
613  mExtraValueDoesNotExist = extraValueDoesNotExist;
615 }
616 
617 
619 {
620  return mExtraValueIndex;
621 }
622 
623 
624 void QgsFeaturePickerModelBase::reload()
625 {
626  mReloadTimer.start();
627 }
628 
629 
630 void QgsFeaturePickerModelBase::setExtraIdentifierValue( const QVariant &extraIdentifierValue )
631 {
633  return;
634 
635  if ( mIsSettingExtraIdentifierValue )
636  return;
637 
638  mIsSettingExtraIdentifierValue = true;
639 
641 
643 
644  mIsSettingExtraIdentifierValue = false;
645 
647 }
648 
QgsFeatureRequest::NoGeometry
@ NoGeometry
Geometry is not required. It may still be returned if e.g. required for a filter condition.
Definition: qgsfeaturerequest.h:81
QgsFeaturePickerModelBase::IdentifierValueRole
@ IdentifierValueRole
Definition: qgsfeaturepickermodelbase.h:50
QgsFeaturePickerModelBase::nullIdentifier
virtual QVariant nullIdentifier() const =0
Returns a null identifier.
qgsconditionalstyle.h
QgsFeature::id
Q_GADGET QgsFeatureId id
Definition: qgsfeature.h:64
QgsFeaturePickerModelBase::isLoading
bool isLoading() const
Indicator if the model is currently performing any feature iteration in the background.
Definition: qgsfeaturepickermodelbase.cpp:112
QgsConditionalStyle::isValid
bool isValid() const
isValid Check if this rule is valid.
Definition: qgsconditionalstyle.h:243
QgsFeaturePickerModelBase::filterValue
QString filterValue
Definition: qgsfeaturepickermodelbase.h:36
QgsFeaturePickerModelBase::extraIdentifierValueIndex
int extraIdentifierValueIndex
Definition: qgsfeaturepickermodelbase.h:41
QgsFeaturePickerModelBase::displayExpressionChanged
void displayExpressionChanged()
The display expression will be used for.
QgsFeaturePickerModelBase::compareEntries
virtual bool compareEntries(const QgsFeatureExpressionValuesGatherer::Entry &a, const QgsFeatureExpressionValuesGatherer::Entry &b) const =0
Returns true if the 2 entries refers to the same feature.
QgsFeaturePickerModelBase::filterExpression
QString filterExpression
Definition: qgsfeaturepickermodelbase.h:37
QgsExpression::referencedColumns
QSet< QString > referencedColumns() const
Gets list of columns referenced by the expression.
Definition: qgsexpression.cpp:217
QgsFeaturePickerModelBase::IdentifierValuesRole
@ IdentifierValuesRole
Used to retrieve the identifierValues (primary keys) of a feature.
Definition: qgsfeaturepickermodelbase.h:51
QgsFeaturePickerModelBase::setExtraIdentifierValue
void setExtraIdentifierValue(const QVariant &extraIdentifierValue)
Allows specifying one value that does not need to match the filter criteria but will still be availab...
Definition: qgsfeaturepickermodelbase.cpp:630
qgsfeaturepickermodelbase.h
QgsFeaturePickerModelBase::identifierIsNull
virtual bool identifierIsNull(const QVariant &identifier) const =0
Returns true if the entry is null The identifier can be either the feature ID or the list of identifi...
QgsFeatureRequest::setSubsetOfAttributes
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
Definition: qgsfeaturerequest.cpp:185
QgsFeaturePickerModelBase::setExtraIdentifierValueUnguarded
void setExtraIdentifierValueUnguarded(const QVariant &identifierValue)
This will set the identifier value to be set in the model even if it doesn't exist currently in the d...
Definition: qgsfeaturepickermodelbase.cpp:487
QgsFeaturePickerModelBase::ValueRole
@ ValueRole
Used to retrieve the displayExpression of a feature.
Definition: qgsfeaturepickermodelbase.h:52
QgsFeaturePickerModelBase::~QgsFeaturePickerModelBase
~QgsFeaturePickerModelBase() override
Definition: qgsfeaturepickermodelbase.cpp:34
QgsConditionalStyle
Conditional styling for a rule.
Definition: qgsconditionalstyle.h:113
QgsFeaturePickerModelBase::filterJobCompleted
void filterJobCompleted()
Indicates that a filter job has been completed and new data may be available.
QgsFeaturePickerModelBase::mExtraIdentifierValue
QVariant mExtraIdentifierValue
The current identifier value.
Definition: qgsfeaturepickermodelbase.h:314
QgsConditionalStyle::compressStyles
static QgsConditionalStyle compressStyles(const QList< QgsConditionalStyle > &styles)
Compress a list of styles into a single style.
Definition: qgsconditionalstyle.cpp:261
QgsFeaturePickerModelBase::endUpdate
void endUpdate()
Notification that the model change is finished.
QgsFeaturePickerModelBase::QgsFeaturePickerModelBase
QgsFeaturePickerModelBase(QObject *parent=nullptr)
Create a new QgsFeaturePickerModelBase, optionally specifying a parent.
Definition: qgsfeaturepickermodelbase.cpp:25
QgsFeaturePickerModelBase::isLoadingChanged
void isLoadingChanged()
Indicator if the model is currently performing any feature iteration in the background.
QgsFeaturePickerModelBase::fetchGeometry
bool fetchGeometry
Definition: qgsfeaturepickermodelbase.h:39
QgsFeatureRequest::setFilterExpression
QgsFeatureRequest & setFilterExpression(const QString &expression)
Set the filter expression.
Definition: qgsfeaturerequest.cpp:124
qgsapplication.h
QgsFeaturePickerModelBase::allowNull
bool allowNull
Definition: qgsfeaturepickermodelbase.h:38
QgsVectorLayer::fields
QgsFields fields() const FINAL
Returns the list of fields of this layer.
Definition: qgsvectorlayer.cpp:3283
QgsFeatureRequest
This class wraps a request for features to a vector layer (or directly its vector data provider).
Definition: qgsfeaturerequest.h:76
QgsFeaturePickerModelBase::createEntry
virtual QgsFeatureExpressionValuesGatherer::Entry createEntry(const QVariant &identifier) const =0
Creates an entry with just the identifier so the feature can be retrieved in a next iteration.
QgsConditionalStyle::icon
QPixmap icon() const
The icon set for style generated from the set symbol.
Definition: qgsconditionalstyle.h:191
QgsFeaturePickerModelBase::sourceLayer
QgsVectorLayer * sourceLayer
Definition: qgsfeaturepickermodelbase.h:34
QgsFeaturePickerModelBase::mEntries
QVector< QgsFeatureExpressionValuesGatherer::Entry > mEntries
Definition: qgsfeaturepickermodelbase.h:310
QgsFeaturePickerModelBase::extraValueDoesNotExist
bool extraValueDoesNotExist() const
Flag indicating that the extraIdentifierValue does not exist in the data.
Definition: qgsfeaturepickermodelbase.cpp:602
qgsfeatureexpressionvaluesgatherer.h
QgsFeaturePickerModelBase::data
QVariant data(const QModelIndex &index, int role) const override
Definition: qgsfeaturepickermodelbase.cpp:145
QgsFeaturePickerModelBase::extraIdentifierValueIndexChanged
void extraIdentifierValueIndexChanged(int index)
The index at which the extra identifier value is available within the model.
QgsConditionalStyle::validBackgroundColor
bool validBackgroundColor() const
Check if the background color is valid for render.
Definition: qgsconditionalstyle.cpp:228
QgsConditionalStyle::backgroundColor
QColor backgroundColor() const
The background color for style.
Definition: qgsconditionalstyle.h:216
QgsFeatureRequest::filterExpression
QgsExpression * filterExpression() const
Returns the filter expression if set.
Definition: qgsfeaturerequest.h:412
QgsFeaturePickerModelBase::extraValueDoesNotExistChanged
void extraValueDoesNotExistChanged()
Flag indicating that the extraIdentifierValue does not exist in the data.
QgsFeaturePickerModelBase::extraIdentifierValue
QVariant extraIdentifierValue() const
Allows specifying one value that does not need to match the filter criteria but will still be availab...
Definition: qgsfeaturepickermodelbase.cpp:117
QgsFeaturePickerModelBase::fetchLimitChanged
void fetchLimitChanged()
Emitted when the fetching limit for the feature request changes.
QgsFeaturePickerModelBase::index
QModelIndex index(int row, int column, const QModelIndex &parent) const override
Definition: qgsfeaturepickermodelbase.cpp:123
QgsFeaturePickerModelBase::requestedAttributes
virtual QSet< QString > requestedAttributes() const
Returns the attributes to be fetched in the request.
Definition: qgsfeaturepickermodelbase.h:287
QgsFeaturePickerModelBase::displayExpression
QString displayExpression
Definition: qgsfeaturepickermodelbase.h:35
QgsFeature::attribute
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
Definition: qgsfeature.cpp:264
QgsFeaturePickerModelBase::requestToReloadCurrentFeature
virtual void requestToReloadCurrentFeature(QgsFeatureRequest &request)=0
Update the request to match the current feature to be reloaded.
QgsFeaturePickerModelBase::rowCount
int rowCount(const QModelIndex &parent) const override
Definition: qgsfeaturepickermodelbase.cpp:137
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:238
QgsFeaturePickerModelBase::setAllowNull
void setAllowNull(bool allowNull)
Add a NULL entry to the list.
Definition: qgsfeaturepickermodelbase.cpp:562
QgsConditionalStyle::font
QFont font() const
The font for the style.
Definition: qgsconditionalstyle.h:229
qgsvectorlayer.h
QgsFeaturePickerModelBase::FeatureRole
@ FeatureRole
Used to retrieve the feature, it might be incomplete if the request doesn't fetch all attributes or g...
Definition: qgsfeaturepickermodelbase.h:53
QgsConditionalLayerStyles::rowStyles
QgsConditionalStyles rowStyles() const
Returns a list of row styles associated with the layer.
Definition: qgsconditionalstyle.cpp:27
QgsFeaturePickerModelBase::setDisplayExpression
void setDisplayExpression(const QString &displayExpression)
The display expression will be used for.
Definition: qgsfeaturepickermodelbase.cpp:67
QgsFeaturePickerModelBase::entryIdentifier
virtual QVariant entryIdentifier(const QgsFeatureExpressionValuesGatherer::Entry &entry) const =0
Returns the identifier of the given entry.
QgsFeaturePickerModelBase::fetchLimit
int fetchLimit
Definition: qgsfeaturepickermodelbase.h:40
QgsConditionalStyle::textColor
QColor textColor() const
The text color set for style.
Definition: qgsconditionalstyle.h:203
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:387
QgsFeaturePickerModelBase::allowNullChanged
void allowNullChanged()
Add a NULL entry to the list.
QgsFeatureRequest::setLimit
QgsFeatureRequest & setLimit(long limit)
Set the maximum number of features to request.
Definition: qgsfeaturerequest.cpp:173
qgssettings.h
QgsFeaturePickerModelBase::createValuesGatherer
virtual QgsFeatureExpressionValuesGatherer * createValuesGatherer(const QgsFeatureRequest &request) const =0
Creates the value gatherer.
QgsVectorLayer::conditionalStyles
QgsConditionalLayerStyles * conditionalStyles() const
Returns the conditional styles that are set for this layer.
Definition: qgsvectorlayer.cpp:988
QgsFeaturePickerModelBase::extraIdentifierValueChanged
void extraIdentifierValueChanged()
Allows specifying one value that does not need to match the filter criteria but will still be availab...
QgsConditionalLayerStyles::fieldStyles
QList< QgsConditionalStyle > fieldStyles(const QString &fieldName) const
Returns the conditional styles set for the field with matching fieldName.
Definition: qgsconditionalstyle.cpp:50
QgsFeature
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:56
QgsExpression::isField
bool isField() const
Checks whether an expression consists only of a single field reference.
Definition: qgsexpression.cpp:1096
QgsFeaturePickerModelBase::mExtraValueIndex
int mExtraValueIndex
The current index.
Definition: qgsfeaturepickermodelbase.h:317
QgsFeaturePickerModelBase::setFetchLimit
void setFetchLimit(int fetchLimit)
Defines the feature request fetch limit If set to 0, no limit is applied when fetching.
Definition: qgsfeaturepickermodelbase.cpp:592
QgsFeaturePickerModelBase::setFetchGeometry
void setFetchGeometry(bool fetchGeometry)
Defines if the geometry will be fetched.
Definition: qgsfeaturepickermodelbase.cpp:578
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:4952
QgsExpression
Class for parsing and evaluation of expressions (formerly called "search strings").
Definition: qgsexpression.h:105
QgsFeaturePickerModelBase::setSourceLayer
void setSourceLayer(QgsVectorLayer *sourceLayer)
The source layer from which features will be fetched.
Definition: qgsfeaturepickermodelbase.cpp:47
QgsVectorLayer::displayExpression
QString displayExpression
Definition: qgsvectorlayer.h:391
QgsFeaturePickerModelBase::parent
QModelIndex parent(const QModelIndex &child) const override
Definition: qgsfeaturepickermodelbase.cpp:130
QgsFeaturePickerModelBase::FeatureIdRole
@ FeatureIdRole
Used to retrieve the id of a feature.
Definition: qgsfeaturepickermodelbase.h:54
QgsConditionalStyle::validTextColor
bool validTextColor() const
Check if the text color is valid for render.
Definition: qgsconditionalstyle.cpp:233
QgsFeaturePickerModelBase::setFilterExpression
void setFilterExpression(const QString &filterExpression)
An additional filter expression to apply, next to the filterValue.
Definition: qgsfeaturepickermodelbase.cpp:101
QgsFeatureRequest::setFlags
QgsFeatureRequest & setFlags(QgsFeatureRequest::Flags flags)
Sets flags that affect how features will be fetched.
Definition: qgsfeaturerequest.cpp:179
QgsFeaturePickerModelBase::sourceLayerChanged
void sourceLayerChanged()
The source layer from which features will be fetched.
QgsExpression::expression
QString expression() const
Returns the original, unmodified expression string.
Definition: qgsexpression.cpp:57
QgsFeaturePickerModelBase::setFilterValue
void setFilterValue(const QString &filterValue)
This value will be used to filter the features available from this model.
Definition: qgsfeaturepickermodelbase.cpp:84
QgsFeaturePickerModelBase::filterValueChanged
void filterValueChanged()
This value will be used to filter the features available from this model.
QgsFeaturePickerModelBase::beginUpdate
void beginUpdate()
Notification that the model is about to be changed because a job was completed.
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:521
QgsFeaturePickerModelBase::filterExpressionChanged
void filterExpressionChanged()
An additional filter expression to apply, next to the filterValue.