QGIS API Documentation  2.99.0-Master (b698612)
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.h"
20 #include "qgis_gui.h"
21 
29 class GUI_EXPORT QgsFileDropEdit: public QLineEdit
30 {
31  Q_OBJECT
32 
33  public:
34  QgsFileDropEdit( QWidget *parent SIP_TRANSFERTHIS = 0 );
35 
36  bool isDirOnly() const { return mDirOnly; }
37 
41  void setDirOnly( bool isDirOnly );
42 
43  bool isFileOnly() const { return mFileOnly; }
44 
48  void setFileOnly( bool isFileOnly );
49 
50  QString suffixFilter() const { return mSuffix; }
51 
55  void setSuffixFilter( const QString &suffix );
56 
57  protected:
58 
59  virtual void dragEnterEvent( QDragEnterEvent *event ) override;
60  virtual void dragLeaveEvent( QDragLeaveEvent *event ) override;
61  virtual void dropEvent( QDropEvent *event ) override;
62  virtual void paintEvent( QPaintEvent *e ) override;
63 
64  private:
65 
69  QString acceptableFilePath( QDropEvent *event ) const;
70 
71  QString mSuffix;
72  bool mDirOnly;
73  bool mFileOnly;
74  bool mDragActive;
75 };
76 
77 #endif
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:34
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...