QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
Signals | Public Member Functions | Static Public Member Functions | List of all members
QgsBookmarkManager Class Reference

Manages storage of a set of bookmarks. More...

#include <qgsbookmarkmanager.h>

Inheritance diagram for QgsBookmarkManager:
Inheritance graph
[legend]

Signals

void bookmarkAboutToBeAdded (const QString &id)
 Emitted when a bookmark is about to be added to the manager.
 
void bookmarkAboutToBeRemoved (const QString &id)
 Emitted when a bookmark is about to be removed from the manager.
 
void bookmarkAdded (const QString &id)
 Emitted when a bookmark has been added to the manager.
 
void bookmarkChanged (const QString &id)
 Emitted when a bookmark is changed.
 
void bookmarkRemoved (const QString &id)
 Emitted when a bookmark was removed from the manager.
 

Public Member Functions

 QgsBookmarkManager (QObject *parent=nullptr)
 Constructor for QgsBookmarkManager, with the specified parent object.
 
 ~QgsBookmarkManager () override
 
QString addBookmark (const QgsBookmark &bookmark, bool *ok=nullptr)
 Adds a bookmark to the manager.
 
QgsBookmark bookmarkById (const QString &id) const
 Returns the bookmark with a matching id, or an empty bookmark if no matching bookmarks were found.
 
QList< QgsBookmarkbookmarks () const
 Returns a list of all bookmarks contained in the manager.
 
QList< QgsBookmarkbookmarksByGroup (const QString &group)
 Returns a list of bookmark with a matching group, or an empty list if no matching bookmarks were found.
 
void clear ()
 Removes and deletes all bookmarks from the manager.
 
QStringList groups () const
 Returns a list of all bookmark groups contained in the manager.
 
bool importFromFile (const QString &path)
 Imports the bookmarks from an xml file at the specified path.
 
void initialize (const QString &filePath)
 Initializes the bookmark manager.
 
bool moveBookmark (const QString &id, QgsBookmarkManager *destination)
 Moves the bookmark with matching id from this manager to a destination manager.
 
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.
 
bool removeBookmark (const QString &id)
 Removes the bookmark with matching id from the manager.
 
void renameGroup (const QString &oldName, const QString &newName)
 Renames an existing group from oldName to newName.
 
bool updateBookmark (const QgsBookmark &bookmark)
 Updates the definition of a bookmark in the manager.
 
QDomElement writeXml (QDomDocument &doc) const
 Returns a DOM element representing the state of the manager.
 

Static Public Member Functions

static QgsBookmarkManagercreateProjectBasedManager (QgsProject *project)
 Returns a newly created QgsBookmarkManager using a project-based bookmark store, linked to the specified project.
 
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.
 

Detailed Description

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

Since
QGIS 3.10

Definition at line 170 of file qgsbookmarkmanager.h.

Constructor & Destructor Documentation

◆ QgsBookmarkManager()

QgsBookmarkManager::QgsBookmarkManager ( QObject *  parent = nullptr)
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 132 of file qgsbookmarkmanager.cpp.

◆ ~QgsBookmarkManager()

QgsBookmarkManager::~QgsBookmarkManager ( )
override

Definition at line 138 of file qgsbookmarkmanager.cpp.

Member Function Documentation

◆ addBookmark()

QString QgsBookmarkManager::addBookmark ( const QgsBookmark bookmark,
bool *  ok = nullptr 
)

Adds a bookmark to the manager.

Parameters
bookmarkthe bookmark to add
okif 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).
Returns
The bookmark's ID (or newly generated ID, if no ID was originally set and one was automatically generated)
See also
removeBookmark()
bookmarkAdded()

Definition at line 143 of file qgsbookmarkmanager.cpp.

◆ bookmarkAboutToBeAdded

void QgsBookmarkManager::bookmarkAboutToBeAdded ( const QString &  id)
signal

Emitted when a bookmark is about to be added to the manager.

◆ bookmarkAboutToBeRemoved

void QgsBookmarkManager::bookmarkAboutToBeRemoved ( const QString &  id)
signal

Emitted when a bookmark is about to be removed from the manager.

◆ bookmarkAdded

void QgsBookmarkManager::bookmarkAdded ( const QString &  id)
signal

Emitted when a bookmark has been added to the manager.

◆ bookmarkById()

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 274 of file qgsbookmarkmanager.cpp.

◆ bookmarkChanged

void QgsBookmarkManager::bookmarkChanged ( const QString &  id)
signal

Emitted when a bookmark is changed.

◆ bookmarkRemoved

void QgsBookmarkManager::bookmarkRemoved ( const QString &  id)
signal

Emitted when a bookmark was removed from the manager.

◆ bookmarks()

QList< QgsBookmark > QgsBookmarkManager::bookmarks ( ) const

Returns a list of all bookmarks contained in the manager.

Definition at line 269 of file qgsbookmarkmanager.cpp.

◆ bookmarksByGroup()

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 284 of file qgsbookmarkmanager.cpp.

◆ clear()

void QgsBookmarkManager::clear ( )

Removes and deletes all bookmarks from the manager.

See also
removeBookmark()

Definition at line 243 of file qgsbookmarkmanager.cpp.

◆ createProjectBasedManager()

QgsBookmarkManager * QgsBookmarkManager::createProjectBasedManager ( QgsProject project)
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 125 of file qgsbookmarkmanager.cpp.

◆ exportToFile()

bool QgsBookmarkManager::exportToFile ( const QString &  path,
const QList< const QgsBookmarkManager * > &  managers,
const QString &  group = QString() 
)
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.

See also
importFromFile()

Definition at line 365 of file qgsbookmarkmanager.cpp.

◆ groups()

QStringList QgsBookmarkManager::groups ( ) const

Returns a list of all bookmark groups contained in the manager.

Definition at line 252 of file qgsbookmarkmanager.cpp.

◆ importFromFile()

bool QgsBookmarkManager::importFromFile ( const QString &  path)

Imports the bookmarks from an xml file at the specified path.

Returns true if the import was successful.

See also
exportToFile()

Definition at line 445 of file qgsbookmarkmanager.cpp.

◆ initialize()

void QgsBookmarkManager::initialize ( const QString &  filePath)

Initializes the bookmark manager.

Definition at line 523 of file qgsbookmarkmanager.cpp.

◆ moveBookmark()

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 353 of file qgsbookmarkmanager.cpp.

◆ readXml()

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.

See also
writeXml()

Definition at line 295 of file qgsbookmarkmanager.cpp.

◆ removeBookmark()

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

See also
addBookmark()
bookmarkRemoved()
bookmarkAboutToBeRemoved()
clear()

Definition at line 179 of file qgsbookmarkmanager.cpp.

◆ renameGroup()

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 257 of file qgsbookmarkmanager.cpp.

◆ updateBookmark()

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

See also
bookmarkChanged()

Definition at line 214 of file qgsbookmarkmanager.cpp.

◆ writeXml()

QDomElement QgsBookmarkManager::writeXml ( QDomDocument &  doc) const

Returns a DOM element representing the state of the manager.

See also
readXml()

Definition at line 341 of file qgsbookmarkmanager.cpp.


The documentation for this class was generated from the following files: