From d5f2ce27f7e774607bdb513089014474a1479947 Mon Sep 17 00:00:00 2001 From: caremoli Date: Tue, 30 Nov 2010 16:29:34 +0000 Subject: [PATCH] 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 --- src/ObjBrowser/OB_Browser.cxx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) 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 ) { -- 2.39.2