1 // Copyright (C) 2007-2015 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;
115 QByteArray getOpenStates( int theColumn ) const;
116 void setOpenStates( const QByteArray&, int theColumn );
118 typedef QMap<QString, bool> MapOfOpenStates;
119 void openStates( bool isGet, MapOfOpenStates&, const QModelIndex& theIndex, int theColumn );
122 void selectionChanged();
123 //void doubleClicked( SUIT_DataObject* );
124 //void dropped( DataObjectList, SUIT_DataObject*, int );
128 void onCollapseAll();
129 virtual void onExpanded( const QModelIndex& ) {}
130 //void onDestroyed( SUIT_DataObject* );
131 //void onDoubleClicked ( QListViewItem* );
132 //void onDropped( QPtrList<QListViewItem>, QListViewItem*, int );
135 //void adjustWidth( QListViewItem* );
136 //virtual void updateText();
138 virtual void contextMenuEvent( QContextMenuEvent* );
139 virtual void createPopupMenu( QMenu* );
142 //typedef QMap<SUIT_DataObject*, QListViewItem*> ItemMap;
143 //typedef SUIT_DataObjectKeyHandle DataObjectKey;
144 //typedef QMap<SUIT_DataObject*, int> DataObjectMap;
145 //typedef QMap<DataObjectKey, int> DataObjectKeyMap;
148 bool hasCollased( const QModelIndex& ) const;
149 bool hasExpanded( const QModelIndex& ) const;
151 //void autoOpenBranches();
152 //void openBranch( QListViewItem*, const int );
154 //void removeReferences( QListViewItem* );
155 //void removeConnections( SUIT_DataObject* );
156 //void createConnections( SUIT_DataObject* );
157 //void removeObject( SUIT_DataObject*, const bool = true );
159 //void updateText( QListViewItem* );
160 //bool needToUpdateTexts( QListViewItem* ) const;
162 //DataObjectKey objectKey( QListViewItem* ) const;
163 //DataObjectKey objectKey( SUIT_DataObject* ) const;
165 //QListViewItem* createTree( const SUIT_DataObject*, QListViewItem*, QListViewItem* = 0, const bool = false );
166 //QListViewItem* createItem( const SUIT_DataObject*, QListViewItem*, QListViewItem* = 0, const bool = false );
168 //SUIT_DataObject* storeState( DataObjectMap&, DataObjectMap&,
169 // DataObjectKeyMap&, DataObjectKeyMap&, DataObjectKey& ) const;
170 //void restoreState( const DataObjectMap&, const DataObjectMap&, const SUIT_DataObject*,
171 // const DataObjectKeyMap&, const DataObjectKeyMap&, const DataObjectKey& );
175 QtxSearchTool* mySearchTool;
176 // TODO: decide what to do with tooltip
177 //QToolTip* myTooltip;
178 //QMap<int, int> myColumnIds;
179 // TODO: decide what to do with tooltip
180 //bool myShowToolTips;
182 unsigned long myModifiedTime;
184 // TODO: decide what to do with tooltip
185 //friend class OB_Browser::ToolTip;
188 #endif // OB_BROWSER_H