]> SALOME platform Git repositories - modules/gui.git/blob - src/SUIT/SUIT_FileDlg.h
Salome HOME
fcdb7da1351a64669481561031ea4d181b1060f1
[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   QString             dirPath() const; // QFileDialog::dirPath() has a bug on Linux Debian (1 level up from correct 
49                                        // directory is returned).  This redefinition fixes the bug.  
50
51   static QString      getFileName( QWidget* parent, const QString& initial, const QStringList& filters, 
52                                    const QString& caption, const bool open, const bool showQuickDir = true,
53                                    SUIT_FileValidator* validator = 0 );
54   static QStringList  getOpenFileNames( QWidget* parent, const QString& initial, const QStringList& filters, 
55                                         const QString& caption, bool showQuickDir = true, 
56                                         SUIT_FileValidator* validator = 0 );
57   static QString      getExistingDirectory( QWidget* parent, const QString& initial,
58                                             const QString& caption, const bool showQuickDir = true );
59
60 public slots:
61   void                polish();
62
63 private:
64   bool                acceptData();
65   void                addExtension();
66   bool                processPath( const QString& path );
67
68 protected slots:
69   void                accept();        
70   void                reject(); 
71   void                quickDir( const QString& );
72   void                addQuickDir();
73
74 protected:
75   bool                myOpen;             //!< open/save selector
76   QString             mySelectedFile;     //!< selected filename
77   SUIT_FileValidator* myValidator;        //!< file validator
78   QLabel*             myQuickLab;         //!< quick dir combo box
79   QComboBox*          myQuickCombo;       //!< quick dir combo box
80   QPushButton*        myQuickButton;      //!< quick dir add button
81   
82   /*! \var myAccepted
83    * \brief flag is used to warkaround the Qt 2.2.2
84    * \bug accept() method is called twice if user presses 'Enter' key 
85    * in file name editor while file name is not acceptable by acceptData()
86    * (e.g. permission denied)
87    */
88 //  bool                myAccepted;
89   /*! ASL: this bug can be fixed with help of call setDefault( false ) 
90    *       and setAutoDefault( false ) methods for all QPushButtons of this dialog
91    */
92
93   static QString      myLastVisitedPath;  //!< last visited path
94 };
95
96 #endif