QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
Loading...
Searching...
No Matches
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
41{
42
43#ifdef SIP_RUN
45 if ( qobject_cast<QgsExternalStorageFileWidget *>( sipCpp ) )
46 sipType = sipType_QgsExternalStorageFileWidget;
47 else
48 sipType = NULL;
50#endif
51
52 Q_OBJECT
53 Q_PROPERTY( QString storageType READ storageType WRITE setStorageType )
54 Q_PROPERTY( QString auth READ storageAuthConfigId WRITE setStorageAuthConfigId )
55 Q_PROPERTY( QString storageUrlExpression READ storageUrlExpressionString WRITE setStorageUrlExpression )
56
57 public:
58
62 explicit QgsExternalStorageFileWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
63
72 void setStorageType( const QString &storageType );
73
80 QString storageType() const;
81
89 QgsExternalStorage *externalStorage() const;
90
96 void setStorageAuthConfigId( const QString &authCfg );
97
102 const QString &storageAuthConfigId() const;
103
111 void setStorageUrlExpression( const QString &urlExpression );
112
120 QString storageUrlExpressionString() const;
121
129 QgsExpression *storageUrlExpression() const;
130
136 void setExpressionContext( const QgsExpressionContext &context );
137
143 const QgsExpressionContext &expressionContext() const;
144
149 void setMessageBar( QgsMessageBar *messageBar );
150
155 QgsMessageBar *messageBar() const;
156
162 static QgsExpressionContextScope *createFileWidgetScope();
163
164 void setReadOnly( bool readOnly ) override;
165
166 protected:
167
168 void updateLayout() override;
169
170 void setSelectedFileNames( QStringList fileNames ) override;
171
175 void addFileWidgetScope();
176
177 void dragEnterEvent( QDragEnterEvent *event ) override;
178
179 void dropEvent( QDropEvent *event ) override;
180
181 private:
182
183 // stores \a fileNames files using current external storage.
184 // This is a recursive method, \a storedUrls contains urls for previously stored
185 // fileNames. When all files have been successfully stored, current mFilePath
186 // is updated
187 void storeExternalFiles( QStringList fileNames, QStringList storedUrls = QStringList() );
188
190 void updateAcceptDrops();
191
192 bool mStoreInProgress = false;
193
194 QgsExternalStorage *mExternalStorage = nullptr;
195 QString mAuthCfg;
196 std::unique_ptr< QgsExpression > mStorageUrlExpression;
197 QgsExpressionContext mExpressionContext;
198 QgsExpressionContextScope *mScope = nullptr;
199
200 QLabel *mProgressLabel = nullptr;
201 QProgressBar *mProgressBar = nullptr;
202 QToolButton *mCancelButton = nullptr;
203 QgsMessageBar *mMessageBar = nullptr;
204
205 friend class TestQgsExternalResourceWidgetWrapper;
206 friend class TestQgsExternalStorageFileWidget;
207};
208
209#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...
Class for parsing and evaluation of expressions (formerly called "search strings").
The QgsExternalStorageFileWidget class creates a widget for selecting a file or a folder and stores i...
Abstract interface for external storage - to be implemented by various backends and registered in Qgs...
The QgsFileWidget class creates 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