Send wxEVT_CHECKLISTBOX when a checkbox is clicked

Fix sending events from wxCheckListBox in wxQt.

Closes https://github.com/wxWidgets/wxWidgets/pull/1403
This commit is contained in:
David Roberts
2019-07-10 16:23:32 +01:00
committed by Vadim Zeitlin
parent cc1ec9e562
commit 18b87b2ab5
2 changed files with 19 additions and 5 deletions

View File

@@ -60,7 +60,7 @@ public:
virtual QWidget *GetHandle() const wxOVERRIDE;
void QtSendEvent(wxEventType evtType, const QModelIndex &index, bool selected);
void QtSendEvent(wxEventType evtType, int rowIndex, bool selected);
protected:
virtual void DoSetFirstItem(int n) wxOVERRIDE;

View File

@@ -21,6 +21,7 @@ public:
private:
void clicked( const QModelIndex &index );
void doubleClicked( const QModelIndex &index );
void itemChanged(QListWidgetItem *item);
};
wxQtListWidget::wxQtListWidget( wxWindow *parent, wxListBox *handler )
@@ -28,22 +29,35 @@ wxQtListWidget::wxQtListWidget( wxWindow *parent, wxListBox *handler )
{
connect(this, &QListWidget::clicked, this, &wxQtListWidget::clicked);
connect(this, &QListWidget::doubleClicked, this, &wxQtListWidget::doubleClicked);
connect(this, &QListWidget::itemChanged, this, &wxQtListWidget::itemChanged);
}
void wxQtListWidget::clicked(const QModelIndex &index )
{
wxListBox *handler = GetHandler();
if ( handler )
handler->QtSendEvent(wxEVT_LISTBOX, index, true);
handler->QtSendEvent(wxEVT_LISTBOX, index.row(), true);
}
void wxQtListWidget::doubleClicked( const QModelIndex &index )
{
wxListBox *handler = GetHandler();
if ( handler )
handler->QtSendEvent(wxEVT_LISTBOX_DCLICK, index, true);
handler->QtSendEvent(wxEVT_LISTBOX_DCLICK, index.row(), true);
}
void wxQtListWidget::itemChanged(QListWidgetItem *item)
{
if ( item->flags() & Qt::ItemIsUserCheckable )
{
wxListBox *handler = GetHandler();
if ( handler )
{
int rowIndex = this->row(item);
handler->QtSendEvent(wxEVT_CHECKLISTBOX, rowIndex, true);
}
}
}
wxListBox::wxListBox() :
m_qtListWidget(NULL)
@@ -282,9 +296,9 @@ QWidget *wxListBox::GetHandle() const
return m_qtListWidget;
}
void wxListBox::QtSendEvent(wxEventType evtType, const QModelIndex &index, bool selected)
void wxListBox::QtSendEvent(wxEventType evtType, int rowIndex, bool selected)
{
SendEvent(evtType, index.row(), selected);
SendEvent(evtType, rowIndex, selected);
}
QScrollArea *wxListBox::QtGetScrollBarsContainer() const