Salome HOME
PR: mergefrom_PAL_OCC_21Oct04
[modules/kernel.git] / src / SALOMEGUI / QAD_ObjectBrowser.h
1 //  SALOME SALOMEGUI : implementation of desktop and GUI kernel
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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : QAD_ObjectBrowser.h
25 //  Author : Nicolas REJNERI
26 //  Module : SALOME
27 //  $Header$
28
29 #ifndef QAD_OBJECTBROWSER_H
30 #define QAD_OBJECTBROWSER_H
31
32 #include "QAD.h"
33 #include "QAD_Popup.h"
34
35 #include "SALOME_InteractiveObject.hxx"
36  
37 // QT Includes
38 #include <qlist.h>
39 #include <qvariant.h>
40 #include <qwidget.h>
41 #include <qtabwidget.h>
42 #include <qtoolbutton.h>
43 #include <qmap.h>
44
45 // IDL headers
46 #include <SALOMEconfig.h>
47 #include CORBA_SERVER_HEADER(SALOMEDS)
48 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
49
50 class QListViewItem;
51 class QListView;
52 class QAD_ObjectBrowserItem;
53 typedef QList<QAD_ObjectBrowserItem> ItemList;
54 typedef QMap<QString, ItemList>      ItemMap;
55
56 class QAD_EXPORT QAD_ObjectBrowser : public QTabWidget, public QAD_PopupClientServer
57 {
58   Q_OBJECT
59
60 public:
61     QAD_ObjectBrowser( SALOMEDS::Study_var study, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
62     virtual ~QAD_ObjectBrowser();
63
64     bool                   eventFilter( QObject* o, QEvent* e );
65
66     void                   setupListView();
67     /* popup management */
68     void                   onCreatePopup();
69
70     QListView*             getListView() const;
71     QListView*             getUseCaseView() const;
72
73     void                   Update();
74     void                   UpdateUseCaseBrowser();
75
76     void                   unHighlightAll();
77     void                   highlight( const Handle(SALOME_InteractiveObject)& IObject, bool highlight );
78     bool                   getItems( const Handle(SALOME_InteractiveObject)& IObject, 
79                                      QList<QAD_ObjectBrowserItem>& List);
80     bool                   getItems( SALOMEDS::SObject_ptr SO, 
81                                      QList<QAD_ObjectBrowserItem>& List);
82     QAD_ObjectBrowserItem* getItem( const Handle(SALOME_InteractiveObject)& IObject );
83     QAD_ObjectBrowserItem* getItem( SALOMEDS::SObject_ptr SO );
84     QAD_ObjectBrowserItem* getUCItem( const Handle(SALOME_InteractiveObject)& IObject );
85     QAD_ObjectBrowserItem* getUCItem( SALOMEDS::SObject_ptr SO );
86     void                   rename( const Handle(SALOME_InteractiveObject)& IObject, QString newName );
87
88     void                   setShowIAPP( bool show );
89     void                   setShowInfoColumns( bool show );
90     void                   setShowValueColumn( bool show );
91     void                   setEnableChronoSort( bool enable );
92     void                   showUseCaseBrowser ( bool show );
93     void                   autoSizeColumns ( bool autosize );
94
95 protected:
96     void                   Update( SALOMEDS::SObject_ptr SO,
97                                    QAD_ObjectBrowserItem* theParentItem );
98     void                   UpdateUCItem( SALOMEDS::SObject_var UCObject, 
99                                          QAD_ObjectBrowserItem* UCItem );
100     QAD_ObjectBrowserItem* AddItem( QListView*             theView,
101                                     const QString&         theName,
102                                     const QString&         theEntry,
103                                     const QString&         theIOR, 
104                                     int                    theType,
105                                     const QString&         theValue,
106                                     QAD_ObjectBrowserItem* theAfter = 0 );
107     QAD_ObjectBrowserItem* AddItem( QAD_ObjectBrowserItem* theParentItem,
108                                     const QString&         theName,
109                                     const QString&         theEntry,
110                                     const QString&         theIOR, 
111                                     int                    theType,
112                                     const QString&         theRef,
113                                     const QString&         theValue,
114                                     QAD_ObjectBrowserItem* theAfter = 0 );
115     QString                getValueFromObject( SALOMEDS::SObject_ptr SO );
116     bool                   hasEditableAttribute( const Handle(SALOME_InteractiveObject)& object );
117     bool                   hasTable( const Handle(SALOME_InteractiveObject)& object );
118
119 protected slots:
120     void                   onSelectedItem();
121     void                   onUseCaseSelectedItem();
122     void                   onEditAttribute();
123
124     void                   showPopupMenu(QListViewItem*);
125     void                   showUseCasePopupMenu(QListViewItem*);
126     
127     void                   onExpandAll();
128     void                   onExpanded (QListViewItem*);
129     void                   onCollapsed(QListViewItem*);
130     void                   onUseCasePopupMenu( int );
131
132     void                   onUseCaseBtn();
133
134 private:
135     ItemMap                myListViewMap;
136     ItemMap                myUseCaseMap;
137     QListView*             myListView;
138     QWidget*               myVBox;
139     QListView*             myUseCaseView;
140     QPopupMenu*            myPopupMenu;
141     SALOMEDS::Study_ptr    myStudy;
142     QToolButton*           myNewBtn;
143     QToolButton*           myAddBtn;
144     QToolButton*           myDelBtn;
145     QToolButton*           myCurrentBtn;
146     QToolButton*           myRenameBtn;
147     QToolButton*           myClearBtn;
148 };
149
150
151 class Btn : public QToolButton
152 {
153   Q_OBJECT
154 public:
155   Btn ( QWidget * parent, const char * name = 0 );
156 public slots:
157   void onClicked();
158 };
159
160 #endif