Back to index

salome-gui  6.5.0
QtxPathDialog.h
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 // File:      QtxPathDialog.h
00024 // Author:    Sergey TELKOV
00025 //
00026 #ifndef QTXPATHDIALOG_H
00027 #define QTXPATHDIALOG_H
00028 
00029 #include "QtxDialog.h"
00030 
00031 #include <QMap>
00032 
00033 class QFrame;
00034 class QLineEdit;
00035 class QPushButton;
00036 class QFileDialog;
00037 
00038 #ifdef WIN32
00039 #pragma warning( disable:4251 )
00040 #endif
00041 
00042 class QTX_EXPORT QtxPathDialog : public QtxDialog
00043 {
00044   Q_OBJECT
00045 
00046 protected:
00047   QtxPathDialog( QWidget* = 0, const bool = true, const bool = false,
00048                  const int = Standard, Qt::WindowFlags = 0 );
00049 
00050 public:
00051   QtxPathDialog( const bool, QWidget* = 0, const bool = true,
00052                  const bool = false, const int = Standard, Qt::WindowFlags = 0 );
00053   virtual ~QtxPathDialog();
00054 
00055   QString            fileName() const;
00056   void               setFileName( const QString&, const bool = false );
00057 
00058   QString            filter() const;
00059   void               setFilter( const QString& );
00060 
00061 signals:
00062   void               fileNameChanged( QString );
00063 
00064 public slots:
00065   virtual void       setVisible( bool );
00066 
00067 protected slots:
00068   void               validate();
00069 
00070 private slots:
00071   void               onBrowse();
00072   void               onReturnPressed();
00073   void               onTextChanged( const QString& );
00074 
00075 protected:
00076   virtual bool       isValid();
00077   virtual bool       acceptData() const;
00078   virtual void       fileNameChanged( int, QString );
00079 
00080   QFrame*            optionsFrame();
00081   QString            fileName( const int ) const;
00082   void               setFileName( const int, const QString&, const bool = false );
00083 
00084   QString            filter( const int ) const;
00085   void               setFilter( const int, const QString& );
00086 
00087   QLineEdit*         fileEntry( const int ) const;
00088   QLineEdit*         fileEntry( const int, int& ) const;
00089   int                createFileEntry( const QString&, const int,
00090                                       const QString& = QString(), const int = -1 );
00091 
00092   int                defaultEntry() const;
00093   void               setDefaultEntry( const int );
00094 
00095 private:
00096   void               initialize();
00097   void               updateVisibility();
00098   QStringList        prepareFilters( const QString& ) const;
00099         bool               hasVisibleChildren( QWidget* ) const;
00100   QStringList        filterWildCards( const QString& ) const;
00101   QString            autoExtension( const QString&, const QString& = QString() ) const;
00102 
00103 protected:
00104   enum { OpenFile, SaveFile, OpenDir, SaveDir, NewDir };
00105 
00106 private:
00107   typedef struct { int mode; QLineEdit* edit; QString filter;
00108                    QPushButton* btn; QFileDialog* dlg; } FileEntry;
00109   typedef QMap<int, FileEntry> FileEntryMap;
00110 
00111 private:
00112   FileEntryMap       myEntries;
00113   int                myDefault;
00114   QWidget*           myEntriesFrame;
00115   QFrame*            myOptionsFrame;
00116 };
00117 
00118 #ifdef WIN32
00119 #pragma warning( default:4251 )
00120 #endif
00121 
00122 #endif