QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
Loading...
Searching...
No Matches
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
40 virtual ~QgsExternalStorage() = default;
41
45 virtual QString type() const = 0;
46
51 virtual QString displayName() const = 0;
52
69 QgsExternalStorageStoredContent *store( const QString &filePath, const QString &url, const QString &authCfg = QString(), Qgis::ActionStart storingMode = Qgis::ActionStart::Deferred ) const SIP_FACTORY;
70
85 QgsExternalStorageFetchedContent *fetch( const QString &url, const QString &authCfg = QString(), Qgis::ActionStart fetchingMode = Qgis::ActionStart::Deferred ) const SIP_FACTORY;
86
87 protected:
88
93 virtual QgsExternalStorageStoredContent *doStore( const QString &filePath, const QString &url, const QString &authCfg = QString() ) const = 0 SIP_FACTORY;
94
99 virtual QgsExternalStorageFetchedContent *doFetch( const QString &url, const QString &authCfg = QString() ) const = 0 SIP_FACTORY;
100};
101
108class CORE_EXPORT QgsExternalStorageContent : public QObject
109{
110 Q_OBJECT
111
112 public:
113
117 Qgis::ContentStatus status() const;
118
122 const QString &errorString() const;
123
124 public slots:
125
129 virtual void cancel() {};
130
131 signals:
132
136 void errorOccurred( const QString &errorString );
137
142 void progressChanged( double progress );
143
147 void canceled();
148
149 protected:
150
155 void reportError( const QString &errorMsg );
156
160 void setStatus( Qgis::ContentStatus status );
161
163
164
165 private:
166
168};
169
177{
178 Q_OBJECT
179
180 public:
181
185 virtual QString filePath() const = 0;
186
190 virtual void fetch() = 0;
191
192 signals:
193
197 void fetched();
198};
199
207{
208 Q_OBJECT
209
210 public:
211
215 virtual QString url() const = 0;
216
220 virtual void store() = 0;
221
222 signals:
223
227 void stored();
228};
229
230#endif // QGSEXTERNALSTORAGE_H
ContentStatus
Status for fetched or stored content.
Definition qgis.h:1692
@ NotStarted
Content fetching/storing has not started yet.
ActionStart
Enum to determine when an operation would begin.
Definition qgis.h:1074
@ 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
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