15 #ifndef QGSFEATUREEXPRESSIONVALUESGATHERER_H
16 #define QGSFEATUREEXPRESSIONVALUESGATHERER_H
36 class QgsFeatureExpressionValuesGatherer:
public QThread
50 const QString &displayExpression = QString(),
52 const QStringList &identifierFields = QStringList() )
54 , mDisplayExpression( displayExpression.isEmpty() ? layer->
displayExpression() : displayExpression )
56 , mIdentifierFields( identifierFields )
64 Entry(
const QVariantList &_identifierFields,
const QString &_value,
const QgsFeature &_feature )
65 : identifierFields( _identifierFields )
72 : featureId( _featureId )
77 QVariantList identifierFields;
82 bool operator()(
const Entry &lhs,
const Entry &rhs )
const;
94 mIterator = mSource->getFeatures( mRequest );
96 mDisplayExpression.prepare( &mExpressionContext );
100 for (
const QString &fieldName : qgis::as_const( mIdentifierFields ) )
103 while ( mIterator.nextFeature( feature ) )
105 mExpressionContext.setFeature( feature );
106 QVariantList attributes;
110 const QString expressionValue = mDisplayExpression.evaluate( &mExpressionContext ).toString();
112 mEntries.append( Entry( attributes, expressionValue, feature ) );
114 QMutexLocker locker( &mCancelMutex );
123 QMutexLocker locker( &mCancelMutex );
128 bool wasCanceled()
const
130 QMutexLocker locker( &mCancelMutex );
134 QVector<Entry> entries()
const
147 QVariant data()
const
155 void setData(
const QVariant &data )
161 QVector<Entry> mEntries;
164 std::unique_ptr<QgsVectorLayerFeatureSource> mSource;
169 bool mWasCanceled =
false;
170 mutable QMutex mCancelMutex;
171 QStringList mIdentifierFields;
178 #endif // QGSFEATUREEXPRESSIONVALUESGATHERER_H