QGIS API Documentation  2.99.0-Master (cb63e82)
qgsfiledropedit.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsfiledropedit.h - File Dropable LineEdit
3  --------------------------------------
4  Date : 31-Jan-2007
5  Copyright : (C) 2007 by Tom Elwertowski
6  Email : telwertowski at users dot sourceforge dot net
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 #ifndef QGSFILEDROPEDIT_H
16 #define QGSFILEDROPEDIT_H
17 
18 #include <QLineEdit>
19 #include "qgis_gui.h"
20 
28 class GUI_EXPORT QgsFileDropEdit: public QLineEdit
29 {
30  Q_OBJECT
31 
32  public:
33  QgsFileDropEdit( QWidget *parent = nullptr );
34 
35  bool isDirOnly() const { return mDirOnly; }
36 
40  void setDirOnly( bool isDirOnly );
41 
42  bool isFileOnly() const { return mFileOnly; }
43 
47  void setFileOnly( bool isFileOnly );
48 
49  QString suffixFilter() const { return mSuffix; }
50 
54  void setSuffixFilter( const QString &suffix );
55 
56  protected:
57 
58  virtual void dragEnterEvent( QDragEnterEvent *event ) override;
59  virtual void dragLeaveEvent( QDragLeaveEvent *event ) override;
60  virtual void dropEvent( QDropEvent *event ) override;
61  virtual void paintEvent( QPaintEvent *e ) override;
62 
63  private:
64 
68  QString acceptableFilePath( QDropEvent *event ) const;
69 
70  QString mSuffix;
71  bool mDirOnly;
72  bool mFileOnly;
73  bool mDragActive;
74 };
75 
76 #endif
QString suffixFilter() const
bool isFileOnly() const
bool isDirOnly() const
A line edit for capturing file names that can have files dropped onto it via drag & drop...