Class: QgsBookmarkManager¶
- class qgis.core.QgsBookmarkManager¶
Bases:
PyQt5.QtCore.QObject
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 aQgsProject
viaQgsProject.bookmarkManager()
, or via the application-wide bookmark store atQgsApplication.bookmarkManager()
.New in version 3.10.
QgsBookmarkManager(parent: QObject = None) Constructor for
QgsBookmarkManager
, with the specifiedparent
object.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.Methods
Adds a
bookmark
to the manager.Returns the bookmark with a matching
id
, or an empty bookmark if no matching bookmarks were found.Returns a list of all bookmarks contained in the manager.
Returns a list of bookmark with a matching
group
, or an empty list if no matching bookmarks were found.Removes and deletes all bookmarks from the manager.
Returns a newly created
QgsBookmarkManager
using a project-based bookmark store, linked to the specifiedproject
.Exports all bookmarks from a list of
managers
to an xml file at the specifiedpath
.Returns a list of all bookmark groups contained in the manager.
Imports the bookmarks from an xml file at the specified
path
.Initializes the bookmark manager.
Moves the bookmark with matching
id
from this manager to adestination
manager.Reads the manager's state from a DOM element, restoring all bookmarks present in the XML document.
Removes the bookmark with matching
id
from the manager.Renames an existing group from
oldName
tonewName
.Updates the definition of a
bookmark
in the manager.Returns a DOM element representing the state of the manager.
Signals
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
- addBookmark(self, bookmark: QgsBookmark) Tuple[str, bool] ¶
Adds a
bookmark
to the manager.- Parameters
bookmark (QgsBookmark) – the bookmark to add
- Return type
Tuple[str, bool]
- Returns
The bookmark’s ID (or newly generated ID, if no ID was originally set and one was automatically generated)
ok: will be set to
True
if the bookmark was successfully added, orFalse
if the bookmark could not be added (eg as a result of a duplicate bookmark ID).
See also
See also
- bookmarkAboutToBeAdded¶
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.
- Parameters
name (str = ...) –
revision (int = ...) –
arguments (Sequence = ...) –
- Return type
PYQT_SIGNAL
- bookmarkAboutToBeRemoved¶
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.
- Parameters
name (str = ...) –
revision (int = ...) –
arguments (Sequence = ...) –
- Return type
PYQT_SIGNAL
- bookmarkAdded¶
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.
- Parameters
name (str = ...) –
revision (int = ...) –
arguments (Sequence = ...) –
- Return type
PYQT_SIGNAL
- bookmarkById(self, id: str) QgsBookmark ¶
Returns the bookmark with a matching
id
, or an empty bookmark if no matching bookmarks were found.- Parameters
id (str) –
- Return type
- bookmarkChanged¶
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.
- Parameters
name (str = ...) –
revision (int = ...) –
arguments (Sequence = ...) –
- Return type
PYQT_SIGNAL
- bookmarkRemoved¶
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.
- Parameters
name (str = ...) –
revision (int = ...) –
arguments (Sequence = ...) –
- Return type
PYQT_SIGNAL
- bookmarks(self) List[QgsBookmark] ¶
Returns a list of all bookmarks contained in the manager.
- Return type
List[QgsBookmark]
- bookmarksByGroup(self, group: str) List[QgsBookmark] ¶
Returns a list of bookmark with a matching
group
, or an empty list if no matching bookmarks were found.- Parameters
group (str) –
- Return type
List[QgsBookmark]
- childEvent(self, QChildEvent)¶
- clear(self)¶
Removes and deletes all bookmarks from the manager.
See also
- connectNotify(self, QMetaMethod)¶
- createProjectBasedManager(project: QgsProject) QgsBookmarkManager ¶
Returns a newly created
QgsBookmarkManager
using a project-based bookmark store, linked to the specifiedproject
.The returned object is parented to the
project
.- Parameters
project (QgsProject) –
- Return type
- customEvent(self, QEvent)¶
- disconnectNotify(self, QMetaMethod)¶
- exportToFile(path: str, managers: Iterable[QgsBookmarkManager], group: str = '') bool ¶
Exports all bookmarks from a list of
managers
to an xml file at the specifiedpath
.If
group
is set then only bookmarks from the matching group will be exported.Returns
True
if the export was successful.See also
- Parameters
path (str) –
managers (Iterable[QgsBookmarkManager]) –
group (str = '') –
- Return type
bool
- groups(self) List[str] ¶
Returns a list of all bookmark groups contained in the manager.
- Return type
List[str]
- importFromFile(self, path: str) bool ¶
Imports the bookmarks from an xml file at the specified
path
.Returns
True
if the import was successful.See also
- Parameters
path (str) –
- Return type
bool
- initialize(self, filePath: str)¶
Initializes the bookmark manager.
- Parameters
filePath (str) –
- isSignalConnected(self, QMetaMethod) bool ¶
- moveBookmark(self, id: str, destination: QgsBookmarkManager) bool ¶
Moves the bookmark with matching
id
from this manager to adestination
manager.Returns
True
if the bookmark was successfully moved.- Parameters
id (str) –
destination (QgsBookmarkManager) –
- Return type
bool
- readXml(self, element: QDomElement, doc: QDomDocument) bool ¶
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
- receivers(self, PYQT_SIGNAL) int ¶
- removeBookmark(self, id: str) bool ¶
Removes the bookmark with matching
id
from the manager.Returns
True
if the removal was successful, orFalse
if 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 (str) –
- Return type
bool
- renameGroup(self, oldName: str, newName: str)¶
Renames an existing group from
oldName
tonewName
. This updates all existing bookmarks to reflect the new name.- Parameters
oldName (str) –
newName (str) –
- sender(self) QObject ¶
- senderSignalIndex(self) int ¶
- timerEvent(self, QTimerEvent)¶
- updateBookmark(self, bookmark: QgsBookmark) bool ¶
Updates the definition of a
bookmark
in 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
True
if the bookmark was successfully updated, orFalse
if the bookmark could not be updated (eg bookmark is not stored in the manager).See also
- Parameters
bookmark (QgsBookmark) –
- Return type
bool