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;
static QString nullRepresentation()
This string is used to represent the value NULL throughout QGIS.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Class for parsing and evaluation of expressions (formerly called "search strings").
Wrapper for iterator of features from vector data provider or vector layer.
bool nextFeature(QgsFeature &f)
This class wraps a request for features to a vector layer (or directly its vector data provider).
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
bool isValid() const
Returns the validity of this feature.
QVariant attribute(const QString &name) const
Lookup attribute value by attribute name.
Container of fields for a vector layer.
Partial snapshot of vector layer's state (only the members necessary for access to features)
Represents a vector layer which manages a vector based data sets.
QgsFields fields() const FINAL
Returns the list of fields of this layer.
QString displayExpression
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
const QgsAttributeList & attributeIndexes