Class: QgsAttributeTableFilterModel¶
A proxy model for filtering an attribute table model.
List of all members, including inherited members
Class Hierarchy¶
Base classes¶
Base class for feature models. |
Constructor
Methods
Gets the index of the first column that contains an action widget. |
|
Disconnect the connections set for the new filterMode |
|
Disconnect the connections set for the current filterMode |
|
Is called upon every change of the visible extents on the map canvas. |
|
Returns the stored filter expression string. |
|
Updates the filtered features in the filter model. |
|
The current filterModel |
|
Gets a list of currently filtered feature ids |
|
Updates the list of currently visible features on the map canvas. |
|
Returns the layer this filter acts on. |
|
Returns the layerCache this filter acts on. |
|
Returns the map canvas |
|
Returns the table model this filter is using |
|
Returns the feature id for a given model index. |
|
Returns if selected features are currently shown on top |
|
Set the attribute table configuration to control which fields are shown, in which order they are shown as well as if and where an action column is shown. |
|
Set the expression and the context to be stored in case of the features need to be filtered again (like on filter or on main model data change). |
|
Set the filter mode the filter will use. |
|
Changes the sort order of the features. |
|
Set the attribute table model that backs this model |
|
The expression which is used to sort the attribute table. |
Virtual Methods
In PyQGIS, only methods marked as virtual can be safely overridden in a Python subclass of QgsAttributeTableFilterModel. See the FAQ for more details.
Returns |
|
Used by the sorting algorithm. |
|
Specify a list of features, which the filter will accept. |
|
Sort by the given column using the given order. |
Signals
Emitted when the filtering of the features has been done |
|
Emitted when an error occurred while filtering features |
|
Emitted whenever the sort column is changed |
|
Emitted when the the visible features on extend are reloaded (the list is created) |
- class qgis.gui.QgsAttributeTableFilterModel[source]¶
Bases:
QSortFilterProxyModel,QgsFeatureModel- __init__(canvas: QgsMapCanvas | None, sourceModel: QgsAttributeTableModel | None, parent: QObject | None = None)¶
Make sure, the master model is already loaded, so the selection will get synchronized.
- Parameters:
parent (QObject|None = None) – parent object (owner)
sourceModel (QgsAttributeTableModel|None) – The
QgsAttributeTableModelto use as source (mostly referred to as master model)canvas (QgsMapCanvas|None) – The mapCanvas. Used to identify the currently visible features.
- ColumnType¶
alias of
ColumnTypeValue
- class CustomRole(*values)¶
Bases:
IntEnumCustom model roles.
Note
Prior to QGIS 3.36 this was available as QgsAttributeTableModel.Role
Added in version 3.36.
FeatureId: Get the feature id of the feature in this rowAvailable as
QgsAttributeTableModel.FeatureIdRolein older QGIS releases.FieldIndex: Get the field index of this columnAvailable as
QgsAttributeTableModel.FieldIndexRolein older QGIS releases.ColumnType: The type of a given column. See ColumnType.Added in version 4.4.
User: Start further roles starting from this roleAvailable as
QgsAttributeTableModel.UserRolein older QGIS releases.Sort: Role used for sorting start hereAvailable as
QgsAttributeTableModel.SortRolein older QGIS releases.
- FilterMode¶
alias of
AttributeTableFilterMode
- Role¶
alias of
CustomRole
- actionColumnIndex(self) int[source]¶
Gets the index of the first column that contains an action widget. Returns -1 if none is defined.
Deprecated since version 4.4.
- Return type:
int
- connectFilterModeConnections(self, filterMode: Qgis.AttributeTableFilterMode)[source]¶
Disconnect the connections set for the new
filterMode- Parameters:
filterMode (Qgis.AttributeTableFilterMode)
- disconnectFilterModeConnections(self)[source]¶
Disconnect the connections set for the current filterMode
- extentsChanged(self)[source]¶
Is called upon every change of the visible extents on the map canvas. When a change is signalled, the filter is updated and invalidated if needed.
Deprecated since version 3.10.3: Made private as
reloadVisible().
- fidToIndexList(self, fid: int) list[QModelIndex][source]¶
- Parameters:
fid (int)
- Return type:
list[QModelIndex]
- virtual filterAcceptsRow(self, sourceRow: int, sourceParent: QModelIndex) bool[source]¶
Returns
Trueif the source row will be accepted- Parameters:
sourceRow (int) – row from the source model
sourceParent (QModelIndex) – parent index in the source model
- Return type:
bool
- signal filterError(errorMessage: str)[source]¶
Emitted when an error occurred while filtering features
Added in version 3.18.
- Parameters:
errorMessage (str)
- filterExpression(self) str[source]¶
Returns the stored filter expression string.
Added in version 3.28.0.
- Return type:
str
- filterFeatures(self)[source]¶
Updates the filtered features in the filter model. It is called when the data of the main table or the filter expression changed.
Added in version 3.10.3.
- filterMode(self) Qgis.AttributeTableFilterMode[source]¶
The current filterModel
- Return type:
- filteredFeatures(self) Any[source]¶
Gets a list of currently filtered feature ids
- Return type:
- Returns:
A list of feature ids
- generateListOfVisibleFeatures(self)[source]¶
Updates the list of currently visible features on the map canvas. Is called automatically when the filter mode is adjusted or the extents changed.
- layer(self) QgsVectorLayer | None[source]¶
Returns the layer this filter acts on.
- Return type:
QgsVectorLayer|None
- Returns:
Abovementioned layer
- layerCache(self) QgsVectorLayerCache | None[source]¶
Returns the layerCache this filter acts on.
- Return type:
QgsVectorLayerCache|None
- Returns:
The layer cache
- virtual lessThan(self, left: QModelIndex, right: QModelIndex) bool[source]¶
Used by the sorting algorithm. Compares the two model indices. Will also consider the selection state of the feature in case selected features are to be shown on top.
- Parameters:
left (QModelIndex)
right (QModelIndex)
- Return type:
bool
- mapCanvas(self) QgsMapCanvas | None[source]¶
Returns the map canvas
- Return type:
QgsMapCanvas|None
- mapFromMaster(self, sourceIndex: QModelIndex) QModelIndex[source]¶
- Parameters:
sourceIndex (QModelIndex)
- Return type:
QModelIndex
- mapToMaster(self, proxyIndex: QModelIndex) QModelIndex[source]¶
- Parameters:
proxyIndex (QModelIndex)
- Return type:
QModelIndex
- masterModel(self) QgsAttributeTableModel | None[source]¶
Returns the table model this filter is using
- Return type:
- Returns:
the table model in quesion
- rowToId(self, row: QModelIndex) int[source]¶
Returns the feature id for a given model index.
- Parameters:
row (QModelIndex) – A model index of the row in question
- Return type:
int
- Returns:
The feature id of the feature visible in the provided row
- selectedOnTop(self) bool[source]¶
Returns if selected features are currently shown on top
- Return type:
bool
- Returns:
Trueif selected are shown on top
- setAttributeTableConfig(self, config: QgsAttributeTableConfig)[source]¶
Set the attribute table configuration to control which fields are shown, in which order they are shown as well as if and where an action column is shown.
- Parameters:
config (QgsAttributeTableConfig) – attribute table config
- setFilterExpression(self, expression: QgsExpression, context: QgsExpressionContext)[source]¶
Set the
expressionand thecontextto be stored in case of the features need to be filtered again (like on filter or on main model data change).Added in version 3.10.3.
- Parameters:
expression (QgsExpression)
context (QgsExpressionContext)
- setFilterMode(self, filterMode: Qgis.AttributeTableFilterMode)[source]¶
Set the filter mode the filter will use.
- Parameters:
filterMode (Qgis.AttributeTableFilterMode) – Sets the current mode of the filter
- virtual setFilteredFeatures(self, ids: Any)[source]¶
Specify a list of features, which the filter will accept. The filter mode will automatically be adjusted to show only these features (ShowFilteredList).
- Parameters:
ids (Any) – The list of feature ids which will be accepted by the filter
- setSelectedOnTop(self, selectedOnTop: bool)[source]¶
Changes the sort order of the features. If set to
True, selected features will be sorted on top, regardless of the current sort column- Parameters:
selectedOnTop (bool) – Specify, if selected features should be sorted on top
- setSourceModel(self, sourceModel: QgsAttributeTableModel | None)[source]¶
Set the attribute table model that backs this model
- Parameters:
sourceModel (QgsAttributeTableModel|None) – The model
- virtual sort(self, column: int, order: Qt.SortOrder = Qt.AscendingOrder)[source]¶
Sort by the given column using the given order. Prefetches all the data from the layer to speed up sorting.
- Parameters:
column (int) – The column which should be sorted
order (Qt.SortOrder = Qt.AscendingOrder) – The order ( Qt.AscendingOrder or Qt.DescendingOrder )
sort(self, expression: str|None, order: Qt.SortOrder = Qt.AscendingOrder) Sort by the given expression using the given order. Prefetches all the data from the layer to speed up sorting.
- Parameters:
expression – The expression which should be used for sorting
order – The order ( Qt.AscendingOrder or Qt.DescendingOrder )
- signal sortColumnChanged(column: int, order: Qt.SortOrder)[source]¶
Emitted whenever the sort column is changed
- Parameters:
column (int) – The sort column
order (Qt.SortOrder) – The sort order