Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
OB_Browser.h
Go to the documentation of this file.
1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007 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, or (at your option) any later version.
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 
23 // File : OB_Browser.h
24 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
25 
26 #ifndef OB_BROWSER_H
27 #define OB_BROWSER_H
28 
29 #include "OB.h"
30 
31 #include <QWidget>
32 #include <QMap>
33 #include <QModelIndex>
34 #include <QItemSelection>
35 
36 #ifdef WIN32
37 #pragma warning( disable:4251 )
38 #endif
39 
40 class QAbstractItemModel;
41 class QAbstractItemDelegate;
42 class QToolTip;
43 class QMenu;
44 class QtxTreeView;
45 class QtxSearchTool;
46 
48 {
49  Q_OBJECT
50 
51  // TODO: commented - to be removed or revised
52  //class ToolTip;
53 
54 public:
56  virtual ~OB_Browser();
57 
58  QAbstractItemModel* model() const;
59  void setModel( QAbstractItemModel* );
60 
61  QAbstractItemDelegate* itemDelegate() const;
62  void setItemDelegate( QAbstractItemDelegate* );
63 
64  bool rootIsDecorated() const;
65  void setRootIsDecorated( const bool );
66 
67  bool sortMenuEnabled() const;
68  void setSortMenuEnabled( const bool );
69 
70  QtxSearchTool* searchTool() const;
71  bool isSearchToolEnabled() const;
72  void setSearchToolEnabled( const bool );
73 
74  int autoOpenLevel() const;
75  void setAutoOpenLevel( const int );
76  void openLevels( const int = -1 );
77 
78  //bool isShowToolTips();
79  //void setShowToolTips( const bool theDisplay );
80 
81  int numberOfSelected() const;
82  QModelIndexList selectedIndexes() const;
83  const QItemSelection selection() const;
84 
85  virtual void select( const QModelIndex&, const bool, const bool = true );
86  virtual void select( const QModelIndexList&, const bool, const bool = true );
87 
88  bool isOpen( const QModelIndex& ) const;
89  virtual void setOpen( const QModelIndex& theObject, const bool theOpen = true );
90 
91  void adjustWidth();
92  void adjustFirstColumnWidth();
93  void adjustColumnsWidth();
94 
95  // san - To be revised or removed
96  // QTreeView::indexAt() should be used
97  //SUIT_DataObject* dataObjectAt( const QPoint& ) const;
98 
99  // san - Removed
100  //OB_Filter* filter() const;
101  //void setFilter( OB_Filter* );
102 
103  // TODO: QTreeView::resizeColumnToContents() can be used instead
104  //virtual void setWidthMode( QListView::WidthMode );
105 
106  unsigned long getModifiedTime() const;
107  void setModified();
108 
109  // san - moved to SUIT_TreeModel
110  //OB_Updater* getUpdater() const;
111  //virtual void setUpdater( OB_Updater* theUpdate = 0 );
112 
113  QtxTreeView* treeView() const;
114 
115  QByteArray getOpenStates( int theColumn ) const;
116  void setOpenStates( const QByteArray&, int theColumn );
117 
118  typedef QMap<QString, bool> MapOfOpenStates;
119  void openStates( bool isGet, MapOfOpenStates&, const QModelIndex& theIndex, int theColumn );
120 
121 signals:
122  void selectionChanged();
123  //void doubleClicked( SUIT_DataObject* );
124  //void dropped( DataObjectList, SUIT_DataObject*, int );
125 
126 private slots:
127  void onExpandAll();
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 );
133 
134 protected:
135  //void adjustWidth( QListViewItem* );
136  //virtual void updateText();
137 
138  virtual void contextMenuEvent( QContextMenuEvent* );
139  virtual void createPopupMenu( QMenu* );
140 
141 private:
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;
146 
147 private:
148  bool hasCollased( const QModelIndex& ) const;
149  bool hasExpanded( const QModelIndex& ) const;
150 
151  //void autoOpenBranches();
152  //void openBranch( QListViewItem*, const int );
153 
154  //void removeReferences( QListViewItem* );
155  //void removeConnections( SUIT_DataObject* );
156  //void createConnections( SUIT_DataObject* );
157  //void removeObject( SUIT_DataObject*, const bool = true );
158 
159  //void updateText( QListViewItem* );
160  //bool needToUpdateTexts( QListViewItem* ) const;
161 
162  //DataObjectKey objectKey( QListViewItem* ) const;
163  //DataObjectKey objectKey( SUIT_DataObject* ) const;
164 
165  //QListViewItem* createTree( const SUIT_DataObject*, QListViewItem*, QListViewItem* = 0, const bool = false );
166  //QListViewItem* createItem( const SUIT_DataObject*, QListViewItem*, QListViewItem* = 0, const bool = false );
167 
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& );
172 
173 private:
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;
183 
184  // TODO: decide what to do with tooltip
185  //friend class OB_Browser::ToolTip;
186 };
187 
188 #endif // OB_BROWSER_H