QGIS API Documentation 3.41.0-Master (d5b93354e9c)
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
QgsProjectStorage Class Referenceabstract

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

#include <qgsprojectstorage.h>

Classes

class  Metadata
 Metadata associated with a project. More...
 

Public Member Functions

virtual ~QgsProjectStorage ()=default
 
virtual QString filePath (const QString &uri)
 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.
 
virtual bool isSupportedUri (const QString &uri) const
 Returns true if the specified uri is supported by the storage provider.
 
virtual QStringList listProjects (const QString &uri)=0
 Returns list of all projects for given URI (specific to each storage backend)
 
virtual bool readProject (const QString &uri, QIODevice *device, QgsReadWriteContext &context)=0
 Reads project file content stored in the backend at the specified URI to the given device (could be e.g.
 
virtual bool readProjectStorageMetadata (const QString &uri, QgsProjectStorage::Metadata &metadata)
 Reads project metadata (e.g.
 
virtual bool removeProject (const QString &uri)=0
 Removes an existing project at the given URI.
 
virtual bool renameProject (const QString &uri, const QString &uriNew)
 Rename an existing project at the given URI to a different URI.
 
virtual Q_DECL_DEPRECATED QString showLoadGui ()
 Opens GUI to allow user to select a project to be loaded (GUI specific to this storage type).
 
virtual Q_DECL_DEPRECATED QString showSaveGui ()
 Opens GUI to allow user to select where a project should be saved (GUI specific to this storage type).
 
virtual QString type ()=0
 Unique identifier of the project storage type.
 
virtual Q_DECL_DEPRECATED QString visibleName ()
 Returns human-readable name of the storage.
 
virtual bool writeProject (const QString &uri, QIODevice *device, QgsReadWriteContext &context)=0
 Writes project file content stored in given device (could be e.g.
 

Detailed Description

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

Since
QGIS 3.2

Definition at line 36 of file qgsprojectstorage.h.

Constructor & Destructor Documentation

◆ ~QgsProjectStorage()

virtual QgsProjectStorage::~QgsProjectStorage ( )
virtualdefault

Member Function Documentation

◆ filePath()

QString QgsProjectStorage::filePath ( const QString &  uri)
virtual

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.

Since
QGIS 3.8.1

Definition at line 23 of file qgsprojectstorage.cpp.

◆ isSupportedUri()

bool QgsProjectStorage::isSupportedUri ( const QString &  uri) const
virtual

Returns true if the specified uri is supported by the storage provider.

Note
This method does not actually test whether the uri contains projects, but rather it is a quick test to determine if it is possible that the uri may contain projects.
Since
QGIS 3.22

Definition at line 18 of file qgsprojectstorage.cpp.

◆ listProjects()

virtual QStringList QgsProjectStorage::listProjects ( const QString &  uri)
pure virtual

Returns list of all projects for given URI (specific to each storage backend)

◆ readProject()

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

◆ readProjectStorageMetadata()

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

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.

Definition at line 108 of file qgsprojectstorage.h.

◆ removeProject()

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

Removes an existing project at the given URI.

Returns true if the removal was successful.

◆ renameProject()

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

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

Returns true if renaming was successful.

Definition at line 102 of file qgsprojectstorage.h.

◆ showLoadGui()

virtual Q_DECL_DEPRECATED QString QgsProjectStorage::showLoadGui ( )
inlinevirtual

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:
QGIS 3.10. Use QgsProjectStorageGuiProvider for GUI-related project storage functionality.

Definition at line 131 of file qgsprojectstorage.h.

◆ showSaveGui()

virtual Q_DECL_DEPRECATED QString QgsProjectStorage::showSaveGui ( )
inlinevirtual

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:
QGIS 3.10. Use QgsProjectStorageGuiProvider for GUI-related project storage functionality.

Definition at line 138 of file qgsprojectstorage.h.

◆ type()

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

◆ visibleName()

virtual Q_DECL_DEPRECATED QString QgsProjectStorage::visibleName ( )
inlinevirtual

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.

Deprecated:
QGIS 3.10. Use QgsProjectStorageGuiProvider for GUI-related project storage functionality.

Definition at line 124 of file qgsprojectstorage.h.

◆ writeProject()

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


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