QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
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
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
ContentStatus
Status for fetched or stored content.
Definition: qgis.h:872
@ NotStarted
Content fetching/storing has not started yet.
ActionStart
Enum to determine when an operation would begin.
Definition: qgis.h:522
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