QgsProjectStorage class

Abstract interface for project storage - to be implemented by various backends and registered in QgsProjectStorageRegistry.

Contents

Public types

class Metadata
Metadata associated with a project.

Public functions

auto listProjects(const QString& uri) -> QStringList pure virtual
Returns list of all projects for given URI (specific to each storage backend)
auto readProject(const QString& uri, QIODevice* device, QgsReadWriteContext& context) -> bool pure virtual
Reads project file content stored in the backend at the specified URI to the given device (could be e.g.
auto readProjectStorageMetadata(const QString& uri, QgsProjectStorage::Metadata& metadata) -> bool virtual
Reads project metadata (e.g.
auto removeProject(const QString& uri) -> bool pure virtual
Removes an existing project at the given URI.
auto renameProject(const QString& uri, const QString& uriNew) -> bool virtual
Rename an existing project at the given URI to a different URI.
auto showLoadGui() -> QString virtual
Opens GUI to allow user to select a project to be loaded (GUI specific to this storage type).
auto showSaveGui() -> QString virtual
Opens GUI to allow user to select where a project should be saved (GUI specific to this storage type).
auto type() -> QString pure virtual
Unique identifier of the project storage type.
auto visibleName() -> QString virtual
Returns human-readable name of the storage.
auto writeProject(const QString& uri, QIODevice* device, QgsReadWriteContext& context) -> bool pure virtual
Writes project file content stored in given device (could be e.g.

Function documentation

bool QgsProjectStorage::readProject(const QString& uri, QIODevice* device, QgsReadWriteContext& context) pure virtual

Reads project file content stored in the backend at the specified URI to the given device (could be e.g.

a temporary file or a memory buffer). The device is expected to be empty when passed to readProject() so that the method can write all data to it and then rewind it using seek(0) to make it ready for reading in QgsProject.

bool QgsProjectStorage::readProjectStorageMetadata(const QString& uri, QgsProjectStorage::Metadata& metadata) virtual

Reads project metadata (e.g.

last modified time) if this is supported by the storage implementation. Returns true if the metadata were read with success.

bool QgsProjectStorage::removeProject(const QString& uri) pure virtual

Removes an existing project at the given URI.

Returns true if the removal was successful.

bool QgsProjectStorage::renameProject(const QString& uri, const QString& uriNew) virtual

Rename an existing project at the given URI to a different URI.

Returns true if renaming was successful.

QString QgsProjectStorage::showLoadGui() virtual

Opens GUI to allow user to select a project to be loaded (GUI specific to this storage type).

Returns project URI if user has picked a project or empty string if the GUI was canceled.

QString QgsProjectStorage::showSaveGui() virtual

Opens GUI to allow user to select where a project should be saved (GUI specific to this storage type).

Returns project URI if user has picked a destination or empty string if the GUI was canceled.

QString QgsProjectStorage::type() pure virtual

Unique identifier of the project storage type.

If type() returns "memory", all project file names starting with "memory:" will have read/write redirected through that storage implementation.

QString QgsProjectStorage::visibleName() virtual

Returns human-readable name of the storage.

Used as the menu item text in QGIS. Empty name indicates that the storage does not implement GUI support (showLoadGui() and showSaveGui()). The name may be translatable and ideally unique as well.

bool QgsProjectStorage::writeProject(const QString& uri, QIODevice* device, QgsReadWriteContext& context) pure virtual

Writes project file content stored in given device (could be e.g.

a temporary file or a memory buffer) using the backend to the specified URI. The device is expected to contain all project file data and having position at the start of the content when passed to writeProject() so that the method can read all data from it until it reaches its end.