From: vsr Date: Mon, 30 Jul 2007 14:52:26 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: qt4_porting_delivery_220807~70 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=86848584c7f37d7e065cd2d6647fec0495856054;p=modules%2Fgui.git *** empty log message *** --- diff --git a/src/ObjBrowser/Makefile.am b/src/ObjBrowser/Makefile.am index ff1db50cb..42d007ffa 100755 --- a/src/ObjBrowser/Makefile.am +++ b/src/ObjBrowser/Makefile.am @@ -25,22 +25,27 @@ include $(top_srcdir)/adm_local/unix/make_common_starter.am lib_LTLIBRARIES = libObjBrowser.la -salomeinclude_HEADERS=\ - OB.h \ - OB_Browser.h \ - OB_ListItem.h \ - OB_ListView.h \ +salomeinclude_HEADERS= \ + OB.h \ + OB_Browser.h + +# OB_ListItem.h \ + OB_ListView.h OB_Filter.h -dist_libObjBrowser_la_SOURCES= \ - OB_Browser.cxx \ +dist_libObjBrowser_la_SOURCES= \ + OB_Browser.cxx + +# OB_ListView.cxx OB_ListItem.cxx \ OB_ListView.cxx \ OB_Filter.cxx -MOC_FILES= \ - OB_Browser_moc.cxx \ - OB_ListView_moc.cxx +MOC_FILES= \ + OB_Browser_moc.cxx + +# OB_ListView_moc.cxx + nodist_libObjBrowser_la_SOURCES= $(MOC_FILES) nodist_salomeres_DATA = OB_msg_en.qm @@ -48,4 +53,4 @@ nodist_salomeres_DATA = OB_msg_en.qm libObjBrowser_la_CPPFLAGS=$(QT_INCLUDES) -I$(srcdir)/../SUIT -I$(srcdir)/../Qtx libObjBrowser_la_LDFLAGS=$(QT_MT_LIBS) -libObjBrowser_la_LIBADD= ../SUIT/libsuit.la ../Qtx/libqtx.la +libObjBrowser_la_LIBADD= ../Qtx/libqtx.la ../SUIT/libsuit.la diff --git a/src/ObjBrowser/OB.h b/src/ObjBrowser/OB.h index dd40fb973..6cec1ff5d 100755 --- a/src/ObjBrowser/OB.h +++ b/src/ObjBrowser/OB.h @@ -19,19 +19,15 @@ #ifndef OB_H #define OB_H -#if defined OB_EXPORTS #if defined WIN32 -#define OB_EXPORT __declspec( dllexport ) -#else -#define OB_EXPORT -#endif -#else -#if defined WIN32 -#define OB_EXPORT __declspec( dllimport ) -#else -#define OB_EXPORT -#endif -#endif +# if defined OB_EXPORTS +# define OB_EXPORT __declspec( dllexport ) +# else +# define OB_EXPORT __declspec( dllimport ) +# endif +#else // WIN32 +# define OB_EXPORT +#endif // WIN32 #if defined SOLARIS #define bool int diff --git a/src/ObjBrowser/OB_Browser.cxx b/src/ObjBrowser/OB_Browser.cxx index 647cac4cf..7db5a893b 100755 --- a/src/ObjBrowser/OB_Browser.cxx +++ b/src/ObjBrowser/OB_Browser.cxx @@ -1,46 +1,50 @@ // Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D -// +// // 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 +// 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 +// +// 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/ or email : webmaster.salome@opencascade.com // +// File : OB_Browser.cxx +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) +// + #include "OB_Browser.h" -#include "OB_Filter.h" -#include "OB_ListItem.h" -#include "OB_ListView.h" +//#include "OB_Filter.h" +//#include "OB_ListItem.h" +//#include "OB_ListView.h" -#include -#include +#include +//#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include + /*! \class OB_Browser::ToolTip Tool tip for OB_Browser. */ +//TODO: ToolTip commented - to be removed or revised +/* class OB_Browser::ToolTip : public QToolTip { public: @@ -52,29 +56,32 @@ public: private: OB_Browser* myBrowser; }; - +*/ /*! Constructor */ +/* OB_Browser::ToolTip::ToolTip( OB_Browser* b, QWidget* p ) : QToolTip( p ), myBrowser( b ) { } - +*/ /*! Destructor */ +/* OB_Browser::ToolTip::~ToolTip() { } - +*/ /*! It is called when there is a possibility that a tool tip should be shown and must decide whether there is a tool tip for the point in the widget that this QToolTip object relates to. \param pos - point co-ordinates */ +/* void OB_Browser::ToolTip::maybeTip( const QPoint& pos ) { if ( !parentWidget() || !myBrowser || !myBrowser->isShowToolTips() ) @@ -96,266 +103,132 @@ void OB_Browser::ToolTip::maybeTip( const QPoint& pos ) tip( aRect, aText ); } - - -typedef SUIT_DataObject* ObjPtr; -typedef OB_ListItem* ItemPtr; - -/*! - \class OB_BrowserSync - Auxiliary class for synchronizing tree of SUIT_DataObjects and list view items */ -class OB_BrowserSync -{ -public: - OB_BrowserSync( OB_Browser* ); - bool isEqual( const ObjPtr&, const ItemPtr& ) const; - ObjPtr nullSrc() const; - ItemPtr nullTrg() const; - ItemPtr createItem( const ObjPtr&, const ItemPtr&, const ItemPtr&, const bool ) const; - void updateItem( const ObjPtr& , const ItemPtr& ) const; - void deleteItemWithChildren( const ItemPtr& ) const; - void children( const ObjPtr&, QValueList& ) const; - void children( const ItemPtr&, QValueList& ) const; - ItemPtr parent( const ItemPtr& ) const; -private: - bool needUpdate( const ItemPtr& ) const; - OB_Browser* myBrowser; -}; /*! - Constructor + \class OB_Browser + Implements public API of an object browser that can be used to display arbitrary + application data in a hierarchical form. It is based on Qt4 model/view + architecture. By default, object browser displays contents of SUIT_TreeModel, + which simply maps tree of data objects to a tree of model indices needed for QTreeView. + However, an arbitrary model derived from QAbstractItemModel can be specified instead. + For example, some SUIT-based application might not like using SUIT_DataObject class, + and in such a case it should provide its own implementation of a data model. + + Allows to get/set selection, + to drag-n-drop of objects, to determine item by SUIT object and + vice versa */ -OB_BrowserSync::OB_BrowserSync( OB_Browser* ob ) -: myBrowser( ob ) -{ -} /*! - \return true if item must be updated - \param item - item to be checked + \brief Constructor + \param parent paren widget + \param model data model */ -bool OB_BrowserSync::needUpdate( const ItemPtr& item ) const -{ - bool update = false; - if ( item ) { - SUIT_DataObject* obj = item->dataObject(); - if ( obj ) { - // 1. check text - update = ( item->text( 0 ) != obj->name() ) || myBrowser->needToUpdateTexts( item ); - - if ( !update ) { - // 2. check pixmap (compare serialNumber()-s) - QPixmap objPix = obj->icon(); - const QPixmap* itemPix = item->pixmap( 0 ); - update = ( objPix.isNull() && ( itemPix && !itemPix->isNull() ) ) || - ( !objPix.isNull() && ( !itemPix || itemPix->isNull() ) ); - if ( !update && !objPix.isNull() && itemPix && !itemPix->isNull() ) { - int aIconW = objPix.width(); - if( aIconW > 20 ) { - QWMatrix aM; - double aScale = 20.0 / aIconW; - aM.scale( aScale, aScale ); - objPix = objPix.xForm( aM ); - } - update = ( objPix.serialNumber() != itemPix->serialNumber() ); - } - } - } - } - return update; -} - -/*! - Updates item - \param p - item -*/ -void OB_BrowserSync::updateItem( const ObjPtr& o, const ItemPtr& p ) const +OB_Browser::OB_Browser( QWidget* parent, QAbstractItemModel* model ) +: QWidget( parent ), + myAutoOpenLevel( 0 ) { - if ( p && needUpdate( p ) ) { - // printf( "--- needUpdate for %s = true ---\n", p->text( 0 ).latin1() ); - myBrowser->updateText( p ); - p->update(); - } - if( o && myBrowser->getUpdater() ) - { - myBrowser->getUpdater()->update( o, p ); - } -} + myView = new QtxTreeView( this ); + myView->setRootIsDecorated( true ); + myView->setSelectionMode( QAbstractItemView::ExtendedSelection ); + myView->installEventFilter( this ); + myView->viewport()->installEventFilter( this ); -/*! - Creates item by SUIT object - \param src - corresponding SUIT object - \param parent - parent for item - \param after - previous sibling for item - \param prepend - item must be added to start of children list -*/ -ItemPtr OB_BrowserSync::createItem( const ObjPtr& src, - const ItemPtr& parent, const ItemPtr& after, - const bool prepend ) const -{ - ItemPtr i = myBrowser ? dynamic_cast( myBrowser->createItem( src, parent, after, prepend ) ) : 0; - if( i ) - i->setOpen( src->isOpen() ); - return i; -} + QVBoxLayout* main = new QVBoxLayout( this ); + main->addWidget( myView ); + main->setMargin( 0 ); -/*! - Deletes object with all children - \param i - item -*/ -void OB_BrowserSync::deleteItemWithChildren( const ItemPtr& i ) const -{ - if( myBrowser && myBrowser->myItems.contains( i->dataObject() ) ) - { - myBrowser->removeReferences( i ); - delete i; - } -} + // TODO: decide what to do with tooltip + //myShowToolTips = true; + //myTooltip = new ToolTip( this, myView->viewport() ); -/*! - \return true if objects correspond each other at all - \param p - suit object - \param q - object browser item -*/ -bool OB_BrowserSync::isEqual( const ObjPtr& p, const ItemPtr& q ) const -{ - bool isRoot = p==myBrowser->getRootObject() && !q, - isEq = p && q && q->dataObject()==p; - return isRoot || ( !p && !q ) || isEq; -} + // TODO: drag-n-drop works differently - SUIT_TreeModel to be updated + // and QTreeView needs some setup + //connect( myView, SIGNAL( dropped( QPtrList, QListViewItem*, int ) ), + // this, SLOT( onDropped( QPtrList, QListViewItem*, int ) ) ); + connect( myView, SIGNAL( selectionChanged() ), this, SIGNAL( selectionChanged() ) ); + connect( myView, SIGNAL( doubleClicked( QListViewItem* ) ), + this, SLOT( onDoubleClicked( QListViewItem* ) ) ); -/*! - \return null suit object -*/ -ObjPtr OB_BrowserSync::nullSrc() const -{ - return 0; + setModel( model ); } /*! - \return null item + \brief Destructor. */ -ItemPtr OB_BrowserSync::nullTrg() const +OB_Browser::~OB_Browser() { - return 0; + //delete myTooltip; + //setUpdater( 0 ); } /*! - Fills list with children of SUIT object - \param p - SUIT object - \param ch - list to be filled + \return tree view of object browser */ -void OB_BrowserSync::children( const ObjPtr& p, QValueList& ch ) const +QtxTreeView* OB_Browser::treeView() const { - DataObjectList l; - if( p ) - { - p->children( l ); - ch.clear(); - for( SUIT_DataObject* o = l.first(); o; o = l.next() ) - ch.append( o ); - } + return myView; } /*! - Fills list with children of item - \param p - item - \param ch - list to be filled + \brief Get popup menu client type. + \return popup client type */ -void OB_BrowserSync::children( const ItemPtr& p, QValueList& ch ) const +QString OB_Browser::popupClientType() const { - for( QListViewItem* item = p ? p->firstChild() : myBrowser->listView()->firstChild(); item; item = item->nextSibling() ) - { - ItemPtr p = dynamic_cast( item ); - if( p ) - ch.append( p ); - } + return "ObjectBrowser"; } /*! - \return parent of item - \param p - item + \brief Get data model. + \return data model + \sa setModel() */ -ItemPtr OB_BrowserSync::parent( const ItemPtr& p ) const +QAbstractItemModel* OB_Browser::model() const { - return p ? dynamic_cast( p->parent() ) : 0; + return myView->model(); } - /*! - Constructor + \brief Set data model. + \param model data model + \sa model() */ -OB_Browser::OB_Browser( QWidget* parent, SUIT_DataObject* root ) -: QFrame( parent ), - -myRoot( 0 ), -myTooltip( 0 ), -myUpdater( 0 ), -myAutoOpenLevel( 0 ), -myAutoUpdate( false ), -myAutoDelObjs( false ), -myRootDecorated( true ) +void OB_Browser::setModel( QAbstractItemModel* model ) { - myView = new OB_ListView( QtxListView::HeaderAuto, this ); - myView->setAppropriate( myView->addColumn( "Data" ), false ); - myView->setSorting( -1 ); - myView->setRootIsDecorated( true ); - myView->setSelectionMode( QListView::Extended ); - myView->installEventFilter( this ); - myView->viewport()->installEventFilter( this ); - - QVBoxLayout* main = new QVBoxLayout( this ); - main->addWidget( myView ); - - myShowToolTips = true; - myTooltip = new ToolTip( this, myView->viewport() ); - - connect( myView, SIGNAL( dropped( QPtrList, QListViewItem*, int ) ), - this, SLOT( onDropped( QPtrList, QListViewItem*, int ) ) ); - connect( myView, SIGNAL( selectionChanged() ), this, SIGNAL( selectionChanged() ) ); - connect( myView, SIGNAL( doubleClicked( QListViewItem* ) ), - this, SLOT( onDoubleClicked( QListViewItem* ) ) ); - - setRootObject( root ); - + myView->setModel( model ); + myView->update(); setModified(); } /*! - Destructor -*/ -OB_Browser::~OB_Browser() -{ - myItems.clear(); - delete myTooltip; - setUpdater( 0 ); -} - -/*! - \return true if root is decorated by + + \brief Check if controls for expanding and collapsing top-level items are shown. + \return \c true if top-level items are decorated + \sa setRootIsDecorated() */ bool OB_Browser::rootIsDecorated() const { - return myRootDecorated; + return myView->rootIsDecorated(); } /*! - Sets state "root is recorated" - \param decor - new value of state + \brief Show/hide controls for expanding and collapsing top-level items. + \param decor if \c true, top-level items are decorated + \sa rootIsDecorated() */ void OB_Browser::setRootIsDecorated( const bool decor ) { - if ( decor == rootIsDecorated() ) - return; - - myRootDecorated = decor; - updateTree( 0, false ); + if ( decor != rootIsDecorated() ) + myView->setRootIsDecorated( decor ); } /*! - \return number of levels to be auto opened on update tree + \brief Get number of levels which should be automatically expanded + when updating the data tree. + \return number of levels to be auto-opened on tree updating + \sa setAutoOpenLevel() */ int OB_Browser::autoOpenLevel() const { @@ -363,39 +236,34 @@ int OB_Browser::autoOpenLevel() const } /*! - Changes number of levels to be auto opened on update tree - \param level - new number of levels + \brief Set number of levels which should be automatically expanded + when updating the data tree. + \param levels number of levels to be auto-opened on tree updating + \sa autoOpenLevel() */ -void OB_Browser::setAutoOpenLevel( const int level ) +void OB_Browser::setAutoOpenLevel( const int levels ) { - if ( myAutoOpenLevel == level ) - return; - - myAutoOpenLevel = level; + if ( myAutoOpenLevel != levels ) + myAutoOpenLevel = levels; } /*! - Opens branches from 1 to \alevels. If parameter value negative then autoOpenLevel() value will be used. + \brief Expand all branches to the specified number of levels. + + If \a levels value is negative, then autoOpenLevel() value is used instead. + + \param levels number of levels to be expanded \sa autoOpenLevel() */ void OB_Browser::openLevels( const int levels ) { - int level = levels < 0 ? autoOpenLevel() : levels; - QListView* lv = listView(); - if ( !lv || level < 1 ) - return; - - QListViewItem* item = lv->firstChild(); - while ( item ) - { - openBranch( item, level ); - item = item->nextSibling(); - } + treeView()->expandLevels( levels < 0 ? autoOpenLevel() : levels ); } /*! \return state "are tooltips shown" */ +/* bool OB_Browser::isShowToolTips() { return myShowToolTips; @@ -405,75 +273,27 @@ bool OB_Browser::isShowToolTips() Sets new value of state "are tooltips shown" \param theDisplay - new value */ +/* void OB_Browser::setShowToolTips( const bool theDisplay ) { myShowToolTips = theDisplay; } - -/*! - \return true if object browser automatically updates tree after SUIT object removing */ -bool OB_Browser::isAutoUpdate() const -{ - return myAutoUpdate; -} - -/*! - Sets new value of "auto update": whether object browser automatically updates tree after SUIT object removing -*/ -void OB_Browser::setAutoUpdate( const bool on ) -{ - myAutoUpdate = on; -} - -/*! - \return true if object browser must delete old tree on setRootObject(), replaceTree() - \sa setRootObject(), replaceTree() -*/ -bool OB_Browser::isAutoDeleteObjects() const -{ - return myAutoDelObjs; -} - -/*! - Sets whether object browser must delete old tree on setRootObject(), replaceTree() - \sa setRootObject(), replaceTree() -*/ -void OB_Browser::setAutoDeleteObjects( const bool on ) -{ - myAutoDelObjs = on; -} - -/*! - \return updater of browser -*/ -OB_Updater* OB_Browser::getUpdater() const -{ - return myUpdater; -} - -/*! - \sets new updater of browser -*/ -void OB_Browser::setUpdater( OB_Updater* theUpdate ) -{ - if( myUpdater ) - delete myUpdater; - myUpdater = theUpdate; -} /*! \return root SUIT object of browser */ +/* TODO: removed SUIT_DataObject* OB_Browser::getRootObject() const { return myRoot; } - +*/ /*! Sets new root SUIT object of browser \param theRoot - new root object */ +/* TODO: removed void OB_Browser::setRootObject( SUIT_DataObject* theRoot ) { DataObjectKey curKey; @@ -511,64 +331,57 @@ void OB_Browser::setRootObject( SUIT_DataObject* theRoot ) if ( selNum != numberOfSelected() ) emit selectionChanged(); } - +*/ /*! + \brief Get number of selected items. \return number of selected items */ int OB_Browser::numberOfSelected() const { int count = 0; - if ( listView() ) - { - for ( QListViewItemIterator it( listView() ); it.current(); ++it ) - if ( it.current()->isSelected() ) - count++; - } + if ( treeView() && treeView()->selectionModel() ) + count = treeView()->selectionModel()->selectedIndexes().count(); return count; } /*! - \return list of selected objects + \brief Get all selected items. + \return unsorted list of selected indexes with no duplicates */ -DataObjectList OB_Browser::getSelected() const +QModelIndexList OB_Browser::getSelected() const { - DataObjectList lst; - getSelected( lst ); - return lst; + QModelIndexList selected = QModelIndexList(); + if ( treeView() && treeView()->selectionModel() ) + selected = treeView()->selectionModel()->selectedIndexes(); + return selected; } /*! - Fills list with selected objects + \brief Get selection containing information about selected ranges. + \return QItemSelection instance */ -void OB_Browser::getSelected( DataObjectList& theObjList ) const +const QItemSelection OB_Browser::selection() const { - theObjList.clear(); - - if ( !listView() ) - return; - - for ( QListViewItemIterator it( listView() ); it.current(); ++it ) - { - if ( it.current()->isSelected() ) - { - SUIT_DataObject* obj = dataObject( it.current() ); - if ( obj ) - theObjList.append( obj ); - } - } + static QItemSelection emptySel; + QItemSelection sel = emptySel; + if ( treeView() && treeView()->selectionModel() ) + sel = treeView()->selectionModel()->selection(); + return sel; } /*! - Sets selected object + \brief Set selected objects. \param theObject - new selected object \param append - if it is true, then other selected objects are left as selected, otherwise only 'theObject' will be selected */ -void OB_Browser::setSelected( const SUIT_DataObject* theObject, const bool append ) +void OB_Browser::setSelected( const QModelIndex& theObject, const bool ) { + /* DataObjectList lst; lst.append( theObject ); setSelected( lst, append ); + */ } /*! @@ -577,8 +390,9 @@ void OB_Browser::setSelected( const SUIT_DataObject* theObject, const bool appen \param append - if it is true, then other selected objects are left as selected, otherwise only 'theObjLst' will be selected */ -void OB_Browser::setSelected( const DataObjectList& theObjLst, const bool append ) +void OB_Browser::setSelected( const QModelIndexList& theObjLst, const bool ) { + /* QListView* lv = listView(); if ( !lv ) @@ -634,35 +448,41 @@ void OB_Browser::setSelected( const DataObjectList& theObjLst, const bool append emit selectionChanged(); } + */ } /*! \return true if item corresponding to object is opened - \param theObject - object to be checked + \param index - object to be checked */ -bool OB_Browser::isOpen( SUIT_DataObject* theObject ) const +bool OB_Browser::isOpen( const QModelIndex& index ) const { - bool res = false; - if ( listView() ) - res = listView()->isOpen( listViewItem( theObject ) ); - return res; + return treeView()->isExpanded( index ); } /*! Sets opened state of item - \param theObject - object corresponding to item - \param theOpen - new opened state + \param index - object corresponding to item + \param open - new opened state */ -void OB_Browser::setOpen( SUIT_DataObject* theObject, const bool theOpen ) +void OB_Browser::setOpen( const QModelIndex& index, const bool open ) { - if ( listView() ) - listView()->setOpen( listViewItem( theObject ), theOpen ); + treeView()->setExpanded( index, open ); +} + +/*! + Adjusts width by root item +*/ +void OB_Browser::adjustWidth() +{ + treeView()->resizeColumnToContents( 0 ); } /*! \return SUIT object correspondint to item at position 'pos' \param pos - position */ +/* TODO: removed - QTreeView::indexAt() should be used SUIT_DataObject* OB_Browser::dataObjectAt( const QPoint& pos ) const { SUIT_DataObject* obj = 0; @@ -673,35 +493,38 @@ SUIT_DataObject* OB_Browser::dataObjectAt( const QPoint& pos ) const return obj; } - +*/ /*! \return filter of list view */ +/* TODO: removed OB_Filter* OB_Browser::filter() const { return myView->filter(); } - +*/ /*! Changes filter of list view \param f - new filter */ +/* TODO: removed void OB_Browser::setFilter( OB_Filter* f ) { myView->setFilter( f ); } - +*/ /*! Adds new column to list view \param label - title of column \param id - id of column \param width - width of column */ +/* TODO: removed int OB_Browser::addColumn( const QString& label, const int id, const int width ) { return addColumn( QIconSet(), label, id, width ); } - +*/ /*! Adds new column to list view \param icon - icon of column @@ -709,6 +532,7 @@ int OB_Browser::addColumn( const QString& label, const int id, const int width ) \param id - id of column \param width - width of column */ +/* TODO: removed int OB_Browser::addColumn( const QIconSet& icon, const QString& label, const int id, const int width ) { QListView* lv = listView(); @@ -739,11 +563,12 @@ int OB_Browser::addColumn( const QIconSet& icon, const QString& label, const int return theId; } - +*/ /*! Removes column \param id - id of column */ +/* TODO: removed void OB_Browser::removeColumn( const int id ) { QListView* lv = listView(); @@ -762,21 +587,23 @@ void OB_Browser::removeColumn( const int id ) } updateText(); } - +*/ /*! Sets title of first column (name column) \param label - new title */ +/* TODO: removed void OB_Browser::setNameTitle( const QString& label ) { setNameTitle( QIconSet(), label ); } - +*/ /*! Sets title and icon of first column (name column) \param icon - new icon \param label - new title */ +/* TODO: removed void OB_Browser::setNameTitle( const QIconSet& icon, const QString& label ) { QListView* lv = listView(); @@ -788,23 +615,25 @@ void OB_Browser::setNameTitle( const QIconSet& icon, const QString& label ) else lv->setColumnText( 0, icon, label ); } - +*/ /*! Sets title of column \param id - column id \param label - new column title */ +/* TODO: removed void OB_Browser::setColumnTitle( const int id, const QString& label ) { setColumnTitle( id, QIconSet(), label ); } - +*/ /*! Sets title and icon of column \param id - column id \param icon - new column icon \param label - new column title */ +/* TODO: removed void OB_Browser::setColumnTitle( const int id, const QIconSet& icon, const QString& label ) { QListView* lv = listView(); @@ -816,19 +645,21 @@ void OB_Browser::setColumnTitle( const int id, const QIconSet& icon, const QStri else lv->setColumnText( myColumnIds[id], icon, label ); } - +*/ /*! \return title of first column (name column) */ +/* TODO: removed QString OB_Browser::nameTitle() const { return myView->columnText( 0 ); } - +*/ /*! \return title of first column (name column) \param id - column id */ +/* TODO: removed QString OB_Browser::columnTitle( const int id ) const { QString txt; @@ -836,21 +667,23 @@ QString OB_Browser::columnTitle( const int id ) const txt = myView->columnText( myColumnIds[id] ); return txt; } - +*/ /*! \return true if column is visible \param id - column id */ +/* TODO: removed bool OB_Browser::isColumnVisible( const int id ) const { return myColumnIds.contains( id ) && myView->isShown( myColumnIds[id] ); } - +*/ /*! Sets visibility of column \param id - column id \param on - new visibility state */ +/* TODO: removed void OB_Browser::setColumnShown( const int id, const bool on ) { if ( !myColumnIds.contains( id ) ) @@ -860,21 +693,23 @@ void OB_Browser::setColumnShown( const int id, const bool on ) if( !on ) myView->setColumnWidthMode( myColumnIds[id], QListView::Manual ); } - +*/ /*! Sets global width mode \param mode - new width mode */ +/* TODO: removed void OB_Browser::setWidthMode( QListView::WidthMode mode ) { for ( int i = 0, n = myView->columns(); i < n; i++ ) if( mode!=QListView::Maximum || myView->columnWidth( i )>0 ) myView->setColumnWidthMode( i, mode ); } - +*/ /*! \return list of columns ids */ +/* TODO: to be revised or removed QValueList OB_Browser::columns() const { QValueList lst; @@ -882,11 +717,12 @@ QValueList OB_Browser::columns() const lst.append( it.key() ); return lst; } - +*/ /*! \return true if it is possible to show/hide column by popup \param id - column id */ +/* TODO: removed bool OB_Browser::appropriateColumn( const int id ) const { bool res = false; @@ -894,12 +730,13 @@ bool OB_Browser::appropriateColumn( const int id ) const res = myView->appropriate( myColumnIds[id] ); return res; } - +*/ /*! Sets "appropriate state": is it possible to show/hide column by popup \param id - column id \param on - new state */ +/* TODO: removed void OB_Browser::setAppropriateColumn( const int id, const bool on ) { if ( !myColumnIds.contains( id ) ) @@ -907,13 +744,14 @@ void OB_Browser::setAppropriateColumn( const int id, const bool on ) myView->setAppropriate( myColumnIds[id], on ); } - +*/ /*! Updates tree \param obj - start object \param autoOpen - to open automatically branches of autoOpenLevel() \sa autoOpenLevel() */ +/* TODO: removed void OB_Browser::updateTree( SUIT_DataObject* obj, const bool autoOpen ) { // QTime t1 = QTime::currentTime(); @@ -944,10 +782,11 @@ void OB_Browser::updateTree( SUIT_DataObject* obj, const bool autoOpen ) // QTime t2 = QTime::currentTime(); // qDebug( QString( "update tree time = %1 msecs" ).arg( t1.msecsTo( t2 ) ) ); } - +*/ /*! Replaces part of tree starting at object 'src' by tree starting at object 'trg' */ +/* TODO: removed void OB_Browser::replaceTree( SUIT_DataObject* src, SUIT_DataObject* trg ) { if ( !src || !trg || src == trg || src->root() != getRootObject() ) @@ -985,11 +824,12 @@ void OB_Browser::replaceTree( SUIT_DataObject* src, SUIT_DataObject* trg ) if ( selNum != numberOfSelected() ) emit selectionChanged(); } - +*/ /*! Updates view \param startObj - start object */ +/* TODO: removed void OB_Browser::updateView( SUIT_DataObject* startObj ) { QListView* lv = listView(); @@ -1014,117 +854,13 @@ void OB_Browser::updateView( SUIT_DataObject* startObj ) synchronize( startObj, startItem, sync ); } } - -/*! - Creates new list item - \return new item - \param o - corresponding SUIT object - \param parent - parent item - \param after - item after that new item must be added - \param prepend - new item must be added as first -*/ -QListViewItem* OB_Browser::createItem( const SUIT_DataObject* o, QListViewItem* parent, - QListViewItem* after, const bool prepend ) -{ - QListView* lv = listView(); - - if ( !lv || !o ) - return 0; - - QListViewItem* item = 0; - SUIT_DataObject* obj = (SUIT_DataObject*)o; - - int type = -1; - - switch ( obj->checkType() ) - { - case SUIT_DataObject::CheckBox: - type = QCheckListItem::CheckBox; - break; - case SUIT_DataObject::RadioButton: - type = QCheckListItem::RadioButton; - break; - } - - if ( parent ) - { - if ( after ) - { - if ( type == -1 ) - item = new OB_ListItem( obj, parent, after ); - else - item = new OB_CheckListItem( obj, parent, after, (QCheckListItem::Type)type ); - } - else if ( prepend ) - { - if ( type == -1 ) - item = new OB_ListItem( obj, parent ); - else - item = new OB_CheckListItem( obj, parent, (QCheckListItem::Type)type ); - } - else // append - { - after = parent->firstChild(); - while ( after && after->nextSibling() ) - after = after->nextSibling(); - if ( type == -1 ) - item = new OB_ListItem( obj, parent, after ); - else - item = new OB_CheckListItem( obj, parent, after, (QCheckListItem::Type)type ); - } - } - else - { - if ( after ) - { - if ( type == -1 ) - item = new OB_ListItem( obj, lv, after ); - else - item = new OB_CheckListItem( obj, lv, after, (QCheckListItem::Type)type ); - } - else if ( prepend ) - { - if ( type == -1 ) - item = new OB_ListItem( obj, lv ); - else - item = new OB_CheckListItem( obj, lv, (QCheckListItem::Type)type ); - } - else // append - { - after = lv->firstChild(); - while ( after && after->nextSibling() ) - after = after->nextSibling(); - if ( type == -1 ) - item = new OB_ListItem( obj, lv, after ); - else - item = new OB_CheckListItem( obj, lv, after, (QCheckListItem::Type)type ); - } - } - - myItems.insert( obj, item ); - obj->connect( this, SLOT( onDestroyed( SUIT_DataObject* ) ) ); - updateText( item ); - - return item; -} - -/*! - Adjusts width by root item */ -void OB_Browser::adjustWidth() -{ - if ( !listView() ) - return; - - listView()->setColumnWidth( 0, 0 ); - if ( listView()->firstChild() ) - adjustWidth( listView()->firstChild() ); -} /*! Adjusts width by item \param item */ +/* void OB_Browser::adjustWidth( QListViewItem* item ) { while ( item ) @@ -1135,48 +871,12 @@ void OB_Browser::adjustWidth( QListViewItem* item ) item = item->nextSibling(); } } - -/*! - \return SUIT object corresponding to item - \param item -*/ -SUIT_DataObject* OB_Browser::dataObject( const QListViewItem* item ) const -{ - SUIT_DataObject* obj = 0; - - if ( item && item->rtti() == OB_ListItem::RTTI() ) - obj = ((OB_ListItem*)item)->dataObject(); - else if ( item && item->rtti() == OB_CheckListItem::RTTI() ) - obj = ((OB_CheckListItem*)item)->dataObject(); - - return obj; -} - -/*! - \return item corresponding to SUIT object - \param obj - SUIT object */ -QListViewItem* OB_Browser::listViewItem( const SUIT_DataObject* obj ) const -{ - QListViewItem* item = 0; - - if ( myItems.contains( (SUIT_DataObject*)obj ) ) - item = myItems[(SUIT_DataObject*)obj]; - - return item; -} - -/*! - \return list view of object browser -*/ -QListView* OB_Browser::listView() const -{ - return myView; -} /*! \remove all items referencing current (through data objects) */ +/* TODO: void OB_Browser::removeReferences( QListViewItem* item ) { if ( !item ) @@ -1197,6 +897,7 @@ void OB_Browser::removeReferences( QListViewItem* item ) /*! Connects all children to SLOT onDestroyed */ +/* TODO: move to SUIT_TreeModel void OB_Browser::createConnections( SUIT_DataObject* obj ) { if ( !obj ) @@ -1210,10 +911,11 @@ void OB_Browser::createConnections( SUIT_DataObject* obj ) for ( DataObjectListIterator it( childList ); it.current(); ++it ) it.current()->connect( this, SLOT( onDestroyed( SUIT_DataObject* ) ) ); } - +*/ /*! Disconnects all children from SLOT onDestroyed */ +/* TODO: move to SUIT_TreeModel void OB_Browser::removeConnections( SUIT_DataObject* obj ) { if ( !obj ) @@ -1227,7 +929,7 @@ void OB_Browser::removeConnections( SUIT_DataObject* obj ) for ( DataObjectListIterator it( childList ); it.current(); ++it ) it.current()->disconnect( this, SLOT( onDestroyed( SUIT_DataObject* ) ) ); } - +*/ /*! Stores states (opened, selected) of current tree items \return current item @@ -1235,6 +937,7 @@ void OB_Browser::removeConnections( SUIT_DataObject* obj ) \param openObjs, openKeys - maps of opened objects \param curKey - map of current objects */ +/* TODO: to be revised SUIT_DataObject* OB_Browser::storeState( DataObjectMap& selObjs, DataObjectMap& openObjs, DataObjectKeyMap& selKeys, DataObjectKeyMap& openKeys, DataObjectKey& curKey ) const @@ -1263,13 +966,14 @@ SUIT_DataObject* OB_Browser::storeState( DataObjectMap& selObjs, DataObjectMap& return curObj; } - +*/ /*! Restores states (opened, selected) of current tree items \param selObjs, selKeys - maps of selected objects \param openObjs, openKeys - maps of opened objects \param curKey - map of current objects */ +/* TODO: to be revised void OB_Browser::restoreState( const DataObjectMap& selObjs, const DataObjectMap& openObjs, const SUIT_DataObject* curObj, const DataObjectKeyMap& selKeys, const DataObjectKeyMap& openKeys, const DataObjectKey& curKey ) @@ -1305,7 +1009,7 @@ void OB_Browser::restoreState( const DataObjectMap& selObjs, const DataObjectMap bool parentOpen = true; if( item && item->parent() ) parentOpen = item->parent()->isOpen(); - + if ( openObjs[obj] && parentOpen ) lv->setOpen( item, true ); } @@ -1328,18 +1032,20 @@ void OB_Browser::restoreState( const DataObjectMap& selObjs, const DataObjectMap lv->blockSignals( block ); } - +*/ /*! Creates object key by tree item */ +/* TODO: move to SUIT_TreeModel OB_Browser::DataObjectKey OB_Browser::objectKey( QListViewItem* i ) const { return objectKey( dataObject( i ) ); } - +*/ /*! Creates object key by SUIT object */ +/* TODO: move to SUIT_TreeModel OB_Browser::DataObjectKey OB_Browser::objectKey( SUIT_DataObject* obj ) const { if ( !obj ) @@ -1347,21 +1053,23 @@ OB_Browser::DataObjectKey OB_Browser::objectKey( SUIT_DataObject* obj ) const return DataObjectKey( obj->key() ); } - +*/ /*! Custom key press event handler, updates tree by F5 */ void OB_Browser::keyPressEvent( QKeyEvent* e ) { if ( e->key() == Qt::Key_F5 ) - updateTree( 0, false ); + //updateTree( 0, false ); + update(); - QFrame::keyPressEvent( e ); + QWidget::keyPressEvent( e ); } /*! SLOT: called if action "Expand all" is activated */ +/* TODO: to be revised void OB_Browser::onExpand() { DataObjectList selected; @@ -1369,29 +1077,34 @@ void OB_Browser::onExpand() for ( DataObjectListIterator itr( selected ); itr.current(); ++itr ) expand( listViewItem( itr.current() ) ); } - +*/ /*! SLOT: called if action "Show/hide column" is activated by popup */ +/* TODO: removed void OB_Browser::onColumnVisible( int id ) { setColumnShown( id, !isColumnVisible( id ) ); } - +*/ /*! SLOT: called if SUIT object is destroyed */ +/* TODO: moved to SUIT_TreeModel void OB_Browser::onDestroyed( SUIT_DataObject* obj ) { removeObject( obj ); } - +*/ /*! SLOT: called on finish of drag-n-drop operation \param items - dragged items \param item - destination (item on that they were dropped) \param action - QDropEvent::Action */ + // TODO: drag-n-drop works differently - SUIT_TreeModel to be updated + // and QTreeView needs some setup +/* void OB_Browser::onDropped( QPtrList items, QListViewItem* item, int action ) { SUIT_DataObject* obj = dataObject( item ); @@ -1409,10 +1122,11 @@ void OB_Browser::onDropped( QPtrList items, QListViewItem* item, if ( !lst.isEmpty() ) emit dropped( lst, obj, action ); } - +*/ /*! Updates texts of items */ +/* TODO: to be removed void OB_Browser::updateText() { if ( myColumnIds.isEmpty() ) @@ -1432,11 +1146,12 @@ void OB_Browser::updateText() it.current()->setText( itr.data(), obj->text( itr.key() ) ); } } - +*/ /*! \return true if item must be updated \param item - item to be checked */ +/* TODO: to be revised bool OB_Browser::needToUpdateTexts( QListViewItem* item ) const { SUIT_DataObject* obj = dataObject( item ); @@ -1448,11 +1163,12 @@ bool OB_Browser::needToUpdateTexts( QListViewItem* item ) const return true; return false; } - +*/ /*! Updates texts of item \param item - item to be updated */ +/* TODO: to be revised void OB_Browser::updateText( QListViewItem* item ) { SUIT_DataObject* obj = dataObject( item ); @@ -1462,10 +1178,11 @@ void OB_Browser::updateText( QListViewItem* item ) for( QMap::iterator it = myColumnIds.begin(); it != myColumnIds.end(); ++it ) item->setText( it.data(), obj->text( it.key() ) ); } - +*/ /*! Custom event filter */ +/* bool OB_Browser::eventFilter( QObject* o, QEvent* e ) { if ( o == myView && e->type() == QEvent::ContextMenu ) @@ -1486,14 +1203,14 @@ bool OB_Browser::eventFilter( QObject* o, QEvent* e ) } } - return QFrame::eventFilter( o, e ); + return QWidget::eventFilter( o, e ); } - +*/ /*! Adds custom actions to popup \param menu - popup menu */ -void OB_Browser::contextMenuPopup( QPopupMenu* menu ) +void OB_Browser::contextMenuPopup( QMenu* menu ) { /* QValueList cols; for ( QMap::ConstIterator it = myColumnIds.begin(); it != myColumnIds.end(); ++it ) @@ -1515,7 +1232,7 @@ void OB_Browser::contextMenuPopup( QPopupMenu* menu ) menu->setItemParameter( id, *iter ); } if ( menu->count() != num ) - menu->insertSeparator();*/ + menu->insertSeparator(); DataObjectList selected; getSelected( selected ); @@ -1529,11 +1246,13 @@ void OB_Browser::contextMenuPopup( QPopupMenu* menu ) menu->insertItem( tr( "MEN_EXPAND_ALL" ), this, SLOT( onExpand() ) ); menu->insertSeparator(); } +*/ } /*! Expands item with all it's children */ +/* TODO: to be revised void OB_Browser::expand( QListViewItem* item ) { if ( !item ) @@ -1543,10 +1262,11 @@ void OB_Browser::expand( QListViewItem* item ) for ( QListViewItem* child = item->firstChild(); child; child = child->nextSibling() ) expand( child ); } - +*/ /*! \return true if item or one of it's children isn't opened */ +/* TODO: to be revised bool OB_Browser::hasClosed( QListViewItem* item ) const { if ( !item ) @@ -1561,12 +1281,13 @@ bool OB_Browser::hasClosed( QListViewItem* item ) const return has; } - +*/ /*! Removes SUIT object \param obj - SUIT object to be removed \param autoUpd - auto tree updating */ +/* TODO: moved to SUIT_TreeModel void OB_Browser::removeObject( SUIT_DataObject* obj, const bool autoUpd ) { if ( !obj ) @@ -1606,21 +1327,23 @@ void OB_Browser::removeObject( SUIT_DataObject* obj, const bool autoUpd ) delete item; } - +*/ /*! Opens branches from 1 to autoOpenLevel() \sa autoOpenLevel() */ +/* TODO: to be revised void OB_Browser::autoOpenBranches() { openLevels(); } - +*/ /*! Opens branch \param item \param level */ +/* TODO: to be revised void OB_Browser::openBranch( QListViewItem* item, const int level ) { if ( level < 1 ) @@ -1633,16 +1356,17 @@ void OB_Browser::openBranch( QListViewItem* item, const int level ) item = item->nextSibling(); } } - +*/ /*! SLOT: called on double click on item, emits signal */ +/* TODO: to be revised void OB_Browser::onDoubleClicked( QListViewItem* item ) { if ( item ) emit doubleClicked( dataObject( item ) ); } - +*/ /*! Stores time of last modification */ @@ -1650,4 +1374,3 @@ void OB_Browser::setModified() { myModifiedTime = clock(); } - diff --git a/src/ObjBrowser/OB_Browser.h b/src/ObjBrowser/OB_Browser.h index 1175b7b9a..4c330bbd5 100755 --- a/src/ObjBrowser/OB_Browser.h +++ b/src/ObjBrowser/OB_Browser.h @@ -16,15 +16,19 @@ // // 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 - -#include -#include +#include +#include +#include +#include #include #include @@ -34,110 +38,94 @@ #pragma warning( disable:4251 ) #endif +class QAbstractItemModel; class QToolTip; -class OB_Filter; -class OB_ListView; -class OB_ListItem; - -class OB_Updater -{ -public: - OB_Updater(){}; - virtual ~OB_Updater(){}; - virtual void update( SUIT_DataObject* theObj, OB_ListItem* theLI ) = 0; -}; +class QtxTreeView; -/*! - \class OB_Browser - Represents object browser. Allows to get/set selection, - to drag-n-drop of objects, to determine item by SUIT object and - vice versa -*/ -class OB_EXPORT OB_Browser : public QFrame, public SUIT_PopupClient +class OB_EXPORT OB_Browser : public QWidget, public SUIT_PopupClient { - 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" ); } + QtxTreeView* treeView() const; - SUIT_DataObject* getRootObject() const; - virtual void setRootObject( SUIT_DataObject* theRoot = 0 ); + virtual QString popupClientType() const; - int numberOfSelected() const; + QAbstractItemModel* model() const; + void setModel( QAbstractItemModel* ); - 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 ); + int autoOpenLevel() const; + void setAutoOpenLevel( const int ); + void openLevels( const int = -1 ); - bool isOpen( SUIT_DataObject* theObject ) const; - virtual void setOpen( SUIT_DataObject* theObject, const bool theOpen = true ); + //bool isShowToolTips(); + //void setShowToolTips( const bool theDisplay ); - bool isAutoUpdate() const; - virtual void setAutoUpdate( const bool ); + int numberOfSelected() const; + QModelIndexList getSelected() const; + const QItemSelection selection() const; - bool isAutoDeleteObjects() const; - virtual void setAutoDeleteObjects( const bool ); + virtual void setSelected( const QModelIndex&, const bool = false ); + virtual void setSelected( const QModelIndexList&, const bool = false ); - virtual void updateTree( SUIT_DataObject* = 0, const bool = false ); - virtual void replaceTree( SUIT_DataObject*, SUIT_DataObject* ); + bool isOpen( const QModelIndex& ) const; + virtual void setOpen( const QModelIndex& theObject, const bool theOpen = true ); - bool isShowToolTips(); - void setShowToolTips( const bool theDisplay ); + void adjustWidth(); - void adjustWidth(); + // san - To be revised or removed + // QTreeView::indexAt() should be used + //SUIT_DataObject* dataObjectAt( const QPoint& ) const; - SUIT_DataObject* dataObjectAt( const QPoint& ) const; + // san - Removed + //OB_Filter* filter() const; + //void setFilter( OB_Filter* ); - OB_Filter* filter() const; - void setFilter( OB_Filter* ); + // san - Removed, columns and titles are controlled by SUIT_TreeModel and SUIT_DataObject + //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 ); - bool rootIsDecorated() const; - void setRootIsDecorated( const bool ); + //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& ); - int autoOpenLevel() const; - void setAutoOpenLevel( const int ); - void openLevels( const int = -1 ); + //QString nameTitle() const; + //QString columnTitle( const int ) const; - 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 ); + // san - These methods are now in QTreeView + //bool isColumnVisible( const int ) const; + //virtual void setColumnShown( const int, const bool ); - 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& ); + // TODO: QTreeView::resizeColumnToContents() can be used instead + //virtual void setWidthMode( QListView::WidthMode ); - QString nameTitle() const; - QString columnTitle( const int ) const; + // san - removed + // QValueList columns() const; - bool isColumnVisible( const int ) const; - virtual void setColumnShown( const int, const bool ); + //bool appropriateColumn( const int ) const; + //virtual void setAppropriateColumn( const int, const bool ); - virtual void setWidthMode( QListView::WidthMode ); + //virtual bool eventFilter(QObject* watched, QEvent* e); - QValueList 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* ); + virtual void contextMenuPopup( QMenu* ); void setModified(); unsigned long getModifiedTime() { return myModifiedTime; } - OB_Updater* getUpdater() const; - virtual void setUpdater( OB_Updater* theUpdate = 0 ); + // san - moved to SUIT_TreeModel + //OB_Updater* getUpdater() const; + //virtual void setUpdater( OB_Updater* theUpdate = 0 ); signals: void selectionChanged(); @@ -145,72 +133,63 @@ signals: void dropped( DataObjectList, SUIT_DataObject*, int ); private slots: - void onExpand(); - void onColumnVisible( int ); - void onDestroyed( SUIT_DataObject* ); - void onDoubleClicked ( QListViewItem* ); - void onDropped( QPtrList, QListViewItem*, int ); + //void onExpand(); + //void onColumnVisible( int ); + //void onDestroyed( SUIT_DataObject* ); + //void onDoubleClicked ( QListViewItem* ); + //void onDropped( QPtrList, QListViewItem*, int ); protected: - void adjustWidth( QListViewItem* ); - virtual void updateView( SUIT_DataObject* = 0 ); - virtual void updateText(); + //void adjustWidth( QListViewItem* ); + //virtual void updateView( SUIT_DataObject* = 0 ); + //virtual void updateText(); virtual void keyPressEvent( QKeyEvent* ); - SUIT_DataObject* dataObject( const QListViewItem* ) const; - QListViewItem* listViewItem( const SUIT_DataObject* ) const; - private: - typedef QMap ItemMap; - typedef SUIT_DataObjectKeyHandle DataObjectKey; - typedef QMap DataObjectMap; - typedef QMap DataObjectKeyMap; + //typedef QMap ItemMap; + //typedef SUIT_DataObjectKeyHandle DataObjectKey; + //typedef QMap DataObjectMap; + //typedef QMap DataObjectKeyMap; private: - void expand( QListViewItem* ); - bool hasClosed( QListViewItem* ) const; + //void expand( QListViewItem* ); + //bool hasClosed( QListViewItem* ) 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* ); - bool needToUpdateTexts( QListViewItem* ) const; + //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, const bool = false ); - QListViewItem* createItem( const SUIT_DataObject*, QListViewItem*, QListViewItem* = 0, const bool = false ); + //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: - friend class OB_BrowserSync; - - OB_ListView* myView; - SUIT_DataObject* myRoot; - ItemMap myItems; - QToolTip* myTooltip; - OB_Updater* myUpdater; - QMap myColumnIds; - bool myAutoUpdate; - bool myAutoDelObjs; - bool myShowToolTips; - bool myRootDecorated; - int myAutoOpenLevel; - - friend class OB_Browser::ToolTip; - - unsigned long myModifiedTime; + QtxTreeView* myView; + // TODO: decide what to do with tooltip + //QToolTip* myTooltip; + //QMap 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