Salome HOME
Porting SMESH module to Qt 4
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_FilterLibraryDlg.h
1 // SMESH SMESHGUI : GUI for SMESH component
2 //
3 // Copyright (C) 2003  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. 
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 // File   : SMESHGUI_FilterLibraryDlg.h
23 // Author : Sergey LITONIN, Open CASCADE S.A.S.
24 //
25
26 #ifndef SMESHGUI_FILTERLIBRARYDLG_H
27 #define SMESHGUI_FILTERLIBRARYDLG_H
28
29 // SMESH includes
30 #include "SMESH_SMESHGUI.hxx"
31
32 // Qt includes
33 #include <QDialog>
34 #include <QList>
35 #include <QMap>
36
37 // IDL includes
38 #include <SALOMEconfig.h>
39 #include CORBA_SERVER_HEADER(SMESH_Filter)
40
41 class QListWidget;
42 class QLineEdit;
43 class QPushButton;
44 class SMESHGUI;
45 class SMESHGUI_FilterTable;
46
47 /*
48   Class       : SMESHGUI_FilterLibraryDlg
49   Description : Dialog to specify filters for VTK viewer
50 */
51
52 class SMESHGUI_EXPORT SMESHGUI_FilterLibraryDlg : public QDialog
53
54   Q_OBJECT
55   
56   // Buttons
57   enum { BTN_OK, BTN_Cancel, BTN_Apply, BTN_Close, BTN_Help };
58
59   class Dialog;
60   
61 public:
62   
63   // Mode
64   enum { ADD_TO, COPY_FROM, EDIT };
65     
66 public:
67   SMESHGUI_FilterLibraryDlg( SMESHGUI*, QWidget*, const QList<int>&, const int );
68   SMESHGUI_FilterLibraryDlg( SMESHGUI*, QWidget*, const int, const int );
69   virtual ~SMESHGUI_FilterLibraryDlg();
70                             
71   void                        Init( const QList<int>&, const int );
72   void                        Init( const int, const int );
73   
74   const SMESHGUI_FilterTable* GetTable() const;
75   void                        SetTable( const SMESHGUI_FilterTable* );
76
77 private:
78   void                        closeEvent( QCloseEvent* );
79   void                        enterEvent( QEvent* );            
80   void                        keyPressEvent( QKeyEvent* );
81   
82 private slots:
83   void                        onOk();
84   bool                        onApply();
85   void                        onClose();
86   void                        onHelp();
87
88   void                        onDeactivate();
89   
90   void                        onBrowse();
91   void                        onReturnPressed();
92   void                        onFilterChanged( const QString& );
93   void                        onAddBtnPressed();
94   void                        onDeleteBtnPressed();
95   void                        onFilterNameChanged( const QString& );
96   void                        onEntityTypeChanged( const int );
97   void                        onNeedValidation();
98
99 private:
100   void                        construct( const QList<int>&, const int ); 
101   QWidget*                    createButtonFrame( QWidget* );
102   QWidget*                    createMainFrame( QWidget* );
103   bool                        isValid( const bool = true ) const;
104   bool                        isNameValid( const bool = true ) const;
105   SMESH::Filter_ptr           createFilter( const int = -1 );
106   QStringList                 prepareFilters() const;
107   QString                     autoExtension( const QString& ) const;
108   bool                        setSelected( const QString& );
109   int                         getIndex( const QString& ) const;
110   void                        updateControlsVisibility();
111   void                        updateMainButtons();
112   void                        enableMainButtons();
113   void                        processNewLibrary();
114   QString                     getFileName() const;
115   void                        setFileName( const QString&, const bool = true );
116   QStringList                 filterWildCards( const QString& ) const;
117   QString&                    getDefaultLibraryName() const;
118   QString                     getDefaultFilterName() const;
119   void                        addFilterToLib( const QString& );
120   void                        updateList();
121   bool                        isPermissionValid( const bool );
122
123 private:
124
125   QWidget*                    myMainFrame;
126   QMap<int, QPushButton*>     myButtons;
127   SMESHGUI_FilterTable*       myTable;
128   QLineEdit*                  myFileName;
129   QPushButton*                myOpenBtn;
130   QListWidget*                myListBox;
131   QPushButton*                myAddBtn;
132   QPushButton*                myDeleteBtn;
133   QWidget*                    myNameGrp;
134   QLineEdit*                  myName;
135   SMESHGUI*                   mySMESHGUI;
136
137   QList<int>                  myTypes;
138   int                         myMode;
139       
140   SMESH::FilterLibrary_var    myLibrary;
141   QString                     myCurrFilterName;
142   int                         myCurrFilter;
143
144   QString                     myHelpFileName;
145 };
146
147 #endif // SMESHGUI_FILTERLIBRARYDLG_H