QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
|
The QgsFileWidget class creates 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 () |
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 |
The QgsFileWidget class creates a widget for selecting a file or a folder.
Definition at line 38 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 78 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 66 of file qgsfilewidget.h.
|
explicit |
QgsFileWidget creates a widget for selecting a file or a folder.
Definition at line 37 of file qgsfilewidget.cpp.
|
inline |
Returns whether a confirmation will be shown when overwriting an existing file.
Definition at line 197 of file qgsfilewidget.h.
QString QgsFileWidget::defaultRoot | ( | ) | const |
Returns the default root path.
Definition at line 219 of file qgsfilewidget.cpp.
QString QgsFileWidget::dialogTitle | ( | ) | const |
Returns the open file dialog title.
Definition at line 116 of file qgsfilewidget.cpp.
|
signal |
Emitted whenever the current file or directory path is changed.
QString QgsFileWidget::filePath | ( | ) |
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 78 of file qgsfilewidget.cpp.
bool QgsFileWidget::fileWidgetButtonVisible | ( | ) | const |
Returns true
if the tool button is shown.
Definition at line 147 of file qgsfilewidget.cpp.
QString QgsFileWidget::filter | ( | ) | const |
returns the filters used for QDialog::getOpenFileName
Definition at line 126 of file qgsfilewidget.cpp.
bool QgsFileWidget::fullUrl | ( | ) | const |
Returns true
if the links shown use the full path.
Definition at line 209 of file qgsfilewidget.cpp.
|
staticprotected |
Returns true if path is a multifiles.
Definition at line 158 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 250 of file qgsfilewidget.cpp.
|
override |
Definition at line 444 of file qgsfilewidget.cpp.
QFileDialog::Options QgsFileWidget::options | ( | ) | const |
Returns the additional options used for QFileDialog.
Definition at line 137 of file qgsfilewidget.cpp.
|
protected |
Returns a filePath with relative path options applied (or not) !
Definition at line 417 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 240 of file qgsfilewidget.cpp.
|
inline |
Returns the selected filter from the last opened file dialog.
Definition at line 179 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 190 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 224 of file qgsfilewidget.cpp.
void QgsFileWidget::setDialogTitle | ( | const QString & | title | ) |
Sets the title to use for the open file dialog.
Definition at line 121 of file qgsfilewidget.cpp.
void QgsFileWidget::setFilePath | ( | const QString & | path | ) |
|
protected |
Update filePath according to filePaths list.
Definition at line 398 of file qgsfilewidget.cpp.
void QgsFileWidget::setFileWidgetButtonVisible | ( | bool | visible | ) |
Sets whether the tool button is visible.
Definition at line 152 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 131 of file qgsfilewidget.cpp.
void QgsFileWidget::setFullUrl | ( | bool | fullUrl | ) |
Sets whether links shown use the full path.
Definition at line 214 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 142 of file qgsfilewidget.cpp.
|
virtual |
Sets whether the widget should be read only.
Reimplemented in QgsExternalStorageFileWidget.
Definition at line 106 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 245 of file qgsfilewidget.cpp.
|
protectedvirtual |
Called whenever user select fileNames from dialog.
Reimplemented in QgsExternalStorageFileWidget.
Definition at line 385 of file qgsfilewidget.cpp.
|
inline |
Sets the selected filter when the file dialog opens.
Definition at line 172 of file qgsfilewidget.h.
void QgsFileWidget::setStorageMode | ( | QgsFileWidget::StorageMode | storageMode | ) |
Sets the widget's storage mode (i.e.
file or directory).
Definition at line 234 of file qgsfilewidget.cpp.
void QgsFileWidget::setUseLink | ( | bool | useLink | ) |
Sets whether the file path will be shown as a link.
Definition at line 200 of file qgsfilewidget.cpp.
|
static |
Split the the quoted and space separated path and returns a list of strings.
Definition at line 83 of file qgsfilewidget.cpp.
QgsFileWidget::StorageMode QgsFileWidget::storageMode | ( | ) | const |
Returns the widget's storage mode (i.e.
file or directory).
Definition at line 229 of file qgsfilewidget.cpp.
|
protected |
returns a HTML code with a link to the given file path
Definition at line 454 of file qgsfilewidget.cpp.
|
protectedvirtual |
Update buttons visibility.
Reimplemented in QgsExternalStorageFileWidget.
Definition at line 255 of file qgsfilewidget.cpp.
bool QgsFileWidget::useLink | ( | ) | const |
Returns true
if the file path will be shown as a link.
Definition at line 195 of file qgsfilewidget.cpp.
|
friend |
Definition at line 357 of file qgsfilewidget.h.
|
friend |
Definition at line 356 of file qgsfilewidget.h.
|
friend |
Definition at line 355 of file qgsfilewidget.h.
|
protected |
Definition at line 325 of file qgsfilewidget.h.
|
protected |
Definition at line 334 of file qgsfilewidget.h.
|
protected |
Definition at line 333 of file qgsfilewidget.h.
|
protected |
Definition at line 330 of file qgsfilewidget.h.
|
protected |
Definition at line 324 of file qgsfilewidget.h.
|
protected |
Definition at line 342 of file qgsfilewidget.h.
|
protected |
Definition at line 331 of file qgsfilewidget.h.
|
protected |
Definition at line 327 of file qgsfilewidget.h.
|
protected |
Definition at line 329 of file qgsfilewidget.h.
|
protected |
Definition at line 343 of file qgsfilewidget.h.
|
protected |
Definition at line 340 of file qgsfilewidget.h.
|
protected |
Definition at line 341 of file qgsfilewidget.h.
|
protected |
Definition at line 339 of file qgsfilewidget.h.
|
protected |
Definition at line 337 of file qgsfilewidget.h.
|
protected |
Definition at line 328 of file qgsfilewidget.h.
|
protected |
Definition at line 336 of file qgsfilewidget.h.
|
protected |
Definition at line 332 of file qgsfilewidget.h.
|
protected |
Definition at line 335 of file qgsfilewidget.h.
|
protected |
Definition at line 326 of file qgsfilewidget.h.
|
readwrite |
Definition at line 56 of file qgsfilewidget.h.
|
readwrite |
Definition at line 54 of file qgsfilewidget.h.
|
readwrite |
Definition at line 51 of file qgsfilewidget.h.
|
readwrite |
Definition at line 55 of file qgsfilewidget.h.
|
readwrite |
Definition at line 53 of file qgsfilewidget.h.
|
readwrite |
Definition at line 59 of file qgsfilewidget.h.
|
readwrite |
Definition at line 58 of file qgsfilewidget.h.
|
readwrite |
Definition at line 57 of file qgsfilewidget.h.
|
readwrite |
Definition at line 52 of file qgsfilewidget.h.