QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Properties | Friends | List of all members
QgsExternalStorageFileWidget Class Reference

The QgsExternalStorageFileWidget class creates a widget for selecting a file or a folder and stores it to a given external storage backend if defined. More...

#include <qgsexternalstoragefilewidget.h>

Inheritance diagram for QgsExternalStorageFileWidget:
Inheritance graph
[legend]

Public Member Functions

 QgsExternalStorageFileWidget (QWidget *parent=nullptr)
 QgsExternalStorageFileWidget creates a widget for selecting a file or a folder.
 
const QgsExpressionContextexpressionContext () const
 Returns expression context used for storage url expression evaluation.
 
QgsExternalStorageexternalStorage () const
 Returns external storage used to store selected file names, nullptr if none have been defined.
 
QgsMessageBarmessageBar () const
 Returns message bar used to report messages.
 
void setExpressionContext (const QgsExpressionContext &context)
 Set expression context to be used when for storage URL expression evaluation.
 
void setMessageBar (QgsMessageBar *messageBar)
 Set messageBar to report messages.
 
void setReadOnly (bool readOnly) override
 Sets whether the widget should be read only.
 
void setStorageAuthConfigId (const QString &authCfg)
 Sets the authentication configuration ID to be used for the current external storage (if defined)
 
void setStorageType (const QString &storageType)
 Set storageType storage type unique identifier as defined in QgsExternalStorageRegistry or null QString if there is no storage defined.
 
void setStorageUrlExpression (const QString &urlExpression)
 Set urlExpression expression, which once evaluated, provide the URL used to store selected documents.
 
const QString & storageAuthConfigId () const
 Returns the authentication configuration ID used for the current external storage (if defined)
 
QString storageType () const
 Returns storage type unique identifier as defined in QgsExternalStorageRegistry.
 
QgsExpressionstorageUrlExpression () const
 Returns expression, which once evaluated, provide the URL used to store selected documents.
 
QString storageUrlExpressionString () const
 Returns the original, unmodified expression string, which once evaluated, provide the URL used to store selected documents.
 
- Public Member Functions inherited from QgsFileWidget
 QgsFileWidget (QWidget *parent=nullptr)
 QgsFileWidget creates a widget for selecting a file or a folder.
 
bool confirmOverwrite () const
 Returns whether a confirmation will be shown when overwriting an existing file.
 
QString defaultRoot () const
 Returns the default root path.
 
QString dialogTitle () const
 Returns the open file dialog title.
 
QString filePath ()
 Returns the current file path(s).
 
bool fileWidgetButtonVisible () const
 Returns true if the tool button is shown.
 
QString filter () const
 returns the filters used for QDialog::getOpenFileName
 
bool fullUrl () const
 Returns true if the links shown use the full path.
 
QgsFilterLineEditlineEdit ()
 Returns a pointer to the widget's line edit, which can be used to customize the appearance and behavior of the line edit portion of the widget.
 
QSize minimumSizeHint () const override
 
QFileDialog::Options options () const
 Returns the additional options used for QFileDialog.
 
QgsFileWidget::RelativeStorage relativeStorage () const
 Returns if the relative path is with respect to the project path or the default path.
 
QString selectedFilter () const
 Returns the selected filter from the last opened file dialog.
 
void setConfirmOverwrite (bool confirmOverwrite)
 Sets whether a confirmation to overwrite an existing file will appear.
 
void setDefaultRoot (const QString &defaultRoot)
 Returns the default root path used as the first shown location when picking a file and used if the RelativeStorage is RelativeDefaultPath.
 
void setDialogTitle (const QString &title)
 Sets the title to use for the open file dialog.
 
void setFilePath (const QString &path)
 Sets the current file path.
 
void setFileWidgetButtonVisible (bool visible)
 Sets whether the tool button is visible.
 
void setFilter (const QString &filter)
 setFilter sets the filter used by the model to filters.
 
