QGIS API Documentation  3.14.0-Pi (9f7028fd23)
qgsfilewidget.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsfilewidget.cpp
3 
4  ---------------------
5  begin : 17.12.2015
6  copyright : (C) 2015 by Denis Rouzaud
7  email : [email protected]
8  ***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 
17 #include "qgsfilewidget.h"
18 
19 #include <QLineEdit>
20 #include <QToolButton>
21 #include <QLabel>
22 #include <QGridLayout>
23 #include <QUrl>
24 #include <QDropEvent>
25 
26 #include "qgssettings.h"
27 #include "qgsfilterlineedit.h"
28 #include "qgsfocuskeeper.h"
29 #include "qgslogger.h"
30 #include "qgsproject.h"
31 #include "qgsapplication.h"
32 #include "qgsfileutils.h"
33 #include "qgsmimedatautils.h"
34 
35 QgsFileWidget::QgsFileWidget( QWidget *parent )
36  : QWidget( parent )
37 {
38  setBackgroundRole( QPalette::Window );
39  setAutoFillBackground( true );
40 
41  mLayout = new QHBoxLayout();
42  mLayout->setMargin( 0 );
43 
44  // If displaying a hyperlink, use a QLabel
45  mLinkLabel = new QLabel( this );
46  // Make Qt opens the link with the OS defined viewer
47  mLinkLabel->setOpenExternalLinks( true );
48  // Label should always be enabled to be able to open
49  // the link on read only mode.
50  mLinkLabel->setEnabled( true );
51  mLinkLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
52  mLinkLabel->setTextFormat( Qt::RichText );
53  mLinkLabel->hide(); // do not show by default
54  mLinkEditButton = new QToolButton( this );
55  mLinkEditButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionToggleEditing.svg" ) ) );
56  connect( mLinkEditButton, &QToolButton::clicked, this, &QgsFileWidget::editLink );
57  mLinkEditButton->hide(); // do not show by default
58 
59  // otherwise, use the traditional QLineEdit subclass
60  mLineEdit = new QgsFileDropEdit( this );
61  mLineEdit->setDragEnabled( true );
62  mLineEdit->setToolTip( tr( "Full path to the file(s), including name and extension" ) );
63  connect( mLineEdit, &QLineEdit::textChanged, this, &QgsFileWidget::textEdited );
64  mLayout->addWidget( mLineEdit );
65 
66  mFileWidgetButton = new QToolButton( this );
67  mFileWidgetButton->setText( QChar( 0x2026 ) );
68  mFileWidgetButton->setToolTip( tr( "Browse" ) );
69  connect( mFileWidgetButton, &QAbstractButton::clicked, this, &QgsFileWidget::openFileDialog );
70  mLayout->addWidget( mFileWidgetButton );
71 
72  setLayout( mLayout );
73 }
74 
76 {
77  return mFilePath;
78 }
79 
80 QStringList QgsFileWidget::splitFilePaths( const QString &path )
81 {
82  QStringList paths;
83  const QStringList pathParts = path.split( QRegExp( "\"\\s+\"" ), QString::SkipEmptyParts );
84  for ( const auto &pathsPart : pathParts )
85  {
86  QString cleaned = pathsPart;
87  cleaned.remove( QRegExp( "(^\\s*\")|(\"\\s*)" ) );
88  paths.append( cleaned );
89  }
90  return paths;
91 }
92 
93 void QgsFileWidget::setFilePath( QString path )
94 {
95  if ( path == QgsApplication::nullRepresentation() )
96  {
97  path.clear();
98  }
99 
100  //will trigger textEdited slot
101  mLineEdit->setValue( path );
102 
103 }
104 
105 void QgsFileWidget::setReadOnly( bool readOnly )
106 {
107  if ( mReadOnly == readOnly )
108  return;
109 
110  mReadOnly = readOnly;
111 
112  updateLayout();
113 }
114 
115 QString QgsFileWidget::dialogTitle() const
116 {
117  return mDialogTitle;
118 }
119 
120 void QgsFileWidget::setDialogTitle( const QString &title )
121 {
122  mDialogTitle = title;
123 }
124 
125 QString QgsFileWidget::filter() const
126 {
127  return mFilter;
128 }
129 
130 void QgsFileWidget::setFilter( const QString &filters )
131 {
132  mFilter = filters;
133  mLineEdit->setFilters( filters );
134 }
135 
136 QFileDialog::Options QgsFileWidget::options() const
137 {
138  return mOptions;
139 }
140 
141 void QgsFileWidget::setOptions( QFileDialog::Options options )
142 {
143  mOptions = options;
144 }
145 
147 {
148  return mButtonVisible;
149 }
150 
152 {
153  mButtonVisible = visible;
154  mFileWidgetButton->setVisible( visible );
155 }
156 
157 void QgsFileWidget::textEdited( const QString &path )
158 {
159  mFilePath = path;
160  mLinkLabel->setText( toUrl( path ) );
161  // Show tooltip if multiple files are selected
162  if ( path.contains( QStringLiteral( "\" \"" ) ) )
163  {
164  mLineEdit->setToolTip( tr( "Selected files:<br><ul><li>%1</li></ul><br>" ).arg( splitFilePaths( path ).join( QStringLiteral( "</li><li>" ) ) ) );
165  }
166  else
167  {
168  mLineEdit->setToolTip( QString() );
169  }
170  emit fileChanged( mFilePath );
171 }
172 
173 void QgsFileWidget::editLink()
174 {
175  if ( !mUseLink || mReadOnly )
176  return;
177 
178  mIsLinkEdited = !mIsLinkEdited;
179  updateLayout();
180 }
181 
182 bool QgsFileWidget::useLink() const
183 {
184  return mUseLink;
185 }
186 
187 void QgsFileWidget::setUseLink( bool useLink )
188 {
189  if ( mUseLink == useLink )
190  return;
191 
192  mUseLink = useLink;
193  updateLayout();
194 }
195 
196 bool QgsFileWidget::fullUrl() const
197 {
198  return mFullUrl;
199 }
200 
201 void QgsFileWidget::setFullUrl( bool fullUrl )
202 {
203  mFullUrl = fullUrl;
204 }
205 
206 QString QgsFileWidget::defaultRoot() const
207 {
208  return mDefaultRoot;
209 }
210 
211 void QgsFileWidget::setDefaultRoot( const QString &defaultRoot )
212 {
213  mDefaultRoot = defaultRoot;
214 }
215 
217 {
218  return mStorageMode;
219 }
220 
222 {
223  mStorageMode = storageMode;
224  mLineEdit->setStorageMode( storageMode );
225 }
226 
228 {
229  return mRelativeStorage;
230 }
231 
233 {
234  mRelativeStorage = relativeStorage;
235 }
236 
238 {
239  return mLineEdit;
240 }
241 
242 void QgsFileWidget::updateLayout()
243 {
244  mLayout->removeWidget( mLineEdit );
245  mLayout->removeWidget( mLinkLabel );
246  mLayout->removeWidget( mLinkEditButton );
247 
248  mLinkEditButton->setVisible( mUseLink && !mReadOnly );
249 
250  mFileWidgetButton->setEnabled( !mReadOnly );
251  mLineEdit->setEnabled( !mReadOnly );
252 
253  if ( mUseLink && !mIsLinkEdited )
254  {
255  mLayout->insertWidget( 0, mLinkLabel );
256  mLineEdit->setVisible( false );
257  mLinkLabel->setVisible( true );
258 
259  if ( !mReadOnly )
260  {
261  mLayout->insertWidget( 1, mLinkEditButton );
262  mLinkEditButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionToggleEditing.svg" ) ) );
263  }
264  }
265  else
266  {
267  mLayout->insertWidget( 0, mLineEdit );
268  mLineEdit->setVisible( true );
269  mLinkLabel->setVisible( false );
270 
271  if ( mIsLinkEdited )
272  {
273  mLayout->insertWidget( 1, mLinkEditButton );
274  mLinkEditButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionSaveEdits.svg" ) ) );
275  }
276  }
277 }
278 
279 void QgsFileWidget::openFileDialog()
280 {
281  QgsSettings settings;
282  QString oldPath;
283 
284  // if we use a relative path option, we need to obtain the full path
285  // first choice is the current file path, if one is entered
286  if ( !mFilePath.isEmpty() )
287  {
288  oldPath = relativePath( mFilePath, false );
289  }
290  // If we use fixed default path
291  // second choice is the default root
292  else if ( !mDefaultRoot.isEmpty() )
293  {
294  oldPath = QDir::cleanPath( mDefaultRoot );
295  }
296 
297  // If there is no valid value, find a default path to use
298  QUrl url = QUrl::fromUserInput( oldPath );
299  if ( !url.isValid() )
300  {
301  QString defPath = QDir::cleanPath( QFileInfo( QgsProject::instance()->absoluteFilePath() ).path() );
302  if ( defPath.isEmpty() )
303  {
304  defPath = QDir::homePath();
305  }
306  oldPath = settings.value( QStringLiteral( "UI/lastFileNameWidgetDir" ), defPath ).toString();
307  }
308 
309  // Handle Storage
310  QString fileName;
311  QStringList fileNames;
312  QString title;
313 
314  {
315  QgsFocusKeeper focusKeeper;
316  switch ( mStorageMode )
317  {
318  case GetFile:
319  title = !mDialogTitle.isEmpty() ? mDialogTitle : tr( "Select a file" );
320  fileName = QFileDialog::getOpenFileName( this, title, QFileInfo( oldPath ).absoluteFilePath(), mFilter, &mSelectedFilter, mOptions );
321  break;
322  case GetMultipleFiles:
323  title = !mDialogTitle.isEmpty() ? mDialogTitle : tr( "Select one or more files" );
324  fileNames = QFileDialog::getOpenFileNames( this, title, QFileInfo( oldPath ).absoluteFilePath(), mFilter, &mSelectedFilter, mOptions );
325  break;
326  case GetDirectory:
327  title = !mDialogTitle.isEmpty() ? mDialogTitle : tr( "Select a directory" );
328  fileName = QFileDialog::getExistingDirectory( this, title, QFileInfo( oldPath ).absoluteFilePath(), mOptions | QFileDialog::ShowDirsOnly );
329  break;
330  case SaveFile:
331  {
332  title = !mDialogTitle.isEmpty() ? mDialogTitle : tr( "Create or select a file" );
333  if ( !confirmOverwrite() )
334  {
335  fileName = QFileDialog::getSaveFileName( this, title, QFileInfo( oldPath ).absoluteFilePath(), mFilter, &mSelectedFilter, mOptions | QFileDialog::DontConfirmOverwrite );
336  }
337  else
338  {
339  fileName = QFileDialog::getSaveFileName( this, title, QFileInfo( oldPath ).absoluteFilePath(), mFilter, &mSelectedFilter, mOptions );
340  }
341 
342  // make sure filename ends with filter. This isn't automatically done by
343  // getSaveFileName on some platforms (e.g. gnome)
344  fileName = QgsFileUtils::addExtensionFromFilter( fileName, mSelectedFilter );
345  }
346  break;
347  }
348  }
349 
350  if ( fileName.isEmpty() && fileNames.isEmpty( ) )
351  return;
352 
353  if ( mStorageMode != GetMultipleFiles )
354  {
355  fileName = QDir::toNativeSeparators( QDir::cleanPath( QFileInfo( fileName ).absoluteFilePath() ) );
356  }
357  else
358  {
359  for ( int i = 0; i < fileNames.length(); i++ )
360  {
361  fileNames.replace( i, QDir::toNativeSeparators( QDir::cleanPath( QFileInfo( fileNames.at( i ) ).absoluteFilePath() ) ) );
362  }
363  }
364 
365  // Store the last used path:
366  switch ( mStorageMode )
367  {
368  case GetFile:
369  case SaveFile:
370  settings.setValue( QStringLiteral( "UI/lastFileNameWidgetDir" ), QFileInfo( fileName ).absolutePath() );
371  break;
372  case GetDirectory:
373  settings.setValue( QStringLiteral( "UI/lastFileNameWidgetDir" ), fileName );
374  break;
375  case GetMultipleFiles:
376  settings.setValue( QStringLiteral( "UI/lastFileNameWidgetDir" ), QFileInfo( fileNames.first( ) ).absolutePath() );
377  break;
378  }
379 
380  // Handle relative Path storage
381  if ( mStorageMode != GetMultipleFiles )
382  {
383  fileName = relativePath( fileName, true );
384  setFilePath( fileName );
385  }
386  else
387  {
388  for ( int i = 0; i < fileNames.length(); i++ )
389  {
390  fileNames.replace( i, relativePath( fileNames.at( i ), true ) );
391  }
392  if ( fileNames.length() > 1 )
393  {
394  setFilePath( QStringLiteral( "\"%1\"" ).arg( fileNames.join( QStringLiteral( "\" \"" ) ) ) );
395  }
396  else
397  {
398  setFilePath( fileNames.first( ) );
399  }
400  }
401 }
402 
403 
404 QString QgsFileWidget::relativePath( const QString &filePath, bool removeRelative ) const
405 {
406  QString RelativePath;
407  if ( mRelativeStorage == RelativeProject )
408  {
409  RelativePath = QDir::toNativeSeparators( QDir::cleanPath( QFileInfo( QgsProject::instance()->absoluteFilePath() ).path() ) );
410  }
411  else if ( mRelativeStorage == RelativeDefaultPath && !mDefaultRoot.isEmpty() )
412  {
413  RelativePath = QDir::toNativeSeparators( QDir::cleanPath( mDefaultRoot ) );
414  }
415 
416  if ( !RelativePath.isEmpty() )
417  {
418  if ( removeRelative )
419  {
420  return QDir::cleanPath( QDir( RelativePath ).relativeFilePath( filePath ) );
421  }
422  else
423  {
424  return QDir::cleanPath( QDir( RelativePath ).filePath( filePath ) );
425  }
426  }
427 
428  return filePath;
429 }
430 
431 
432 QString QgsFileWidget::toUrl( const QString &path ) const
433 {
434  QString rep;
435  if ( path.isEmpty() )
436  {
438  }
439 
440  QString urlStr = relativePath( path, false );
441  QUrl url = QUrl::fromUserInput( urlStr );
442  if ( !url.isValid() || !url.isLocalFile() )
443  {
444  QgsDebugMsg( QStringLiteral( "URL: %1 is not valid or not a local file!" ).arg( path ) );
445  rep = path;
446  }
447 
448  QString pathStr = url.toString();
449  if ( mFullUrl )
450  {
451  rep = QStringLiteral( "<a href=\"%1\">%2</a>" ).arg( pathStr, path );
452  }
453  else
454  {
455  QString fileName = QFileInfo( urlStr ).fileName();
456  rep = QStringLiteral( "<a href=\"%1\">%2</a>" ).arg( pathStr, fileName );
457  }
458 
459  return rep;
460 }
461 
462 
463 
465 
466 
467 QgsFileDropEdit::QgsFileDropEdit( QWidget *parent )
468  : QgsHighlightableLineEdit( parent )
469 {
470  setAcceptDrops( true );
471 }
472 
473 void QgsFileDropEdit::setFilters( const QString &filters )
474 {
475  mAcceptableExtensions.clear();
476 
477  if ( filters.contains( QStringLiteral( "*.*" ) ) )
478  return; // everything is allowed!
479 
480  QRegularExpression rx( QStringLiteral( "\\*\\.(\\w+)" ) );
481  QRegularExpressionMatchIterator i = rx.globalMatch( filters );
482  while ( i.hasNext() )
483  {
484  QRegularExpressionMatch match = i.next();
485  if ( match.hasMatch() )
486  {
487  mAcceptableExtensions << match.captured( 1 ).toLower();
488  }
489  }
490 }
491 
492 QString QgsFileDropEdit::acceptableFilePath( QDropEvent *event ) const
493 {
494  QStringList rawPaths;
495  QStringList paths;
496  if ( event->mimeData()->hasUrls() )
497  {
498  const QList< QUrl > urls = event->mimeData()->urls();
499  rawPaths.reserve( urls.count() );
500  for ( const QUrl &url : urls )
501  {
502  const QString local = url.toLocalFile();
503  if ( !rawPaths.contains( local ) )
504  rawPaths.append( local );
505  }
506  }
507 
509  for ( const QgsMimeDataUtils::Uri &u : lst )
510  {
511  if ( !rawPaths.contains( u.uri ) )
512  rawPaths.append( u.uri );
513  }
514 
515  if ( !event->mimeData()->text().isEmpty() && !rawPaths.contains( event->mimeData()->text() ) )
516  rawPaths.append( event->mimeData()->text() );
517 
518  paths.reserve( rawPaths.count() );
519  for ( const QString &path : qgis::as_const( rawPaths ) )
520  {
521  QFileInfo file( path );
522  switch ( mStorageMode )
523  {
527  {
528  if ( file.isFile() && ( mAcceptableExtensions.isEmpty() || mAcceptableExtensions.contains( file.suffix(), Qt::CaseInsensitive ) ) )
529  paths.append( file.filePath() );
530 
531  break;
532  }
533 
535  {
536  if ( file.isDir() )
537  paths.append( file.filePath() );
538  else if ( file.isFile() )
539  {
540  // folder mode, but a file dropped. So get folder name from file
541  paths.append( file.absolutePath() );
542  }
543 
544  break;
545  }
546  }
547  }
548 
549  if ( paths.size() > 1 )
550  {
551  return QStringLiteral( "\"%1\"" ).arg( paths.join( QStringLiteral( "\" \"" ) ) );
552  }
553  else if ( paths.size() == 1 )
554  {
555  return paths.first();
556  }
557  else
558  {
559  return QString();
560  }
561 }
562 
563 void QgsFileDropEdit::dragEnterEvent( QDragEnterEvent *event )
564 {
565  QString filePath = acceptableFilePath( event );
566  if ( !filePath.isEmpty() )
567  {
568  event->acceptProposedAction();
569  setHighlighted( true );
570  }
571  else
572  {
573  event->ignore();
574  }
575 }
576 
577 void QgsFileDropEdit::dragLeaveEvent( QDragLeaveEvent *event )
578 {
579  QgsFilterLineEdit::dragLeaveEvent( event );
580  event->accept();
581  setHighlighted( false );
582 }
583 
584 void QgsFileDropEdit::dropEvent( QDropEvent *event )
585 {
586  QString filePath = acceptableFilePath( event );
587  if ( !filePath.isEmpty() )
588  {
589  setText( filePath );
590  selectAll();
591  setFocus( Qt::MouseFocusReason );
592  event->acceptProposedAction();
593  setHighlighted( false );
594  }
595 }
596 
QgsFileWidget::lineEdit
QgsFilterLineEdit * lineEdit()
Returns a pointer to the widget's line edit, which can be used to customize the appearance and behavi...
Definition: qgsfilewidget.cpp:237
QgsFileWidget::fileChanged
void fileChanged(const QString &path)
Emitted whenever the current file or directory path is changed.
QgsFileWidget::setFilePath
void setFilePath(QString path)
Sets the file path.
Definition: qgsfilewidget.cpp:93
QgsFileWidget::setDialogTitle
void setDialogTitle(const QString &title)
setDialogTitle defines the open file dialog title
Definition: qgsfilewidget.cpp:120
QgsHighlightableLineEdit
Definition: qgshighlightablelineedit.h:33
QgsApplication::getThemeIcon
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon.
Definition: qgsapplication.cpp:605
QgsSettings::value
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
Definition: qgssettings.cpp:174
qgsfilterlineedit.h
QgsFileWidget::GetFile
@ GetFile
Select a single file.
Definition: qgsfilewidget.h:66
QgsFilterLineEdit
Definition: qgsfilterlineedit.h:39
QgsProject::instance
static QgsProject * instance()
Returns the QgsProject singleton instance.
Definition: qgsproject.cpp:458
QgsSettings
Definition: qgssettings.h:61
QgsFileWidget::setFileWidgetButtonVisible
void setFileWidgetButtonVisible(bool visible)
determines if the tool button is shown
Definition: qgsfilewidget.cpp:151
qgsmimedatautils.h
QgsMimeDataUtils::UriList
QList< QgsMimeDataUtils::Uri > UriList
Definition: qgsmimedatautils.h:156
QgsFileWidget::useLink
bool useLink
Definition: qgsfilewidget.h:50
QgsDebugMsg
#define QgsDebugMsg(str)
Definition: qgslogger.h:38
QgsFileWidget::storageMode
StorageMode storageMode
Definition: qgsfilewidget.h:55
QgsFileWidget::SaveFile
@ SaveFile
Select a single new or pre-existing file.
Definition: qgsfilewidget.h:69
QgsFileWidget::RelativeProject
@ RelativeProject
Definition: qgsfilewidget.h:79
qgsapplication.h
QgsFileWidget::setUseLink
void setUseLink(bool useLink)
determines if the file path will be shown as a link
Definition: qgsfilewidget.cpp:187
QgsFocusKeeper
Definition: qgsfocuskeeper.h:34
QgsFileWidget::filter
QString filter
Definition: qgsfilewidget.h:53
QgsFileWidget::GetDirectory
@ GetDirectory
Select a directory.
Definition: qgsfilewidget.h:67
QgsFileWidget::GetMultipleFiles
@ GetMultipleFiles
Select multiple files.
Definition: qgsfilewidget.h:68
qgsfocuskeeper.h
QgsApplication::nullRepresentation
static QString nullRepresentation()
This string is used to represent the value NULL throughout QGIS.
Definition: qgsapplication.cpp:1802
QgsFileWidget::fullUrl
bool fullUrl
Definition: qgsfilewidget.h:51
QgsFileWidget::setRelativeStorage
void setRelativeStorage(QgsFileWidget::RelativeStorage relativeStorage)
determines if the relative path is with respect to the project path or the default path
Definition: qgsfilewidget.cpp:232
QgsFileWidget::dialogTitle
QString dialogTitle
Definition: qgsfilewidget.h:52
QgsFileWidget::defaultRoot
QString defaultRoot
Definition: qgsfilewidget.h:54
QgsFileWidget::RelativeDefaultPath
@ RelativeDefaultPath
Definition: qgsfilewidget.h:80
QgsSettings::setValue
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
Definition: qgssettings.cpp:289
QgsFileWidget::options
QFileDialog::Options options
Definition: qgsfilewidget.h:57
QgsMimeDataUtils::Uri
Definition: qgsmimedatautils.h:40
qgsfileutils.h
QgsFileWidget::RelativeStorage
RelativeStorage
The RelativeStorage enum determines if path is absolute, relative to the current project path or rela...
Definition: qgsfilewidget.h:76
QgsFileWidget::setReadOnly
void setReadOnly(bool readOnly)
defines if the widget is readonly
Definition: qgsfilewidget.cpp:105
QgsFileWidget::relativeStorage
RelativeStorage relativeStorage
Definition: qgsfilewidget.h:56
QgsMimeDataUtils::decodeUriList
static UriList decodeUriList(const QMimeData *data)
Definition: qgsmimedatautils.cpp:210
QgsFileWidget::StorageMode
StorageMode
The StorageMode enum determines if the file picker should pick files or directories.
Definition: qgsfilewidget.h:64
QgsFileWidget::setStorageMode
void setStorageMode(QgsFileWidget::StorageMode storageMode)
determines the storage mode (i.e. file or directory)
Definition: qgsfilewidget.cpp:221
QgsFileWidget::setDefaultRoot
void setDefaultRoot(const QString &defaultRoot)
determines the default root path used as the first shown location when picking a file and used if the...
Definition: qgsfilewidget.cpp:211
QgsFileWidget::QgsFileWidget
QgsFileWidget(QWidget *parent=nullptr)
QgsFileWidget creates a widget for selecting a file or a folder.
Definition: qgsfilewidget.cpp:35
qgssettings.h
QgsFileWidget::setFilter
void setFilter(const QString &filter)
setFilter sets the filter used by the model to filters.
Definition: qgsfilewidget.cpp:130
qgsfilewidget.h
QgsFileWidget::splitFilePaths
static QStringList splitFilePaths(const QString &path)
Split the the quoted and space separated path and returns a QString list.
Definition: qgsfilewidget.cpp:80
QgsFileWidget::setFullUrl
void setFullUrl(bool fullUrl)
determines if the links shows the full path or not
Definition: qgsfilewidget.cpp:201
qgslogger.h
QgsFileWidget::confirmOverwrite
bool confirmOverwrite() const
Returns whether a confirmation will be shown when overwriting an existing file.
Definition: qgsfilewidget.h:159
qgsproject.h
QgsFileWidget::setOptions
void setOptions(QFileDialog::Options options)
setOptions sets additional options used for QFileDialog.
Definition: qgsfilewidget.cpp:141
QgsFileWidget::fileWidgetButtonVisible
bool fileWidgetButtonVisible
Definition: qgsfilewidget.h:49
QgsFileWidget::filePath
QString filePath()
Returns the current file path(s) when multiple files are selected, they are quoted and separated by a...
Definition: qgsfilewidget.cpp:75
QgsFileUtils::addExtensionFromFilter
static QString addExtensionFromFilter(const QString &fileName, const QString &filter)
Ensures that a fileName ends with an extension from the specified filter string.
Definition: qgsfileutils.cpp:86