mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Better model selection, much faster
This commit is contained in:
committed by
Mathew Sutcliffe
parent
74a4570a40
commit
1522c8175e
@@ -418,15 +418,17 @@ namespace BlackGui
|
||||
|
||||
void CViewBaseNonTemplate::selectRows(const QSet<int> &rows)
|
||||
{
|
||||
// Multi row selection only work in MultiSelection
|
||||
if (!this->selectionModel()) { return; }
|
||||
|
||||
// multiple times faster than multiple than this->selectRow()
|
||||
this->clearSelection();
|
||||
const SelectionMode m = this->selectionMode();
|
||||
this->setSelectionMode(MultiSelection);
|
||||
QItemSelection selectedItems;
|
||||
const int columns = this->model()->columnCount() - 1;
|
||||
for (int r : rows)
|
||||
{
|
||||
this->selectRow(r);
|
||||
selectedItems.select(this->model()->index(r, 0), this->model()->index(r, columns));
|
||||
}
|
||||
this->setSelectionMode(m);
|
||||
this->selectionModel()->select(selectedItems, QItemSelectionModel::Select);
|
||||
}
|
||||
|
||||
int CViewBaseNonTemplate::selectedRowCount() const
|
||||
|
||||
Reference in New Issue
Block a user