# HG changeset patch # User Teemu Piippo # Date 1410219374 -10800 # Node ID 49afb6b98253e054b374a84326c119441f68cd07 # Parent 903ec1e46298912233b6a81a3b88587e01868d3b - rewritten updateSelection() core loop, a new algorithm there makes selection updating a ton lot faster than before diff -r 903ec1e46298 -r 49afb6b98253 src/actions.cc --- a/src/actions.cc Tue Sep 09 01:16:24 2014 +0300 +++ b/src/actions.cc Tue Sep 09 02:36:14 2014 +0300 @@ -268,9 +268,6 @@ { for (LDObjectPtr obj : CurrentDocument()->objects()) obj->select(); - - ui->objectList->selectAll(); - refresh(); } // ============================================================================= @@ -296,9 +293,6 @@ if (colors.contains (obj->color())) obj->select(); } - - updateSelection(); - refresh(); } // ============================================================================= @@ -336,9 +330,6 @@ obj->select(); } - - updateSelection(); - refresh(); } // ============================================================================= diff -r 903ec1e46298 -r 49afb6b98253 src/ldObject.cc --- a/src/ldObject.cc Tue Sep 09 01:16:24 2014 +0300 +++ b/src/ldObject.cc Tue Sep 09 02:36:14 2014 +0300 @@ -880,10 +880,12 @@ document().toStrongRef()->addToSelection (self()); // If this object is inverted with INVERTNEXT, pick the INVERTNEXT as well. + /* LDBFCPtr invertnext; if (previousIsInvertnext (invertnext)) invertnext->select(); + */ } // ============================================================================= diff -r 903ec1e46298 -r 49afb6b98253 src/mainWindow.cc --- a/src/mainWindow.cc Tue Sep 09 01:16:24 2014 +0300 +++ b/src/mainWindow.cc Tue Sep 09 02:36:14 2014 +0300 @@ -562,18 +562,44 @@ void MainWindow::updateSelection() { g_isSelectionLocked = true; - - ui->objectList->clearSelection(); + QItemSelection itemselect; + int top = -1; + int bottom = -1; + QTime t0 = QTime::currentTime(); for (LDObjectPtr obj : Selection()) { if (obj->qObjListEntry == null) continue; - obj->qObjListEntry->setSelected (true); + int row = ui->objectList->row (obj->qObjListEntry); + + if (top == -1) + { + top = bottom = row; + } + else + { + if (row != bottom + 1) + { + itemselect.select (ui->objectList->model()->index (top, 0), + ui->objectList->model()->index (bottom, 0)); + top = -1; + } + + bottom = row; + } } + if (top != -1) + { + itemselect.select (ui->objectList->model()->index (top, 0), + ui->objectList->model()->index (bottom, 0)); + } + + ui->objectList->selectionModel()->select (itemselect, QItemSelectionModel::ClearAndSelect); g_isSelectionLocked = false; + printf ("Selection performed in %dms\n", t0.msecsTo (QTime::currentTime())); } // =============================================================================