QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 
24 class GUI_EXPORT QgsFileDropEdit: public QLineEdit
25 {
26  Q_OBJECT
27 
28  public:
29  QgsFileDropEdit( QWidget *parent = nullptr );
30  virtual ~QgsFileDropEdit();
31 
32  bool isDirOnly() const { return mDirOnly; }
33  void setDirOnly( bool isDirOnly );
34 
35  bool isFileOnly() const { return mFileOnly; }
36  void setFileOnly( bool isFileOnly );
37 
38  QString suffixFilter() const { return mSuffix; }
39  void setSuffixFilter( const QString& suffix );
40 
41  protected:
42 
43  virtual void dragEnterEvent( QDragEnterEvent *event ) override;
44  virtual void dragLeaveEvent( QDragLeaveEvent *event ) override;
45  virtual void dropEvent( QDropEvent *event ) override;
46  virtual void paintEvent( QPaintEvent *e ) override;
47 
48  private:
49  QString acceptableFilePath( QDropEvent *event ) const;
50 
51  QString mSuffix;
52  bool mDirOnly;
53  bool mFileOnly;
54  bool mDragActive;
55 };
56 
57 #endif
virtual void dragEnterEvent(QDragEnterEvent *e)
QString suffixFilter() const
bool isFileOnly() const
bool isDirOnly() const
virtual void paintEvent(QPaintEvent *)
virtual void dragLeaveEvent(QDragLeaveEvent *e)
A line edit for capturing file names that can have files dropped onto it via drag & drop...
virtual void dropEvent(QDropEvent *e)