17 #ifndef QGSFILEWIDGET_H
18 #define QGSFILEWIDGET_H
24 class QgsFileDropEdit;
27 #include <QFileDialog>
43 if ( qobject_cast<QgsFileWidget *>( sipCpp ) )
44 sipType = sipType_QgsFileWidget;
51 Q_PROPERTY(
bool fileWidgetButtonVisible READ fileWidgetButtonVisible WRITE setFileWidgetButtonVisible )
52 Q_PROPERTY(
bool useLink READ useLink WRITE setUseLink )
53 Q_PROPERTY(
bool fullUrl READ fullUrl WRITE setFullUrl )
54 Q_PROPERTY( QString dialogTitle READ dialogTitle WRITE setDialogTitle )
55 Q_PROPERTY( QString filter READ filter WRITE setFilter )
56 Q_PROPERTY( QString defaultRoot READ defaultRoot WRITE setDefaultRoot )
57 Q_PROPERTY(
StorageMode storageMode READ storageMode WRITE setStorageMode )
58 Q_PROPERTY(
RelativeStorage relativeStorage READ relativeStorage WRITE setRelativeStorage )
59 Q_PROPERTY( QFileDialog::Options options READ options WRITE setOptions )
84 Q_ENUM( RelativeStorage )
107 static QStringList splitFilePaths(
const QString &path );
114 void setFilePath(
const QString &path );
119 virtual void setReadOnly(
bool readOnly );
126 QString dialogTitle()
const;
135 void setDialogTitle(
const QString &title );
138 QString filter()
const;
144 void setFilter(
const QString &filter );
153 QFileDialog::Options options()
const;
165 void setOptions( QFileDialog::Options options );
204 bool fileWidgetButtonVisible()
const;
211 void setFileWidgetButtonVisible(
bool visible );
218 bool useLink()
const;
225 void setUseLink(
bool useLink );
232 bool fullUrl()
const;
239 void setFullUrl(
bool fullUrl );
246 QString defaultRoot()
const;
253 void setDefaultRoot(
const QString &defaultRoot );
295 void fileChanged(
const QString &path );
298 void openFileDialog();
299 void textEdited(
const QString &path );
301 void fileDropped(
const QString &filePath );
308 virtual void updateLayout();
313 virtual void setSelectedFileNames( QStringList fileNames );
318 static bool isMultiFiles(
const QString &path );
323 void setFilePaths(
const QStringList &filePaths );
326 bool mButtonVisible =
true;
327 bool mUseLink =
false;
328 bool mFullUrl =
false;
329 bool mReadOnly =
false;
330 bool mIsLinkEdited =
false;
335 bool mConfirmOverwrite =
true;
338 QFileDialog::Options mOptions = QFileDialog::Options();
340 QLabel *mLinkLabel =
nullptr;
341 QgsFileDropEdit *mLineEdit =
nullptr;
342 QToolButton *mLinkEditButton =
nullptr;
343 QToolButton *mFileWidgetButton =
nullptr;
344 QHBoxLayout *mLayout =
nullptr;
347 QString toUrl(
const QString &path )
const;
350 QString relativePath(
const QString &filePath,
bool removeRelative )
const;
352 friend class TestQgsFileWidget;
353 friend class TestQgsExternalStorageFileWidget;
354 friend class TestQgsExternalResourceWidgetWrapper;
381 void setFilters(
const QString &filters );
384 QStringList acceptableFilePaths( QDropEvent *event )
const;
391 void fileDropped(
const QString &filePath );
396 QString acceptableFilePath( QDropEvent *event )
const;
398 void dragEnterEvent( QDragEnterEvent *event )
override;
399 void dragLeaveEvent( QDragLeaveEvent *event )
override;
400 void dropEvent( QDropEvent *event )
override;
405 QStringList mAcceptableExtensions;
407 friend class TestQgsFileWidget;
413 #endif // QGSFILEWIDGET_H