QGIS API Documentation  3.4.15-Madeira (e83d02e274)
qgsprojectstorage.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsprojectstorage.h
3  --------------------------------------
4  Date : March 2018
5  Copyright : (C) 2018 by Martin Dobias
6  Email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSPROJECTSTORAGE_H
17 #define QGSPROJECTSTORAGE_H
18 
19 #include "qgis_core.h"
20 #include "qgis_sip.h"
21 
22 #include <QDateTime>
23 #include <QString>
24 
25 class QIODevice;
26 class QStringList;
27 
29 
37 class CORE_EXPORT QgsProjectStorage
38 {
39  public:
40 
46  class Metadata
47  {
48  public:
50  QString name;
52  QDateTime lastModified;
53  };
54 
55  virtual ~QgsProjectStorage() = default;
56 
61  virtual QString type() = 0;
62 
64  virtual QStringList listProjects( const QString &uri ) = 0;
65 
72  virtual bool readProject( const QString &uri, QIODevice *device, QgsReadWriteContext &context ) = 0;
73 
80  virtual bool writeProject( const QString &uri, QIODevice *device, QgsReadWriteContext &context ) = 0;
81 
86  virtual bool removeProject( const QString &uri ) = 0;
87 
92  virtual bool renameProject( const QString &uri, const QString &uriNew ) { Q_UNUSED( uri ); Q_UNUSED( uriNew ); return false; }
93 
98  virtual bool readProjectStorageMetadata( const QString &uri, QgsProjectStorage::Metadata &metadata SIP_OUT ) { Q_UNUSED( uri ); Q_UNUSED( metadata ); return false; }
99 
105  virtual QString visibleName() { return QString(); }
106 
111  virtual QString showLoadGui() { return QString(); }
112 
117  virtual QString showSaveGui() { return QString(); }
118 };
119 
120 #endif // QGSPROJECTSTORAGE_H
The class is used as a container of context for various read/write operations on other objects...
QString name
Name of the project - equivalent to a file&#39;s base name (i.e. without path and extension).
QDateTime lastModified
Date and local time when the file was last modified.
virtual QString visibleName()
Returns human-readable name of the storage.
virtual bool readProjectStorageMetadata(const QString &uri, QgsProjectStorage::Metadata &metadata)
Reads project metadata (e.g.
Metadata associated with a project.
virtual bool renameProject(const QString &uri, const QString &uriNew)
Rename an existing project at the given URI to a different URI.
virtual QString showLoadGui()
Opens GUI to allow user to select a project to be loaded (GUI specific to this storage type)...
#define SIP_OUT
Definition: qgis_sip.h:51
Abstract interface for project storage - to be implemented by various backends and registered in QgsP...
virtual QString showSaveGui()
Opens GUI to allow user to select where a project should be saved (GUI specific to this storage type)...