QGIS API Documentation
3.20.0-Odense (decaadbb31)
|
Manages storage of a set of bookmarks. More...
#include <qgsbookmarkmanager.h>
Signals | |
void | bookmarkAboutToBeAdded (const QString &id) |
Emitted when a bookmark is about to be added to the manager. More... | |
void | bookmarkAboutToBeRemoved (const QString &id) |
Emitted when a bookmark is about to be removed from the manager. More... | |
void | bookmarkAdded (const QString &id) |
Emitted when a bookmark has been added to the manager. More... | |
void | bookmarkChanged (const QString &id) |
Emitted when a bookmark is changed. More... | |
void | bookmarkRemoved (const QString &id) |
Emitted when a bookmark was removed from the manager. More... | |
Public Member Functions | |
QgsBookmarkManager (QObject *parent=nullptr) | |
Constructor for QgsBookmarkManager, with the specified parent object. More... | |
~QgsBookmarkManager () override | |
QString | addBookmark (const QgsBookmark &bookmark, bool *ok=nullptr) |
Adds a bookmark to the manager. More... | |
QgsBookmark | bookmarkById (const QString &id) const |
Returns the bookmark with a matching id, or an empty bookmark if no matching bookmarks were found. More... | |
QList< QgsBookmark > | bookmarks () const |
Returns a list of all bookmarks contained in the manager. More... | |
QList< QgsBookmark > | bookmarksByGroup (const QString &group) |
Returns a list of bookmark with a matching group, or an empty list if no matching bookmarks were found. More... | |
void | clear () |
Removes and deletes all bookmarks from the manager. More... | |
QStringList | groups () const |
Returns a list of all bookmark groups contained in the manager. More... | |
bool | importFromFile (const QString &path) |
Imports the bookmarks from an xml file at the specified path. More... | |
void | initialize (const QString &filePath) |
Initializes the bookmark manager. More... | |
bool | moveBookmark (const QString &id, QgsBookmarkManager *destination) |
Moves the bookmark with matching id from this manager to a destination manager. More... | |
bool | readXml (const QDomElement &element, const QDomDocument &doc) |
Reads the manager's state from a DOM element, restoring all bookmarks present in the XML document. More... | |
bool | removeBookmark (const QString &id) |
Removes the bookmark with matching id from the manager. More... | |
void | renameGroup (const QString &oldName, const QString &newName) |
Renames an existing group from oldName to newName. More... | |
bool | updateBookmark (const QgsBookmark &bookmark) |
Updates the definition of a bookmark in the manager. More... | |
QDomElement | writeXml (QDomDocument &doc) const |
Returns a DOM element representing the state of the manager. More... | |
Static Public Member Functions | |
static QgsBookmarkManager * | createProjectBasedManager (QgsProject *project) |
Returns a newly created QgsBookmarkManager using a project-based bookmark store, linked to the specified project. More... | |
static bool | exportToFile (const QString &path, const QList< const QgsBookmarkManager * > &managers, const QString &group=QString()) |
Exports all bookmarks from a list of managers to an xml file at the specified path. More... | |
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().
Definition at line 144 of file qgsbookmarkmanager.h.
|
explicit |
Constructor for QgsBookmarkManager, with the specified parent 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.
Definition at line 115 of file qgsbookmarkmanager.cpp.
|
override |
Definition at line 121 of file qgsbookmarkmanager.cpp.
QString QgsBookmarkManager::addBookmark | ( | const QgsBookmark & | bookmark, |
bool * | ok = nullptr |
||
) |
Adds a bookmark to the manager.
bookmark | the bookmark to add |
ok | if specified, will be set to true if the bookmark was successfully added, or false if the bookmark could not be added (eg as a result of a duplicate bookmark ID). |
Definition at line 126 of file qgsbookmarkmanager.cpp.
|
signal |
Emitted when a bookmark is about to be added to the manager.
|
signal |
Emitted when a bookmark is about to be removed from the manager.
|
signal |
Emitted when a bookmark has been added to the manager.
QgsBookmark QgsBookmarkManager::bookmarkById | ( | const QString & | id | ) | const |
Returns the bookmark with a matching id, or an empty bookmark if no matching bookmarks were found.
Definition at line 257 of file qgsbookmarkmanager.cpp.
|
signal |
Emitted when a bookmark is changed.
|
signal |
Emitted when a bookmark was removed from the manager.
QList< QgsBookmark > QgsBookmarkManager::bookmarks | ( | ) | const |
Returns a list of all bookmarks contained in the manager.
Definition at line 252 of file qgsbookmarkmanager.cpp.
QList< QgsBookmark > QgsBookmarkManager::bookmarksByGroup | ( | const QString & | group | ) |
Returns a list of bookmark with a matching group, or an empty list if no matching bookmarks were found.
Definition at line 267 of file qgsbookmarkmanager.cpp.
void QgsBookmarkManager::clear | ( | ) |
Removes and deletes all bookmarks from the manager.
Definition at line 226 of file qgsbookmarkmanager.cpp.
|
static |
Returns a newly created QgsBookmarkManager using a project-based bookmark store, linked to the specified project.
The returned object is parented to the project.
Definition at line 108 of file qgsbookmarkmanager.cpp.
|
static |
Exports all bookmarks from a list of managers to an xml file at the specified path.
If group is set then only bookmarks from the matching group will be exported.
Returns true
if the export was successful.
Definition at line 348 of file qgsbookmarkmanager.cpp.
QStringList QgsBookmarkManager::groups | ( | ) | const |
Returns a list of all bookmark groups contained in the manager.
Definition at line 235 of file qgsbookmarkmanager.cpp.
bool QgsBookmarkManager::importFromFile | ( | const QString & | path | ) |
Imports the bookmarks from an xml file at the specified path.
Returns true
if the import was successful.
Definition at line 423 of file qgsbookmarkmanager.cpp.
void QgsBookmarkManager::initialize | ( | const QString & | filePath | ) |
Initializes the bookmark manager.
Definition at line 499 of file qgsbookmarkmanager.cpp.
bool QgsBookmarkManager::moveBookmark | ( | const QString & | id, |
QgsBookmarkManager * | destination | ||
) |
Moves the bookmark with matching id from this manager to a destination manager.
Returns true
if the bookmark was successfully moved.
Definition at line 336 of file qgsbookmarkmanager.cpp.
bool QgsBookmarkManager::readXml | ( | const QDomElement & | element, |
const QDomDocument & | doc | ||
) |
Reads the manager's state from a DOM element, restoring all bookmarks present in the XML document.
Definition at line 278 of file qgsbookmarkmanager.cpp.
bool QgsBookmarkManager::removeBookmark | ( | const QString & | id | ) |
Removes the bookmark with matching id from the manager.
Returns true
if the removal was successful, or false
if the removal failed (eg as a result of removing a bookmark which is not contained in the manager).
Definition at line 162 of file qgsbookmarkmanager.cpp.
void QgsBookmarkManager::renameGroup | ( | const QString & | oldName, |
const QString & | newName | ||
) |
Renames an existing group from oldName to newName.
This updates all existing bookmarks to reflect the new name.
Definition at line 240 of file qgsbookmarkmanager.cpp.
bool QgsBookmarkManager::updateBookmark | ( | const QgsBookmark & | bookmark | ) |
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, or false
if the bookmark could not be updated (eg bookmark is not stored in the manager).
Definition at line 197 of file qgsbookmarkmanager.cpp.
QDomElement QgsBookmarkManager::writeXml | ( | QDomDocument & | doc | ) | const |
Returns a DOM element representing the state of the manager.
Definition at line 324 of file qgsbookmarkmanager.cpp.