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

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. More...
 
- 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. More...
 

Protected Member Functions

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

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. More...
 
- Static Protected Member Functions inherited from QgsFileWidget
static bool isMultiFiles (const QString &path)
 Returns true if path is a multifiles. More...
 
- 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 39 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 41 of file qgsexternalstoragefilewidget.cpp.

Member Function Documentation

◆ addFileWidgetScope()

void QgsExternalStorageFileWidget::addFileWidgetScope ( )
protected

Add file widget specific scope to expression context.

Definition at line 135 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
3.22

Definition at line 144 of file qgsexternalstoragefilewidget.cpp.

◆ dragEnterEvent()

void QgsExternalStorageFileWidget::dragEnterEvent ( QDragEnterEvent *  event)
overrideprotected

Definition at line 286 of file qgsexternalstoragefilewidget.cpp.

◆ dropEvent()

void QgsExternalStorageFileWidget::dropEvent ( QDropEvent *  event)
overrideprotected

Definition at line 299 of file qgsexternalstoragefilewidget.cpp.

◆ expressionContext()

const QgsExpressionContext & QgsExternalStorageFileWidget::expressionContext ( ) const

Returns expression context used for storage url expression evaluation.

See also
storageUrlExpression
Since
3.22

Definition at line 153 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 97 of file qgsexternalstoragefilewidget.cpp.

◆ messageBar()

QgsMessageBar * QgsExternalStorageFileWidget::messageBar ( ) const

Returns message bar used to report messages.

Since
QGIS 3.22

Definition at line 164 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
3.22

Definition at line 128 of file qgsexternalstoragefilewidget.cpp.

◆ setMessageBar()

void QgsExternalStorageFileWidget::setMessageBar ( QgsMessageBar messageBar)

Set messageBar to report messages.

Since
QGIS 3.22

Definition at line 159 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 81 of file qgsexternalstoragefilewidget.cpp.

◆ setSelectedFileNames()

void QgsExternalStorageFileWidget::setSelectedFileNames ( QStringList  fileNames)
overrideprotectedvirtual

Called whenever user select fileNames from dialog.

Reimplemented from QgsFileWidget.

Definition at line 190 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 102 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 60 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
3.22

Definition at line 112 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 107 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 92 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
3.22

Definition at line 117 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
3.22

Definition at line 122 of file qgsexternalstoragefilewidget.cpp.

◆ updateLayout()

void QgsExternalStorageFileWidget::updateLayout ( )
overrideprotectedvirtual

Update buttons visibility.

Reimplemented from QgsFileWidget.

Definition at line 169 of file qgsexternalstoragefilewidget.cpp.

Friends And Related Function Documentation

◆ TestQgsExternalResourceWidgetWrapper

friend class TestQgsExternalResourceWidgetWrapper
friend

Definition at line 203 of file qgsexternalstoragefilewidget.h.

◆ TestQgsExternalStorageFileWidget

friend class TestQgsExternalStorageFileWidget
friend

Definition at line 204 of file qgsexternalstoragefilewidget.h.

Property Documentation

◆ auth

QString QgsExternalStorageFileWidget::auth
readwrite

Definition at line 1 of file qgsexternalstoragefilewidget.h.

◆ storageType

QString QgsExternalStorageFileWidget::storageType
readwrite

Definition at line 1 of file qgsexternalstoragefilewidget.h.

◆ storageUrlExpression

QString QgsExternalStorageFileWidget::storageUrlExpression
readwrite

Definition at line 1 of file qgsexternalstoragefilewidget.h.


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