Salome HOME
Copyrights update
[modules/gui.git] / src / Qtx / QtxPathDialog.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 // File:      QtxPathDialog.h
20 // Author:    Sergey TELKOV
21
22 #ifndef QTXPATHDIALOG_H
23 #define QTXPATHDIALOG_H
24
25 #include "QtxDialog.h"
26
27 #include <qmap.h>
28
29 class QFrame;
30 class QLineEdit;
31 class QPushButton;
32 class QFileDialog;
33
34 #ifdef WIN32
35 #pragma warning( disable:4251 )
36 #endif
37
38 class QTX_EXPORT QtxPathDialog : public QtxDialog
39 {
40   Q_OBJECT
41
42 protected:
43   QtxPathDialog( QWidget* = 0, const bool = true, const bool = false, const int = Standard, WFlags = 0 );
44
45 public:
46   QtxPathDialog( const bool, QWidget* = 0, const bool = true, const bool = false, const int = Standard, WFlags = 0 );
47   virtual ~QtxPathDialog();
48
49   QString            fileName() const;
50   void               setFileName( const QString&, const bool = false );
51
52   QString            filter() const;
53   void               setFilter( const QString& );
54
55   virtual void       show();
56
57 signals:
58   void               fileNameChanged( QString );
59
60 protected slots:
61   void               validate();
62
63 private slots:
64   void               onBrowse();
65   void               onReturnPressed();
66   void               onTextChanged( const QString& );
67
68 protected:
69   virtual bool       isValid();
70   virtual bool       acceptData() const;
71   virtual void       fileNameChanged( int, QString );
72
73   QFrame*            optionsFrame();
74   QString            fileName( const int ) const;
75   void               setFileName( const int, const QString&, const bool = false );
76
77   QLineEdit*         fileEntry( const int ) const;
78   QLineEdit*         fileEntry( const int, int& ) const;
79   int                createFileEntry( const QString&, const int, const int = -1 );
80
81   int                defaultEntry() const;
82   void               setDefaultEntry( const int );
83
84 private:
85   void               initialize();
86   QStringList        prepareFilters() const;
87         bool               hasVisibleChildren( QWidget* ) const;
88   QStringList        filterWildCards( const QString& ) const;
89   QString            autoExtension( const QString&, const QString& = QString::null ) const;
90
91 protected:
92   enum { OpenFile, SaveFile, OpenDir, SaveDir, NewDir };
93
94 private:
95   typedef struct { int mode; QLineEdit* edit;
96                    QPushButton* btn; QFileDialog* dlg; } FileEntry;
97   typedef QMap<int, FileEntry> FileEntryMap;
98
99 private:
100   QString            myFilter;
101   FileEntryMap       myEntries;
102   int                myDefault;
103   QFrame*            myEntriesFrame;
104   QFrame*            myOptionsFrame;
105 };
106
107 #ifdef WIN32
108 #pragma warning( default:4251 )
109 #endif
110
111 #endif