]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
CCAR: small optimization for selection of large number of objects in the object browser
authorcaremoli <caremoli>
Tue, 30 Nov 2010 16:29:34 +0000 (16:29 +0000)
committercaremoli <caremoli>
Tue, 30 Nov 2010 16:29:34 +0000 (16:29 +0000)
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

index e0e649a4d2b14c2262405d8dd1fbbb17088dc201..b8c30eb3cb7642469b84f5f82e6b2cfedc763ecb 100755 (executable)
@@ -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 ) {