mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-18 11:25:33 +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)
|
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();
|
this->clearSelection();
|
||||||
const SelectionMode m = this->selectionMode();
|
QItemSelection selectedItems;
|
||||||
this->setSelectionMode(MultiSelection);
|
const int columns = this->model()->columnCount() - 1;
|
||||||
for (int r : rows)
|
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
|
int CViewBaseNonTemplate::selectedRowCount() const
|
||||||
|
|||||||
Reference in New Issue
Block a user