Skip to content

Commit f378a23

Browse files
authored
[FEATURE] Projects in PostgreSQL
Merge of pull request #6752
2 parents bff8976 + d6e7043 commit f378a23

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1979
-88
lines changed

python/core/core_auto.sip

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@
9191
%Include qgsprojectbadlayerhandler.sip
9292
%Include qgsprojectfiletransform.sip
9393
%Include qgsprojectproperty.sip
94+
%Include qgsprojectstorage.sip
95+
%Include qgsprojectstorageregistry.sip
9496
%Include qgsprojectversion.sip
9597
%Include qgsproperty.sip
9698
%Include qgspropertycollection.sip

python/core/qgsapplication.sip.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,13 @@ Returns registry of available 3D renderers.
735735
not available in Python bindings
736736

737737
.. versionadded:: 3.0
738+
%End
739+
740+
static QgsProjectStorageRegistry *projectStorageRegistry();
741+
%Docstring
742+
Returns registry of available project storage implementations.
743+
744+
.. versionadded:: 3.2
738745
%End
739746

740747
static QString nullRepresentation();

python/core/qgsdataitem.sip.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,9 @@ Data item that can be used to represent QGIS projects.
586586

587587
virtual bool hasDragEnabled() const;
588588

589+
virtual QgsMimeDataUtils::Uri mimeUri() const;
590+
591+
589592
};
590593

591594
class QgsErrorItem : QgsDataItem

python/core/qgsdatasourceuri.sip.in

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,20 @@ Returns the srid
274274
void setSrid( const QString &srid );
275275
%Docstring
276276
Sets the srid
277+
%End
278+
279+
static SslMode decodeSslMode( const QString &sslMode );
280+
%Docstring
281+
Decodes SSL mode string into enum value. If the string is not recognized, SslPrefer is returned.
282+
283+
.. versionadded:: 3.2
284+
%End
285+
286+
static QString encodeSslMode( SslMode sslMode );
287+
%Docstring
288+
Encodes SSL mode enum value into a string.
289+
290+
.. versionadded:: 3.2
277291
%End
278292

279293
};

python/core/qgsproject.sip.in

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,51 @@ representation.
9797
.. seealso:: :py:func:`fileInfo`
9898
%End
9999

100-
QFileInfo fileInfo() const;
100+
QFileInfo fileInfo() const /Deprecated/;
101101
%Docstring
102102
Returns QFileInfo object for the project's associated file.
103103

104+
.. note::
105+
106+
The use of this method is discouraged since QGIS 3.2 as it only works with project files stored
107+
in the file system. It is recommended to use absoluteFilePath(), baseName(), lastModifiedTime() as
108+
replacements that are aware of the fact that projects may be saved in other project storages.
109+
104110
.. seealso:: :py:func:`fileName`
105111

106112
.. versionadded:: 2.9
113+
\deprecated
114+
%End
115+
116+
QgsProjectStorage *projectStorage() const;
117+
%Docstring
118+
Returns pointer to project storage implementation that handles read/write of the project file.
119+
If the project file is stored in the local file system, returns null pointer.
120+
The project storage object is inferred from fileName() of the project.
121+
122+
.. versionadded:: 3.2
123+
%End
124+
125+
QDateTime lastModified() const;
126+
%Docstring
127+
Returns last modified time of the project file as returned by the file system (or other project storage).
128+
129+
.. versionadded:: 3.2
130+
%End
131+
132+
QString absoluteFilePath() const;
133+
%Docstring
134+
Returns full absolute path to the project file if the project is stored in a file system - derived from fileName().
135+
Returns empty string when the project is stored in a project storage (there is no concept of paths for custom project storages).
136+
137+
.. versionadded:: 3.2
138+
%End
139+
140+
QString baseName() const;
141+
%Docstring
142+
Returns the base name of the project file without the path and without extension - derived from fileName().
143+
144+
.. versionadded:: 3.2
107145
%End
108146

109147
QgsCoordinateReferenceSystem crs() const;

