Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduced QgsProjectStorage and QgsProjectStorageRegistry
This is going to be used as an abstraction of how/where project files are stored.
- Loading branch information
Showing
15 changed files
with
565 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/qgsprojectstorage.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
|
||
|
||
class QgsProjectStorage | ||
{ | ||
%Docstring | ||
Abstract interface for project storage - to be implemented by various backends | ||
and registered in QgsProjectStorageRegistry. | ||
|
||
.. versionadded:: 3.2 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgsprojectstorage.h" | ||
%End | ||
public: | ||
virtual ~QgsProjectStorage(); | ||
|
||
virtual QString type() = 0; | ||
%Docstring | ||
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. | ||
%End | ||
|
||
virtual QStringList listProjects( const QString &uri ) = 0; | ||
%Docstring | ||
Returns list of all projects for given URI (specific to each storage backend) | ||
%End | ||
|
||
virtual bool readProject( const QString &uri, QIODevice *device, QgsReadWriteContext &context ) = 0; | ||
%Docstring | ||
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 :py:class:`QgsProject`. | ||
%End | ||
|
||
virtual bool writeProject( const QString &uri, QIODevice *device, QgsReadWriteContext &context ) = 0; | ||
%Docstring | ||
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. | ||
%End | ||
|
||
|
||
}; | ||
|
||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/qgsprojectstorage.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/qgsprojectstorageregistry.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
|
||
|
||
class QgsProjectStorageRegistry | ||
{ | ||
%Docstring | ||
Registry of storage backends that QgsProject may use. | ||
This is a singleton that should be accessed through :py:func:`QgsApplication.projectStorageRegistry()` | ||
|
||
.. versionadded:: 3.2 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgsprojectstorageregistry.h" | ||
%End | ||
public: | ||
QgsProjectStorageRegistry(); | ||
~QgsProjectStorageRegistry(); | ||
|
||
QgsProjectStorage *projectStorageFromUri( const QString &uri ); | ||
%Docstring | ||
Returns storage implementation if the URI matches one. Returns null pointer otherwise (it is a normal file) | ||
%End | ||
|
||
QList<QgsProjectStorage *> projectStorages() const; | ||
%Docstring | ||
Returns a list of registered project storage implementations | ||
%End | ||
|
||
void registerProjectStorage( QgsProjectStorage *storage /Transfer/ ); | ||
%Docstring | ||
Registers a storage backend and takes ownership of it | ||
%End | ||
|
||
void unregisterProjectStorage( QgsProjectStorage *storage ); | ||
%Docstring | ||
Unregisters a storage backend and destroys its instance | ||
%End | ||
|
||
}; | ||
|
||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/qgsprojectstorageregistry.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/*************************************************************************** | ||
qgsprojectstorage.cpp | ||
-------------------------------------- | ||
Date : March 2018 | ||
Copyright : (C) 2018 by Martin Dobias | ||
Email : wonder dot sk at gmail dot com | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgsprojectstorage.h" | ||
|
||
|
||
QgsProjectStorage::~QgsProjectStorage() | ||
{ | ||
} |
Oops, something went wrong.