1 // Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
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.
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.
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
17 // See http://www.salome-platform.org/
27 #include <qlistview.h>
29 #include <SUIT_DataObject.h>
30 #include <SUIT_DataObjectKey.h>
31 #include <SUIT_PopupClient.h>
34 #pragma warning( disable:4251 )
42 class OB_EXPORT OB_Browser : public QFrame, public SUIT_PopupClient
49 OB_Browser( QWidget* = 0, SUIT_DataObject* theRoot = 0 );
50 virtual ~OB_Browser();
52 virtual QString popupClientType() const { return QString( "ObjectBrowser" ); }
54 SUIT_DataObject* getRootObject() const;
55 virtual void setRootObject( SUIT_DataObject* theRoot = 0 );
57 int numberOfSelected() const;
59 DataObjectList getSelected() const;
60 void getSelected( DataObjectList& ) const;
62 virtual void setSelected( const SUIT_DataObject* theObject, const bool = false );
63 virtual void setSelected( const DataObjectList& theObjLst, const bool = false );
65 bool isOpen( SUIT_DataObject* theObject ) const;
66 virtual void setOpen( SUIT_DataObject* theObject, const bool theOpen = true );
68 bool isAutoUpdate() const;
69 virtual void setAutoUpdate( const bool );
71 bool isAutoDeleteObjects() const;
72 virtual void setAutoDeleteObjects( const bool );
74 virtual void updateTree( SUIT_DataObject* = 0, const bool autoOpen = true );
75 virtual void replaceTree( SUIT_DataObject*, SUIT_DataObject* );
77 bool isShowToolTips();
78 void setShowToolTips( const bool theDisplay );
82 SUIT_DataObject* dataObjectAt( const QPoint& ) const;
84 OB_Filter* filter() const;
85 void setFilter( OB_Filter* );
87 bool rootIsDecorated() const;
88 void setRootIsDecorated( const bool );
90 int autoOpenLevel() const;
91 void setAutoOpenLevel( const int );
93 virtual int addColumn( const QString&, const int id = -1, const int width = -1 );
94 virtual int addColumn( const QIconSet&, const QString&, const int id = -1, const int width = -1 );
95 virtual void removeColumn( const int id );
97 void setNameTitle( const QString& );
98 virtual void setNameTitle( const QIconSet&, const QString& );
99 void setColumnTitle( const int id, const QString& );
100 virtual void setColumnTitle( const int id, const QIconSet&, const QString& );
102 QString nameTitle() const;
103 QString columnTitle( const int ) const;
105 bool isColumnVisible( const int ) const;
106 virtual void setColumnShown( const int, const bool );
108 virtual void setWidthMode( QListView::WidthMode );
110 QValueList<int> columns() const;
112 bool appropriateColumn( const int ) const;
113 virtual void setAppropriateColumn( const int, const bool );
115 virtual bool eventFilter(QObject* watched, QEvent* e);
117 QListView* listView() const;
119 virtual void contextMenuPopup( QPopupMenu* );
122 unsigned long getModifiedTime() { return myModifiedTime; }
125 void selectionChanged();
126 void doubleClicked( SUIT_DataObject* );
127 void dropped( DataObjectList, SUIT_DataObject*, int );
131 void onColumnVisible( int );
132 void onDestroyed( SUIT_DataObject* );
133 void onDoubleClicked ( QListViewItem* );
134 void onDropped( QPtrList<QListViewItem>, QListViewItem*, int );
137 void adjustWidth( QListViewItem* );
138 virtual void updateView( SUIT_DataObject* = 0 );
139 virtual void updateText();
141 virtual void keyPressEvent( QKeyEvent* );
143 SUIT_DataObject* dataObject( const QListViewItem* ) const;
144 QListViewItem* listViewItem( const SUIT_DataObject* ) const;
147 typedef QMap<SUIT_DataObject*, QListViewItem*> ItemMap;
148 typedef SUIT_DataObjectKeyHandle DataObjectKey;
149 typedef QMap<SUIT_DataObject*, int> DataObjectMap;
150 typedef QMap<DataObjectKey, int> DataObjectKeyMap;
153 void expand( QListViewItem* );
154 bool hasClosed( QListViewItem* ) const;
156 void autoOpenBranches();
157 void openBranch( QListViewItem*, const int );
159 void removeReferences( QListViewItem* );
160 void removeConnections( SUIT_DataObject* );
161 void createConnections( SUIT_DataObject* );
162 void removeObject( SUIT_DataObject*, const bool = true );
164 void updateText( QListViewItem* );
166 DataObjectKey objectKey( QListViewItem* ) const;
167 DataObjectKey objectKey( SUIT_DataObject* ) const;
169 QListViewItem* createTree( const SUIT_DataObject*, QListViewItem*, QListViewItem* = 0, const bool = false );
170 QListViewItem* createItem( const SUIT_DataObject*, QListViewItem*, QListViewItem* = 0, const bool = false );
172 SUIT_DataObject* storeState( DataObjectMap&, DataObjectMap&,
173 DataObjectKeyMap&, DataObjectKeyMap&, DataObjectKey& ) const;
174 void restoreState( const DataObjectMap&, const DataObjectMap&, const SUIT_DataObject*,
175 const DataObjectKeyMap&, const DataObjectKeyMap&, const DataObjectKey& );
178 friend class OB_BrowserSync;
181 SUIT_DataObject* myRoot;
184 QMap<int, int> myColumnIds;
188 bool myRootDecorated;
191 friend class OB_Browser::ToolTip;
193 unsigned long myModifiedTime;