Skip to content
Permalink
Browse files

[FEATURE] Projects in PostgreSQL

Merge of pull request #6752
  • Loading branch information
wonder-sk committed Apr 9, 2018
2 parents bff8976 + d6e7043 commit f378a23ed8e56d225ab5734766fc26fa5d832369
Showing with 1,979 additions and 88 deletions.
  1. +2 −0 python/core/core_auto.sip
  2. +7 −0 python/core/qgsapplication.sip.in
  3. +3 −0 python/core/qgsdataitem.sip.in
  4. +14 −0 python/core/qgsdatasourceuri.sip.in
  5. +39 −1 python/core/qgsproject.sip.in
  6. +117 −0 python/core/qgsprojectstorage.sip.in
  7. +61 −0 python/core/qgsprojectstorageregistry.sip.in
  8. +1 −1 python/gui/qgsbrowserdockwidget.sip.in
  9. +81 −22 src/app/qgisapp.cpp
  10. +6 −3 src/app/qgisapp.h
  11. +9 −1 src/app/qgswelcomepageitemsmodel.cpp
  12. +4 −0 src/core/CMakeLists.txt
  13. +1 −0 src/core/expression/qgsexpression.cpp
  14. +1 −1 src/core/layout/qgslayoutitemhtml.cpp
  15. +1 −1 src/core/layout/qgslayoutitemlabel.cpp
  16. +8 −0 src/core/qgsapplication.cpp
  17. +8 −0 src/core/qgsapplication.h
  18. +3 −6 src/core/qgsauxiliarystorage.cpp
  19. +0 −10 src/core/qgsbrowsermodel.cpp
  20. +9 −0 src/core/qgsdataitem.cpp
  21. +2 −0 src/core/qgsdataitem.h
  22. +37 −26 src/core/qgsdatasourceuri.cpp
  23. +12 −0 src/core/qgsdatasourceuri.h
  24. +9 −3 src/core/qgsexpressioncontext.cpp
  25. +2 −1 src/core/qgsmimedatautils.h
  26. +97 −0 src/core/qgsproject.cpp
  27. +35 −1 src/core/qgsproject.h
  28. +16 −0 src/core/qgsprojectstorage.cpp
  29. +120 −0 src/core/qgsprojectstorage.h
  30. +56 −0 src/core/qgsprojectstorageregistry.cpp
  31. +57 −0 src/core/qgsprojectstorageregistry.h
  32. +6 −0 src/core/qgsproviderregistry.cpp
  33. +3 −2 src/gui/editorwidgets/qgsexternalresourceconfigdlg.cpp
  34. +2 −2 src/gui/qgsbrowserdockwidget.cpp
  35. +1 −1 src/gui/qgsbrowserdockwidget.h
  36. +1 −1 src/gui/qgsdatasourcemanagerdialog.h
  37. +1 −1 src/gui/qgsexternalresourcewidget.cpp
  38. +2 −2 src/gui/qgsfilewidget.cpp
  39. +3 −0 src/providers/postgres/CMakeLists.txt
  40. +2 −0 src/providers/postgres/qgspgnewconnection.cpp
  41. +6 −0 src/providers/postgres/qgspostgresconn.cpp
  42. +1 −0 src/providers/postgres/qgspostgresconn.h
  43. +19 −0 src/providers/postgres/qgspostgresdataitems.cpp
  44. +304 −0 src/providers/postgres/qgspostgresprojectstorage.cpp
  45. +50 −0 src/providers/postgres/qgspostgresprojectstorage.h
  46. +173 −0 src/providers/postgres/qgspostgresprojectstoragedialog.cpp
  47. +36 −0 src/providers/postgres/qgspostgresprojectstoragedialog.h
  48. +15 −0 src/providers/postgres/qgspostgresprovider.cpp
  49. +1 −1 src/server/services/wms/qgswmsgetcontext.cpp
  50. +13 −1 src/ui/qgisapp.ui
  51. +7 −0 src/ui/qgspgnewconnectionbase.ui
  52. +105 −0 src/ui/qgspostgresprojectstoragedialog.ui
  53. +1 −0 tests/src/core/CMakeLists.txt
  54. +245 −0 tests/src/core/testqgsprojectstorage.cpp
  55. +1 −0 tests/src/python/CMakeLists.txt
  56. +163 −0 tests/src/python/test_project_storage_postgres.py
@@ -91,6 +91,8 @@
%Include qgsprojectbadlayerhandler.sip
%Include qgsprojectfiletransform.sip
%Include qgsprojectproperty.sip
%Include qgsprojectstorage.sip
%Include qgsprojectstorageregistry.sip
%Include qgsprojectversion.sip
%Include qgsproperty.sip
%Include qgspropertycollection.sip
@@ -735,6 +735,13 @@ Returns registry of available 3D renderers.
not available in Python bindings

.. versionadded:: 3.0
%End

static QgsProjectStorageRegistry *projectStorageRegistry();
%Docstring
Returns registry of available project storage implementations.

.. versionadded:: 3.2
%End

static QString nullRepresentation();
@@ -586,6 +586,9 @@ Data item that can be used to represent QGIS projects.

virtual bool hasDragEnabled() const;

virtual QgsMimeDataUtils::Uri mimeUri() const;


};

class QgsErrorItem : QgsDataItem
@@ -274,6 +274,20 @@ Returns the srid
void setSrid( const QString &srid );
%Docstring
Sets the srid
%End

static SslMode decodeSslMode( const QString &sslMode );
%Docstring
Decodes SSL mode string into enum value. If the string is not recognized, SslPrefer is returned.

.. versionadded:: 3.2
%End

static QString encodeSslMode( SslMode sslMode );
%Docstring
Encodes SSL mode enum value into a string.

.. versionadded:: 3.2
%End

};
@@ -97,13 +97,51 @@ representation.
.. seealso:: :py:func:`fileInfo`
%End

QFileInfo fileInfo() const;
QFileInfo fileInfo() const /Deprecated/;
%Docstring
Returns QFileInfo object for the project's associated file.

.. note::

The use of this method is discouraged since QGIS 3.2 as it only works with project files stored
in the file system. It is recommended to use absoluteFilePath(), baseName(), lastModifiedTime() as
replacements that are aware of the fact that projects may be saved in other project storages.

.. seealso:: :py:func:`fileName`

.. versionadded:: 2.9
\deprecated
%End

QgsProjectStorage *projectStorage() const;
%Docstring
Returns pointer to project storage implementation that handles read/write of the project file.
If the project file is stored in the local file system, returns null pointer.
The project storage object is inferred from fileName() of the project.

.. versionadded:: 3.2
%End

QDateTime lastModified() const;
%Docstring
Returns last modified time of the project file as returned by the file system (or other project storage).

.. versionadded:: 3.2
%End

QString absoluteFilePath() const;
%Docstring
Returns full absolute path to the project file if the project is stored in a file system - derived from fileName().
Returns empty string when the project is stored in a project storage (there is no concept of paths for custom project storages).

.. versionadded:: 3.2
%End

QString baseName() const;
%Docstring
Returns the base name of the project file without the path and without extension - derived from fileName().

.. versionadded:: 3.2
%End

QgsCoordinateReferenceSystem crs() const;
@@ -0,0 +1,117 @@
/************************************************************************
* 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:

class Metadata
{
%Docstring
Metadata associated with a project

.. versionadded:: 3.2
%End

%TypeHeaderCode
#include "qgsprojectstorage.h"
%End
public:
QString name;
QDateTime lastModified;
};

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

virtual bool removeProject( const QString &uri ) = 0;
%Docstring
Removes an existing project at the given URI. Returns true if the removal
was successful.
%End

virtual bool renameProject( const QString &uri, const QString &uriNew );
%Docstring
Rename an existing project at the given URI to a different URI. Returns true if renaming
was successful.
%End

virtual bool readProjectStorageMetadata( const QString &uri, QgsProjectStorage::Metadata &metadata /Out/ );
%Docstring
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.
%End

virtual QString visibleName();
%Docstring
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.
%End

virtual QString showLoadGui();
%Docstring
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.
%End

virtual QString showSaveGui();
%Docstring
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.
%End
};

/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsprojectstorage.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
@@ -0,0 +1,61 @@
/************************************************************************
* 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();

QgsProjectStorage *projectStorageFromType( const QString &type );
%Docstring
Returns storage implementation if the storage type matches one. Returns null pointer otherwise (it is a normal file)
%End

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 *
************************************************************************/
@@ -116,7 +116,7 @@ Splitter has been moved
%End

signals:
void openFile( const QString & );
void openFile( const QString &fileName, const QString &fileTypeHint = QString() );
%Docstring
Emitted when a file needs to be opened
%End

0 comments on commit f378a23

Please sign in to comment.
You can’t perform that action at this time.