15 #ifndef QGSFEATUREFILTERMODELBASE_H
16 #define QGSFEATUREFILTERMODELBASE_H
21 #include <QAbstractItemModel>
36 Q_PROPERTY(
QgsVectorLayer *sourceLayer READ sourceLayer WRITE setSourceLayer NOTIFY sourceLayerChanged )
37 Q_PROPERTY( QString displayExpression READ displayExpression WRITE setDisplayExpression NOTIFY displayExpressionChanged )
38 Q_PROPERTY( QString filterValue READ filterValue WRITE setFilterValue NOTIFY filterValueChanged )
39 Q_PROPERTY( QString filterExpression READ filterExpression WRITE setFilterExpression NOTIFY filterExpressionChanged )
40 Q_PROPERTY(
bool allowNull READ allowNull WRITE setAllowNull NOTIFY allowNullChanged )
41 Q_PROPERTY(
bool fetchGeometry READ fetchGeometry WRITE setFetchGeometry NOTIFY fetchGeometryChanged )
42 Q_PROPERTY(
int fetchLimit READ fetchLimit WRITE setFetchLimit NOTIFY fetchLimitChanged )
43 Q_PROPERTY(
int extraIdentifierValueIndex READ extraIdentifierValueIndex NOTIFY extraIdentifierValueIndexChanged )
52 IdentifierValueRole = Qt::UserRole,
81 QString displayExpression()
const;
89 void setDisplayExpression(
const QString &displayExpression );
96 QString filterValue()
const;
103 void setFilterValue(
const QString &filterValue );
105 QModelIndex index(
int row,
int column,
const QModelIndex &parent )
const override;
106 QModelIndex parent(
const QModelIndex &child )
const override;
107 int rowCount(
const QModelIndex &parent )
const override;
108 int columnCount(
const QModelIndex &parent )
const override
113 QVariant data(
const QModelIndex &index,
int role )
const override;
119 QString filterExpression()
const;
125 void setFilterExpression(
const QString &filterExpression );
130 bool isLoading()
const;
136 virtual void setExtraIdentifierValueToNull() = 0;
141 int extraIdentifierValueIndex()
const;
146 bool extraValueDoesNotExist()
const;
151 bool allowNull()
const;
156 void setAllowNull(
bool allowNull );
161 bool fetchGeometry()
const;
166 void setFetchGeometry(
bool fetchGeometry );
171 int fetchLimit()
const;
177 void setFetchLimit(
int fetchLimit );
187 void currentFeatureChanged();
192 void sourceLayerChanged();
200 void displayExpressionChanged();
207 void filterValueChanged();
213 void filterExpressionChanged();
218 void isLoadingChanged();
223 void filterJobCompleted();
229 void extraIdentifierValueChanged();
234 void extraIdentifierValueIndexChanged(
int index );
239 void extraValueDoesNotExistChanged();
254 void allowNullChanged();
259 void fetchGeometryChanged();
264 void fetchLimitChanged();
268 void updateCompleter();
269 void scheduledReload();
277 QVariant extraIdentifierValue()
const;
283 void setExtraIdentifierValue(
const QVariant &extraIdentifierValue );
289 void setExtraIdentifierValueUnguarded(
const QVariant &identifierValue );
297 virtual QSet<QString> requestedAttributes()
const {
return {};}
300 virtual QgsFeatureExpressionValuesGatherer *createValuesGatherer(
const QgsFeatureRequest &request )
const = 0;
303 virtual QgsFeatureExpressionValuesGatherer::Entry createEntry(
const QVariant &identifier )
const = 0;
306 virtual QVariant entryIdentifier(
const QgsFeatureExpressionValuesGatherer::Entry &entry )
const = 0;
309 virtual bool compareEntries(
const QgsFeatureExpressionValuesGatherer::Entry &a,
const QgsFeatureExpressionValuesGatherer::Entry &b )
const = 0;
312 virtual QVariant nullIdentifier()
const = 0;
318 virtual bool identifierIsNull(
const QVariant &identifier )
const = 0;
320 QVector<QgsFeatureExpressionValuesGatherer::Entry> mEntries;
324 QVariant mExtraIdentifierValue;
327 int mExtraValueIndex = -1;
330 void setExtraIdentifierValueIndex(
int index,
bool force =
false );
331 void setExtraValueDoesNotExist(
bool extraValueDoesNotExist );
333 void reloadCurrentFeature();
334 QSet<QString> requestedAttributesForStyle()
const;
340 QString mFilterValue;
341 QString mFilterExpression;
344 mutable QMap< QgsFeatureId, QgsConditionalStyle > mEntryStylesMap;
346 QgsFeatureExpressionValuesGatherer *mGatherer =
nullptr;
347 bool mFetchGeometry =
true;
348 int mFetchLimit = 100;
351 bool mShouldReloadCurrentFeature =
false;
352 bool mKeepCurrentEntry =
false;
353 bool mExtraValueDoesNotExist =
false;
354 bool mAllowNull =
false;
355 bool mIsSettingExtraIdentifierValue =
false;
357 friend class TestQgsFeatureListComboBox;
360 #endif // QGSFEATUREFILTERMODELBASE_H