Doxymentation

This commit is contained in:
Matthias Kuhn 2017-10-25 01:35:03 +02:00
parent 5c32db94fd
commit d8b641b591
No known key found for this signature in database
GPG Key ID: A0E766808764D73F
2 changed files with 223 additions and 2 deletions

View File

@ -14,12 +14,15 @@ class QgsFeatureFilterModel : QAbstractItemModel
%Docstring %Docstring
Provides a list of features based on filter conditions. Provides a list of features based on filter conditions.
Features are fetched asynchronously. Features are fetched asynchronously.
.. versionadded:: 3.0
%End %End
%TypeHeaderCode %TypeHeaderCode
#include "qgsfeaturefiltermodel.h" #include "qgsfeaturefiltermodel.h"
%End %End
public: public:
enum Role enum Role
{ {
IdentifierValueRole, IdentifierValueRole,
@ -31,21 +34,46 @@ class QgsFeatureFilterModel : QAbstractItemModel
QgsVectorLayer *sourceLayer() const; QgsVectorLayer *sourceLayer() const;
%Docstring %Docstring
The source layer from which features will be fetched.
:rtype: QgsVectorLayer :rtype: QgsVectorLayer
%End %End
void setSourceLayer( QgsVectorLayer *sourceLayer ); void setSourceLayer( QgsVectorLayer *sourceLayer );
%Docstring
The source layer from which features will be fetched.
%End
QString displayExpression() const; QString displayExpression() const;
%Docstring %Docstring
The display expression will be used for
- displaying values in the combobox
- filtering based on filterValue
:rtype: str :rtype: str
%End %End
void setDisplayExpression( const QString &displayExpression ); void setDisplayExpression( const QString &displayExpression );
%Docstring
The display expression will be used for
- displaying values in the combobox
- filtering based on filterValue
%End
QString filterValue() const; QString filterValue() const;
%Docstring %Docstring
This value will be used to filter the features available from
this model. Whenever a substring of the displayExpression of a feature
matches the filter value, it will be accessible by this model.
:rtype: str :rtype: str
%End %End
void setFilterValue( const QString &filterValue ); void setFilterValue( const QString &filterValue );
%Docstring
This value will be used to filter the features available from
this model. Whenever a substring of the displayExpression of a feature
matches the filter value, it will be accessible by this model.
%End
virtual QModelIndex index( int row, int column, const QModelIndex &parent ) const; virtual QModelIndex index( int row, int column, const QModelIndex &parent ) const;
virtual QModelIndex parent( const QModelIndex &child ) const; virtual QModelIndex parent( const QModelIndex &child ) const;
@ -68,44 +96,117 @@ class QgsFeatureFilterModel : QAbstractItemModel
bool isLoading() const; bool isLoading() const;
%Docstring %Docstring
Indicator if the model is currently performing any feature iteration in the background.
:rtype: bool :rtype: bool
%End %End
QString identifierField() const; QString identifierField() const;
%Docstring %Docstring
The identifier field should be a unique field that can be used to identify individual features.
It is normally set to the primary key of the layer.
:rtype: str :rtype: str
%End %End
void setIdentifierField( const QString &identifierField ); void setIdentifierField( const QString &identifierField );
%Docstring
The identifier field should be a unique field that can be used to identify individual features.
It is normally set to the primary key of the layer.
%End
QVariant extraIdentifierValue() const; QVariant extraIdentifierValue() const;
%Docstring %Docstring
Allows specifying one value that does not need to match the filter criteria but will
still be available in the model.
:rtype: QVariant :rtype: QVariant
%End %End
void setExtraIdentifierValue( const QVariant &extraIdentifierValue ); void setExtraIdentifierValue( const QVariant &extraIdentifierValue );
%Docstring
Allows specifying one value that does not need to match the filter criteria but will
still be available in the model.
%End
int extraIdentifierValueIndex() const; int extraIdentifierValueIndex() const;
%Docstring %Docstring
The index at which the extra identifier value is available within the model.
:rtype: int :rtype: int
%End %End
bool extraValueDoesNotExist() const; bool extraValueDoesNotExist() const;
%Docstring %Docstring
Flag indicating that the extraIdentifierValue does not exist in the data.
:rtype: bool :rtype: bool
%End %End
signals: signals:
void sourceLayerChanged(); void sourceLayerChanged();
%Docstring
The source layer from which features will be fetched.
%End
void displayExpressionChanged(); void displayExpressionChanged();
%Docstring
The display expression will be used for
- displaying values in the combobox
- filtering based on filterValue
%End
void filterValueChanged(); void filterValueChanged();
%Docstring
This value will be used to filter the features available from
this model. Whenever a substring of the displayExpression of a feature
matches the filter value, it will be accessible by this model.
%End
void filterExpressionChanged(); void filterExpressionChanged();
%Docstring
An additional filter expression to apply, next to the filterValue.
Can be used for spatial filtering etc.
%End
void isLoadingChanged(); void isLoadingChanged();
%Docstring
Indicator if the model is currently performing any feature iteration in the background.
%End
void identifierFieldChanged(); void identifierFieldChanged();
%Docstring
The identifier field should be a unique field that can be used to identify individual features.
It is normally set to the primary key of the layer.
%End
void filterJobCompleted(); void filterJobCompleted();
%Docstring
Indicates that a filter job has been completed and new data may be available.
%End
void extraIdentifierValueChanged(); void extraIdentifierValueChanged();
%Docstring
Allows specifying one value that does not need to match the filter criteria but will
still be available in the model.
%End
void extraIdentifierValueIndexChanged( int index ); void extraIdentifierValueIndexChanged( int index );
%Docstring
The index at which the extra identifier value is available within the model.
%End
void extraValueDoesNotExistChanged(); void extraValueDoesNotExistChanged();
%Docstring
Flag indicating that the extraIdentifierValue does not exist in the data.
%End
void beginUpdate(); void beginUpdate();
%Docstring
Notification that the model is about to be changed because a job was completed.
%End
void endUpdate(); void endUpdate();
%Docstring
Notification that the model change is finished. Will always be emitted in sync with beginUpdate.
%End
}; };

