From: caremoli Date: Tue, 30 Nov 2010 16:29:34 +0000 (+0000) Subject: CCAR: small optimization for selection of large number of objects in the object browser X-Git-Tag: V6_2_0a1~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d5f2ce27f7e774607bdb513089014474a1479947;p=modules%2Fgui.git CCAR: small optimization for selection of large number of objects in the object browser Qt TreeView is not very fast when looping on select of modelindex It is faster to build a QItemSelection and make a single selection with this object It is sensible for number of objects greater than 1000 --- diff --git a/src/ObjBrowser/OB_Browser.cxx b/src/ObjBrowser/OB_Browser.cxx index e0e649a4d..b8c30eb3c 100755 --- a/src/ObjBrowser/OB_Browser.cxx +++ b/src/ObjBrowser/OB_Browser.cxx @@ -415,12 +415,18 @@ void OB_Browser::select( const QModelIndexList& indexes, const bool on, const bo myView->blockSignals( true ); QModelIndex idx; - bool first = true; if ( !indexes.isEmpty() ) { + QItemSelection mysel; foreach( idx, indexes ) { - select( idx, on, first ? keepSelection : true ); - first = false; + mysel.select(idx,idx); + } + if ( myView->selectionModel() ) { + QItemSelectionModel::SelectionFlags f = on ? QItemSelectionModel::Select : QItemSelectionModel::Deselect; + f = f | QItemSelectionModel::Rows; + if ( !keepSelection ) + f = f | QItemSelectionModel::Clear; + myView->selectionModel()->select( mysel, f ); } } else if ( !keepSelection ) {