QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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 "qgsexpression.h"
29#include "qgsfilewidget.h"
30
31#include <QFileDialog>
32#include <QWidget>
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 )
54
55 public:
59 explicit QgsExternalStorageFileWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
60
69 void setStorageType( const QString &storageType );
70
77 QString storageType() const;
78
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
127
133 void setExpressionContext( const QgsExpressionContext &context );
134
141
147
152 QgsMessageBar *messageBar() const;
153
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
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").
void updateLayout() override
Update buttons visibility.
void setSelectedFileNames(QStringList fileNames) override
Called whenever user select fileNames from dialog.
void setMessageBar(QgsMessageBar *messageBar)
Set messageBar to report messages.
const QString & storageAuthConfigId() const
Returns the authentication configuration ID used for the current external storage (if defined).
void setStorageType(const QString &storageType)
Set storageType storage type unique identifier as defined in QgsExternalStorageRegistry or an empty Q...
void setExpressionContext(const QgsExpressionContext &context)
Set expression context to be used when for storage URL expression evaluation.
QString storageUrlExpressionString() const
Returns the original, unmodified expression string, which once evaluated, provide the URL used to sto...
void setStorageUrlExpression(const QString &urlExpression)
Set urlExpression expression, which once evaluated, provide the URL used to store selected documents.
static QgsExpressionContextScope * createFileWidgetScope()
Creates and Returns an expression context scope specific to QgsExternalStorageFileWidget It defines t...
QgsExternalStorageFileWidget(QWidget *parent=nullptr)
QgsExternalStorageFileWidget creates a widget for selecting a file or a folder.
void setReadOnly(bool readOnly) override
Sets whether the widget should be read only.
QgsExternalStorage * externalStorage() const
Returns external storage used to store selected file names, nullptr if none have been defined.
void setStorageAuthConfigId(const QString &authCfg)
Sets the authentication configuration ID to be used for the current external storage (if defined).
QgsMessageBar * messageBar() const
Returns message bar used to report messages.
void addFileWidgetScope()
Add file widget specific scope to expression context.
void dragEnterEvent(QDragEnterEvent *event) override
const QgsExpressionContext & expressionContext() const
Returns expression context used for storage url expression evaluation.
void dropEvent(QDropEvent *event) override
Abstract interface for external storage - to be implemented by various backends and registered in Qgs...
QgsFileWidget(QWidget *parent=nullptr)
QgsFileWidget 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:199
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_END
Definition qgis_sip.h:216