Subgroup: Locator

Class: QgsLocatorFilter

class qgis.core.QgsLocatorFilter

Bases: PyQt5.QtCore.QObject

Abstract base class for filters which collect locator results.

New in version 3.0: Methods

blockSignals
childEvent
children
connectNotify
customEvent
deleteLater
disconnect
disconnectNotify
displayName Returns a translated, user-friendly name for the filter.
dumpObjectInfo
dumpObjectTree
dynamicPropertyNames
enabled Returns true if the filter is enabled.
event
eventFilter
fetchResults Retrieves the filter results for a specified search string.
findChild findChild(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> QObject
findChildren findChildren(self, Tuple, name: str = ‘’, options: Union[Qt.FindChildOptions, Qt.FindChildOption] = Qt.FindChildrenRecursively) -> List[QObject]
hasConfigWidget Should return true if the filter has a configuration widget.
inherits
installEventFilter
isSignalConnected
isWidgetType
isWindowType
killTimer
metaObject
moveToThread
name Returns the unique name for the filter.
objectName
openConfigWidget Opens the configuration widget for the filter (if it has one), with the specified parent widget.
parent
prefix Returns the search prefix character(s) for this filter.
priority Returns the priority for the filter, which controls how results are ordered in the locator.
property
pyqtConfigure Each keyword argument is either the name of a Qt property or a Qt signal.
receivers
removeEventFilter
sender
senderSignalIndex
setEnabled Sets whether the filter is enabled.
setObjectName
setParent
setProperty
setUseWithoutPrefix Sets whether the filter should be used when no prefix is entered.
signalsBlocked
startTimer
stringMatches Tests a candidate string to see if it should be considered a match for a specified search string.
thread
timerEvent
tr
triggerResult Triggers a filter result from this filter.
useWithoutPrefix Returns true if the filter should be used when no prefix is entered.

Attributes

High
Highest
Low
Lowest
Medium
destroyed destroyed(self, QObject = None) [signal]
objectNameChanged objectNameChanged(self, str) [signal]
resultFetched Should be emitted by filters whenever they encounter a matching result during within their fetchResults() implementation.
staticMetaObject
High = 1
Highest = 0
Low = 3
Lowest = 4
Medium = 2
class Priority

Bases: int

childEvent()
connectNotify()
customEvent()
disconnectNotify()
displayName(self) → str

Returns a translated, user-friendly name for the filter.

See also

name()

enabled(self) → bool

Returns true if the filter is enabled.

See also

setEnabled()

fetchResults(self, string: str, context: QgsLocatorContext, feedback: QgsFeedback)

Retrieves the filter results for a specified search string. The context argument encapsulates the context relating to the search (such as a map extent to prioritize).

Implementations of fetchResults() should emit the resultFetched() signal whenever they encounter a matching result.

Subclasses should periodically check the feedback object to determine whether the query has been canceled. If so, the subclass should return from this method as soon as possible.

hasConfigWidget(self) → bool

Should return true if the filter has a configuration widget.

See also

createConfigWidget()

isSignalConnected()
name(self) → str

Returns the unique name for the filter. This should be an untranslated string identifying the filter.

See also

displayName()

openConfigWidget(self, parent: QWidget = None)

Opens the configuration widget for the filter (if it has one), with the specified parent widget. The base class implementation does nothing. Subclasses can override this to show their own custom configuration widget.

Note

hasConfigWidget() must return true to indicate that the filter supports configuration.

prefix(self) → str

Returns the search prefix character(s) for this filter. Prefix a search with these characters will restrict the locator search to only include results from this filter.

Note

Plugins are not permitted to utilize prefixes with < 3 characters, as these are reserved for core QGIS functions. If a plugin registers a filter with a prefix shorter than 3 characters then the prefix will be ignored.

priority(self) → QgsLocatorFilter.Priority

Returns the priority for the filter, which controls how results are ordered in the locator.

receivers()
resultFetched

Should be emitted by filters whenever they encounter a matching result during within their fetchResults() implementation. [signal]

sender()
senderSignalIndex()
setEnabled(self, enabled: bool)

Sets whether the filter is enabled.

See also

enabled()

setUseWithoutPrefix(self, useWithoutPrefix: bool)

Sets whether the filter should be used when no prefix is entered.

stringMatches(candidate: str, search: str) → bool

Tests a candidate string to see if it should be considered a match for a specified search string. Filter subclasses should use this method when comparing strings instead of directly using QString.contains() or Python ‘in’ checks.

timerEvent()
triggerResult(self, result: QgsLocatorResult)

Triggers a filter result from this filter. This is called when one of the results obtained by a call to fetchResults() is triggered by a user. The filter subclass must implement logic here to perform the desired operation for the search result. E.g. a file search filter would open file associated with the triggered result.

useWithoutPrefix(self) → bool

Returns true if the filter should be used when no prefix is entered.