Class: QgsAttributeTableFilterModel

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

Bases: PyQt5.QtCore.QSortFilterProxyModel, 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.

Return type

int

beginInsertColumns()
beginInsertRows()
beginMoveColumns()
beginMoveRows()
beginRemoveColumns()
beginRemoveRows()
beginResetModel()
changePersistentIndex()
changePersistentIndexList()
childEvent()
columnCount(self, parent: QModelIndex) → int
Parameters

parent (QModelIndex) –

Return type

int

connectNotify()
createIndex()
customEvent()
data(self, index: QModelIndex, role: int) → Any
Parameters
  • index (QModelIndex) –

  • role (int) –

Return type

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
Parameters

fid (int) –

Return type

QModelIndex

fidToIndexList(self, fid: int) → object
Parameters

fid (int) –

Return type

object

filterAcceptsColumn()
filterAcceptsRow(self, sourceRow: int, sourceParent: QModelIndex) → bool

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

filterMode(self) → QgsAttributeTableFilterModel.FilterMode

The current filterModel

Return type

QgsAttributeTableFilterModel.FilterMode

filteredFeatures(self) → object

Gets a list of currently filtered feature ids

Return type

object

Returns

A list of feature ids

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

index (QModelIndex) –

Return type

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
Parameters
  • section (int) –

  • orientation (Qt.Orientation) –

  • role (int) –

Return type

Any

invalidateFilter()
isSignalConnected()
layer(self) → QgsVectorLayer

Returns the layer this filter acts on.

Return type

QgsVectorLayer

Returns

Abovementioned layer

layerCache(self) → QgsVectorLayerCache

Returns the layerCache this filter acts on.

Return type

QgsVectorLayerCache

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.

Parameters
  • left (QModelIndex) –

  • right (QModelIndex) –

Return type

bool

mapCanvas(self) → QgsMapCanvas

Returns the map canvas

Return type

QgsMapCanvas

mapFromMaster(self, sourceIndex: QModelIndex) → QModelIndex
Parameters

sourceIndex (QModelIndex) –

Return type

QModelIndex

mapFromSource(self, sourceIndex: QModelIndex) → QModelIndex
Parameters

sourceIndex (QModelIndex) –

Return type

QModelIndex

mapToMaster(self, proxyIndex: QModelIndex) → QModelIndex
Parameters

proxyIndex (QModelIndex) –

Return type

QModelIndex

mapToSource(self, proxyIndex: QModelIndex) → QModelIndex
Parameters

proxyIndex (QModelIndex) –

Return type

QModelIndex

masterModel(self) → QgsAttributeTableModel

Returns the table model this filter is using

Return type

QgsAttributeTableModel

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 (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

Returns if selected features are currently shown on top

Return type

bool

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.

Parameters

config (QgsAttributeTableConfig) –

setFilterMode(self, filterMode: QgsAttributeTableFilterModel.FilterMode)

Set the filter mode the filter will use.

Parameters

filterMode (QgsAttributeTableFilterModel.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 (object) – 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 (bool) – Specify, if selected features should be sorted on top

setSourceModel(self, sourceModel: QgsAttributeTableModel)

Set the attribute table model that backs this model

Parameters

sourceModel (QgsAttributeTableModel) – 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 (int) – The column which should be sorted

  • order (Qt.SortOrder = Qt.AscendingOrder) – 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

Is 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.

Return type

str

timerEvent()