mirror of
https://github.com/parchlinux/calamares.git
synced 2025-07-02 03:45:38 -04:00
[keyboardq] apply the style script
This commit is contained in:
parent
1a46e08cc2
commit
835850c02a
11 changed files with 411 additions and 342 deletions
|
@ -23,7 +23,7 @@
|
|||
|
||||
|
||||
KeyboardLayoutModel::KeyboardLayoutModel( QObject* parent )
|
||||
: QAbstractListModel( parent )
|
||||
: QAbstractListModel( parent )
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
@ -40,60 +40,67 @@ QVariant
|
|||
KeyboardLayoutModel::data( const QModelIndex& index, int role ) const
|
||||
{
|
||||
if ( !index.isValid() )
|
||||
{
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
switch ( role )
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
return m_layouts.at( index.row() ).second.description;
|
||||
case KeyboardVariantsRole:
|
||||
return QVariant::fromValue( m_layouts.at( index.row() ).second.variants );
|
||||
case KeyboardLayoutKeyRole:
|
||||
return m_layouts.at( index.row() ).first;
|
||||
case Qt::DisplayRole:
|
||||
return m_layouts.at( index.row() ).second.description;
|
||||
case KeyboardVariantsRole:
|
||||
return QVariant::fromValue( m_layouts.at( index.row() ).second.variants );
|
||||
case KeyboardLayoutKeyRole:
|
||||
return m_layouts.at( index.row() ).first;
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
const QPair< QString, KeyboardGlobal::KeyboardInfo >
|
||||
KeyboardLayoutModel::item(const int &index) const
|
||||
KeyboardLayoutModel::item( const int& index ) const
|
||||
{
|
||||
if(index >= m_layouts.count() || index < 0)
|
||||
if ( index >= m_layouts.count() || index < 0 )
|
||||
{
|
||||
return QPair< QString, KeyboardGlobal::KeyboardInfo >();
|
||||
}
|
||||
|
||||
return m_layouts.at(index);
|
||||
return m_layouts.at( index );
|
||||
}
|
||||
|
||||
void
|
||||
KeyboardLayoutModel::init()
|
||||
{
|
||||
KeyboardGlobal::LayoutsMap layouts =
|
||||
KeyboardGlobal::getKeyboardLayouts();
|
||||
for ( KeyboardGlobal::LayoutsMap::const_iterator it = layouts.constBegin();
|
||||
it != layouts.constEnd(); ++it )
|
||||
m_layouts.append( qMakePair( it.key(), it.value() ) );
|
||||
|
||||
std::stable_sort( m_layouts.begin(), m_layouts.end(), []( const QPair< QString, KeyboardGlobal::KeyboardInfo >& a,
|
||||
const QPair< QString, KeyboardGlobal::KeyboardInfo >& b )
|
||||
KeyboardGlobal::LayoutsMap layouts = KeyboardGlobal::getKeyboardLayouts();
|
||||
for ( KeyboardGlobal::LayoutsMap::const_iterator it = layouts.constBegin(); it != layouts.constEnd(); ++it )
|
||||
{
|
||||
return a.second.description < b.second.description;
|
||||
} );
|
||||
m_layouts.append( qMakePair( it.key(), it.value() ) );
|
||||
}
|
||||
|
||||
std::stable_sort( m_layouts.begin(),
|
||||
m_layouts.end(),
|
||||
[]( const QPair< QString, KeyboardGlobal::KeyboardInfo >& a,
|
||||
const QPair< QString, KeyboardGlobal::KeyboardInfo >& b ) {
|
||||
return a.second.description < b.second.description;
|
||||
} );
|
||||
}
|
||||
|
||||
QHash<int, QByteArray>
|
||||
QHash< int, QByteArray >
|
||||
KeyboardLayoutModel::roleNames() const
|
||||
{
|
||||
return {{Qt::DisplayRole, "label"}, {KeyboardLayoutKeyRole, "key"}, {KeyboardVariantsRole, "variants"}};
|
||||
return { { Qt::DisplayRole, "label" }, { KeyboardLayoutKeyRole, "key" }, { KeyboardVariantsRole, "variants" } };
|
||||
}
|
||||
|
||||
void
|
||||
KeyboardLayoutModel::setCurrentIndex(const int &index)
|
||||
KeyboardLayoutModel::setCurrentIndex( const int& index )
|
||||
{
|
||||
if(index >= m_layouts.count() || index < 0)
|
||||
if ( index >= m_layouts.count() || index < 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_currentIndex = index;
|
||||
emit currentIndexChanged(m_currentIndex);
|
||||
emit currentIndexChanged( m_currentIndex );
|
||||
}
|
||||
|
||||
int
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue