Class: QgsLocatorModel

class qgis.core.QgsLocatorModel

Bases: PyQt5.QtCore.QAbstractTableModel

An abstract list model for displaying the results of locator searches.

Note that this class should generally be used with a QgsLocatorProxyModel in order to ensure correct sorting of results by priority and match level.

QgsLocatorModel(parent: Optional[QObject] = None) Constructor for QgsLocatorModel.

Enums

CustomRole

Bases: enum.IntEnum

Role

alias of CustomRole

Methods

addResult

Adds a new result to the model.

beginInsertColumns

beginInsertRows

beginMoveColumns

beginMoveRows

beginRemoveColumns

beginRemoveRows

beginResetModel

changePersistentIndex

changePersistentIndexList

childEvent

clear

Resets the model and clears all existing results.

columnCount

param parent:

connectNotify

createIndex

customEvent

data

param index:

decodeData

deferredClear

Resets the model and clears all existing results after a short delay, or whenever the next result is added to the model (whichever occurs first).

disconnectNotify

encodeData

endInsertColumns

endInsertRows

endMoveColumns

endMoveRows

endRemoveColumns

endRemoveRows

endResetModel

flags

param index:

isSignalConnected

persistentIndexList

receivers

resetInternalData

roleNames

rtype:

Dict[int, QByteArray]

rowCount

param parent:

sender

senderSignalIndex

timerEvent

Attributes

NoGroup

class CustomRole(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: enum.IntEnum

Custom model roles.

Note

Prior to QGIS 3.36 this was available as QgsLocatorModel.Role

Added in version 3.36.

  • ResultDataRole: QgsLocatorResult data

  • ResultTypeRole: Result type

  • ResultFilterPriorityRole: Result priority, used by QgsLocatorProxyModel for sorting roles.

  • ResultScoreRole: Result match score, used by QgsLocatorProxyModel for sorting roles.

  • ResultFilterNameRole: Associated filter name which created the result

  • ResultFilterGroupSortingRole: Group results within the same filter results

  • ResultActionsRole: The actions to be shown for the given result in a context menu

baseClass

alias of QgsLocatorModel

NoGroup = 9999
Role

alias of CustomRole

addResult(self, result: QgsLocatorResult)

Adds a new result to the model.

Parameters:

result (QgsLocatorResult)

beginInsertColumns(self, parent: QModelIndex, first: int, last: int)
beginInsertRows(self, parent: QModelIndex, first: int, last: int)
beginMoveColumns(self, sourceParent: QModelIndex, sourceFirst: int, sourceLast: int, destinationParent: QModelIndex, destinationColumn: int) bool
beginMoveRows(self, sourceParent: QModelIndex, sourceFirst: int, sourceLast: int, destinationParent: QModelIndex, destinationRow: int) bool
beginRemoveColumns(self, parent: QModelIndex, first: int, last: int)
beginRemoveRows(self, parent: QModelIndex, first: int, last: int)
beginResetModel(self)
changePersistentIndex(self, from_: QModelIndex, to: QModelIndex)
changePersistentIndexList(self, from_: Iterable[QModelIndex], to: Iterable[QModelIndex])
childEvent(self, a0: QChildEvent | None)
clear(self)

Resets the model and clears all existing results.

See also

deferredClear()

columnCount(self, parent: QModelIndex = QModelIndex()) int
Parameters:

parent (QModelIndex = QModelIndex())

Return type:

int

connectNotify(self, signal: QMetaMethod)
createIndex(self, row: int, column: int, object: Any = None) QModelIndex
customEvent(self, a0: QEvent | None)
data(self, index: QModelIndex, role: int = Qt.DisplayRole) Any
Parameters:
  • index (QModelIndex)

  • role (int = Qt.DisplayRole)

Return type:

Any

decodeData(self, row: int, column: int, parent: QModelIndex, stream: QDataStream) bool
deferredClear(self)

Resets the model and clears all existing results after a short delay, or whenever the next result is added to the model (whichever occurs first). Using deferredClear() instead of clear() can avoid the visually distracting frequent clears which may occur if the model is being updated quickly multiple times as a result of users typing in a search query.

See also

deferredClear()

disconnectNotify(self, signal: QMetaMethod)
encodeData(self, indexes: Iterable[QModelIndex], stream: QDataStream)
endInsertColumns(self)
endInsertRows(self)
endMoveColumns(self)
endMoveRows(self)
endRemoveColumns(self)
endRemoveRows(self)
endResetModel(self)
flags(self, index: QModelIndex) Qt.ItemFlags
Parameters:

index (QModelIndex)

Return type:

Qt.ItemFlags

isSignalConnected(self, signal: QMetaMethod) bool
persistentIndexList(self) List[QModelIndex]
receivers(self, signal: PYQT_SIGNAL) int
resetInternalData(self)
roleNames(self) Dict[int, QByteArray]
Return type:

Dict[int, QByteArray]

rowCount(self, parent: QModelIndex = QModelIndex()) int
Parameters:

parent (QModelIndex = QModelIndex())

Return type:

int

sender(self) QObject | None
senderSignalIndex(self) int
timerEvent(self, a0: QTimerEvent | None)