Salome HOME
bcbd24d60d97c60e47699ed8a3e5614c4bc2a13a
[modules/gui.git] / src / SUIT / SUIT_FileDlg.h
1 #ifndef SUIT_FILEDIALOG_H
2 #define SUIT_FILEDIALOG_H
3
4 #include "SUIT.h"
5
6 #include <qfiledialog.h>
7
8 class QLabel;
9 class QComboBox;
10 class QPushButton;
11 class SUIT_FileValidator;
12
13 /*! \class QFileDialog
14  *  For more information see <a href="http://doc.trolltech.com">QT documentation</a>.
15 */
16 class SUIT_EXPORT SUIT_FileDlg : public QFileDialog
17 {
18   Q_OBJECT
19
20 public:
21   SUIT_FileDlg( QWidget*, bool open, bool showQuickDir = true, bool modal = true );
22   virtual ~SUIT_FileDlg();
23
24 public:    
25   bool                isOpenDlg()    const;    
26   QString             selectedFile() const;
27
28   void                setValidator( SUIT_FileValidator* );
29
30   static QString      getFileName( QWidget* parent, const QString& initial, const QStringList& filters, 
31                                    const QString& caption, const bool open, const bool showQuickDir = true,
32                                    SUIT_FileValidator* validator = 0 );
33   static QStringList  getOpenFileNames( QWidget* parent, const QString& initial, const QStringList& filters, 
34                                         const QString& caption, bool showQuickDir = true, 
35                                         SUIT_FileValidator* validator = 0 );
36   static QString      getExistingDirectory( QWidget* parent, const QString& initial,
37                                             const QString& caption, const bool showQuickDir = true );
38
39 public slots:
40   void                polish();
41
42 private:
43   bool                acceptData();
44   void                addExtension();
45   bool                processPath( const QString& path );
46
47 protected slots:
48   void                accept();        
49   void                reject(); 
50   void                quickDir( const QString& );
51   void                addQuickDir();
52
53 protected:
54   bool                myOpen;             //!< open/save selector
55   QString             mySelectedFile;     //!< selected filename
56   SUIT_FileValidator* myValidator;        //!< file validator
57   QLabel*             myQuickLab;         //!< quick dir combo box
58   QComboBox*          myQuickCombo;       //!< quick dir combo box
59   QPushButton*        myQuickButton;      //!< quick dir add button
60   
61   /*! \var myAccepted
62    * \brief flag is used to warkaround the Qt 2.2.2
63    * \bug accept() method is called twice if user presses 'Enter' key 
64    * in file name editor while file name is not acceptable by acceptData()
65    * (e.g. permission denied)
66    */
67 //  bool                myAccepted;
68   /*! ASL: this bug can be fixed with help of call setDefault( false ) 
69    *       and setAutoDefault( false ) methods for all QPushButtons of this dialog
70    */
71
72   static QString      myLastVisitedPath;  //!< last visited path
73 };
74
75 #endif