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;
96 mDisplayExpression.prepare( &mExpressionContext );
100 for (
auto it = mIdentifierFields.constBegin(); it != mIdentifierFields.constEnd(); ++it )
105 mExpressionContext.setFeature( feature );
106 QVariantList attributes;
110 const QString expressionValue = mDisplayExpression.evaluate( &mExpressionContext ).toString();
112 mEntries.append( Entry( attributes, expressionValue, feature ) );
114 const QMutexLocker locker( &mCancelMutex );
123 const QMutexLocker locker( &mCancelMutex );
128 bool wasCanceled()
const
130 const 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;
168 bool mWasCanceled =
false;
169 mutable QMutex mCancelMutex;
170 QStringList mIdentifierFields;
177 #endif // QGSFEATUREEXPRESSIONVALUESGATHERER_H