From: san Date: Mon, 27 Sep 2010 12:20:14 +0000 (+0000) Subject: Optimisation of adjust item width after item expanding. X-Git-Tag: V5_1_10~22 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8f9a95bfc0c314c7f3abc13f19f0de85d03d4efe;p=modules%2Fgui.git Optimisation of adjust item width after item expanding. --- diff --git a/src/SUIT/SUIT_DataBrowser.cxx b/src/SUIT/SUIT_DataBrowser.cxx index e2bff47ce..b08628fe4 100644 --- a/src/SUIT/SUIT_DataBrowser.cxx +++ b/src/SUIT/SUIT_DataBrowser.cxx @@ -24,6 +24,7 @@ #include #include +#include #include #include @@ -48,9 +49,12 @@ SUIT_DataBrowser::SUIT_DataBrowser( QWidget* parent ) \param parent parent widget */ SUIT_DataBrowser::SUIT_DataBrowser( SUIT_DataObject* root, QWidget* parent ) -: OB_Browser( parent ) + : OB_Browser( parent ) { init( root ); + + myExpandTimer = new QTimer( this ); + connect( myExpandTimer, SIGNAL( timeout() ), this, SLOT( onExpandUpdate() ) ); } /*! @@ -404,9 +408,26 @@ void SUIT_DataBrowser::onDblClicked( const QModelIndex& index ) */ void SUIT_DataBrowser::onExpanded( const QModelIndex& index ) { - if (myResizeOnExpandItem) { - adjustFirstColumnWidth(); - adjustColumnsWidth(); - } + if ( myResizeOnExpandItem ) + triggerExpandUpdate(); +} + +/*! + \brief Set the delayed update for expanding items event. + \internal +*/ +void SUIT_DataBrowser::triggerExpandUpdate() +{ + myExpandTimer->stop(); + myExpandTimer->start( 0 ); } +/*! + \brief Update for expanding items event. Called after the required items were expanded. + \internal +*/ +void SUIT_DataBrowser::onExpandUpdate() +{ + adjustFirstColumnWidth(); + adjustColumnsWidth(); +} diff --git a/src/SUIT/SUIT_DataBrowser.h b/src/SUIT/SUIT_DataBrowser.h index 5544e7f10..37b621035 100644 --- a/src/SUIT/SUIT_DataBrowser.h +++ b/src/SUIT/SUIT_DataBrowser.h @@ -31,6 +31,7 @@ #include +class QTimer; class QShortcut; class SUIT_EXPORT SUIT_DataBrowser : public OB_Browser, public SUIT_PopupClient @@ -74,6 +75,7 @@ protected: virtual void contextMenuEvent( QContextMenuEvent* ); private: + void triggerExpandUpdate(); void init( SUIT_DataObject* ); signals: @@ -84,9 +86,11 @@ private slots: void onModelUpdated(); void onDblClicked( const QModelIndex& ); void onExpanded( const QModelIndex& ); + void onExpandUpdate(); private: QShortcut* myShortcut; + QTimer* myExpandTimer; bool myAutoSizeFirstColumn; bool myAutoSizeColumns; diff --git a/src/SUIT/SUIT_TreeModel.cxx b/src/SUIT/SUIT_TreeModel.cxx index 70f59a390..841ff6dc7 100755 --- a/src/SUIT/SUIT_TreeModel.cxx +++ b/src/SUIT/SUIT_TreeModel.cxx @@ -444,6 +444,7 @@ SUIT_TreeModel::~SUIT_TreeModel() this, SLOT( onInserted( SUIT_DataObject*, SUIT_DataObject* ) ) ); SUIT_DataObject::disconnect( SIGNAL( removed( SUIT_DataObject*, SUIT_DataObject* ) ), this, SLOT( onRemoved( SUIT_DataObject*, SUIT_DataObject* ) ) ); + SUIT_DataObject::disconnect( SIGNAL( changed( SUIT_DataObject* ) ), this, SLOT( onChanged( SUIT_DataObject* ) ) ); delete myRoot; } @@ -475,6 +476,7 @@ void SUIT_TreeModel::setRoot( SUIT_DataObject* r ) this, SLOT( onInserted( SUIT_DataObject*, SUIT_DataObject* ) ) ); SUIT_DataObject::disconnect( SIGNAL( removed( SUIT_DataObject*, SUIT_DataObject* ) ), this, SLOT( onRemoved( SUIT_DataObject*, SUIT_DataObject* ) ) ); + SUIT_DataObject::disconnect( SIGNAL( changed( SUIT_DataObject* ) ), this, SLOT( onChanged( SUIT_DataObject* ) ) ); delete myRoot; } @@ -839,6 +841,8 @@ void SUIT_TreeModel::setAutoUpdate( const bool on, const bool updateImmediately this, SLOT( onInserted( SUIT_DataObject*, SUIT_DataObject* ) ) ); SUIT_DataObject::disconnect( SIGNAL( removed( SUIT_DataObject*, SUIT_DataObject* ) ), this, SLOT( onRemoved( SUIT_DataObject*, SUIT_DataObject* ) ) ); + SUIT_DataObject::disconnect( SIGNAL( changed( SUIT_DataObject* ) ), this, SLOT( onChanged( SUIT_DataObject* ) ) ); + myAutoUpdate = on; if ( myAutoUpdate ) { @@ -846,6 +850,7 @@ void SUIT_TreeModel::setAutoUpdate( const bool on, const bool updateImmediately this, SLOT( onInserted( SUIT_DataObject*, SUIT_DataObject* ) ) ); SUIT_DataObject::connect( SIGNAL( removed( SUIT_DataObject*, SUIT_DataObject* ) ), this, SLOT( onRemoved( SUIT_DataObject*, SUIT_DataObject* ) ) ); + SUIT_DataObject::connect( SIGNAL( changed( SUIT_DataObject* ) ), this, SLOT( onChanged( SUIT_DataObject* ) ) ); if ( updateImmediately ) updateTree(); @@ -939,11 +944,13 @@ void SUIT_TreeModel::initialize() this, SLOT( onInserted( SUIT_DataObject*, SUIT_DataObject* ) ) ); SUIT_DataObject::disconnect( SIGNAL( removed( SUIT_DataObject*, SUIT_DataObject* ) ), this, SLOT( onRemoved( SUIT_DataObject*, SUIT_DataObject* ) ) ); + SUIT_DataObject::disconnect( SIGNAL( changed( SUIT_DataObject* ) ), this, SLOT( onChanged( SUIT_DataObject* ) ) ); if ( autoUpdate() ) { SUIT_DataObject::connect( SIGNAL( inserted( SUIT_DataObject*, SUIT_DataObject* ) ), this, SLOT( onInserted( SUIT_DataObject*, SUIT_DataObject* ) ) ); SUIT_DataObject::connect( SIGNAL( removed( SUIT_DataObject*, SUIT_DataObject* ) ), this, SLOT( onRemoved( SUIT_DataObject*, SUIT_DataObject* ) ) ); + SUIT_DataObject::connect( SIGNAL( changed( SUIT_DataObject* ) ), this, SLOT( onChanged( SUIT_DataObject* ) ) ); } myItems.clear(); // ????? is it really necessary