Added setStyle method to wxListBox to allow for the proper setting of sorting and selection style of the QListWidget

This commit is contained in:
Liam Treacy
2019-01-21 14:04:47 +00:00
parent 58df1ee13f
commit eb6b660d27
2 changed files with 25 additions and 4 deletions

View File

@@ -90,6 +90,7 @@ protected:
private:
virtual void Init(); //common construction
void setStyle(long style);
void UnSelectAll();
wxDECLARE_DYNAMIC_CLASS(wxListBox);

View File

@@ -90,10 +90,7 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
QListWidgetItem* item;
m_qtWindow = m_qtListWidget = new wxQtListWidget( parent, this );
if ( style == wxLB_SORT )
{
m_qtListWidget->setSortingEnabled(true);
}
setStyle(style);
while ( n-- > 0 )
{
@@ -120,6 +117,8 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
Init();
m_qtWindow = m_qtListWidget = new wxQtListWidget( parent, this );
setStyle(style);
QStringList items;
for (size_t i = 0; i < choices.size(); ++i)
@@ -130,6 +129,27 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
return wxListBoxBase::Create( parent, id, pos, size, style, validator, name );
}
void wxListBox::setStyle(long style)
{
if ( style & wxLB_SORT )
{
m_qtListWidget->setSortingEnabled(true);
}
if ( style & wxLB_SINGLE )
{
m_qtListWidget->setSelectionMode(QAbstractItemView::SingleSelection);
}
else if ( style & wxLB_MULTIPLE )
{
m_qtListWidget->setSelectionMode(QAbstractItemView::MultiSelection);
}
else if ( style & wxLB_EXTENDED )
{
wxMISSING_IMPLEMENTATION( wxSTRINGIZE( wxLB_EXTENDED ));
}
}
void wxListBox::Init()
{
#if wxUSE_CHECKLISTBOX