QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgsexternalstorage.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsexternalstorage.h
3  --------------------------------------
4  Date : March 2021
5  Copyright : (C) 2021 by Julien Cabieces
6  Email : julien dot cabieces at oslandia 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 QGSEXTERNALSTORAGE_H
17 #define QGSEXTERNALSTORAGE_H
18 
19 #include "qgis_core.h"
20 #include "qgis_sip.h"
21 #include "qgis.h"
22 
23 #include <QObject>
24 #include <QString>
25 
28 
36 class CORE_EXPORT QgsExternalStorage
37 {
38  public:
39 
43  virtual ~QgsExternalStorage() = default;
44 
48  virtual QString type() const = 0;
49 
54  virtual QString displayName() const = 0;
55 
72  QgsExternalStorageStoredContent *store( const QString &filePath, const QString &url, const QString &authCfg = QString(), Qgis::ActionStart storingMode = Qgis::ActionStart::Deferred ) const SIP_FACTORY;
73 
88  QgsExternalStorageFetchedContent *fetch( const QString &url, const QString &authCfg = QString(), Qgis::ActionStart fetchingMode = Qgis::ActionStart::Deferred ) const SIP_FACTORY;
89 
90  protected:
91 
96  virtual QgsExternalStorageStoredContent *doStore( const QString &filePath, const QString &url, const QString &authCfg = QString() ) const = 0 SIP_FACTORY;
97 
102  virtual QgsExternalStorageFetchedContent *doFetch( const QString &url, const QString &authCfg = QString() ) const = 0 SIP_FACTORY;
103 };
104 
111 class CORE_EXPORT QgsExternalStorageContent : public QObject
112 {
113  Q_OBJECT
114 
115  public:
116 
120  Qgis::ContentStatus status() const;
121 
125  const QString &errorString() const;
126 
127  public slots:
128 
132  virtual void cancel() {};
133 
134  signals:
135 
139  void errorOccurred( const QString &errorString );
140 
145  void progressChanged( double progress );
146 
150  void canceled();
151 
152  protected:
153 
158  void reportError( const QString &errorMsg );
159 
161  QString mErrorString;
162 };
163 
171 {
172  Q_OBJECT
173 
174  public:
175 
179  virtual QString filePath() const = 0;
180 
184  virtual void fetch() = 0;
185 
186  signals:
187 
191  void fetched();
192 };
193 
201 {
202  Q_OBJECT
203 
204  public:
205 
209  virtual QString url() const = 0;
210 
214  virtual void store() = 0;
215 
216  signals:
217 
221  void stored();
222 };
223 
224 #endif // QGSEXTERNALSTORAGE_H
Qgis::ContentStatus
ContentStatus
Status for fetched or stored content.
Definition: qgis.h:818
QgsExternalStorageFetchedContent
Class for QgsExternalStorage fetched content.
Definition: qgsexternalstorage.h:170
Qgis::ContentStatus::NotStarted
@ NotStarted
Content fetching/storing has not started yet.
qgis.h
Qgis::ActionStart
ActionStart
Enum to determine when an operation would begin.
Definition: qgis.h:521
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsExternalStorageContent
Base class for QgsExternalStorage stored and fetched content.
Definition: qgsexternalstorage.h:111
qgis_sip.h
QgsExternalStorageStoredContent
Class for QgsExternalStorage stored content.
Definition: qgsexternalstorage.h:200
QgsExternalStorage
Abstract interface for external storage - to be implemented by various backends and registered in Qgs...
Definition: qgsexternalstorage.h:36
QgsExternalStorageContent::mErrorString
QString mErrorString
Definition: qgsexternalstorage.h:161
QgsExternalStorageContent::cancel
virtual void cancel()
Cancels content fetching/storing.
Definition: qgsexternalstorage.h:132