QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
|
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. More... | |
Public Member Functions | |
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... | |
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. 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... | |
virtual void | setReadOnly (bool readOnly) |
Sets whether the widget should be read only. 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 QStringList | splitFilePaths (const QString &path) |
Split the the quoted and space separated path and returns a list of strings. More... | |
Protected Member Functions | |
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... | |
virtual void | setSelectedFileNames (QStringList fileNames) |
Called whenever user select fileNames from dialog. More... | |
QString | toUrl (const QString &path) const |
returns a HTML code with a link to the given file path More... | |
virtual void | updateLayout () |
Update buttons visibility. More... | |
Static Protected Member Functions | |
static bool | isMultiFiles (const QString &path) |
Returns true if path is a multifiles. More... | |
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 36 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 222 of file qgsfilewidget.cpp.
QString QgsFileWidget::dialogTitle | ( | ) | const |
Returns the open file dialog title.
Definition at line 119 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 77 of file qgsfilewidget.cpp.
bool QgsFileWidget::fileWidgetButtonVisible | ( | ) | const |
Returns true
if the tool button is shown.
Definition at line 150 of file qgsfilewidget.cpp.
QString QgsFileWidget::filter | ( | ) | const |
returns the filters used for QDialog::getOpenFileName
Definition at line 129 of file qgsfilewidget.cpp.
bool QgsFileWidget::fullUrl | ( | ) | const |
Returns true
if the links shown use the full path.
Definition at line 212 of file qgsfilewidget.cpp.
|
staticprotected |
Returns true if path is a multifiles.
Definition at line 161 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 253 of file qgsfilewidget.cpp.
QFileDialog::Options QgsFileWidget::options | ( | ) | const |
Returns the additional options used for QFileDialog.
Definition at line 140 of file qgsfilewidget.cpp.
|
protected |
Returns a filePath with relative path options applied (or not) !
Definition at line 408 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 243 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 227 of file qgsfilewidget.cpp.
void QgsFileWidget::setDialogTitle | ( | const QString & | title | ) |
Sets the title to use for the open file dialog.
Definition at line 124 of file qgsfilewidget.cpp.
void QgsFileWidget::setFilePath | ( | const QString & | path | ) |
|
protected |
Update filePath according to filePaths list.
Definition at line 389 of file qgsfilewidget.cpp.
void QgsFileWidget::setFileWidgetButtonVisible | ( | bool | visible | ) |
Sets whether the tool button is visible.
Definition at line 155 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 134 of file qgsfilewidget.cpp.
void QgsFileWidget::setFullUrl | ( | bool | fullUrl | ) |
Sets whether links shown use the full path.
Definition at line 217 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 145 of file qgsfilewidget.cpp.
|
virtual |
Sets whether the widget should be read only.
Reimplemented in QgsExternalStorageFileWidget.
Definition at line 109 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 248 of file qgsfilewidget.cpp.
|
protectedvirtual |
Called whenever user select fileNames from dialog.
Reimplemented in QgsExternalStorageFileWidget.
Definition at line 376 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 237 of file qgsfilewidget.cpp.
void QgsFileWidget::setUseLink | ( | bool | useLink | ) |
Sets whether the file path will be shown as a link.
Definition at line 203 of file qgsfilewidget.cpp.
|
static |
Split the the quoted and space separated path and returns a list of strings.
Definition at line 82 of file qgsfilewidget.cpp.
QgsFileWidget::StorageMode QgsFileWidget::storageMode | ( | ) | const |
Returns the widget's storage mode (i.e.
file or directory).
Definition at line 232 of file qgsfilewidget.cpp.
|
protected |
returns a HTML code with a link to the given file path
Definition at line 436 of file qgsfilewidget.cpp.
|
protectedvirtual |
Update buttons visibility.
Reimplemented in QgsExternalStorageFileWidget.
Definition at line 258 of file qgsfilewidget.cpp.
bool QgsFileWidget::useLink | ( | ) | const |
Returns true
if the file path will be shown as a link.
Definition at line 198 of file qgsfilewidget.cpp.
|
friend |
Definition at line 354 of file qgsfilewidget.h.
|
friend |
Definition at line 353 of file qgsfilewidget.h.
|
friend |
Definition at line 352 of file qgsfilewidget.h.
|
protected |
Definition at line 326 of file qgsfilewidget.h.
|
protected |
Definition at line 335 of file qgsfilewidget.h.
|
protected |
Definition at line 334 of file qgsfilewidget.h.
|
protected |
Definition at line 331 of file qgsfilewidget.h.
|
protected |
Definition at line 325 of file qgsfilewidget.h.
|
protected |
Definition at line 343 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 330 of file qgsfilewidget.h.
|
protected |
Definition at line 344 of file qgsfilewidget.h.
|
protected |
Definition at line 341 of file qgsfilewidget.h.
|
protected |
Definition at line 342 of file qgsfilewidget.h.
|
protected |
Definition at line 340 of file qgsfilewidget.h.
|
protected |
Definition at line 338 of file qgsfilewidget.h.
|
protected |
Definition at line 329 of file qgsfilewidget.h.
|
protected |
Definition at line 337 of file qgsfilewidget.h.
|
protected |
Definition at line 333 of file qgsfilewidget.h.
|
protected |
Definition at line 336 of file qgsfilewidget.h.
|
protected |
Definition at line 327 of file qgsfilewidget.h.
|
readwrite |
Definition at line 38 of file qgsfilewidget.h.
|
readwrite |
Definition at line 38 of file qgsfilewidget.h.
|
readwrite |
Definition at line 38 of file qgsfilewidget.h.
|
readwrite |
Definition at line 38 of file qgsfilewidget.h.
|
readwrite |
Definition at line 38 of file qgsfilewidget.h.
|
readwrite |
Definition at line 38 of file qgsfilewidget.h.
|
readwrite |
Definition at line 38 of file qgsfilewidget.h.
|
readwrite |
Definition at line 38 of file qgsfilewidget.h.
|
readwrite |
Definition at line 38 of file qgsfilewidget.h.