QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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->setContentsMargins( 0, 0, 0, 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  //will trigger textEdited slot
96  mLineEdit->setValue( path );
97 }
98 
99 void QgsFileWidget::setReadOnly( bool readOnly )
100 {
101  if ( mReadOnly == readOnly )
102  return;
103 
104  mReadOnly = readOnly;
105 
106  updateLayout();
107 }
108 
110 {
111  return mDialogTitle;
112 }
113 
114 void QgsFileWidget::setDialogTitle( const QString &title )
115 {
116  mDialogTitle = title;
117 }
118 
119 QString QgsFileWidget::filter() const
120 {
121  return mFilter;
122 }
123 
124 void QgsFileWidget::setFilter( const QString &filters )
125 {
126  mFilter = filters;
127  mLineEdit->setFilters( filters );
128 }
129 
130 QFileDialog::Options QgsFileWidget::options() const
131 {
132  return mOptions;
133 }
134 
135 void QgsFileWidget::setOptions( QFileDialog::Options options )
136 {
137  mOptions = options;
138 }
139 
141 {
142  return mButtonVisible;
143 }
144 
146 {
147  mButtonVisible = visible;
148  mFileWidgetButton->setVisible( visible );
149 }
150 
151 void QgsFileWidget::textEdited( const QString &path )
152 {
153  mFilePath = path;
154  mLinkLabel->setText( toUrl( path ) );
155  // Show tooltip if multiple files are selected
156  if ( path.contains( QStringLiteral( "\" \"" ) ) )
157  {
158  mLineEdit->setToolTip( tr( "Selected files:<br><ul><li>%1</li></ul><br>" ).arg( splitFilePaths( path ).join( QLatin1String( "</li><li>" ) ) ) );
159  }
160  else
161  {
162  mLineEdit->setToolTip( QString() );
163  }
164  emit fileChanged( mFilePath );
165 }
166 
167 void QgsFileWidget::editLink()
168 {
169  if ( !mUseLink || mReadOnly )
170  return;
171 
172  mIsLinkEdited = !mIsLinkEdited;
173  updateLayout();
174 }
175 
177 {
178  return mUseLink;
179 }
180 
181 void QgsFileWidget::setUseLink( bool useLink )
182 {
183  if ( mUseLink == useLink )
184  return;
185 
186  mUseLink = useLink;
187  updateLayout();
188 }
189 
191 {
192  return mFullUrl;
193 }
194 
195 void QgsFileWidget::setFullUrl( bool fullUrl )
196 {
197  mFullUrl = fullUrl;
198 }
199 
201 {
202  return mDefaultRoot;
203 }
204 
205 void QgsFileWidget::setDefaultRoot( const QString &defaultRoot )
206 {
207  mDefaultRoot = defaultRoot;
208 }
209 
211 {
212  return mStorageMode;
213 }
214 
216 {
217  mStorageMode = storageMode;
218  mLineEdit->setStorageMode( storageMode );
219 }
220 
222 {
223  return mRelativeStorage;
224 }
225 
227 {
228  mRelativeStorage = relativeStorage;
229 }
230 
232 {
233  return mLineEdit;
234 }
235 
236 void QgsFileWidget::updateLayout()
237 {
238  mLayout->removeWidget( mLineEdit );
239  mLayout->removeWidget( mLinkLabel );
240  mLayout->removeWidget( mLinkEditButton );
241 
242  mLinkEditButton->setVisible( mUseLink && !mReadOnly );
243 
244  mFileWidgetButton->setEnabled( !mReadOnly );
245  mLineEdit->setEnabled( !mReadOnly );
246 
247  if ( mUseLink && !mIsLinkEdited )
248  {
249  mLayout->insertWidget( 0, mLinkLabel );
250  mLineEdit->setVisible( false );
251  mLinkLabel->setVisible( true );
252 
253  if ( !mReadOnly )
254  {
255  mLayout->insertWidget( 1, mLinkEditButton );
256  mLinkEditButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionToggleEditing.svg" ) ) );
257  }
258  }
259  else
260  {
261  mLayout->insertWidget( 0, mLineEdit );
262  mLineEdit->setVisible( true );
263  mLinkLabel->setVisible( false );
264 
265  if ( mIsLinkEdited )
266  {
267  mLayout->insertWidget( 1, mLinkEditButton );
268  mLinkEditButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionSaveEdits.svg" ) ) );
269  }
270  }
271 }
272 
273 void QgsFileWidget::openFileDialog()
274 {
275  QgsSettings settings;
276  QString oldPath;
277 
278  // if we use a relative path option, we need to obtain the full path
279  // first choice is the current file path, if one is entered
280  if ( !mFilePath.isEmpty() )
281  {
282  oldPath = relativePath( mFilePath, false );
283  }
284  // If we use fixed default path
285  // second choice is the default root
286  else if ( !mDefaultRoot.isEmpty() )
287  {
288  oldPath = QDir::cleanPath( mDefaultRoot );
289  }
290 
291  // If there is no valid value, find a default path to use
292  QUrl url = QUrl::fromUserInput( oldPath );
293  if ( !url.isValid() )
294  {
295  QString defPath = QDir::cleanPath( QFileInfo( QgsProject::instance()->absoluteFilePath() ).path() );
296  if ( defPath.isEmpty() )
297  {
298  defPath = QDir::homePath();
299  }
300  oldPath = settings.value( QStringLiteral( "UI/lastFileNameWidgetDir" ), defPath ).toString();
301  }
302 
303  // Handle Storage
304  QString fileName;
305  QStringList fileNames;
306  QString title;
307 
308  {
309  QgsFocusKeeper focusKeeper;
310  switch ( mStorageMode )
311  {
312  case GetFile:
313  title = !mDialogTitle.isEmpty() ? mDialogTitle : tr( "Select a file" );
314  fileName = QFileDialog::getOpenFileName( this, title, QFileInfo( oldPath ).absoluteFilePath(), mFilter, &mSelectedFilter, mOptions );
315  break;
316  case GetMultipleFiles:
317  title = !mDialogTitle.isEmpty() ? mDialogTitle : tr( "Select one or more files" );
318  fileNames = QFileDialog::getOpenFileNames( this, title, QFileInfo( oldPath ).absoluteFilePath(), mFilter, &mSelectedFilter, mOptions );
319  break;
320  case GetDirectory:
321  title = !mDialogTitle.isEmpty() ? mDialogTitle : tr( "Select a directory" );
322  fileName = QFileDialog::getExistingDirectory( this, title, QFileInfo( oldPath ).absoluteFilePath(), mOptions | QFileDialog::ShowDirsOnly );
323  break;
324  case SaveFile:
325  {
326  title = !mDialogTitle.isEmpty() ? mDialogTitle : tr( "Create or select a file" );
327  if ( !confirmOverwrite() )
328  {
329  fileName = QFileDialog::getSaveFileName( this, title, QFileInfo( oldPath ).absoluteFilePath(), mFilter, &mSelectedFilter, mOptions | QFileDialog::DontConfirmOverwrite );
330  }
331  else
332  {
333  fileName = QFileDialog::getSaveFileName( this, title, QFileInfo( oldPath ).absoluteFilePath(), mFilter, &mSelectedFilter, mOptions );
334  }
335 
336  // make sure filename ends with filter. This isn't automatically done by
337  // getSaveFileName on some platforms (e.g. gnome)
338  fileName = QgsFileUtils::addExtensionFromFilter( fileName, mSelectedFilter );
339  }
340  break;
341  }
342  }
343 
344  if ( fileName.isEmpty() && fileNames.isEmpty( ) )
345  return;
346 
347  if ( mStorageMode != GetMultipleFiles )
348  {
349  fileName = QDir::toNativeSeparators( QDir::cleanPath( QFileInfo( fileName ).absoluteFilePath() ) );
350  }
351  else
352  {
353  for ( int i = 0; i < fileNames.length(); i++ )
354  {
355  fileNames.replace( i, QDir::toNativeSeparators( QDir::cleanPath( QFileInfo( fileNames.at( i ) ).absoluteFilePath() ) ) );
356  }
357  }
358 
359  // Store the last used path:
360  switch ( mStorageMode )
361  {
362  case GetFile:
363  case SaveFile:
364  settings.setValue( QStringLiteral( "UI/lastFileNameWidgetDir" ), QFileInfo( fileName ).absolutePath() );
365  break;
366  case GetDirectory:
367  settings.setValue( QStringLiteral( "UI/lastFileNameWidgetDir" ), fileName );
368  break;
369  case GetMultipleFiles:
370  settings.setValue( QStringLiteral( "UI/lastFileNameWidgetDir" ), QFileInfo( fileNames.first( ) ).absolutePath() );
371  break;
372  }
373 
374  // Handle relative Path storage
375  if ( mStorageMode != GetMultipleFiles )
376  {
377  fileName = relativePath( fileName, true );
378  setFilePath( fileName );
379  }
380  else
381  {
382  for ( int i = 0; i < fileNames.length(); i++ )
383  {
384  fileNames.replace( i, relativePath( fileNames.at( i ), true ) );
385  }
386  if ( fileNames.length() > 1 )
387  {
388  setFilePath( QStringLiteral( "\"%1\"" ).arg( fileNames.join( QLatin1String( "\" \"" ) ) ) );
389  }
390  else
391  {
392  setFilePath( fileNames.first( ) );
393  }
394  }
395 }
396 
397 
398 QString QgsFileWidget::relativePath( const QString &filePath, bool removeRelative ) const
399 {
400  QString RelativePath;
401  if ( mRelativeStorage == RelativeProject )
402  {
403  RelativePath = QDir::toNativeSeparators( QDir::cleanPath( QFileInfo( QgsProject::instance()->absoluteFilePath() ).path() ) );
404  }
405  else if ( mRelativeStorage == RelativeDefaultPath && !mDefaultRoot.isEmpty() )
406  {
407  RelativePath = QDir::toNativeSeparators( QDir::cleanPath( mDefaultRoot ) );
408  }
409 
410  if ( !RelativePath.isEmpty() )
411  {
412  if ( removeRelative )
413  {
414  return QDir::cleanPath( QDir( RelativePath ).relativeFilePath( filePath ) );
415  }
416  else
417  {
418  return QDir::cleanPath( QDir( RelativePath ).filePath( filePath ) );
419  }
420  }
421 
422  return filePath;
423 }
424 
425 
426 QString QgsFileWidget::toUrl( const QString &path ) const
427 {
428  QString rep;
429  if ( path.isEmpty() )
430  {
432  }
433 
434  QString urlStr = relativePath( path, false );
435  QUrl url = QUrl::fromUserInput( urlStr );
436  if ( !url.isValid() || !url.isLocalFile() )
437  {
438  QgsDebugMsg( QStringLiteral( "URL: %1 is not valid or not a local file!" ).arg( path ) );
439  rep = path;
440  }
441 
442  QString pathStr = url.toString();
443  if ( mFullUrl )
444  {
445  rep = QStringLiteral( "<a href=\"%1\">%2</a>" ).arg( pathStr, path );
446  }
447  else
448  {
449  QString fileName = QFileInfo( urlStr ).fileName();
450  rep = QStringLiteral( "<a href=\"%1\">%2</a>" ).arg( pathStr, fileName );
451  }
452 
453  return rep;
454 }
455 
456 
457 
459 
460 
461 QgsFileDropEdit::QgsFileDropEdit( QWidget *parent )
462  : QgsHighlightableLineEdit( parent )
463 {
464  setAcceptDrops( true );
465 }
466 
467 void QgsFileDropEdit::setFilters( const QString &filters )
468 {
469  mAcceptableExtensions.clear();
470 
471  if ( filters.contains( QStringLiteral( "*.*" ) ) )
472  return; // everything is allowed!
473 
474  QRegularExpression rx( QStringLiteral( "\\*\\.(\\w+)" ) );
475  QRegularExpressionMatchIterator i = rx.globalMatch( filters );
476  while ( i.hasNext() )
477  {
478  QRegularExpressionMatch match = i.next();
479  if ( match.hasMatch() )
480  {
481  mAcceptableExtensions << match.captured( 1 ).toLower();
482  }
483  }
484 }
485 
486 QString QgsFileDropEdit::acceptableFilePath( QDropEvent *event ) const
487 {
488  QStringList rawPaths;
489  QStringList paths;
490  if ( event->mimeData()->hasUrls() )
491  {
492  const QList< QUrl > urls = event->mimeData()->urls();
493  rawPaths.reserve( urls.count() );
494  for ( const QUrl &url : urls )
495  {
496  const QString local = url.toLocalFile();
497  if ( !rawPaths.contains( local ) )
498  rawPaths.append( local );
499  }
500  }
501 
503  for ( const QgsMimeDataUtils::Uri &u : lst )
504  {
505  if ( !rawPaths.contains( u.uri ) )
506  rawPaths.append( u.uri );
507  }
508 
509  if ( !event->mimeData()->text().isEmpty() && !rawPaths.contains( event->mimeData()->text() ) )
510  rawPaths.append( event->mimeData()->text() );
511 
512  paths.reserve( rawPaths.count() );
513  for ( const QString &path : qgis::as_const( rawPaths ) )
514  {
515  QFileInfo file( path );
516  switch ( mStorageMode )
517  {
521  {
522  if ( file.isFile() && ( mAcceptableExtensions.isEmpty() || mAcceptableExtensions.contains( file.suffix(), Qt::CaseInsensitive ) ) )
523  paths.append( file.filePath() );
524 
525  break;
526  }
527 
529  {
530  if ( file.isDir() )
531  paths.append( file.filePath() );
532  else if ( file.isFile() )
533  {
534  // folder mode, but a file dropped. So get folder name from file
535  paths.append( file.absolutePath() );
536  }
537 
538  break;
539  }
540  }
541  }
542 
543  if ( paths.size() > 1 )
544  {
545  return QStringLiteral( "\"%1\"" ).arg( paths.join( QLatin1String( "\" \"" ) ) );
546  }
547  else if ( paths.size() == 1 )
548  {
549  return paths.first();
550  }
551  else
552  {
553  return QString();
554  }
555 }
556 
557 void QgsFileDropEdit::dragEnterEvent( QDragEnterEvent *event )
558 {
559  QString filePath = acceptableFilePath( event );
560  if ( !filePath.isEmpty() )
561  {
562  event->acceptProposedAction();
563  setHighlighted( true );
564  }
565  else
566  {
567  event->ignore();
568  }
569 }
570 
571 void QgsFileDropEdit::dragLeaveEvent( QDragLeaveEvent *event )
572 {
573  QgsFilterLineEdit::dragLeaveEvent( event );
574  event->accept();
575  setHighlighted( false );
576 }
577 
578 void QgsFileDropEdit::dropEvent( QDropEvent *event )
579 {
580  QString filePath = acceptableFilePath( event );
581  if ( !filePath.isEmpty() )
582  {
583  setText( filePath );
584  selectAll();
585  setFocus( Qt::MouseFocusReason );
586  event->acceptProposedAction();
587  setHighlighted( false );
588  }
589 }
590 
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:231
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:114
QgsHighlightableLineEdit
A QgsFilterLineEdit subclass with the ability to "highlight" the edges of the widget.
Definition: qgshighlightablelineedit.h:34
QgsApplication::getThemeIcon
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon.
Definition: qgsapplication.cpp:626
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
QLineEdit subclass with built in support for clearing the widget's value and handling custom null val...
Definition: qgsfilterlineedit.h:40
QgsProject::instance
static QgsProject * instance()
Returns the QgsProject singleton instance.
Definition: qgsproject.cpp:468
QgsSettings
This class is a composition of two QSettings instances:
Definition: qgssettings.h:62
QgsFileWidget::setFileWidgetButtonVisible
void setFileWidgetButtonVisible(bool visible)
determines if the tool button is shown
Definition: qgsfilewidget.cpp:145
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::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:181
QgsFocusKeeper
Trick to keep a widget focused and avoid QT crashes.
Definition: qgsfocuskeeper.h:35
QgsFileWidget::filter
QString filter
Definition: qgsfilewidget.h:53
QgsFileWidget::relativeStorage
RelativeStorage relativeStorage
Definition: qgsfilewidget.h:56
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:1851
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:226
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:41
qgsfileutils.h
QgsFileWidget::RelativeStorage
RelativeStorage
The RelativeStorage enum determines if path is absolute, relative to the current project path or rela...
Definition: qgsfilewidget.h:77
QgsFileWidget::setReadOnly
void setReadOnly(bool readOnly)
defines if the widget is readonly
Definition: qgsfilewidget.cpp:99
QgsMimeDataUtils::decodeUriList
static UriList decodeUriList(const QMimeData *data)
Definition: qgsmimedatautils.cpp:211
QgsFileWidget::StorageMode
StorageMode
The StorageMode enum determines if the file picker should pick files or directories.
Definition: qgsfilewidget.h:65
QgsFileWidget::setStorageMode
void setStorageMode(QgsFileWidget::StorageMode storageMode)
determines the storage mode (i.e. file or directory)
Definition: qgsfilewidget.cpp:215
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:205
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:124
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:195
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:135
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
QgsFileWidget::storageMode
StorageMode storageMode
Definition: qgsfilewidget.h:55
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