From: stv Date: Fri, 11 Nov 2011 06:08:02 +0000 (+0000) Subject: SUIT_DataBrowser::ensureVisible() methods were added. X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1cb60b94e2ebb7be53462cd860893e3d73f95070;p=modules%2Fgui.git SUIT_DataBrowser::ensureVisible() methods were added. --- diff --git a/src/SUIT/SUIT_DataBrowser.cxx b/src/SUIT/SUIT_DataBrowser.cxx index d4ec696a8..8e172710c 100644 --- a/src/SUIT/SUIT_DataBrowser.cxx +++ b/src/SUIT/SUIT_DataBrowser.cxx @@ -236,6 +236,39 @@ void SUIT_DataBrowser::setSelected( const DataObjectList& lst, const bool append } } +/*! + \brief Make the view item for specified data object is visible. + \param obj data object +*/ +void SUIT_DataBrowser::ensureVisible( SUIT_DataObject* obj ) +{ + if ( !obj ) + return; + + DataObjectList lst; + lst.append( obj ); + ensureVisible( lst ); +} + +/*! + \brief Make the view items for specified data objects is visible. + \param lst data object list +*/ +void SUIT_DataBrowser::ensureVisible( const DataObjectList& lst ) +{ + QtxTreeView* tv = treeView(); + SUIT_AbstractModel* treeModel = dynamic_cast( model() ); + if ( !tv || !treeModel ) + return; + + for ( DataObjectList::const_iterator it = lst.begin(); it != lst.end(); ++it ) + { + QModelIndex idx = treeModel->index( *it ); + if ( idx.isValid() ) + tv->scrollTo( idx ); + } +} + /*! \brief Add custom actions to the popup menu. \param menu popup menu diff --git a/src/SUIT/SUIT_DataBrowser.h b/src/SUIT/SUIT_DataBrowser.h index 1c8e8d958..25bfd350b 100644 --- a/src/SUIT/SUIT_DataBrowser.h +++ b/src/SUIT/SUIT_DataBrowser.h @@ -37,7 +37,7 @@ class SUIT_EXPORT SUIT_DataBrowser : public OB_Browser, public SUIT_PopupClient public: SUIT_DataBrowser( QWidget* = 0 ); SUIT_DataBrowser( SUIT_DataObject*, QWidget* = 0 ); - ~SUIT_DataBrowser(); + virtual ~SUIT_DataBrowser(); virtual QString popupClientType() const; @@ -64,6 +64,9 @@ public: void setAutoSizeColumns( const bool on ); void setResizeOnExpandItem( const bool on ); + void ensureVisible( SUIT_DataObject* ); + void ensureVisible( const DataObjectList& ); + protected: virtual void contextMenuEvent( QContextMenuEvent* );