QGIS API Documentation 3.43.0-Master (c67cf405802)
qgsexternalstoragefilewidget.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsexternalstoragefilewidget.h
3 --------------------------------------
4 Date : August 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 QGSEXTERNALSTORAGEFILEWIDGET_H
17#define QGSEXTERNALSTORAGEFILEWIDGET_H
18
19class QLabel;
20class QToolButton;
21class QVariant;
22class QHBoxLayout;
23class QProgressBar;
25class QgsMessageBar;
26
27#include <QWidget>
28#include <QFileDialog>
29
30#include "qgsfilewidget.h"
32#include "qgsexpression.h"
33
40{
41#ifdef SIP_RUN
43 if ( qobject_cast<QgsExternalStorageFileWidget *>( sipCpp ) )
44 sipType = sipType_QgsExternalStorageFileWidget;
45 else
46 sipType = NULL;
48#endif
49
50 Q_OBJECT
51 Q_PROPERTY( QString storageType READ storageType WRITE setStorageType )
52 Q_PROPERTY( QString auth READ storageAuthConfigId WRITE setStorageAuthConfigId )
53 Q_PROPERTY( QString storageUrlExpression READ storageUrlExpressionString WRITE setStorageUrlExpression )
54
55 public:
59 explicit QgsExternalStorageFileWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
60
69 void setStorageType( const QString &storageType );
70
77 QString storageType() const;
78
86 QgsExternalStorage *externalStorage() const;
87
93 void setStorageAuthConfigId( const QString &authCfg );
94
99 const QString &storageAuthConfigId() const;
100
108 void setStorageUrlExpression( const QString &urlExpression );
109
117 QString storageUrlExpressionString() const;
118
126 QgsExpression *storageUrlExpression() const;
127
133 void setExpressionContext( const QgsExpressionContext &context );
134
140 const QgsExpressionContext &expressionContext() const;
141
146 void setMessageBar( QgsMessageBar *messageBar );
147
152 QgsMessageBar *messageBar() const;
153
159 static QgsExpressionContextScope *createFileWidgetScope();
160
161 void setReadOnly( bool readOnly ) override;
162
163 protected:
164 void updateLayout() override;
165
166 void setSelectedFileNames( QStringList fileNames ) override;
167
171 void addFileWidgetScope();
172
173 void dragEnterEvent( QDragEnterEvent *event ) override;
174
175 void dropEvent( QDropEvent *event ) override;
176
177 private:
178 // stores \a fileNames files using current external storage.
179 // This is a recursive method, \a storedUrls contains urls for previously stored
180 // fileNames. When all files have been successfully stored, current mFilePath
181 // is updated
182 void storeExternalFiles( QStringList fileNames, QStringList storedUrls = QStringList() );
183
185 void updateAcceptDrops();
186
187 bool mStoreInProgress = false;
188
189 QgsExternalStorage *mExternalStorage = nullptr;
190 QString mAuthCfg;
191 std::unique_ptr<QgsExpression> mStorageUrlExpression;
192 QgsExpressionContext mExpressionContext;
193 QgsExpressionContextScope *mScope = nullptr;
194
195 QLabel *mProgressLabel = nullptr;
196 QProgressBar *mProgressBar = nullptr;
197 QToolButton *mCancelButton = nullptr;
198 QgsMessageBar *mMessageBar = nullptr;
199
200 friend class TestQgsExternalResourceWidgetWrapper;
201 friend class TestQgsExternalStorageFileWidget;
202};
203
204#endif // QGSEXTERNALSTORAGEFILEWIDGET_H
Single scope for storing variables and functions for use within a QgsExpressionContext.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Handles parsing and evaluation of expressions (formerly called "search strings").
A widget for selecting a file or a folder and optionally storing it to an external storage backend.
Abstract interface for external storage - to be implemented by various backends and registered in Qgs...
A widget for selecting a file or a folder.
A bar for displaying non-blocking messages to the user.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition qgis_sip.h:191
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_END
Definition qgis_sip.h:208