QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
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
36class 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
111class 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
163 void setStatus( Qgis::ContentStatus status );
164
166
167
168 private:
169
171};
172
180{
181 Q_OBJECT
182
183 public:
184
188 virtual QString filePath() const = 0;
189
193 virtual void fetch() = 0;
194
195 signals:
196
200 void fetched();
201};
202
210{
211 Q_OBJECT
212
213 public:
214
218 virtual QString url() const = 0;
219
223 virtual void store() = 0;
224
225 signals:
226
230 void stored();
231};
232
233#endif // QGSEXTERNALSTORAGE_H
ContentStatus
Status for fetched or stored content.
Definition: qgis.h:1432
@ NotStarted
Content fetching/storing has not started yet.
ActionStart
Enum to determine when an operation would begin.
Definition: qgis.h:875
@ Deferred
Do not start immediately the action.
Base class for QgsExternalStorage stored and fetched content.
void canceled()
The signal is emitted when content fetching/storing has been canceled.
void progressChanged(double progress)
The signal is emitted whenever content fetching/storing estimated progression value progress has chan...
void errorOccurred(const QString &errorString)
The signal is emitted when an error occurred.
virtual void cancel()
Cancels content fetching/storing.
Class for QgsExternalStorage fetched content.
virtual QString filePath() const =0
Returns fetched resource file path.
void fetched()
The signal is emitted when the resource has successfully been fetched.
virtual void fetch()=0
Starts fetching.
Class for QgsExternalStorage stored content.
void stored()
The signal is emitted when the resource has successfully been stored.
virtual QString url() const =0
Returns stored resource URL.
virtual void store()=0
Starts storing.
Abstract interface for external storage - to be implemented by various backends and registered in Qgs...
virtual ~QgsExternalStorage()=default
Destructor.
virtual QString type() const =0
Unique identifier of the external storage type.
virtual QgsExternalStorageFetchedContent * doFetch(const QString &url, const QString &authCfg=QString()) const =0
Fetches file from url using authCfg for this project external storage.
virtual QgsExternalStorageStoredContent * doStore(const QString &filePath, const QString &url, const QString &authCfg=QString()) const =0
Stores file filePath to the url using authCfg authentication for this project external storage.
virtual QString displayName() const =0
Returns the translated external storage name, which should be used for any user-visible display of th...
#define SIP_FACTORY
Definition: qgis_sip.h:76