1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : OB_Browser.h
24 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
33 #include <QModelIndex>
34 #include <QItemSelection>
37 #pragma warning( disable:4251 )
40 class QAbstractItemModel;
41 class QAbstractItemDelegate;
47 class OB_EXPORT OB_Browser : public QWidget
51 // TODO: commented - to be removed or revised
55 OB_Browser( QWidget* = 0, QAbstractItemModel* = 0 );
56 virtual ~OB_Browser();
58 QAbstractItemModel* model() const;
59 void setModel( QAbstractItemModel* );
61 QAbstractItemDelegate* itemDelegate() const;
62 void setItemDelegate( QAbstractItemDelegate* );
64 bool rootIsDecorated() const;
65 void setRootIsDecorated( const bool );
67 bool sortMenuEnabled() const;
68 void setSortMenuEnabled( const bool );
70 QtxSearchTool* searchTool() const;
71 bool isSearchToolEnabled() const;
72 void setSearchToolEnabled( const bool );
74 int autoOpenLevel() const;
75 void setAutoOpenLevel( const int );
76 void openLevels( const int = -1 );
78 //bool isShowToolTips();
79 //void setShowToolTips( const bool theDisplay );
81 int numberOfSelected() const;
82 QModelIndexList selectedIndexes() const;
83 const QItemSelection selection() const;
85 virtual void select( const QModelIndex&, const bool, const bool = true );
86 virtual void select( const QModelIndexList&, const bool, const bool = true );
88 bool isOpen( const QModelIndex& ) const;
89 virtual void setOpen( const QModelIndex& theObject, const bool theOpen = true );
92 void adjustFirstColumnWidth();
93 void adjustColumnsWidth();
95 // san - To be revised or removed
96 // QTreeView::indexAt() should be used
97 //SUIT_DataObject* dataObjectAt( const QPoint& ) const;
100 //OB_Filter* filter() const;
101 //void setFilter( OB_Filter* );
103 // TODO: QTreeView::resizeColumnToContents() can be used instead
104 //virtual void setWidthMode( QListView::WidthMode );
106 unsigned long getModifiedTime() const;
109 // san - moved to SUIT_TreeModel
110 //OB_Updater* getUpdater() const;
111 //virtual void setUpdater( OB_Updater* theUpdate = 0 );
113 QtxTreeView* treeView() const;
116 void selectionChanged();
117 //void doubleClicked( SUIT_DataObject* );
118 //void dropped( DataObjectList, SUIT_DataObject*, int );
122 void onCollapseAll();
123 virtual void onExpanded( const QModelIndex& ) {}
124 //void onDestroyed( SUIT_DataObject* );
125 //void onDoubleClicked ( QListViewItem* );
126 //void onDropped( QPtrList<QListViewItem>, QListViewItem*, int );
129 //void adjustWidth( QListViewItem* );
130 //virtual void updateText();
132 virtual void contextMenuEvent( QContextMenuEvent* );
133 virtual void createPopupMenu( QMenu* );
136 //typedef QMap<SUIT_DataObject*, QListViewItem*> ItemMap;
137 //typedef SUIT_DataObjectKeyHandle DataObjectKey;
138 //typedef QMap<SUIT_DataObject*, int> DataObjectMap;
139 //typedef QMap<DataObjectKey, int> DataObjectKeyMap;
142 bool hasCollased( const QModelIndex& ) const;
143 bool hasExpanded( const QModelIndex& ) const;
145 //void autoOpenBranches();
146 //void openBranch( QListViewItem*, const int );
148 //void removeReferences( QListViewItem* );
149 //void removeConnections( SUIT_DataObject* );
150 //void createConnections( SUIT_DataObject* );
151 //void removeObject( SUIT_DataObject*, const bool = true );
153 //void updateText( QListViewItem* );
154 //bool needToUpdateTexts( QListViewItem* ) const;
156 //DataObjectKey objectKey( QListViewItem* ) const;
157 //DataObjectKey objectKey( SUIT_DataObject* ) const;
159 //QListViewItem* createTree( const SUIT_DataObject*, QListViewItem*, QListViewItem* = 0, const bool = false );
160 //QListViewItem* createItem( const SUIT_DataObject*, QListViewItem*, QListViewItem* = 0, const bool = false );
162 //SUIT_DataObject* storeState( DataObjectMap&, DataObjectMap&,
163 // DataObjectKeyMap&, DataObjectKeyMap&, DataObjectKey& ) const;
164 //void restoreState( const DataObjectMap&, const DataObjectMap&, const SUIT_DataObject*,
165 // const DataObjectKeyMap&, const DataObjectKeyMap&, const DataObjectKey& );
169 QtxSearchTool* mySearchTool;
170 // TODO: decide what to do with tooltip
171 //QToolTip* myTooltip;
172 //QMap<int, int> myColumnIds;
173 // TODO: decide what to do with tooltip
174 //bool myShowToolTips;
176 unsigned long myModifiedTime;
178 // TODO: decide what to do with tooltip
179 //friend class OB_Browser::ToolTip;
182 #endif // OB_BROWSER_H