View File

@ -25,6 +25,8 @@ class QgsFieldExpressionValuesGatherer;
/** /**
* Provides a list of features based on filter conditions. * Provides a list of features based on filter conditions.
* Features are fetched asynchronously. * Features are fetched asynchronously.
*
* \since QGIS 3.0
*/ */
class CORE_EXPORT QgsFeatureFilterModel : public QAbstractItemModel class CORE_EXPORT QgsFeatureFilterModel : public QAbstractItemModel
{ {
@ -51,22 +53,57 @@ class CORE_EXPORT QgsFeatureFilterModel : public QAbstractItemModel
Q_PROPERTY( int extraIdentifierValueIndex READ extraIdentifierValueIndex NOTIFY extraIdentifierValueIndexChanged ) Q_PROPERTY( int extraIdentifierValueIndex READ extraIdentifierValueIndex NOTIFY extraIdentifierValueIndexChanged )
public: public:
/**
* Extra roles that can be used to fetch data from this model.
*/
enum Role enum Role
{ {
IdentifierValueRole = Qt::UserRole, IdentifierValueRole = Qt::UserRole, //!<
ValueRole ValueRole
}; };
QgsFeatureFilterModel( QObject *parent = nullptr ); QgsFeatureFilterModel( QObject *parent = nullptr );
~QgsFeatureFilterModel(); ~QgsFeatureFilterModel();
/**
* The source layer from which features will be fetched.
*/
QgsVectorLayer *sourceLayer() const; QgsVectorLayer *sourceLayer() const;
/**
* The source layer from which features will be fetched.
*/
void setSourceLayer( QgsVectorLayer *sourceLayer ); void setSourceLayer( QgsVectorLayer *sourceLayer );
/**
* The display expression will be used for
*
* - displaying values in the combobox
* - filtering based on filterValue
*/
QString displayExpression() const; QString displayExpression() const;
/**
* The display expression will be used for
*
* - displaying values in the combobox
* - filtering based on filterValue
*/
void setDisplayExpression( const QString &displayExpression ); void setDisplayExpression( const QString &displayExpression );
/**
* This value will be used to filter the features available from
* this model. Whenever a substring of the displayExpression of a feature
* matches the filter value, it will be accessible by this model.
*/
QString filterValue() const; QString filterValue() const;
/**
* This value will be used to filter the features available from
* this model. Whenever a substring of the displayExpression of a feature
* matches the filter value, it will be accessible by this model.
*/
void setFilterValue( const QString &filterValue ); void setFilterValue( const QString &filterValue );
virtual QModelIndex index( int row, int column, const QModelIndex &parent ) const override; virtual QModelIndex index( int row, int column, const QModelIndex &parent ) const override;
@ -87,30 +124,113 @@ class CORE_EXPORT QgsFeatureFilterModel : public QAbstractItemModel
*/ */
void setFilterExpression( const QString &filterExpression ); void setFilterExpression( const QString &filterExpression );
/**
* Indicator if the model is currently performing any feature iteration in the background.
*/
bool isLoading() const; bool isLoading() const;
/**
* The identifier field should be a unique field that can be used to identify individual features.
* It is normally set to the primary key of the layer.
*/
QString identifierField() const; QString identifierField() const;
/**
* The identifier field should be a unique field that can be used to identify individual features.
* It is normally set to the primary key of the layer.
*/
void setIdentifierField( const QString &identifierField ); void setIdentifierField( const QString &identifierField );
/**
* Allows specifying one value that does not need to match the filter criteria but will
* still be available in the model.
*/
QVariant extraIdentifierValue() const; QVariant extraIdentifierValue() const;
/**
* Allows specifying one value that does not need to match the filter criteria but will
* still be available in the model.
*/
void setExtraIdentifierValue( const QVariant &extraIdentifierValue ); void setExtraIdentifierValue( const QVariant &extraIdentifierValue );
/**
* The index at which the extra identifier value is available within the model.
*/
int extraIdentifierValueIndex() const; int extraIdentifierValueIndex() const;
/**
* Flag indicating that the extraIdentifierValue does not exist in the data.
*/
bool extraValueDoesNotExist() const; bool extraValueDoesNotExist() const;
signals: signals:
/**
* The source layer from which features will be fetched.
*/
void sourceLayerChanged(); void sourceLayerChanged();
/**
* The display expression will be used for
*
* - displaying values in the combobox
* - filtering based on filterValue
*/
void displayExpressionChanged(); void displayExpressionChanged();
/**
* This value will be used to filter the features available from
* this model. Whenever a substring of the displayExpression of a feature
* matches the filter value, it will be accessible by this model.
*/
void filterValueChanged(); void filterValueChanged();
/**
* An additional filter expression to apply, next to the filterValue.
* Can be used for spatial filtering etc.
*/
void filterExpressionChanged(); void filterExpressionChanged();
/**
* Indicator if the model is currently performing any feature iteration in the background.
*/
void isLoadingChanged(); void isLoadingChanged();
/**
* The identifier field should be a unique field that can be used to identify individual features.
* It is normally set to the primary key of the layer.
*/
void identifierFieldChanged(); void identifierFieldChanged();
/**
* Indicates that a filter job has been completed and new data may be available.
*/
void filterJobCompleted(); void filterJobCompleted();
/**
* Allows specifying one value that does not need to match the filter criteria but will
* still be available in the model.
*/
void extraIdentifierValueChanged(); void extraIdentifierValueChanged();
/**
* The index at which the extra identifier value is available within the model.
*/
void extraIdentifierValueIndexChanged( int index ); void extraIdentifierValueIndexChanged( int index );
/**
* Flag indicating that the extraIdentifierValue does not exist in the data.
*/
void extraValueDoesNotExistChanged(); void extraValueDoesNotExistChanged();
/**
* Notification that the model is about to be changed because a job was completed.
*/
void beginUpdate(); void beginUpdate();
/**
* Notification that the model change is finished. Will always be emitted in sync with beginUpdate.
*/
void endUpdate(); void endUpdate();
private slots: private slots:
@ -148,7 +268,7 @@ class CORE_EXPORT QgsFeatureFilterModel : public QAbstractItemModel
QVector<Entry> mEntries; QVector<Entry> mEntries;
QgsFieldExpressionValuesGatherer *mGatherer = nullptr; QgsFieldExpressionValuesGatherer *mGatherer = nullptr;
QTimer mReloadTimer; QTimer mReloadTimer;
bool mShouldReloadCurrentFeature; bool mShouldReloadCurrentFeature = false;
bool mExtraValueDoesNotExist = false; bool mExtraValueDoesNotExist = false;
QString mIdentifierField; QString mIdentifierField;