15#ifndef QGSFEATUREEXPRESSIONVALUESGATHERER_H
16#define QGSFEATUREEXPRESSIONVALUESGATHERER_H
37class QgsFeatureExpressionValuesGatherer:
public QThread
51 const QString &displayExpression = QString(),
53 const QStringList &identifierFields = QStringList() )
55 , mDisplayExpression( displayExpression.isEmpty() ? layer->
displayExpression() : displayExpression )
58 , mIdentifierFields( identifierFields )
66 Entry(
const QVariantList &_identifierFields,
const QString &_value,
const QgsFeature &_feature )
67 : identifierFields( _identifierFields )
74 : featureId( _featureId )
79 QVariantList identifierFields;
84 bool operator()(
const Entry &lhs,
const Entry &rhs )
const;
98 mDisplayExpression.prepare( &mExpressionContext );
102 for (
auto it = mIdentifierFields.constBegin(); it != mIdentifierFields.constEnd(); ++it )
107 mExpressionContext.setFeature( feature );
108 QVariantList attributes;
112 const QString expressionValue = mDisplayExpression.evaluate( &mExpressionContext ).toString();
114 mEntries.append( Entry( attributes, expressionValue, feature ) );
116 const QMutexLocker locker( &mCancelMutex );
125 const QMutexLocker locker( &mCancelMutex );
130 bool wasCanceled()
const
132 const QMutexLocker locker( &mCancelMutex );
136 QVector<Entry> entries()
const
149 QVariant data()
const
157 void setData(
const QVariant &data )
163 QVector<Entry> mEntries;
166 std::unique_ptr<QgsVectorLayerFeatureSource> mSource;
170 bool mWasCanceled =
false;
171 mutable QMutex mCancelMutex;
172 QStringList mIdentifierFields;
static QString nullRepresentation()
This string is used to represent the value NULL throughout QGIS.
static QList< QgsExpressionContextScope * > globalProjectLayerScopes(const QgsMapLayer *layer)
Creates a list of three scopes: global, layer's project and layer.
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.
int indexOf(const QString &fieldName) const
Gets the field index from the field name.
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