Class: QgsAttributeTableFilterModel¶
Class Hierarchy¶
Base classes¶
Enums
The additional roles defined by this filter model. |
|
alias of |
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 |
|
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. |
|
Used by the sorting algorithm. |
|
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. |
|
Specify a list of features, which the filter will accept. |
|
Changes the sort order of the features. |
|
Set the attribute table model that backs this model |
|
Sort by the given column using the given order. |
|
The expression which is used to sort the attribute table. |
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) |
Attributes
- class qgis.gui.QgsAttributeTableFilterModel(canvas: QgsMapCanvas | None, sourceModel: QgsAttributeTableModel | None, parent: QObject | None = None)[source]¶
Bases:
QSortFilterProxyModel
,QgsFeatureModel
- class ColumnType¶
Bases:
int
- ColumnTypeActionButton = 1¶
- ColumnTypeField = 0¶
- class CustomRole(*values)¶
Bases:
IntEnum
The additional roles defined by this filter model. The values of these roles start just after the roles defined by
QgsAttributeTableModel
so they do not conflict.Note
Prior to QGIS 3.36 this was available as QgsAttributeTableFilterModel.Role
Added in version 3.36.
Type
:Available as
QgsAttributeTableFilterModel.TypeRole
in older QGIS releases.
- class FilterMode¶
Bases:
int
- Role¶
alias of
CustomRole
- ShowAll = 0¶
- ShowEdited = 4¶
- ShowFilteredList = 3¶
- ShowInvalid = 5¶
- ShowSelected = 1¶
- ShowVisible = 2¶
- actionColumnIndex(self) int [source]¶
Gets the index of the first column that contains an action widget. Returns -1 if none is defined.
- Return type:
int
- connectFilterModeConnections(self, filterMode: QgsAttributeTableFilterModel.FilterMode)[source]¶
Disconnect the connections set for the new
filterMode
- Parameters:
filterMode (QgsAttributeTableFilterModel.FilterMode)
- 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]
- filterAcceptsRow(self, sourceRow: int, sourceParent: QModelIndex) bool [source]¶
Returns
True
if 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) QgsAttributeTableFilterModel.FilterMode [source]¶
The current filterModel
- Return type:
- filteredFeatures(self) Any [source]¶
Gets a list of currently filtered feature ids
- Return type:
Any
- 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:
Optional[QgsVectorLayer]
- Returns:
Abovementioned layer
- layerCache(self) QgsVectorLayerCache | None [source]¶
Returns the layerCache this filter acts on.
- Return type:
Optional[QgsVectorLayerCache]
- Returns:
The layer cache
- 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:
Optional[QgsMapCanvas]
- 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:
Optional[QgsAttributeTableModel]
- 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:
True
if 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
expression
and thecontext
to 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: QgsAttributeTableFilterModel.FilterMode)[source]¶
Set the filter mode the filter will use.
- Parameters:
filterMode (QgsAttributeTableFilterModel.FilterMode) – Sets the current mode of the filter
- 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 (Optional[QgsAttributeTableModel]) – The model
- 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)[source]
Sort by the given expression using the given order. Prefetches all the data from the layer to speed up sorting.
- Parameters:
expression (Optional[str]) – The expression which should be used for sorting
order (Qt.SortOrder = Qt.AscendingOrder) – 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