void setFullUrl (bool fullUrl)
 Sets whether links shown use the full path.
 
void setOptions (QFileDialog::Options options)
 Set additional options used for QFileDialog.
 
void setRelativeStorage (QgsFileWidget::RelativeStorage relativeStorage)
 Sets whether the relative path is with respect to the project path or the default path.
 
void setSelectedFilter (const QString &selectedFilter)
 Sets the selected filter when the file dialog opens.
 
void setStorageMode (QgsFileWidget::StorageMode storageMode)
 Sets the widget's storage mode (i.e.
 
void setUseLink (bool useLink)
 Sets whether the file path will be shown as a link.
 
QgsFileWidget::StorageMode storageMode () const
 Returns the widget's storage mode (i.e.
 
bool useLink () const
 Returns true if the file path will be shown as a link.
 

Static Public Member Functions

static QgsExpressionContextScopecreateFileWidgetScope ()
 Creates and Returns an expression context scope specific to QgsExternalStorageFileWidget It defines the variable containing the user selected file name.
 
- Static Public Member Functions inherited from QgsFileWidget
static QStringList splitFilePaths (const QString &path)
 Split the the quoted and space separated path and returns a list of strings.
 

Protected Member Functions

void addFileWidgetScope ()
 Add file widget specific scope to expression context.
 
void dragEnterEvent (QDragEnterEvent *event) override
 
void dropEvent (QDropEvent *event) override
 
void setSelectedFileNames (QStringList fileNames) override
 Called whenever user select fileNames from dialog.
 
void updateLayout () override
 Update buttons visibility.
 
- Protected Member Functions inherited from QgsFileWidget
QString relativePath (const QString &filePath, bool removeRelative) const
 Returns a filePath with relative path options applied (or not) !
 
void setFilePaths (const QStringList &filePaths)
 Update filePath according to filePaths list.
 
QString toUrl (const QString &path) const
 returns a HTML code with a link to the given file path
 

Properties

QString auth
 
QString storageType
 
QString storageUrlExpression
 
- Properties inherited from QgsFileWidget
QString defaultRoot
 
QString dialogTitle
 
bool fileWidgetButtonVisible
 
QString filter
 
bool fullUrl
 
QFileDialog::Options options
 
RelativeStorage relativeStorage
 
StorageMode storageMode
 
bool useLink
 

Friends

class TestQgsExternalResourceWidgetWrapper
 
class TestQgsExternalStorageFileWidget
 

Additional Inherited Members

- Public Types inherited from QgsFileWidget
enum  RelativeStorage { Absolute , RelativeProject , RelativeDefaultPath }
 The RelativeStorage enum determines if path is absolute, relative to the current project path or relative to a defined default path. More...
 
enum  StorageMode { GetFile , GetDirectory , GetMultipleFiles , SaveFile }
 The StorageMode enum determines if the file picker should pick files or directories. More...
 
- Signals inherited from QgsFileWidget
void fileChanged (const QString &path)
 Emitted whenever the current file or directory path is changed.
 
- Static Protected Member Functions inherited from QgsFileWidget
static bool isMultiFiles (const QString &path)
 Returns true if path is a multifiles.
 
- Protected Attributes inherited from QgsFileWidget
bool mButtonVisible = true
 
bool mConfirmOverwrite = true
 
QString mDefaultRoot
 
QString mDialogTitle
 
QString mFilePath
 
QToolButton * mFileWidgetButton = nullptr
 
QString mFilter
 
bool mFullUrl = false
 
bool mIsLinkEdited = false
 
QHBoxLayout * mLayout = nullptr
 
QgsFileDropEdit * mLineEdit = nullptr
 
QToolButton * mLinkEditButton = nullptr
 
QLabel * mLinkLabel = nullptr
 
QFileDialog::Options mOptions = QFileDialog::Options()
 
bool mReadOnly = false
 
