Class: QgsAttributeTableFilterModel

class qgis.gui.QgsAttributeTableFilterModel(canvas: QgsMapCanvas, sourceModel: QgsAttributeTableModel, parent: QObject = None)

Bases: PyQt5.QtCore.QSortFilterProxyModel, qgis._gui.QgsFeatureModel

Make sure, the master model is already loaded, so the selection will get synchronized.

Parameters
class ColumnType

Bases: int

baseClass

alias of QgsAttributeTableFilterModel

ColumnTypeActionButton = 1
ColumnTypeField = 0
class FilterMode

Bases: int

baseClass

alias of QgsAttributeTableFilterModel

class Role

Bases: int

ShowAll = 0
ShowEdited = 4
ShowFilteredList = 3
ShowSelected = 1
ShowVisible = 2
TypeRole = 258
actionColumnIndex(self) → int

Gets the index of the first column that contains an action widget. Returns -1 if none is defined.

beginInsertColumns()
beginInsertRows()
beginMoveColumns()
beginMoveRows()
beginRemoveColumns()
beginRemoveRows()
beginResetModel()
changePersistentIndex()
changePersistentIndexList()
childEvent()
columnCount(self, parent: QModelIndex) → int
connectNotify()
createIndex()
customEvent()
data(self, index: QModelIndex, role: int) → Any
decodeData()
disconnectNotify()
encodeData()
endInsertColumns()
endInsertRows()
endMoveColumns()
endMoveRows()
endRemoveColumns()
endRemoveRows()
endResetModel()
extentsChanged(self)

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.

fidToIndex(self, fid: int) → QModelIndex
fidToIndexList(self, fid: int) → List[QModelIndex]
filterAcceptsColumn()
filterAcceptsRow(self, sourceRow: int, sourceParent: QModelIndex) → bool

Returns True if the source row will be accepted

Parameters
  • sourceRow – row from the source model

  • sourceParent – parent index in the source model

filterMode(self) → QgsAttributeTableFilterModel.FilterMode

The current filterModel

filteredFeatures(self) → object

Gets a list of currently filtered feature ids

Returns

A list of feature ids

flags(self, index: QModelIndex) → Qt.ItemFlags
generateListOfVisibleFeatures(self)

Updates the list of currently visible features on the map canvas. Is called automatically when the filter mode is adjusted or the extents changed.

headerData(self, section: int, orientation: Qt.Orientation, role: int) → Any
invalidateFilter()
isSignalConnected()
layer(self) → QgsVectorLayer

Returns the layer this filter acts on.

Returns

Abovementioned layer

layerCache(self) → QgsVectorLayerCache

Returns the layerCache this filter acts on.

Returns

The layer cache

lessThan(self, left: QModelIndex, right: QModelIndex) → bool

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.

mapCanvas(self) → QgsMapCanvas

Returns the map canvas

mapFromMaster(self, sourceIndex: QModelIndex) → QModelIndex
mapFromSource(self, sourceIndex: QModelIndex) → QModelIndex
mapToMaster(self, proxyIndex: QModelIndex) → QModelIndex
mapToSource(self, proxyIndex: QModelIndex) → QModelIndex
masterModel(self) → QgsAttributeTableModel

Returns the table model this filter is using

Returns

the table model in quesion

persistentIndexList()
receivers()
resetInternalData()
rowToId(self, row: QModelIndex) → int

Returns the feature id for a given model index.

Parameters

row – A model index of the row in question

Returns

The feature id of the feature visible in the provided row

selectedOnTop(self) → bool

Returns if selected features are currently shown on top

Returns

True if selected are shown on top

sender()
senderSignalIndex()
setAttributeTableConfig(self, config: QgsAttributeTableConfig)

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.

setFilterMode(self, filterMode: QgsAttributeTableFilterModel.FilterMode)

Set the filter mode the filter will use.

Parameters

filterMode – Sets the current mode of the filter

setFilteredFeatures(self, ids: object)

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 – The list of feature ids which will be accepted by the filter

setSelectedOnTop(self, selectedOnTop: bool)

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 – Specify, if selected features should be sorted on top

setSourceModel(self, sourceModel: QgsAttributeTableModel)

Set the attribute table model that backs this model

Parameters

sourceModel – The model

New in version 2.0.

sort(self, column: int, order: Qt.SortOrder = Qt.AscendingOrder)

Sort by the given column using the given order. Prefetches all the data from the layer to speed up sorting.

Parameters
  • column – The column which should be sorted

  • order – The order ( Qt.AscendingOrder or Qt.DescendingOrder )

sort(self, expression: str, 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 )

sortColumnChanged

Emitted whenever the sort column is changed

Parameters
  • column – The sort column

  • order – The sort order [signal]

sortExpression(self) → str

The expression which is used to sort the attribute table.

timerEvent()