QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
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
110 void setStorageUrlExpression( const QString &urlExpression );
111
119 QString storageUrlExpressionString() const;
120
128 QgsExpression *storageUrlExpression() const;
129
135 void setExpressionContext( const QgsExpressionContext &context );
136
142 const QgsExpressionContext &expressionContext() const;
143
148 void setMessageBar( QgsMessageBar *messageBar );
149
154 QgsMessageBar *messageBar() const;
155
161 static QgsExpressionContextScope *createFileWidgetScope();
162
163 void setReadOnly( bool readOnly ) override;
164
165 protected:
166
167 void updateLayout() override;
168
169 void setSelectedFileNames( QStringList fileNames ) override;
170
174 void addFileWidgetScope();
175
176 void dragEnterEvent( QDragEnterEvent *event ) override;
177
178 void dropEvent( QDropEvent *event ) override;
179
180 private:
181
182 // stores \a fileNames files using current external storage.
183 // This is a recursive method, \a storedUrls contains urls for previously stored
184 // fileNames. When all files have been successfully stored, current mFilePath
185 // is updated
186 void storeExternalFiles( QStringList fileNames, QStringList storedUrls = QStringList() );
187
189 void updateAcceptDrops();
190
191 bool mStoreInProgress = false;
192
193 QgsExternalStorage *mExternalStorage = nullptr;
194 QString mAuthCfg;
195 std::unique_ptr< QgsExpression > mStorageUrlExpression;
196 QgsExpressionContext mExpressionContext;
197 QgsExpressionContextScope *mScope = nullptr;
198
199 QLabel *mProgressLabel = nullptr;
200 QProgressBar *mProgressBar = nullptr;
201 QToolButton *mCancelButton = nullptr;
202 QgsMessageBar *mMessageBar = nullptr;
203
204 friend class TestQgsExternalResourceWidgetWrapper;
205 friend class TestQgsExternalStorageFileWidget;
206};
207
208#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.
Definition: qgsfilewidget.h:39
virtual void setSelectedFileNames(QStringList fileNames)
Called whenever user select fileNames from dialog.
virtual void setReadOnly(bool readOnly)
Sets whether the widget should be read only.
virtual void updateLayout()
Update buttons visibility.
A bar for displaying non-blocking messages to the user.
Definition: qgsmessagebar.h:61
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:186
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
#define SIP_END
Definition: qgis_sip.h:203