RelativeStorage mRelativeStorage = Absolute
 
QString mSelectedFilter
 
StorageMode mStorageMode = GetFile
 
bool mUseLink = false
 

Detailed Description

The QgsExternalStorageFileWidget class creates a widget for selecting a file or a folder and stores it to a given external storage backend if defined.

Since
QGIS 3.22

Definition at line 40 of file qgsexternalstoragefilewidget.h.

Constructor & Destructor Documentation

◆ QgsExternalStorageFileWidget()

QgsExternalStorageFileWidget::QgsExternalStorageFileWidget ( QWidget *  parent = nullptr)
explicit

QgsExternalStorageFileWidget creates a widget for selecting a file or a folder.

Definition at line 37 of file qgsexternalstoragefilewidget.cpp.

Member Function Documentation

◆ addFileWidgetScope()

void QgsExternalStorageFileWidget::addFileWidgetScope ( )
protected

Add file widget specific scope to expression context.

Definition at line 131 of file qgsexternalstoragefilewidget.cpp.

◆ createFileWidgetScope()

QgsExpressionContextScope * QgsExternalStorageFileWidget::createFileWidgetScope ( )
static

Creates and Returns an expression context scope specific to QgsExternalStorageFileWidget It defines the variable containing the user selected file name.

Since
QGIS 3.22

Definition at line 140 of file qgsexternalstoragefilewidget.cpp.

◆ dragEnterEvent()

void QgsExternalStorageFileWidget::dragEnterEvent ( QDragEnterEvent *  event)
overrideprotected

Definition at line 282 of file qgsexternalstoragefilewidget.cpp.

◆ dropEvent()

void QgsExternalStorageFileWidget::dropEvent ( QDropEvent *  event)
overrideprotected

Definition at line 295 of file qgsexternalstoragefilewidget.cpp.

◆ expressionContext()

const QgsExpressionContext & QgsExternalStorageFileWidget::expressionContext ( ) const

Returns expression context used for storage url expression evaluation.

See also
storageUrlExpression
Since
QGIS 3.22

Definition at line 149 of file qgsexternalstoragefilewidget.cpp.

◆ externalStorage()

QgsExternalStorage * QgsExternalStorageFileWidget::externalStorage ( ) const

Returns external storage used to store selected file names, nullptr if none have been defined.

If no external storage has been defined, QgsExternalStorageFileWidget will only update file path according to selected files.

See also
setStorageType
Since
QGIS 3.22

Definition at line 93 of file qgsexternalstoragefilewidget.cpp.

◆ messageBar()

QgsMessageBar * QgsExternalStorageFileWidget::messageBar ( ) const

Returns message bar used to report messages.

Since
QGIS 3.22

Definition at line 160 of file qgsexternalstoragefilewidget.cpp.

◆ setExpressionContext()

void QgsExternalStorageFileWidget::setExpressionContext ( const QgsExpressionContext context)

Set expression context to be used when for storage URL expression evaluation.

See also
setStorageUrlExpression
Since
QGIS 3.22

Definition at line 124 of file qgsexternalstoragefilewidget.cpp.

◆ setMessageBar()

void QgsExternalStorageFileWidget::setMessageBar ( QgsMessageBar messageBar)

Set messageBar to report messages.

Since
QGIS 3.22

Definition at line 155 of file qgsexternalstoragefilewidget.cpp.

◆ setReadOnly()

void QgsExternalStorageFileWidget::setReadOnly ( bool  readOnly)
overridevirtual

Sets whether the widget should be read only.

Reimplemented from QgsFileWidget.

Definition at line 77 of file qgsexternalstoragefilewidget.cpp.

◆ setSelectedFileNames()

void QgsExternalStorageFileWidget::setSelectedFileNames ( QStringList  fileNames)
overrideprotectedvirtual

Called whenever user select fileNames from dialog.

Reimplemented from QgsFileWidget.

