Salome HOME
b4c106e78ee3793a2a6a7e3d0d0ac9ca1bb88c0e
[modules/gui.git] / src / SUIT / SUIT_FileDlg.h
1 // Copyright (C) 2007-2023  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 // File   : SUIT_FileDlg.h
24 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
25 //
26 #ifndef SUIT_FILEDLG_H
27 #define SUIT_FILEDLG_H
28
29 #include "SUIT.h"
30
31 #include <QFileDialog>
32
33 class QLabel;
34 class QLineEdit;
35 class QComboBox;
36 class QPushButton;
37 class QUrl;
38 class SUIT_FileValidator;
39
40 class SUIT_EXPORT SUIT_FileDlg : public QFileDialog
41 {
42   Q_OBJECT
43
44 public:
45   SUIT_FileDlg( QWidget*, bool, bool = true, bool = true );
46   virtual ~SUIT_FileDlg();
47
48   bool                isOpenDlg()    const;    
49   
50   bool                checkPermissions() const;
51   void                setCheckPermissions( const bool );
52
53   SUIT_FileValidator* validator() const;
54   void                setValidator( SUIT_FileValidator* );
55
56   bool                addWidgets( QWidget*, QWidget*, QWidget* );
57
58   QStringList         selectedFiles() const;
59   QString             selectedFile() const;
60
61   void selectFile( const QString& );
62
63   static QString      getLastVisitedDirectory();
64
65   static QString      getFileName( QWidget*, 
66                                    const QString&, 
67                                    const QStringList&, 
68                                    const QString& = QString(), 
69                                    const bool = true, 
70                                    const bool = true,
71                                    SUIT_FileValidator* = 0 );
72   static QString      getFileName( QWidget*, 
73                                    const QString&, 
74                                    const QString&,
75                                    const QString& = QString(), 
76                                    const bool = true,
77                                    const bool = true,
78                                    SUIT_FileValidator* = 0 );
79
80   static QStringList  getOpenFileNames( QWidget*, 
81                                         const QString&,
82                                         const QStringList&, 
83                                         const QString& = QString(),
84                                         const bool = true, 
85                                         SUIT_FileValidator* = 0 );
86   static QStringList  getOpenFileNames( QWidget*, 
87                                         const QString&,
88                                         const QString&, 
89                                         const QString& = QString(),
90                                         const bool = true, 
91                                         SUIT_FileValidator* = 0 );
92
93   static QString      getExistingDirectory( QWidget*, 
94                                             const QString&,
95                                             const QString& = QString(), 
96                                             const bool = true,
97                                             SUIT_FileValidator* = 0 );
98
99   static QString      getLastVisitedPath();
100
101 protected:
102   virtual bool        event( QEvent* );
103   QLineEdit*          lineEdit() const;
104   virtual bool        acceptData();
105   QString             addExtension( const QString& ) const;
106   bool                processPath( const QString& );
107   void                addFilter( const QString& );
108   static bool         hasWildCards( const QString& );
109
110 protected slots:
111   void                accept();        
112   void                quickDir( const QString& );
113   void                addQuickDir();
114
115 private:
116   void                polish();
117   void                updateSideBar();
118
119 private:
120   SUIT_FileValidator* myValidator;        //!< file validator
121   QLabel*             myQuickLab;         //!< quick dir panel: label
122   QComboBox*          myQuickCombo;       //!< quick dir panel: combo box
123   QPushButton*        myQuickButton;      //!< quick dir panel: button
124   QStringList         myUrls;             //!< sidebar urls
125   bool                myCheckPermissions; //!< check permissions option
126   static QString      myLastVisitedPath;  //!< last visited path
127 };
128
129 #endif  // SUIT_FILEDLG_H