Class: QgsHistoryProviderRegistry

The QgsHistoryProviderRegistry is 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

Methods

addEntries

Adds a list of entries to the history logs.

addEntry

Adds an entry to the history logs.

addProvider

Adds a provider to the registry.

clearHistory

Clears the history for the specified backend.

entry

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

providerById

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

providerIds

Returns a list of the registered provider IDs.

queryEntries

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

removeProvider

Removes the provider with matching id.

updateEntry

Updates the existing entry with matching id.

Static Methods

userHistoryDbPath

Returns the path to user's local history database.

Signals

entryAdded

Emitted when an entry is added.

entryUpdated

Emitted when an entry is updated.

historyCleared

Emitted when the history is cleared for a backend.

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

Target storage backends

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

Adds an entry to the history logs.

Parameters:
  • entry (QgsHistoryEntry) – entry to add

  • options (QgsHistoryProviderRegistry.HistoryEntryOptions = QgsHistoryProviderRegistry.HistoryEntryOptions()) -> (int) – 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(id: int, entry: QgsHistoryEntry, backend: Qgis.HistoryProviderBackend)[source]

Emitted when an entry is added.

Added in version 3.32.

Parameters:
signal entryUpdated(id: int, entry: Dict[str, object], backend: Qgis.HistoryProviderBackend)[source]

Emitted when an entry is updated.

Added in version 3.32.

Parameters:
signal historyCleared(backend: Qgis.HistoryProviderBackend, providerId: str)[source]

Emitted when the history is cleared for a backend.

If providerId is non-empty then the history has only been cleared for the specified provider.

Added in version 3.32.

Parameters:
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