Definition at line 186 of file qgsexternalstoragefilewidget.cpp.

◆ setStorageAuthConfigId()

void QgsExternalStorageFileWidget::setStorageAuthConfigId ( const QString &  authCfg)

Sets the authentication configuration ID to be used for the current external storage (if defined)

Since
QGIS 3.22

Definition at line 98 of file qgsexternalstoragefilewidget.cpp.

◆ setStorageType()

void QgsExternalStorageFileWidget::setStorageType ( const QString &  storageType)

Set storageType storage type unique identifier as defined in QgsExternalStorageRegistry or null QString if there is no storage defined.

If no external storage has been defined, QgsExternalStorageFileWidget will only update file path according to selected files.

See also
storageType
Since
QGIS 3.22

Definition at line 56 of file qgsexternalstoragefilewidget.cpp.

◆ setStorageUrlExpression()

void QgsExternalStorageFileWidget::setStorageUrlExpression ( const QString &  urlExpression)

Set urlExpression expression, which once evaluated, provide the URL used to store selected documents.

This is used only if an external storage has been defined

See also
setStorageType()
externalStorage()
Since
QGIS 3.22

Definition at line 108 of file qgsexternalstoragefilewidget.cpp.

◆ storageAuthConfigId()

const QString & QgsExternalStorageFileWidget::storageAuthConfigId ( ) const

Returns the authentication configuration ID used for the current external storage (if defined)

Since
QGIS 3.22

Definition at line 103 of file qgsexternalstoragefilewidget.cpp.

◆ storageType()

QString QgsExternalStorageFileWidget::storageType ( ) const

Returns storage type unique identifier as defined in QgsExternalStorageRegistry.

Returns null QString if there is no storage defined, only file selection.

See also
setStorageType
Since
QGIS 3.22

Definition at line 88 of file qgsexternalstoragefilewidget.cpp.

◆ storageUrlExpression()

QgsExpression * QgsExternalStorageFileWidget::storageUrlExpression ( ) const

Returns expression, which once evaluated, provide the URL used to store selected documents.

This is used only if an external storage has been defined. Returns null if no expression has been set.

See also
setStorageUrlExpression()
Since
QGIS 3.22

Definition at line 113 of file qgsexternalstoragefilewidget.cpp.

◆ storageUrlExpressionString()

QString QgsExternalStorageFileWidget::storageUrlExpressionString ( ) const

Returns the original, unmodified expression string, which once evaluated, provide the URL used to store selected documents.

This is used only if an external storage has been defined. Returns null if no expression has been set.

See also
setStorageUrlExpression()
Since
QGIS 3.22

Definition at line 118 of file qgsexternalstoragefilewidget.cpp.

◆ updateLayout()

void QgsExternalStorageFileWidget::updateLayout ( )
overrideprotectedvirtual

Update buttons visibility.

Reimplemented from QgsFileWidget.

Definition at line 165 of file qgsexternalstoragefilewidget.cpp.

Friends And Related Symbol Documentation

◆ TestQgsExternalResourceWidgetWrapper

friend class TestQgsExternalResourceWidgetWrapper
friend

Definition at line 205 of file qgsexternalstoragefilewidget.h.

◆ TestQgsExternalStorageFileWidget

friend class TestQgsExternalStorageFileWidget
friend

Definition at line 206 of file qgsexternalstoragefilewidget.h.

Property Documentation

◆ auth

QString QgsExternalStorageFileWidget::auth
readwrite

Definition at line 54 of file qgsexternalstoragefilewidget.h.

◆ storageType

QString QgsExternalStorageFileWidget::storageType
readwrite

Definition at line 53 of file qgsexternalstoragefilewidget.h.

◆ storageUrlExpression

QString QgsExternalStorageFileWidget::storageUrlExpression
readwrite

Definition at line 55 of file qgsexternalstoragefilewidget.h.


The documentation for this class was generated from the following files: