15 #ifndef QGSFEATUREFILTERMODELBASE_H
16 #define QGSFEATUREFILTERMODELBASE_H
18 #include <QAbstractItemModel>
34 Q_PROPERTY(
QgsVectorLayer *sourceLayer READ sourceLayer WRITE setSourceLayer NOTIFY sourceLayerChanged )
35 Q_PROPERTY( QString displayExpression READ displayExpression WRITE setDisplayExpression NOTIFY displayExpressionChanged )
36 Q_PROPERTY( QString filterValue READ filterValue WRITE setFilterValue NOTIFY filterValueChanged )
37 Q_PROPERTY( QString filterExpression READ filterExpression WRITE setFilterExpression NOTIFY filterExpressionChanged )
38 Q_PROPERTY(
bool allowNull READ allowNull WRITE setAllowNull NOTIFY allowNullChanged )
39 Q_PROPERTY(
bool fetchGeometry READ fetchGeometry WRITE setFetchGeometry NOTIFY fetchGeometryChanged )
40 Q_PROPERTY(
int fetchLimit READ fetchLimit WRITE setFetchLimit NOTIFY fetchLimitChanged )
41 Q_PROPERTY(
int extraIdentifierValueIndex READ extraIdentifierValueIndex NOTIFY extraIdentifierValueIndexChanged )
50 IdentifierValueRole = Qt::UserRole,
79 QString displayExpression()
const;
87 void setDisplayExpression(
const QString &displayExpression );
94 QString filterValue()
const;
101 void setFilterValue(
const QString &filterValue );
103 QModelIndex index(
int row,
int column,
const QModelIndex &parent )
const override;
104 QModelIndex parent(
const QModelIndex &child )
const override;
105 int rowCount(
const QModelIndex &parent )
const override;
106 int columnCount(
const QModelIndex &parent )
const override
111 QVariant data(
const QModelIndex &index,
int role )
const override;
117 QString filterExpression()
const;
123 void setFilterExpression(
const QString &filterExpression );
128 bool isLoading()
const;
134 virtual void setExtraIdentifierValueToNull() = 0;
139 int extraIdentifierValueIndex()
const;
144 bool extraValueDoesNotExist()
const;
149 bool allowNull()
const;
154 void setAllowNull(
bool allowNull );
159 bool fetchGeometry()
const;
164 void setFetchGeometry(
bool fetchGeometry );
169 int fetchLimit()
const;
175 void setFetchLimit(
int fetchLimit );
182 void sourceLayerChanged();
190 void displayExpressionChanged();
197 void filterValueChanged();
203 void filterExpressionChanged();
208 void isLoadingChanged();
213 void filterJobCompleted();
219 void extraIdentifierValueChanged();
224 void extraIdentifierValueIndexChanged(
int index );
229 void extraValueDoesNotExistChanged();
244 void allowNullChanged();
249 void fetchGeometryChanged();
254 void fetchLimitChanged();
258 void updateCompleter();
259 void scheduledReload();
267 QVariant extraIdentifierValue()
const;
273 void setExtraIdentifierValue(
const QVariant &extraIdentifierValue );
279 void setExtraIdentifierValueUnguarded(
const QVariant &identifierValue );
287 virtual QSet<QString> requestedAttributes()
const {
return {};}
290 virtual QgsFeatureExpressionValuesGatherer *createValuesGatherer(
const QgsFeatureRequest &request )
const = 0;
293 virtual QgsFeatureExpressionValuesGatherer::Entry createEntry(
const QVariant &identifier )
const = 0;
296 virtual QVariant entryIdentifier(
const QgsFeatureExpressionValuesGatherer::Entry &entry )
const = 0;
299 virtual bool compareEntries(
const QgsFeatureExpressionValuesGatherer::Entry &a,
const QgsFeatureExpressionValuesGatherer::Entry &b )
const = 0;
302 virtual QVariant nullIentifier()
const = 0;
308 virtual bool identifierIsNull(
const QVariant &identifier )
const = 0;
310 QVector<QgsFeatureExpressionValuesGatherer::Entry> mEntries;
314 QVariant mExtraIdentifierValue;
317 int mExtraValueIndex = -1;
320 void setExtraIdentifierValueIndex(
int index,
bool force =
false );
321 void setExtraValueDoesNotExist(
bool extraValueDoesNotExist );
323 void reloadCurrentFeature();
324 QSet<QString> requestedAttributesForStyle()
const;
330 QString mFilterValue;
331 QString mFilterExpression;
334 mutable QMap< QgsFeatureId, QgsConditionalStyle > mEntryStylesMap;
336 QgsFeatureExpressionValuesGatherer *mGatherer =
nullptr;
337 bool mFetchGeometry =
true;
338 int mFetchLimit = 100;
341 bool mShouldReloadCurrentFeature =
false;
342 bool mKeepCurrentEntry =
false;
343 bool mExtraValueDoesNotExist =
false;
344 bool mAllowNull =
false;
345 bool mIsSettingExtraIdentifierValue =
false;
347 friend class TestQgsFeatureListComboBox;
350 #endif // QGSFEATUREFILTERMODELBASE_H