-// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
-//
+// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
+// File : OB_Browser.h
+// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
+
#ifndef OB_BROWSER_H
#define OB_BROWSER_H
#include "OB.h"
-#include <qframe.h>
-
-#include <qmap.h>
-#include <qlistview.h>
+#include <QWidget>
+#include <QMap>
+#include <QModelIndex>
+#include <QItemSelection>
-#include <SUIT_DataObject.h>
-#include <SUIT_DataObjectKey.h>
-#include <SUIT_PopupClient.h>
-
-#ifdef WNT
+#ifdef WIN32
#pragma warning( disable:4251 )
#endif
+class QAbstractItemModel;
+class QAbstractItemDelegate;
class QToolTip;
-class OB_Filter;
-class OB_ListView;
+class QMenu;
+class QtxTreeView;
+class QtxSearchTool;
-class OB_EXPORT OB_Browser : public QFrame, public SUIT_PopupClient
+class OB_EXPORT OB_Browser : public QWidget
{
- Q_OBJECT
+ Q_OBJECT
- class ToolTip;
+ // TODO: commented - to be removed or revised
+ //class ToolTip;
public:
- OB_Browser( QWidget* = 0, SUIT_DataObject* theRoot = 0 );
+ OB_Browser( QWidget* = 0, QAbstractItemModel* = 0 );
virtual ~OB_Browser();
- virtual QString popupClientType() const { return QString( "ObjectBrowser" ); }
-
- SUIT_DataObject* getRootObject() const;
- virtual void setRootObject( SUIT_DataObject* theRoot = 0 );
+ QAbstractItemModel* model() const;
+ void setModel( QAbstractItemModel* );
- int numberOfSelected() const;
+ QAbstractItemDelegate* itemDelegate() const;
+ void setItemDelegate( QAbstractItemDelegate* );
- DataObjectList getSelected() const;
- void getSelected( DataObjectList& ) const;
+ bool rootIsDecorated() const;
+ void setRootIsDecorated( const bool );
- virtual void setSelected( const SUIT_DataObject* theObject, const bool = false );
- virtual void setSelected( const DataObjectList& theObjLst, const bool = false );
+ bool sortMenuEnabled() const;
+ void setSortMenuEnabled( const bool );
- bool isOpen( SUIT_DataObject* theObject ) const;
- virtual void setOpen( SUIT_DataObject* theObject, const bool theOpen = true );
+ QtxSearchTool* searchTool() const;
+ bool isSearchToolEnabled() const;
+ void setSearchToolEnabled( const bool );
- bool isAutoUpdate() const;
- virtual void setAutoUpdate( const bool );
+ int autoOpenLevel() const;
+ void setAutoOpenLevel( const int );
+ void openLevels( const int = -1 );
- bool isAutoDeleteObjects() const;
- virtual void setAutoDeleteObjects( const bool );
+ //bool isShowToolTips();
+ //void setShowToolTips( const bool theDisplay );
- virtual void updateTree( SUIT_DataObject* = 0 );
- virtual void replaceTree( SUIT_DataObject*, SUIT_DataObject* );
+ int numberOfSelected() const;
+ QModelIndexList selectedIndexes() const;
+ const QItemSelection selection() const;
- bool isShowToolTips();
- void setShowToolTips( const bool theDisplay );
+ virtual void select( const QModelIndex&, const bool, const bool = true );
+ virtual void select( const QModelIndexList&, const bool, const bool = true );
- void adjustWidth();
+ bool isOpen( const QModelIndex& ) const;
+ virtual void setOpen( const QModelIndex& theObject, const bool theOpen = true );
- SUIT_DataObject* dataObjectAt( const QPoint& ) const;
+ void adjustWidth();
+ void adjustFirstColumnWidth();
+ void adjustColumnsWidth();
- OB_Filter* filter() const;
- void setFilter( OB_Filter* );
+ // san - To be revised or removed
+ // QTreeView::indexAt() should be used
+ //SUIT_DataObject* dataObjectAt( const QPoint& ) const;
- bool rootIsDecorated() const;
- void setRootIsDecorated( const bool );
+ // san - Removed
+ //OB_Filter* filter() const;
+ //void setFilter( OB_Filter* );
- int autoOpenLevel() const;
- void setAutoOpenLevel( const int );
+ // TODO: QTreeView::resizeColumnToContents() can be used instead
+ //virtual void setWidthMode( QListView::WidthMode );
- virtual int addColumn( const QString&, const int id = -1, const int width = -1 );
- virtual int addColumn( const QIconSet&, const QString&, const int id = -1, const int width = -1 );
- virtual void removeColumn( const int id );
+ unsigned long getModifiedTime() const;
+ void setModified();
- void setNameTitle( const QString& );
- virtual void setNameTitle( const QIconSet&, const QString& );
- void setColumnTitle( const int id, const QString& );
- virtual void setColumnTitle( const int id, const QIconSet&, const QString& );
+ // san - moved to SUIT_TreeModel
+ //OB_Updater* getUpdater() const;
+ //virtual void setUpdater( OB_Updater* theUpdate = 0 );
- QString nameTitle() const;
- QString columnTitle( const int ) const;
+ QtxTreeView* treeView() const;
- bool isColumnVisible( const int ) const;
- virtual void setColumnShown( const int, const bool );
+ QByteArray getOpenStates( int theColumn ) const;
+ void setOpenStates( const QByteArray&, int theColumn );
- virtual void setWidthMode( QListView::WidthMode );
-
- QValueList<int> columns() const;
-
- bool appropriateColumn( const int ) const;
- virtual void setAppropriateColumn( const int, const bool );
-
- virtual bool eventFilter(QObject* watched, QEvent* e);
-
- QListView* listView() const;
-
- virtual void contextMenuPopup( QPopupMenu* );
+ typedef QMap<QString, bool> MapOfOpenStates;
+ void openStates( bool isGet, MapOfOpenStates&, const QModelIndex& theIndex, int theColumn );
signals:
- void selectionChanged();
- void doubleClicked( SUIT_DataObject* );
- void dropped( DataObjectList, SUIT_DataObject*, int );
+ void selectionChanged();
+ //void doubleClicked( SUIT_DataObject* );
+ //void dropped( DataObjectList, SUIT_DataObject*, int );
private slots:
- void onExpand();
- void onColumnVisible( int );
- void onDestroyed( SUIT_DataObject* );
- void onDoubleClicked ( QListViewItem* );
- void onDropped( QPtrList<QListViewItem>, QListViewItem*, int );
+ void onExpandAll();
+ void onCollapseAll();
+ virtual void onExpanded( const QModelIndex& ) {}
+ //void onDestroyed( SUIT_DataObject* );
+ //void onDoubleClicked ( QListViewItem* );
+ //void onDropped( QPtrList<QListViewItem>, QListViewItem*, int );
protected:
- void adjustWidth( QListViewItem* );
- virtual void updateView( const SUIT_DataObject* theStartObj = 0 );
- virtual void updateText();
-
- virtual void keyPressEvent( QKeyEvent* );
+ //void adjustWidth( QListViewItem* );
+ //virtual void updateText();
- SUIT_DataObject* dataObject( const QListViewItem* ) const;
- QListViewItem* listViewItem( const SUIT_DataObject* ) const;
+ virtual void contextMenuEvent( QContextMenuEvent* );
+ virtual void createPopupMenu( QMenu* );
private:
- typedef QMap<SUIT_DataObject*, QListViewItem*> ItemMap;
- typedef SUIT_DataObjectKeyHandle DataObjectKey;
- typedef QMap<SUIT_DataObject*, int> DataObjectMap;
- typedef QMap<DataObjectKey, int> DataObjectKeyMap;
+ //typedef QMap<SUIT_DataObject*, QListViewItem*> ItemMap;
+ //typedef SUIT_DataObjectKeyHandle DataObjectKey;
+ //typedef QMap<SUIT_DataObject*, int> DataObjectMap;
+ //typedef QMap<DataObjectKey, int> DataObjectKeyMap;
private:
- void expand( QListViewItem* );
- bool hasClosed( QListViewItem* ) const;
+ bool hasCollased( const QModelIndex& ) const;
+ bool hasExpanded( const QModelIndex& ) const;
- void autoOpenBranches();
- void openBranch( QListViewItem*, const int );
+ //void autoOpenBranches();
+ //void openBranch( QListViewItem*, const int );
- void removeReferences( QListViewItem* );
- void removeConnections( SUIT_DataObject* );
- void createConnections( SUIT_DataObject* );
- void removeObject( SUIT_DataObject*, const bool = true );
+ //void removeReferences( QListViewItem* );
+ //void removeConnections( SUIT_DataObject* );
+ //void createConnections( SUIT_DataObject* );
+ //void removeObject( SUIT_DataObject*, const bool = true );
- void updateText( QListViewItem* );
+ //void updateText( QListViewItem* );
+ //bool needToUpdateTexts( QListViewItem* ) const;
- DataObjectKey objectKey( QListViewItem* ) const;
- DataObjectKey objectKey( SUIT_DataObject* ) const;
+ //DataObjectKey objectKey( QListViewItem* ) const;
+ //DataObjectKey objectKey( SUIT_DataObject* ) const;
- QListViewItem* createTree( const SUIT_DataObject*, QListViewItem*, QListViewItem* = 0 );
- QListViewItem* createItem( const SUIT_DataObject*, QListViewItem*, QListViewItem* = 0 );
+ //QListViewItem* createTree( const SUIT_DataObject*, QListViewItem*, QListViewItem* = 0, const bool = false );
+ //QListViewItem* createItem( const SUIT_DataObject*, QListViewItem*, QListViewItem* = 0, const bool = false );
- SUIT_DataObject* storeState( DataObjectMap&, DataObjectMap&,
- DataObjectKeyMap&, DataObjectKeyMap&, DataObjectKey& ) const;
- void restoreState( const DataObjectMap&, const DataObjectMap&, const SUIT_DataObject*,
- const DataObjectKeyMap&, const DataObjectKeyMap&, const DataObjectKey& );
+ //SUIT_DataObject* storeState( DataObjectMap&, DataObjectMap&,
+ // DataObjectKeyMap&, DataObjectKeyMap&, DataObjectKey& ) const;
+ //void restoreState( const DataObjectMap&, const DataObjectMap&, const SUIT_DataObject*,
+ // const DataObjectKeyMap&, const DataObjectKeyMap&, const DataObjectKey& );
private:
- OB_ListView* myView;
- SUIT_DataObject* myRoot;
- ItemMap myItems;
- QToolTip* myTooltip;
- QMap<int, int> myColumnIds;
- bool myAutoUpdate;
- bool myAutoDelObjs;
- bool myShowToolTips;
- bool myRootDecorated;
- int myAutoOpenLevel;
-
- friend class OB_Browser::ToolTip;
+ QtxTreeView* myView;
+ QtxSearchTool* mySearchTool;
+ // TODO: decide what to do with tooltip
+ //QToolTip* myTooltip;
+ //QMap<int, int> myColumnIds;
+ // TODO: decide what to do with tooltip
+ //bool myShowToolTips;
+ int myAutoOpenLevel;
+ unsigned long myModifiedTime;
+
+ // TODO: decide what to do with tooltip
+ //friend class OB_Browser::ToolTip;
};
-#endif
+#endif // OB_BROWSER_H