|
QGIS API Documentation 3.99.0-Master (d270888f95f)
|
A widget for selecting a file or a folder. More...
#include <qgsfilewidget.h>

Public Types | |
| 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 | |
| void | fileChanged (const QString &path) |
| Emitted whenever the current file or directory path is changed. | |
Public Member Functions | |
| 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 () const |
| 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. | |
| QgsFilterLineEdit * | lineEdit () |
| 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. | |
| virtual void | setReadOnly (bool readOnly) |
| Sets whether the widget should be read only. | |
| 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 QStringList | splitFilePaths (const QString &path) |
| Split the the quoted and space separated path and returns a list of strings. | |
Protected Member Functions | |
| 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. | |
| virtual void | setSelectedFileNames (QStringList fileNames) |
| Called whenever user select fileNames from dialog. | |
| QString | toUrl (const QString &path) const |
| returns a HTML code with a link to the given file path | |
| virtual void | updateLayout () |
| Update buttons visibility. | |
Static Protected Member Functions | |
| static bool | isMultiFiles (const QString &path) |
| Returns true if path is a multifiles. | |
Protected Attributes | |
| 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 |
Properties | |
| QString | defaultRoot |
| QString | dialogTitle |
| bool | fileWidgetButtonVisible |
| QString | filter |
| bool | fullUrl |
| QFileDialog::Options | options |
| RelativeStorage | relativeStorage |
| StorageMode | storageMode |
| bool | useLink |
Friends | |
| class | TestQgsExternalResourceWidgetWrapper |
| class | TestQgsExternalStorageFileWidget |
| class | TestQgsFileWidget |
A widget for selecting a file or a folder.
Definition at line 37 of file qgsfilewidget.h.
The RelativeStorage enum determines if path is absolute, relative to the current project path or relative to a defined default path.
| Enumerator | |
|---|---|
| Absolute | |
| RelativeProject | |
| RelativeDefaultPath | |
Definition at line 75 of file qgsfilewidget.h.
The StorageMode enum determines if the file picker should pick files or directories.
| Enumerator | |
|---|---|
| GetFile | Select a single file. |
| GetDirectory | Select a directory. |
| GetMultipleFiles | Select multiple files. |
| SaveFile | Select a single new or pre-existing file. |
Definition at line 63 of file qgsfilewidget.h.
|
explicit |
QgsFileWidget creates a widget for selecting a file or a folder.
Definition at line 41 of file qgsfilewidget.cpp.
|
inline |
Returns whether a confirmation will be shown when overwriting an existing file.
Definition at line 194 of file qgsfilewidget.h.
| QString QgsFileWidget::defaultRoot | ( | ) | const |
Returns the default root path.
Definition at line 252 of file qgsfilewidget.cpp.
| QString QgsFileWidget::dialogTitle | ( | ) | const |
Returns the open file dialog title.
Definition at line 149 of file qgsfilewidget.cpp.
|
signal |
Emitted whenever the current file or directory path is changed.
| QString QgsFileWidget::filePath | ( | ) | const |
Returns the current file path(s).
When multiple files are selected they are quoted and separated by a single space (for example: '"/path/foo" "path/bar"')
Definition at line 82 of file qgsfilewidget.cpp.
| bool QgsFileWidget::fileWidgetButtonVisible | ( | ) | const |
Returns true if the tool button is shown.
Definition at line 180 of file qgsfilewidget.cpp.
| QString QgsFileWidget::filter | ( | ) | const |
returns the filters used for QDialog::getOpenFileName
Definition at line 159 of file qgsfilewidget.cpp.
| bool QgsFileWidget::fullUrl | ( | ) | const |
Returns true if the links shown use the full path.
Definition at line 242 of file qgsfilewidget.cpp.
|
staticprotected |
Returns true if path is a multifiles.
Definition at line 191 of file qgsfilewidget.cpp.
| QgsFilterLineEdit * QgsFileWidget::lineEdit | ( | ) |
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.
Definition at line 283 of file qgsfilewidget.cpp.
|
override |
Definition at line 473 of file qgsfilewidget.cpp.
| QFileDialog::Options QgsFileWidget::options | ( | ) | const |
Returns the additional options used for QFileDialog.
Definition at line 170 of file qgsfilewidget.cpp.
|
protected |
Returns a filePath with relative path options applied (or not) !
Definition at line 446 of file qgsfilewidget.cpp.
| QgsFileWidget::RelativeStorage QgsFileWidget::relativeStorage | ( | ) | const |
Returns if the relative path is with respect to the project path or the default path.
Definition at line 273 of file qgsfilewidget.cpp.
|
inline |
Returns the selected filter from the last opened file dialog.
Definition at line 176 of file qgsfilewidget.h.
|
inline |
Sets whether a confirmation to overwrite an existing file will appear.
By default, a confirmation will appear.
| confirmOverwrite | If set to true, an overwrite confirmation will be shown |
Definition at line 187 of file qgsfilewidget.h.
| void QgsFileWidget::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.
Definition at line 257 of file qgsfilewidget.cpp.
| void QgsFileWidget::setDialogTitle | ( | const QString & | title | ) |
Sets the title to use for the open file dialog.
Definition at line 154 of file qgsfilewidget.cpp.
| void QgsFileWidget::setFilePath | ( | const QString & | path | ) |
|
protected |
Update filePath according to filePaths list.
Definition at line 427 of file qgsfilewidget.cpp.
| void QgsFileWidget::setFileWidgetButtonVisible | ( | bool | visible | ) |
Sets whether the tool button is visible.
Definition at line 185 of file qgsfilewidget.cpp.
| void QgsFileWidget::setFilter | ( | const QString & | filter | ) |
setFilter sets the filter used by the model to filters.
The filter is used to specify the kind of files that should be shown.
| filter | Only files that match the given filter are shown, it may be an empty string. If you want multiple filters, separate them with ';;', |
Definition at line 164 of file qgsfilewidget.cpp.
| void QgsFileWidget::setFullUrl | ( | bool | fullUrl | ) |
Sets whether links shown use the full path.
Definition at line 247 of file qgsfilewidget.cpp.
| void QgsFileWidget::setOptions | ( | QFileDialog::Options | options | ) |
Set additional options used for QFileDialog.
These options affect the look and feel of the QFileDialog shown when a user is interactively browsing for paths.
Definition at line 175 of file qgsfilewidget.cpp.
|
virtual |
Sets whether the widget should be read only.
Reimplemented in QgsExternalStorageFileWidget.
Definition at line 139 of file qgsfilewidget.cpp.
| void QgsFileWidget::setRelativeStorage | ( | QgsFileWidget::RelativeStorage | relativeStorage | ) |
Sets whether the relative path is with respect to the project path or the default path.
Definition at line 278 of file qgsfilewidget.cpp.
|
protectedvirtual |
Called whenever user select fileNames from dialog.
Reimplemented in QgsExternalStorageFileWidget.
Definition at line 414 of file qgsfilewidget.cpp.
|
inline |
Sets the selected filter when the file dialog opens.
Definition at line 169 of file qgsfilewidget.h.
| void QgsFileWidget::setStorageMode | ( | QgsFileWidget::StorageMode | storageMode | ) |
Sets the widget's storage mode (i.e.
file or directory).
Definition at line 267 of file qgsfilewidget.cpp.
| void QgsFileWidget::setUseLink | ( | bool | useLink | ) |
Sets whether the file path will be shown as a link.
Definition at line 233 of file qgsfilewidget.cpp.
|
static |
Split the the quoted and space separated path and returns a list of strings.
Definition at line 87 of file qgsfilewidget.cpp.
| QgsFileWidget::StorageMode QgsFileWidget::storageMode | ( | ) | const |
Returns the widget's storage mode (i.e.
file or directory).
Definition at line 262 of file qgsfilewidget.cpp.
|
protected |
returns a HTML code with a link to the given file path
Definition at line 483 of file qgsfilewidget.cpp.
|
protectedvirtual |
Update buttons visibility.
Reimplemented in QgsExternalStorageFileWidget.
Definition at line 288 of file qgsfilewidget.cpp.
| bool QgsFileWidget::useLink | ( | ) | const |
Returns true if the file path will be shown as a link.
Definition at line 228 of file qgsfilewidget.cpp.
|
friend |
Definition at line 353 of file qgsfilewidget.h.
|
friend |
Definition at line 352 of file qgsfilewidget.h.
|
friend |
Definition at line 351 of file qgsfilewidget.h.
|
protected |
Definition at line 321 of file qgsfilewidget.h.
|
protected |
Definition at line 330 of file qgsfilewidget.h.
|
protected |
Definition at line 329 of file qgsfilewidget.h.
|
protected |
Definition at line 326 of file qgsfilewidget.h.
|
protected |
Definition at line 320 of file qgsfilewidget.h.
|
protected |
Definition at line 338 of file qgsfilewidget.h.
|
protected |
Definition at line 327 of file qgsfilewidget.h.
|
protected |
Definition at line 323 of file qgsfilewidget.h.
|
protected |
Definition at line 325 of file qgsfilewidget.h.
|
protected |
Definition at line 339 of file qgsfilewidget.h.
|
protected |
Definition at line 336 of file qgsfilewidget.h.
|
protected |
Definition at line 337 of file qgsfilewidget.h.
|
protected |
Definition at line 335 of file qgsfilewidget.h.
|
protected |
Definition at line 333 of file qgsfilewidget.h.
|
protected |
Definition at line 324 of file qgsfilewidget.h.
|
protected |
Definition at line 332 of file qgsfilewidget.h.
|
protected |
Definition at line 328 of file qgsfilewidget.h.
|
protected |
Definition at line 331 of file qgsfilewidget.h.
|
protected |
Definition at line 322 of file qgsfilewidget.h.
|
readwrite |
Definition at line 54 of file qgsfilewidget.h.
|
readwrite |
Definition at line 52 of file qgsfilewidget.h.
|
readwrite |
Definition at line 49 of file qgsfilewidget.h.
|
readwrite |
Definition at line 53 of file qgsfilewidget.h.
|
readwrite |
Definition at line 51 of file qgsfilewidget.h.
|
readwrite |
Definition at line 57 of file qgsfilewidget.h.
|
readwrite |
Definition at line 56 of file qgsfilewidget.h.
|
readwrite |
Definition at line 55 of file qgsfilewidget.h.
|
readwrite |
Definition at line 50 of file qgsfilewidget.h.