python/core/qgsprojectstorage.sip.in

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/************************************************************************
2+
* This file has been generated automatically from *
3+
* *
4+
* src/core/qgsprojectstorage.h *
5+
* *
6+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
7+
************************************************************************/
8+
9+
10+
11+
12+
13+
14+
class QgsProjectStorage
15+
{
16+
%Docstring
17+
Abstract interface for project storage - to be implemented by various backends
18+
and registered in QgsProjectStorageRegistry.
19+
20+
.. versionadded:: 3.2
21+
%End
22+
23+
%TypeHeaderCode
24+
#include "qgsprojectstorage.h"
25+
%End
26+
public:
27+
28+
class Metadata
29+
{
30+
%Docstring
31+
Metadata associated with a project
32+
33+
.. versionadded:: 3.2
34+
%End
35+
36+
%TypeHeaderCode
37+
#include "qgsprojectstorage.h"
38+
%End
39+
public:
40+
QString name;
41+
QDateTime lastModified;
42+
};
43+
44+
virtual ~QgsProjectStorage();
45+
46+
virtual QString type() = 0;
47+
%Docstring
48+
Unique identifier of the project storage type. If type() returns "memory", all project file names
49+
starting with "memory:" will have read/write redirected through that storage implementation.
50+
%End
51+
52+
virtual QStringList listProjects( const QString &uri ) = 0;
53+
%Docstring
54+
Returns list of all projects for given URI (specific to each storage backend)
55+
%End
56+
57+
virtual bool readProject( const QString &uri, QIODevice *device, QgsReadWriteContext &context ) = 0;
58+
%Docstring
59+
Reads project file content stored in the backend at the specified URI to the given device
60+
(could be e.g. a temporary file or a memory buffer). The device is expected to be empty
61+
when passed to readProject() so that the method can write all data to it and then rewind
62+
it using seek(0) to make it ready for reading in :py:class:`QgsProject`.
63+
%End
64+
65+
virtual bool writeProject( const QString &uri, QIODevice *device, QgsReadWriteContext &context ) = 0;
66+
%Docstring
67+
Writes project file content stored in given device (could be e.g. a temporary file or a memory buffer)
68+
using the backend to the specified URI. The device is expected to contain all project file data
69+
and having position at the start of the content when passed to writeProject() so that the method
70+
can read all data from it until it reaches its end.
71+
%End
72+
73+
virtual bool removeProject( const QString &uri ) = 0;
74+
%Docstring
75+
Removes an existing project at the given URI. Returns true if the removal
76+
was successful.
77+
%End
78+
79+
virtual bool renameProject( const QString &uri, const QString &uriNew );
80+
%Docstring
81+
Rename an existing project at the given URI to a different URI. Returns true if renaming
82+
was successful.
83+
%End
84+
85+
virtual bool readProjectStorageMetadata( const QString &uri, QgsProjectStorage::Metadata &metadata /Out/ );
86+
%Docstring
87+
Reads project metadata (e.g. last modified time) if this is supported by the storage implementation.
88+
Returns true if the metadata were read with success.
89+
%End
90+
91+
virtual QString visibleName();
92+
%Docstring
93+
Returns human-readable name of the storage. Used as the menu item text in QGIS. Empty name
94+
indicates that the storage does not implement GUI support (showLoadGui() and showSaveGui()).
95+
The name may be translatable and ideally unique as well.
96+
%End
97+
98+
virtual QString showLoadGui();
99+
%Docstring
100+
Opens GUI to allow user to select a project to be loaded (GUI specific to this storage type).
101+
Returns project URI if user has picked a project or empty string if the GUI was canceled.
102+
%End
103+
104+
virtual QString showSaveGui();
105+
%Docstring
106+
Opens GUI to allow user to select where a project should be saved (GUI specific to this storage type).
107+
Returns project URI if user has picked a destination or empty string if the GUI was canceled.
108+
%End
109+
};
110+
111+
/************************************************************************
112+
* This file has been generated automatically from *
113+
* *
114+
* src/core/qgsprojectstorage.h *
115+
* *
116+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
117+
************************************************************************/
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/************************************************************************
2+
* This file has been generated automatically from *
3+
* *
4+
* src/core/qgsprojectstorageregistry.h *
5+
* *
6+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
7+
************************************************************************/
8+
9+
10+
11+
12+
13+
class QgsProjectStorageRegistry
14+
{
15+
%Docstring
16+
Registry of storage backends that QgsProject may use.
17+
This is a singleton that should be accessed through :py:func:`QgsApplication.projectStorageRegistry()`
18+
19+
.. versionadded:: 3.2
20+
%End
21+
22+
%TypeHeaderCode
23+
#include "qgsprojectstorageregistry.h"
24+
%End
25+
public:
26+
~QgsProjectStorageRegistry();
27+
28+
QgsProjectStorage *projectStorageFromType( const QString &type );
29+
%Docstring
30+
Returns storage implementation if the storage type matches one. Returns null pointer otherwise (it is a normal file)
31+
%End
32+
33+
QgsProjectStorage *projectStorageFromUri( const QString &uri );
34+
%Docstring
35+
Returns storage implementation if the URI matches one. Returns null pointer otherwise (it is a normal file)
36+
%End
37+
38+
QList<QgsProjectStorage *> projectStorages() const;
39+
%Docstring
40+
Returns a list of registered project storage implementations
41+
%End
42+
43+
void registerProjectStorage( QgsProjectStorage *storage /Transfer/ );
44+
%Docstring
45+
Registers a storage backend and takes ownership of it
46+
%End
47+
48+
void unregisterProjectStorage( QgsProjectStorage *storage );
49+
%Docstring
50+
Unregisters a storage backend and destroys its instance
51+
%End
52+
53+
};
54+
55+
/************************************************************************
56+
* This file has been generated automatically from *
57+
* *
58+
* src/core/qgsprojectstorageregistry.h *
59+
* *
60+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
61+
************************************************************************/

python/gui/qgsbrowserdockwidget.sip.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ Splitter has been moved
116116
%End
117117

118118
signals:
119-
void openFile( const QString & );
119+
void openFile( const QString &fileName, const QString &fileTypeHint = QString() );
120120
%Docstring
121121
Emitted when a file needs to be opened
122122
%End

0 commit comments

Comments
 (0)