Class: QgsHistoryProviderRegistry

A registry for objects which track user history (i.e. operations performed through the GUI).

QgsHistoryProviderRegistry is not usually directly created, but rather accessed through QgsGui.historyProviderRegistry().

Added in version 3.24.

Class Hierarchy

Inheritance diagram of qgis.gui.QgsHistoryProviderRegistry

Base classes

QObject

class qgis.gui.QgsHistoryProviderRegistry[source]

Bases: QObject

__init__(parent: QObject | None = None, useMemoryDatabase: bool = False)

Creates a new empty history provider registry.

QgsHistoryProviderRegistry is not usually directly created, but rather accessed through QgsGui.historyProviderRegistry().

Parameters:
  • parent (Optional[QObject] = None)

  • useMemoryDatabase (bool = False)

class HistoryEntryOptions[source]

Bases: object

Contains options for storing history entries.

Added in version 3.24.

QgsHistoryProviderRegistry.HistoryEntryOptions() Constructor for HistoryEntryOptions.

QgsHistoryProviderRegistry.HistoryEntryOptions(a0: QgsHistoryProviderRegistry.HistoryEntryOptions)

storageBackends: Qgis.HistoryProviderBackends
addEntries(self, entries: Iterable[QgsHistoryEntry], options: QgsHistoryProviderRegistry.HistoryEntryOptions = QgsHistoryProviderRegistry.HistoryEntryOptions()) bool[source]

Adds a list of entries to the history logs.

See also

addEntry()

See also

entryAdded()

Parameters:
  • entries (Iterable[QgsHistoryEntry])

  • options (QgsHistoryProviderRegistry.HistoryEntryOptions = QgsHistoryProviderRegistry.HistoryEntryOptions())

Return type:

bool

addEntry(self, providerId: str | None, entry: Dict[str, Any], options: QgsHistoryProviderRegistry.HistoryEntryOptions = QgsHistoryProviderRegistry.HistoryEntryOptions())

Adds an entry to the history logs.

The entry will be tagged with the current date/time as the timestamp.

The providerId specifies the history provider responsible for this entry. Entry options are specified via the options argument.

Parameters:
  • providerId (Optional[str]) – associated QgsAbstractHistoryProvider.id()

  • entry (Dict[str, Any]) – entry to add

  • options (QgsHistoryProviderRegistry.HistoryEntryOptions = QgsHistoryProviderRegistry.HistoryEntryOptions()) -> (int) – options

Returns:

  • ID of newly added entry.

  • ok: True if entry was successfully added

addEntry(self, entry: QgsHistoryEntry, options: QgsHistoryProviderRegistry.HistoryEntryOptions = QgsHistoryProviderRegistry.HistoryEntryOptions()) -> (int, bool) Adds an entry to the history logs.

Parameters:
  • entry – entry to add

  • options – options

Returns:

  • ID of newly added entry.

  • ok: True if entry was successfully added

See also

entryAdded()

addProvider(self, provider: QgsAbstractHistoryProvider | None) bool[source]

Adds a provider to the registry. Ownership of the provider is transferred to the registry.

Returns True if the provider was successfully added.

Parameters:

provider (Optional[QgsAbstractHistoryProvider])

Return type:

bool

clearHistory(self, backend: Qgis.HistoryProviderBackend, providerId: str | None = '') bool[source]

Clears the history for the specified backend.

See also

historyCleared()

Parameters:
Return type:

bool

entry(self, id: int, backend: Qgis.HistoryProviderBackend = Qgis.HistoryProviderBackend.LocalProfile)[source]

Returns the entry with matching ID, from the specified backend.

Parameters:
  • id (int) – ID of entry to find

  • ok – will be set to True if entry was found

  • backend (Qgis.HistoryProviderBackend = Qgis.HistoryProviderBackend.LocalProfile) -> (QgsHistoryEntry) – associated backend

Returns:

matching entry if found

signal entryAdded[source]

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

signal entryUpdated[source]

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

signal historyCleared[source]

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

providerById(self, id: str | None) QgsAbstractHistoryProvider | None[source]

Returns the provider with matching id, or None if no matching provider is registered.

Parameters:

id (Optional[str])

Return type:

Optional[QgsAbstractHistoryProvider]

providerIds(self) List[str][source]

Returns a list of the registered provider IDs.

Return type:

List[str]

queryEntries(self, start: QDateTime | datetime.datetime = QDateTime(), end: QDateTime | datetime.datetime = QDateTime(), providerId: str | None = '', backends: Qgis.HistoryProviderBackends | Qgis.HistoryProviderBackend = Qgis.HistoryProviderBackend.LocalProfile) List[QgsHistoryEntry]

Queries history entries which occurred between the specified start and end times.

The optional providerId and backends arguments can be used to filter entries.

Parameters:
Return type:

List[QgsHistoryEntry]

removeProvider(self, id: str | None) bool[source]

Removes the provider with matching id.

The provider will be deleted.

Returns True if the provider was successfully removed.

Parameters:

id (Optional[str])

Return type:

bool

updateEntry(self, id: int, entry: Dict[str, Any], backend: Qgis.HistoryProviderBackend = Qgis.HistoryProviderBackend.LocalProfile) bool[source]

Updates the existing entry with matching id.

This method allows the content of an entry to be updated, e.g. to add additional properties to the content. (Such as recording the results of after a long-running operation completes).

Parameters:
  • id (int)

  • entry (Dict[str, Any])

  • backend (Qgis.HistoryProviderBackend = Qgis.HistoryProviderBackend.LocalProfile)

Return type:

bool

static userHistoryDbPath() str[source]

Returns the path to user’s local history database.

Return type:

str