Class: QgsProjectStorage¶
- class qgis.core.QgsProjectStorage¶
Bases:
sip.wrapper
Abstract interface for project storage - to be implemented by various backends and registered in
QgsProjectStorageRegistry
.Methods
Extracts and returns the file path from a storage backend
uri
, filesystem-based storage backends should implement this method in order to support relative paths storage.Returns list of all projects for given URI (specific to each storage backend)
Reads project file content stored in the backend at the specified URI to the given device (could be e.g.
Reads project metadata (e.g.
Removes an existing project at the given URI.
Rename an existing project at the given URI to a different URI.
Opens GUI to allow user to select a project to be loaded (GUI specific to this storage type).
Opens GUI to allow user to select where a project should be saved (GUI specific to this storage type).
Unique identifier of the project storage type.
Returns human-readable name of the storage.
Writes project file content stored in given device (could be e.g.
- class Metadata¶
Bases:
sip.wrapper
Metadata associated with a project
New in version 3.2.
- lastModified¶
- name¶
- filePath(self, uri: str) → str¶
Extracts and returns the file path from a storage backend
uri
, filesystem-based storage backends should implement this method in order to support relative paths storage. The default implementation returns an empty string.New in version 3.8.1.
- Parameters
uri (str) –
- Return type
str
- listProjects(self, uri: str) → List[str]¶
Returns list of all projects for given URI (specific to each storage backend)
- Parameters
uri (str) –
- Return type
List[str]
- readProject(self, uri: str, device: QIODevice, context: QgsReadWriteContext) → bool¶
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 inQgsProject
.- Parameters
uri (str) –
device (QIODevice) –
context (QgsReadWriteContext) –
- Return type
bool
- readProjectStorageMetadata(self, uri: str) → Tuple[bool, QgsProjectStorage.Metadata]¶
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.- Parameters
uri (str) –
- Return type
Tuple[bool, QgsProjectStorage.Metadata]
- removeProject(self, uri: str) → bool¶
Removes an existing project at the given URI. Returns
True
if the removal was successful.- Parameters
uri (str) –
- Return type
bool
- renameProject(self, uri: str, uriNew: str) → bool¶
Rename an existing project at the given URI to a different URI. Returns
True
if renaming was successful.- Parameters
uri (str) –
uriNew (str) –
- Return type
bool
- showLoadGui(self) → str¶
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.
Deprecated since version QGIS: 3.10 - use
QgsProjectStorageGuiProvider
for GUI-related project storage functionality- Return type
str
- showSaveGui(self) → str¶
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.
Deprecated since version QGIS: 3.10 - use
QgsProjectStorageGuiProvider
for GUI-related project storage functionality- Return type
str
- type(self) → str¶
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.- Return type
str
- visibleName(self) → str¶
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()
andshowSaveGui()
). The name may be translatable and ideally unique as well.Deprecated since version QGIS: 3.10 - use
QgsProjectStorageGuiProvider
for GUI-related project storage functionality- Return type
str
- writeProject(self, uri: str, device: QIODevice, context: QgsReadWriteContext) → bool¶
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.- Parameters
uri (str) –
device (QIODevice) –
context (QgsReadWriteContext) –
- Return type
bool