Deselect all items in wxQt wxListBox::SetSelection(wxNOT_FOUND)

Follow wxWidgets API convention in wxQt too.
This commit is contained in:
Liam Treacy
2018-12-06 14:42:50 +00:00
committed by Vadim Zeitlin
parent 1f0e456620
commit 10381cb94e
2 changed files with 17 additions and 0 deletions

View File

@@ -90,6 +90,8 @@ protected:
private:
virtual void Init(); //common construction
void UnSelectAll();
wxDECLARE_DYNAMIC_CLASS(wxListBox);
};

View File

@@ -182,6 +182,12 @@ void wxListBox::DoSetFirstItem(int WXUNUSED(n))
void wxListBox::DoSetSelection(int n, bool select)
{
if ( n == wxNOT_FOUND )
{
UnSelectAll();
return;
}
return m_qtListWidget->setCurrentRow(n, select ? QItemSelectionModel::Select : QItemSelectionModel::Deselect );
}
@@ -248,3 +254,12 @@ QScrollArea *wxListBox::QtGetScrollBarsContainer() const
{
return (QScrollArea *) m_qtListWidget;
}
void wxListBox::UnSelectAll()
{
for ( unsigned int i = 0; i < GetCount(); ++i )
{
if ( IsSelected(i) )
DoSetSelection(i, false);
}
}