QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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  case Qt::BackgroundColorRole:
173  case Qt::TextColorRole:
174  case Qt::DecorationRole:
175  case Qt::FontRole:
176  {
177  bool isNull = identifierIsNull( entryIdentifier( mEntries.value( index.row() ) ) );
178  if ( isNull )
179  {
180  // Representation for NULL value
181  if ( role == Qt::TextColorRole )
182  {
183  return QBrush( QColor( Qt::gray ) );
184  }
185  if ( role == Qt::FontRole )
186  {
187  QFont font = QFont();
188  if ( index.row() == mExtraValueIndex )
189  font.setBold( true );
190  else
191  font.setItalic( true );
192  return font;
193  }
194  }
195  else
196  {
197  // Respect conditional style
198  const QgsConditionalStyle style = featureStyle( mEntries.value( index.row() ).feature );
199 
200  if ( style.isValid() )
201  {
202  if ( role == Qt::BackgroundColorRole && style.validBackgroundColor() )
203  return style.backgroundColor();
204  if ( role == Qt::TextColorRole && style.validTextColor() )
205  return style.textColor();
206  if ( role == Qt::DecorationRole )
207  return style.icon();
208  if ( role == Qt::FontRole )
209  return style.font();
210  }
211  }
212  break;
213  }
214  }
215 
216  return QVariant();
217 }
218 
219 
220 void QgsFeaturePickerModelBase::updateCompleter()
221 {
222  emit beginUpdate();
223 
224  QgsFeatureExpressionValuesGatherer *gatherer = qobject_cast<QgsFeatureExpressionValuesGatherer *>( sender() );
225  if ( gatherer->wasCanceled() )
226  {
227  delete gatherer;
228  return;
229  }
230 
231  QVector<QgsFeatureExpressionValuesGatherer::Entry> entries = mGatherer->entries();
232 
233  if ( mExtraValueIndex == -1 )
234  {
236  }
237 
238  // Only reloading the current entry?
239  bool reloadCurrentFeatureOnly = mGatherer->data().toBool();
240  if ( reloadCurrentFeatureOnly )
241  {
242  if ( !entries.isEmpty() )
243  {
244  mEntries.replace( mExtraValueIndex, entries.at( 0 ) );
245  emit dataChanged( index( mExtraValueIndex, 0, QModelIndex() ), index( mExtraValueIndex, 0, QModelIndex() ) );
246  mShouldReloadCurrentFeature = false;
247  setExtraValueDoesNotExist( false );
248  }
249  else
250  {
251  setExtraValueDoesNotExist( true );
252  }
253 
254  mKeepCurrentEntry = true;
255  mShouldReloadCurrentFeature = false;
256 
257  if ( mFilterValue.isEmpty() )
258  reload();
259  }
260  else
261  {
262  // We got strings for a filter selection
263  std::sort( entries.begin(), entries.end(), []( const QgsFeatureExpressionValuesGatherer::Entry & a, const QgsFeatureExpressionValuesGatherer::Entry & b ) { return a.value.localeAwareCompare( b.value ) < 0; } );
264 
265  if ( mAllowNull )
266  {
267  entries.prepend( QgsFeatureExpressionValuesGatherer::nullEntry( mSourceLayer ) );
268  }
269 
270  const int newEntriesSize = entries.size();
271 
272  // fixed entry is either NULL or extra value
273  const int nbFixedEntry = ( mKeepCurrentEntry ? 1 : 0 ) + ( mAllowNull ? 1 : 0 );
274 
275  // Find the index of the current entry in the new list
276  int currentEntryInNewList = -1;
277  if ( mExtraValueIndex != -1 && mExtraValueIndex < mEntries.count() )
278  {
279  for ( int i = 0; i < newEntriesSize; ++i )
280  {
281  if ( compareEntries( entries.at( i ), mEntries.at( mExtraValueIndex ) ) )
282  {
283  mEntries.replace( mExtraValueIndex, entries.at( i ) );
284  currentEntryInNewList = i;
285  setExtraValueDoesNotExist( false );
286  break;
287  }
288  }
289  }
290 
291  int firstRow = 0;
292 
293  // Move current entry to the first position if this is a fixed entry or because
294  // the entry exists in the new list
295  if ( mExtraValueIndex > -1 && ( mExtraValueIndex < nbFixedEntry || currentEntryInNewList != -1 ) )
296  {
297  if ( mExtraValueIndex != 0 )
298  {
299  beginMoveRows( QModelIndex(), mExtraValueIndex, mExtraValueIndex, QModelIndex(), 0 );
300  mEntries.move( mExtraValueIndex, 0 );
301  endMoveRows();
302  }
303  firstRow = 1;
304  }
305 
306  // Remove all entries (except for extra entry if existent)
307  beginRemoveRows( QModelIndex(), firstRow, mEntries.size() - firstRow );
308  mEntries.remove( firstRow, mEntries.size() - firstRow );
309 
310  // if we remove all rows before endRemoveRows, setExtraIdentifierValuesUnguarded will be called
311  // and a null value will be added to mEntries, so we block setExtraIdentifierValuesUnguarded call
312 
313  mIsSettingExtraIdentifierValue = true;
314  endRemoveRows();
315  mIsSettingExtraIdentifierValue = false;
316 
317  if ( currentEntryInNewList == -1 )
318  {
319  beginInsertRows( QModelIndex(), firstRow, entries.size() + 1 );
320  mEntries += entries;
321  endInsertRows();
322 
323  // if all entries have been cleaned (firstRow == 0)
324  // and there is a value in entries, prefer this value over NULL
325  // else chose the first one (the previous one)
326  setExtraIdentifierValueIndex( firstRow == 0 && mAllowNull && !entries.isEmpty() ? 1 : 0, firstRow == 0 );
327  }
328  else
329  {
330  if ( currentEntryInNewList != 0 )
331  {
332  beginInsertRows( QModelIndex(), 0, currentEntryInNewList - 1 );
333  mEntries = entries.mid( 0, currentEntryInNewList ) + mEntries;
334  endInsertRows();
335  }
336  else
337  {
338  mEntries.replace( 0, entries.at( 0 ) );
339  }
340 
341  // don't notify for a change if it's a fixed entry
342  if ( currentEntryInNewList >= nbFixedEntry )
343  {
344  emit dataChanged( index( currentEntryInNewList, 0, QModelIndex() ), index( currentEntryInNewList, 0, QModelIndex() ) );
345  }
346 
347  beginInsertRows( QModelIndex(), currentEntryInNewList + 1, newEntriesSize - currentEntryInNewList - 1 );
348  mEntries += entries.mid( currentEntryInNewList + 1 );
349  endInsertRows();
350  setExtraIdentifierValueIndex( currentEntryInNewList );
351  }
352 
353  emit filterJobCompleted();
354 
355  mKeepCurrentEntry = false;
356  }
357  emit endUpdate();
358 
359  // scheduleReload and updateCompleter lives in the same thread so if the gatherer hasn't been stopped
360  // (checked before), mGatherer still references the current gatherer
361  Q_ASSERT( gatherer == mGatherer );
362  delete mGatherer;
363  mGatherer = nullptr;
364  emit isLoadingChanged();
365 }
366 
367 
368 void QgsFeaturePickerModelBase::scheduledReload()
369 {
370  if ( !mSourceLayer )
371  return;
372 
373  bool wasLoading = false;
374 
375  if ( mGatherer )
376  {
377  mGatherer->stop();
378  wasLoading = true;
379  }
380 
381  QgsFeatureRequest request;
382 
383  if ( mShouldReloadCurrentFeature )
384  {
386  }
387  else
388  {
389  QString filterClause;
390 
391  if ( mFilterValue.isEmpty() && !mFilterExpression.isEmpty() )
392  filterClause = mFilterExpression;
393  else if ( mFilterExpression.isEmpty() && !mFilterValue.isEmpty() )
394  filterClause = QStringLiteral( "(%1) ILIKE '%%2%'" ).arg( mDisplayExpression, mFilterValue );
395  else if ( !mFilterExpression.isEmpty() && !mFilterValue.isEmpty() )
396  filterClause = QStringLiteral( "(%1) AND ((%2) ILIKE '%%3%')" ).arg( mFilterExpression, mDisplayExpression, mFilterValue );
397 
398  if ( !filterClause.isEmpty() )
399  request.setFilterExpression( filterClause );
400  }
401  QSet<QString> attributes = requestedAttributes();
402  if ( !attributes.isEmpty() )
403  {
404  if ( request.filterExpression() )
405  attributes += request.filterExpression()->referencedColumns();
406  attributes += requestedAttributesForStyle();
407 
408  request.setSubsetOfAttributes( attributes, mSourceLayer->fields() );
409  }
410 
411  if ( !mFetchGeometry )
413  if ( mFetchLimit > 0 )
414  request.setLimit( mFetchLimit );
415 
416  mGatherer = createValuesGatherer( request );
417  mGatherer->setData( mShouldReloadCurrentFeature );
418  connect( mGatherer, &QgsFeatureExpressionValuesGatherer::finished, this, &QgsFeaturePickerModelBase::updateCompleter );
419 
420  mGatherer->start();
421  if ( !wasLoading )
422  emit isLoadingChanged();
423 }
424 
425 
426 QSet<QString> QgsFeaturePickerModelBase::requestedAttributesForStyle() const
427 {
428  QSet<QString> requestedAttrs;
429 
430  const auto rowStyles = mSourceLayer->conditionalStyles()->rowStyles();
431 
432  for ( const QgsConditionalStyle &style : rowStyles )
433  {
434  QgsExpression exp( style.rule() );
435  requestedAttrs += exp.referencedColumns();
436  }
437 
438  if ( mDisplayExpression.isField() )
439  {
440  QString fieldName = *mDisplayExpression.referencedColumns().constBegin();
441  const auto constFieldStyles = mSourceLayer->conditionalStyles()->fieldStyles( fieldName );
442  for ( const QgsConditionalStyle &style : constFieldStyles )
443  {
444  QgsExpression exp( style.rule() );
445  requestedAttrs += exp.referencedColumns();
446  }
447  }
448 
449  return requestedAttrs;
450 }
451 
452 
453 void QgsFeaturePickerModelBase::setExtraIdentifierValueIndex( int index, bool force )
454 {
455  if ( mExtraValueIndex == index && !force )
456  return;
457 
460 }
461 
462 
463 void QgsFeaturePickerModelBase::reloadCurrentFeature()
464 {
465  mShouldReloadCurrentFeature = true;
466  mReloadTimer.start();
467 }
468 
469 
470 void QgsFeaturePickerModelBase::setExtraIdentifierValueUnguarded( const QVariant &identifierValue )
471 {
472  const QVector<QgsFeatureExpressionValuesGatherer::Entry> entries = mEntries;
473 
474  int index = 0;
475  for ( const QgsFeatureExpressionValuesGatherer::Entry &entry : entries )
476  {
477  if ( compareEntries( entry, createEntry( identifierValue ) ) )
478  {
479  setExtraIdentifierValueIndex( index );
480  break;
481  }
482 
483  index++;
484  }
485 
486  // Value not found in current entries
487  if ( mExtraValueIndex != index )
488  {
489  bool isNull = identifierIsNull( identifierValue );
490  if ( !isNull || mAllowNull )
491  {
492  beginInsertRows( QModelIndex(), 0, 0 );
493  if ( !isNull )
494  {
495  mEntries.prepend( createEntry( identifierValue ) );
496  reloadCurrentFeature();
497  }
498  else
499  {
500  mEntries.prepend( QgsFeatureExpressionValuesGatherer::nullEntry( mSourceLayer ) );
501  }
502  endInsertRows();
503 
504  setExtraIdentifierValueIndex( 0, true );
505  }
506  }
507 }
508 
509 
510 QgsConditionalStyle QgsFeaturePickerModelBase::featureStyle( const QgsFeature &feature ) const
511 {
512  if ( !mSourceLayer )
513  return QgsConditionalStyle();
514 
515  QgsVectorLayer *layer = mSourceLayer;
516  QgsFeatureId fid = feature.id();
517  mExpressionContext.setFeature( feature );
518 
519  auto styles = QgsConditionalStyle::matchingConditionalStyles( layer->conditionalStyles()->rowStyles(), QVariant(), mExpressionContext );
520 
521  if ( mDisplayExpression.referencedColumns().count() == 1 )
522  {
523  // Style specific for this field
524  QString fieldName = *mDisplayExpression.referencedColumns().constBegin();
525  const auto allStyles = layer->conditionalStyles()->fieldStyles( fieldName );
526  const auto matchingFieldStyles = QgsConditionalStyle::matchingConditionalStyles( allStyles, feature.attribute( fieldName ), mExpressionContext );
527 
528  styles += matchingFieldStyles;
529  }
530 
531  QgsConditionalStyle style;
532  style = QgsConditionalStyle::compressStyles( styles );
533  mEntryStylesMap.insert( fid, style );
534 
535  return style;
536 }
537 
538 
540 {
541  return mAllowNull;
542 }
543 
544 
546 {
547  if ( mAllowNull == allowNull )
548  return;
549 
550  mAllowNull = allowNull;
551  emit allowNullChanged();
552 
553  reload();
554 }
555 
557 {
558  return mFetchGeometry;
559 }
560 
562 {
563  if ( mFetchGeometry == fetchGeometry )
564  return;
565 
566  mFetchGeometry = fetchGeometry;
567  reload();
568 }
569 
571 {
572  return mFetchLimit;
573 }
574 
576 {
577  if ( fetchLimit == mFetchLimit )
578  return;
579 
580  mFetchLimit = fetchLimit;
581  emit fetchLimitChanged();
582 }
583 
584 
586 {
587  return mExtraValueDoesNotExist;
588 }
589 
590 
591 void QgsFeaturePickerModelBase::setExtraValueDoesNotExist( bool extraValueDoesNotExist )
592 {
593  if ( mExtraValueDoesNotExist == extraValueDoesNotExist )
594  return;
595 
596  mExtraValueDoesNotExist = extraValueDoesNotExist;
598 }
599 
600 
602 {
603  return mExtraValueIndex;
604 }
605 
606 
607 void QgsFeaturePickerModelBase::reload()
608 {
609  mReloadTimer.start();
610 }
611 
612 
613 void QgsFeaturePickerModelBase::setExtraIdentifierValue( const QVariant &extraIdentifierValue )
614 {
616  return;
617 
618  if ( mIsSettingExtraIdentifierValue )
619  return;
620 
621  mIsSettingExtraIdentifierValue = true;
622 
624 
626 
627  mIsSettingExtraIdentifierValue = false;
628 
630 }
631 
QgsFeatureRequest::NoGeometry
@ NoGeometry
Geometry is not required. It may still be returned if e.g. required for a filter condition.
Definition: qgsfeaturerequest.h:107
QgsFeaturePickerModelBase::IdentifierValueRole
@ IdentifierValueRole
Definition: qgsfeaturepickermodelbase.h:63
qgsconditionalstyle.h
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:49
QgsFeaturePickerModelBase::extraIdentifierValueIndex
int extraIdentifierValueIndex
Definition: qgsfeaturepickermodelbase.h:54
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:50
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:64
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:613
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:190
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:470
QgsFeaturePickerModelBase::ValueRole
@ ValueRole
Used to retrieve the displayExpression of a feature.
Definition: qgsfeaturepickermodelbase.h:65
QgsFeaturePickerModelBase::~QgsFeaturePickerModelBase
~QgsFeaturePickerModelBase() override
Definition: qgsfeaturepickermodelbase.cpp:34
QgsConditionalStyle
Definition: qgsconditionalstyle.h:112
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:327
QgsConditionalStyle::compressStyles
static QgsConditionalStyle compressStyles(const QList< QgsConditionalStyle > &styles)
Compress a list of styles into a single style.
Definition: qgsconditionalstyle.cpp:262
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:52
QgsFeatureRequest::setFilterExpression
QgsFeatureRequest & setFilterExpression(const QString &expression)
Set the filter expression.
Definition: qgsfeaturerequest.cpp:129
qgsapplication.h
QgsFeaturePickerModelBase::allowNull
bool allowNull
Definition: qgsfeaturepickermodelbase.h:51
QgsVectorLayer::fields
QgsFields fields() const FINAL
Returns the list of fields of this layer.
Definition: qgsvectorlayer.cpp:3280
QgsFeature::id
QgsFeatureId id
Definition: qgsfeature.h:68
QgsFeatureRequest
Definition: qgsfeaturerequest.h:75
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:47
QgsFeaturePickerModelBase::mEntries
QVector< QgsFeatureExpressionValuesGatherer::Entry > mEntries
Definition: qgsfeaturepickermodelbase.h:323
QgsFeaturePickerModelBase::extraValueDoesNotExist
bool extraValueDoesNotExist() const
Flag indicating that the extraIdentifierValue does not exist in the data.
Definition: qgsfeaturepickermodelbase.cpp:585
qgsfeatureexpressionvaluesgatherer.h
QgsFeaturePickerModelBase::data
QVariant data(const QModelIndex &index, int role) const override
Definition: qgsfeaturepickermodelbase.cpp:145
QgsFeaturePickerModelBase::nullIentifier
virtual QVariant nullIentifier() const =0
Returns a null identifier.
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:229
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:425
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:300
QgsFeaturePickerModelBase::displayExpression
QString displayExpression
Definition: qgsfeaturepickermodelbase.h:48
QgsFeature::attribute
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
Definition: qgsfeature.cpp:262
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:239
QgsFeaturePickerModelBase::setAllowNull
void setAllowNull(bool allowNull)
Add a NULL entry to the list.
Definition: qgsfeaturepickermodelbase.cpp:545
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:66
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:53
QgsConditionalStyle::textColor
QColor textColor() const
The text color set for style.
Definition: qgsconditionalstyle.h:203
QgsVectorLayer
Definition: qgsvectorlayer.h:385
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:178
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
Definition: qgsfeature.h:55
QgsExpression::isField
bool isField() const
Checks whether an expression consists only of a single field reference.
Definition: qgsexpression.cpp:1079
QgsFeaturePickerModelBase::mExtraValueIndex
int mExtraValueIndex
The current index.
Definition: qgsfeaturepickermodelbase.h:330
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:575
QgsFeaturePickerModelBase::setFetchGeometry
void setFetchGeometry(bool fetchGeometry)
Defines if the geometry will be fetched.
Definition: qgsfeaturepickermodelbase.cpp:561
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:4933
QgsExpression
Definition: qgsexpression.h:113
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:390
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:67
QgsConditionalStyle::validTextColor
bool validTextColor() const
Check if the text color is valid for render.
Definition: qgsconditionalstyle.cpp:234
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:184
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
Definition: qgsfeatureid.h:25
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.