Remove unnecessary wxNotebook::DoSetSelection() from wxQt
Having this method didn't really help, it's simpler and more straightforward to implement ChangeSelection() as a signal-blocking wrapper around SetSelection() instead. No real changes in behaviour, this is a pure refactoring.
This commit is contained in:
@@ -42,14 +42,13 @@ public:
|
||||
|
||||
virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
|
||||
|
||||
int SetSelection(size_t nPage) { return DoSetSelection(nPage, SetSelection_SendEvent); }
|
||||
int ChangeSelection(size_t nPage) { return DoSetSelection(nPage); }
|
||||
int SetSelection(size_t nPage);
|
||||
int ChangeSelection(size_t nPage);
|
||||
|
||||
virtual QWidget *GetHandle() const;
|
||||
|
||||
protected:
|
||||
virtual wxWindow *DoRemovePage(size_t page);
|
||||
int DoSetSelection(size_t nPage, int flags = 0);
|
||||
|
||||
private:
|
||||
QTabWidget *m_qtTabWidget;
|
||||
|
@@ -169,27 +169,31 @@ wxSize wxNotebook::CalcSizeFromPage(const wxSize& sizePage) const
|
||||
return sizePage;
|
||||
}
|
||||
|
||||
int wxNotebook::DoSetSelection(size_t page, int flags)
|
||||
int wxNotebook::SetSelection(size_t page)
|
||||
{
|
||||
wxCHECK_MSG(page < GetPageCount(), wxNOT_FOUND, "invalid notebook index");
|
||||
|
||||
int selOld = GetSelection();
|
||||
|
||||
// do not fire signals for certain methods (i.e. ChangeSelection
|
||||
if ( !(flags & SetSelection_SendEvent) )
|
||||
{
|
||||
m_qtTabWidget->blockSignals(true);
|
||||
}
|
||||
// change the QTabWidget selected page:
|
||||
m_selection = page;
|
||||
m_qtTabWidget->setCurrentIndex( page );
|
||||
if ( !(flags & SetSelection_SendEvent) )
|
||||
{
|
||||
m_qtTabWidget->blockSignals(false);
|
||||
}
|
||||
|
||||
return selOld;
|
||||
}
|
||||
|
||||
int wxNotebook::ChangeSelection(size_t nPage)
|
||||
{
|
||||
// ChangeSelection() is not supposed to generate events, unlike
|
||||
// SetSelection().
|
||||
m_qtTabWidget->blockSignals(true);
|
||||
|
||||
const int selOld = SetSelection(nPage);
|
||||
|
||||
m_qtTabWidget->blockSignals(false);
|
||||
|
||||
return selOld;
|
||||
}
|
||||
|
||||
wxWindow *wxNotebook::DoRemovePage(size_t page)
|
||||
{
|
||||
|
Reference in New Issue
Block a user