]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
SUIT_DataBrowser::ensureVisible() methods were added.
authorstv <stv@opencascade.com>
Fri, 11 Nov 2011 06:08:02 +0000 (06:08 +0000)
committerstv <stv@opencascade.com>
Fri, 11 Nov 2011 06:08:02 +0000 (06:08 +0000)
src/SUIT/SUIT_DataBrowser.cxx
src/SUIT/SUIT_DataBrowser.h

index d4ec696a8feec3acdcf1daf4f2e3d4bc6411ff11..8e172710c806b0805e072aebc613d3b553a6717e 100644 (file)
@@ -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<SUIT_AbstractModel*>( 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
index 1c8e8d9582750513b3870c88eff81a3912f2c549..25bfd350b52ae58cc2484517429f984018462921 100644 (file)
@@ -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* );