]> SALOME platform Git repositories - modules/gui.git/blob - src/SUIT/SUIT_FileDlg.h
Salome HOME
bb9ae4e3f1350524d66a17d367653dab36be956c
[modules/gui.git] / src / SUIT / SUIT_FileDlg.h
1 // Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
2 // 
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either 
6 // version 2.1 of the License.
7 // 
8 // This library is distributed in the hope that it will be useful 
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public  
14 // License along with this library; if not, write to the Free Software 
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/
18 //
19 #ifndef SUIT_FILEDIALOG_H
20 #define SUIT_FILEDIALOG_H
21
22 #include "SUIT.h"
23
24 #include <qfiledialog.h>
25
26 class QLabel;
27 class QComboBox;
28 class QPushButton;
29 class SUIT_FileValidator;
30
31 /*! \class QFileDialog
32  *  For more information see <a href="http://doc.trolltech.com">QT documentation</a>.
33 */
34 class SUIT_EXPORT SUIT_FileDlg : public QFileDialog
35 {
36   Q_OBJECT
37
38 public:
39   SUIT_FileDlg( QWidget*, bool open, bool showQuickDir = true, bool modal = true );
40   virtual ~SUIT_FileDlg();
41
42 public:    
43   bool                isOpenDlg()    const;    
44   QString             selectedFile() const;
45
46   void                setValidator( SUIT_FileValidator* );
47
48   static QString      getFileName( QWidget* parent, const QString& initial, const QStringList& filters, 
49                                    const QString& caption, const bool open, const bool showQuickDir = true,
50                                    SUIT_FileValidator* validator = 0 );
51   static QStringList  getOpenFileNames( QWidget* parent, const QString& initial, const QStringList& filters, 
52                                         const QString& caption, bool showQuickDir = true, 
53                                         SUIT_FileValidator* validator = 0 );
54   static QString      getExistingDirectory( QWidget* parent, const QString& initial,
55                                             const QString& caption, const bool showQuickDir = true );
56
57 public slots:
58   void                polish();
59
60 private:
61   bool                acceptData();
62   void                addExtension();
63   bool                processPath( const QString& path );
64
65 protected slots:
66   void                accept();        
67   void                reject(); 
68   void                quickDir( const QString& );
69   void                addQuickDir();
70
71 protected:
72   bool                myOpen;             //!< open/save selector
73   QString             mySelectedFile;     //!< selected filename
74   SUIT_FileValidator* myValidator;        //!< file validator
75   QLabel*             myQuickLab;         //!< quick dir combo box
76   QComboBox*          myQuickCombo;       //!< quick dir combo box
77   QPushButton*        myQuickButton;      //!< quick dir add button
78   
79   /*! \var myAccepted
80    * \brief flag is used to warkaround the Qt 2.2.2
81    * \bug accept() method is called twice if user presses 'Enter' key 
82    * in file name editor while file name is not acceptable by acceptData()
83    * (e.g. permission denied)
84    */
85 //  bool                myAccepted;
86   /*! ASL: this bug can be fixed with help of call setDefault( false ) 
87    *       and setAutoDefault( false ) methods for all QPushButtons of this dialog
88    */
89
90   static QString      myLastVisitedPath;  //!< last visited path
91 };
92
93 #endif