[keyboard] Sanity in setCurrentIndex() parameters

This commit is contained in:
Adriaan de Groot 2020-10-28 16:47:52 +01:00
parent 9e141636c5
commit 0bf28b0b94
2 changed files with 7 additions and 4 deletions

View File

@ -183,15 +183,18 @@ KeyboardLayoutModel::roleNames() const
}
void
KeyboardLayoutModel::setCurrentIndex( const int& index )
KeyboardLayoutModel::setCurrentIndex( int index )
{
if ( index >= m_layouts.count() || index < 0 )
{
return;
}
m_currentIndex = index;
emit currentIndexChanged( m_currentIndex );
if ( m_currentIndex != index )
{
m_currentIndex = index;
emit currentIndexChanged( m_currentIndex );
}
}
int

View File

@ -114,7 +114,7 @@ public:
QVariant data( const QModelIndex& index, int role ) const override;
void setCurrentIndex( const int& index );
void setCurrentIndex( int index );
int currentIndex() const;
const QPair< QString, KeyboardGlobal::KeyboardInfo > item( const int& index ) const;