From ab3c460a9350207bb5d6b0ad353452b5163f4900 Mon Sep 17 00:00:00 2001 From: Liam Treacy Date: Mon, 21 Jan 2019 16:00:03 +0000 Subject: [PATCH] Updated the GetSelections method to use QListWidget method to retrieve selected items rather than iterating through the list. Also updated the UnSelectAll method to be more efficient --- src/qt/listbox.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/qt/listbox.cpp b/src/qt/listbox.cpp index bdac7368a8..6aa053b2fb 100644 --- a/src/qt/listbox.cpp +++ b/src/qt/listbox.cpp @@ -167,10 +167,9 @@ int wxListBox::GetSelections(wxArrayInt& aSelections) const { aSelections.clear(); - for ( unsigned int i = 0; i < GetCount(); ++i) + Q_FOREACH(QListWidgetItem* l, m_qtListWidget->selectedItems()) { - if ( IsSelected(i) ) - aSelections.push_back(i); + aSelections.push_back( m_qtListWidget->row(l) ); } return aSelections.size(); @@ -299,9 +298,8 @@ QScrollArea *wxListBox::QtGetScrollBarsContainer() const void wxListBox::UnSelectAll() { - for ( unsigned int i = 0; i < GetCount(); ++i ) + Q_FOREACH(QListWidgetItem* l, m_qtListWidget->selectedItems()) { - if ( IsSelected(i) ) - DoSetSelection(i, false); + m_qtListWidget->setItemSelected( l, false ); } }