Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
QtxPathDialog.h
Go to the documentation of this file.
1 // Copyright (C) 2007-2016 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: QtxPathDialog.h
24 // Author: Sergey TELKOV
25 //
26 #ifndef QTXPATHDIALOG_H
27 #define QTXPATHDIALOG_H
28 
29 #include "QtxDialog.h"
30 
31 #include <QMap>
32 
33 class QFrame;
34 class QLineEdit;
35 class QPushButton;
36 class QFileDialog;
37 
38 #ifdef WIN32
39 #pragma warning( disable:4251 )
40 #endif
41 
43 {
44  Q_OBJECT
45 
46 protected:
47  QtxPathDialog( QWidget* = 0, const bool = true, const bool = false,
48  const int = Standard, Qt::WindowFlags = 0 );
49 
50 public:
51  QtxPathDialog( const bool, QWidget* = 0, const bool = true,
52  const bool = false, const int = Standard, Qt::WindowFlags = 0 );
53  virtual ~QtxPathDialog();
54 
55  QString fileName() const;
56  void setFileName( const QString&, const bool = false );
57 
58  QString filter() const;
59  void setFilter( const QString& );
60 
61 signals:
62  void fileNameChanged( QString );
63 
64 public slots:
65  virtual void setVisible( bool );
66 
67 protected slots:
68  void validate();
69 
70 private slots:
71  void onBrowse();
72  void onReturnPressed();
73  void onTextChanged( const QString& );
74 
75 protected:
76  virtual bool isValid();
77  virtual bool acceptData() const;
78  virtual void fileNameChanged( int, QString );
79 
80  QFrame* optionsFrame();
81  QString fileName( const int ) const;
82  void setFileName( const int, const QString&, const bool = false );
83 
84  QString filter( const int ) const;
85  void setFilter( const int, const QString& );
86 
87  QLineEdit* fileEntry( const int ) const;
88  QLineEdit* fileEntry( const int, int& ) const;
89  int createFileEntry( const QString&, const int,
90  const QString& = QString(), const int = -1 );
91 
92  int defaultEntry() const;
93  void setDefaultEntry( const int );
94 
95 private:
96  void initialize();
97  void updateVisibility();
98  QStringList prepareFilters( const QString& ) const;
99  bool hasVisibleChildren( QWidget* ) const;
100  QStringList filterWildCards( const QString& ) const;
101  QString autoExtension( const QString&, const QString& = QString() ) const;
102 
103 protected:
104  enum { OpenFile, SaveFile, OpenDir, SaveDir, NewDir };
105 
106 private:
107  typedef struct { int mode; QLineEdit* edit; QString filter;
108  QPushButton* btn; QFileDialog* dlg; } FileEntry;
109  typedef QMap<int, FileEntry> FileEntryMap;
110 
111 private:
116 };
117 
118 #ifdef WIN32
119 #pragma warning( default:4251 )
120 #endif
121 
122 #endif