Change a couple of data types and simplify code a bit
This commit is contained in:
@@ -43,7 +43,7 @@ public:
|
|||||||
wxAcceleratorTable(int n, const wxAcceleratorEntry entries[]);
|
wxAcceleratorTable(int n, const wxAcceleratorEntry entries[]);
|
||||||
|
|
||||||
// Implementation
|
// Implementation
|
||||||
QList < QShortcut* > *ConvertShortcutTable( QWidget *parent ) const;
|
wxVector<QShortcut*> ConvertShortcutTable( QWidget *parent ) const;
|
||||||
|
|
||||||
bool Ok() const { return IsOk(); }
|
bool Ok() const { return IsOk(); }
|
||||||
bool IsOk() const;
|
bool IsOk() const;
|
||||||
|
@@ -234,7 +234,7 @@ private:
|
|||||||
bool m_mouseInside;
|
bool m_mouseInside;
|
||||||
|
|
||||||
#if wxUSE_ACCEL
|
#if wxUSE_ACCEL
|
||||||
QScopedPointer< QList<QShortcut*> > m_qtShortcuts; // always allocated
|
wxVector<QShortcut*> m_qtShortcuts; // owned by whatever GetHandle() returns
|
||||||
QScopedPointer<wxQtShortcutHandler> m_qtShortcutHandler; // always allocated
|
QScopedPointer<wxQtShortcutHandler> m_qtShortcutHandler; // always allocated
|
||||||
bool m_processingShortcut;
|
bool m_processingShortcut;
|
||||||
#endif // wxUSE_ACCEL
|
#endif // wxUSE_ACCEL
|
||||||
|
@@ -82,16 +82,17 @@ wxAcceleratorTable::wxAcceleratorTable(int n, const wxAcceleratorEntry entries[]
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QList< QShortcut* > *wxAcceleratorTable::ConvertShortcutTable( QWidget *parent ) const
|
wxVector<QShortcut*> wxAcceleratorTable::ConvertShortcutTable( QWidget *parent ) const
|
||||||
{
|
{
|
||||||
QList< QShortcut* > *qtList = new QList< QShortcut* >;
|
wxVector<QShortcut*> shortcuts;
|
||||||
|
|
||||||
for ( wxAccelList::compatibility_iterator node = M_ACCELDATA->m_accels.GetFirst(); node; node = node->GetNext() )
|
for ( wxAccelList::compatibility_iterator node = M_ACCELDATA->m_accels.GetFirst();
|
||||||
|
node; node = node->GetNext() )
|
||||||
{
|
{
|
||||||
qtList->push_back(ConvertAccelerator( node->GetData(), parent ));
|
shortcuts.push_back(ConvertAccelerator(node->GetData(), parent));
|
||||||
}
|
}
|
||||||
|
|
||||||
return qtList;
|
return shortcuts;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxObjectRefData *wxAcceleratorTable::CreateRefData() const
|
wxObjectRefData *wxAcceleratorTable::CreateRefData() const
|
||||||
|
@@ -248,16 +248,6 @@ wxWindowQt::~wxWindowQt()
|
|||||||
|
|
||||||
DestroyChildren(); // This also destroys scrollbars
|
DestroyChildren(); // This also destroys scrollbars
|
||||||
|
|
||||||
#if wxUSE_ACCEL
|
|
||||||
if ( m_qtShortcuts )
|
|
||||||
{
|
|
||||||
for ( int i = 0; i < m_qtShortcuts->size(); ++i )
|
|
||||||
{
|
|
||||||
delete m_qtShortcuts->at(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if wxUSE_DRAG_AND_DROP
|
#if wxUSE_DRAG_AND_DROP
|
||||||
SetDropTarget(NULL);
|
SetDropTarget(NULL);
|
||||||
#endif
|
#endif
|
||||||
@@ -994,22 +984,25 @@ bool wxWindowQt::DoPopupMenu(wxMenu *menu, int x, int y)
|
|||||||
#if wxUSE_ACCEL
|
#if wxUSE_ACCEL
|
||||||
void wxWindowQt::SetAcceleratorTable( const wxAcceleratorTable& accel )
|
void wxWindowQt::SetAcceleratorTable( const wxAcceleratorTable& accel )
|
||||||
{
|
{
|
||||||
|
wxCHECK_RET(GetHandle(), "Window has not been created");
|
||||||
|
|
||||||
wxWindowBase::SetAcceleratorTable( accel );
|
wxWindowBase::SetAcceleratorTable( accel );
|
||||||
|
|
||||||
if ( m_qtShortcuts )
|
// Disable previously set accelerators
|
||||||
|
for ( wxVector<QShortcut*>::const_iterator it = m_qtShortcuts.begin();
|
||||||
|
it != m_qtShortcuts.end(); ++it )
|
||||||
{
|
{
|
||||||
// Disable previously set accelerators
|
delete *it;
|
||||||
while ( !m_qtShortcuts->isEmpty() )
|
|
||||||
delete m_qtShortcuts->takeFirst();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_qtShortcuts.reset(accel.ConvertShortcutTable(GetHandle()));
|
m_qtShortcuts = accel.ConvertShortcutTable(GetHandle());
|
||||||
|
|
||||||
// Connect shortcuts to window
|
// Connect shortcuts to window
|
||||||
Q_FOREACH( QShortcut *s, *m_qtShortcuts )
|
for ( wxVector<QShortcut*>::const_iterator it = m_qtShortcuts.begin();
|
||||||
|
it != m_qtShortcuts.end(); ++it )
|
||||||
{
|
{
|
||||||
QObject::connect( s, &QShortcut::activated, m_qtShortcutHandler.get(), &wxQtShortcutHandler::activated );
|
QObject::connect( *it, &QShortcut::activated, m_qtShortcutHandler.get(), &wxQtShortcutHandler::activated );
|
||||||
QObject::connect( s, &QShortcut::activatedAmbiguously, m_qtShortcutHandler.get(), &wxQtShortcutHandler::activated );
|
QObject::connect( *it, &QShortcut::activatedAmbiguously, m_qtShortcutHandler.get(), &wxQtShortcutHandler::activated );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // wxUSE_ACCEL
|
#endif // wxUSE_ACCEL
|
||||||
|
Reference in New Issue
Block a user