Class: QgsBookmarkManager¶
Manages storage of a set of bookmarks.
QgsBookmarkManager handles the storage, serializing and
deserializing of geographic bookmarks. Usually this class is not
constructed directly, but rather accessed through a
QgsProject via QgsProject.bookmarkManager(), or
via the application-wide bookmark store at
QgsApplication.bookmarkManager().
Added in version 3.10.
Class Hierarchy¶
Base classes¶
- class qgis.core.QgsBookmarkManager[source]¶
Bases:
QObject- __init__(parent: QObject | None = None)
Constructor for QgsBookmarkManager, with the specified
parentobject.This constructor creates a bookmark manager which stores bookmarks in an XML file. A call to
initialize()is required to initialize the manager and set the corresponding file path.- Parameters:
parent (Optional[QObject] = None)
- addBookmark(self, bookmark: QgsBookmark)[source]¶
Adds a
bookmarkto the manager.- Parameters:
bookmark (
QgsBookmark) -> (str) – the bookmark to add- Returns:
The bookmark’s ID (or newly generated ID, if no ID was originally set and one was automatically generated)
ok:
Trueif the bookmark was successfully added, orFalseif the bookmark could not be added (eg as a result of a duplicate bookmark ID).
See also
See also
- signal bookmarkAboutToBeAdded[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 bookmarkAboutToBeRemoved[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 bookmarkAdded[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.
- bookmarkById(self, id: str | None) QgsBookmark[source]¶
Returns the bookmark with a matching
id, or an empty bookmark if no matching bookmarks were found.- Parameters:
id (Optional[str])
- Return type:
- signal bookmarkChanged[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 bookmarkRemoved[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.
- bookmarks(self) List[QgsBookmark]¶
Returns a list of all bookmarks contained in the manager.
- Return type:
- bookmarksByGroup(self, group: str | None) List[QgsBookmark]¶
Returns a list of bookmark with a matching
group, or an empty list if no matching bookmarks were found.- Parameters:
group (Optional[str])
- Return type:
- static createProjectBasedManager(project: QgsProject | None) QgsBookmarkManager | None[source]¶
Returns a newly created
QgsBookmarkManagerusing a project-based bookmark store, linked to the specifiedproject.The returned object is parented to the
project.- Parameters:
project (Optional[QgsProject])
- Return type:
Optional[QgsBookmarkManager]
- static exportToFile(path: str | None, managers: Iterable[QgsBookmarkManager], group: str | None = '') bool[source]¶
Exports all bookmarks from a list of
managersto an xml file at the specifiedpath.If
groupis set then only bookmarks from the matching group will be exported.Returns
Trueif the export was successful.See also
- Parameters:
path (Optional[str])
managers (Iterable[QgsBookmarkManager])
group (Optional[str] = '')
- Return type:
bool
- groups(self) List[str][source]¶
Returns a list of all bookmark groups contained in the manager.
- Return type:
List[str]
- importFromFile(self, path: str | None) bool[source]¶
Imports the bookmarks from an xml file at the specified
path.Returns
Trueif the import was successful.See also
- Parameters:
path (Optional[str])
- Return type:
bool
- initialize(self, filePath: str | None)[source]¶
Initializes the bookmark manager.
- Parameters:
filePath (Optional[str])
- moveBookmark(self, id: str | None, destination: QgsBookmarkManager | None) bool[source]¶
Moves the bookmark with matching
idfrom this manager to adestinationmanager.Returns
Trueif the bookmark was successfully moved.- Parameters:
id (Optional[str])
destination (Optional[QgsBookmarkManager])
- Return type:
bool
- readXml(self, element: QDomElement, doc: QDomDocument) bool[source]¶
Reads the manager’s state from a DOM element, restoring all bookmarks present in the XML document.
See also
- Parameters:
element (QDomElement)
doc (QDomDocument)
- Return type:
bool
- removeBookmark(self, id: str | None) bool[source]¶
Removes the bookmark with matching
idfrom the manager.Returns
Trueif the removal was successful, orFalseif the removal failed (eg as a result of removing a bookmark which is not contained in the manager).See also
See also
See also
See also
- Parameters:
id (Optional[str])
- Return type:
bool
- renameGroup(self, oldName: str | None, newName: str | None)[source]¶
Renames an existing group from
oldNametonewName. This updates all existing bookmarks to reflect the new name.- Parameters:
oldName (Optional[str])
newName (Optional[str])
- updateBookmark(self, bookmark: QgsBookmark) bool[source]¶
Updates the definition of a
bookmarkin the manager.Replaces the current definition of the bookmark with matching ID in the manager with a new definition (new bookmark name or extent).
Returns
Trueif the bookmark was successfully updated, orFalseif the bookmark could not be updated (eg bookmark is not stored in the manager).See also
- Parameters:
bookmark (QgsBookmark)
- Return type:
bool