QGIS API Documentation 3.41.0-Master (cea29feecf2)
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#ifdef SIP_RUN
44 if ( qobject_cast<QgsExternalStorageFileWidget *>( sipCpp ) )
45 sipType = sipType_QgsExternalStorageFileWidget;
46 else
47 sipType = NULL;
49#endif
50
51 Q_OBJECT
52 Q_PROPERTY( QString storageType READ storageType WRITE setStorageType )
53 Q_PROPERTY( QString auth READ storageAuthConfigId WRITE setStorageAuthConfigId )
54 Q_PROPERTY( QString storageUrlExpression READ storageUrlExpressionString WRITE setStorageUrlExpression )
55
56 public:
60 explicit QgsExternalStorageFileWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
61
70 void setStorageType( const QString &storageType );
71
78 QString storageType() const;
79
87 QgsExternalStorage *externalStorage() const;
88
94 void setStorageAuthConfigId( const QString &authCfg );
95
100 const QString &storageAuthConfigId() const;
101
109 void setStorageUrlExpression( const QString &urlExpression );
110
118 QString storageUrlExpressionString() const;
119
127 QgsExpression *storageUrlExpression() const;
128
134 void setExpressionContext( const QgsExpressionContext &context );
135
141 const QgsExpressionContext &expressionContext() const;
142
147 void setMessageBar( QgsMessageBar *messageBar );
148
153 QgsMessageBar *messageBar() const;
154
160 static QgsExpressionContextScope *createFileWidgetScope();
161
162 void setReadOnly( bool readOnly ) override;
163
164 protected:
165 void updateLayout() override;
166
167 void setSelectedFileNames( QStringList fileNames ) override;
168
172 void addFileWidgetScope();
173
174 void dragEnterEvent( QDragEnterEvent *event ) override;
175
176 void dropEvent( QDropEvent *event ) override;
177
178 private:
179 // stores \a fileNames files using current external storage.
180 // This is a recursive method, \a storedUrls contains urls for previously stored
181 // fileNames. When all files have been successfully stored, current mFilePath
182 // is updated
183 void storeExternalFiles( QStringList fileNames, QStringList storedUrls = QStringList() );
184
186 void updateAcceptDrops();
187
188 bool mStoreInProgress = false;
189
190 QgsExternalStorage *mExternalStorage = nullptr;
191 QString mAuthCfg;
192 std::unique_ptr<QgsExpression> mStorageUrlExpression;
193 QgsExpressionContext mExpressionContext;
194 QgsExpressionContextScope *mScope = nullptr;
195
196 QLabel *mProgressLabel = nullptr;
197 QProgressBar *mProgressBar = nullptr;
198 QToolButton *mCancelButton = nullptr;
199 QgsMessageBar *mMessageBar = nullptr;
200
201 friend class TestQgsExternalResourceWidgetWrapper;
202 friend class TestQgsExternalStorageFileWidget;
203};
204
205#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