[libcalamares] Apply coding style

This commit is contained in:
Adriaan de Groot 2020-03-24 22:57:36 +01:00
parent 08b5012946
commit 177d6fe861
2 changed files with 24 additions and 17 deletions

View file

@ -239,7 +239,8 @@ CStringListModel::CStringListModel( CStringPairList l )
{ {
} }
void CStringListModel::setList(CalamaresUtils::Locale::CStringPairList l) void
CStringListModel::setList( CalamaresUtils::Locale::CStringPairList l )
{ {
beginResetModel(); beginResetModel();
m_list = l; m_list = l;
@ -270,10 +271,12 @@ CStringListModel::data( const QModelIndex& index, int role ) const
} }
void void
CStringListModel::setCurrentIndex(const int &index) CStringListModel::setCurrentIndex( const int& index )
{ {
if ( ( index < 0 ) || ( index >= m_list.count() ) ) if ( ( index < 0 ) || ( index >= m_list.count() ) )
{
return; return;
}
m_currentIndex = index; m_currentIndex = index;
emit currentIndexChanged(); emit currentIndexChanged();
@ -285,10 +288,10 @@ CStringListModel::currentIndex() const
return m_currentIndex; return m_currentIndex;
} }
QHash<int, QByteArray> QHash< int, QByteArray >
CStringListModel::roleNames() const CStringListModel::roleNames() const
{ {
return {{Qt::DisplayRole,"label"}, {Qt::UserRole, "key"}}; return { { Qt::DisplayRole, "label" }, { Qt::UserRole, "key" } };
} }
const CStringPair* const CStringPair*

View file

@ -141,7 +141,7 @@ protected:
class CStringListModel : public QAbstractListModel class CStringListModel : public QAbstractListModel
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged) Q_PROPERTY( int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged )
public: public:
/// @brief Create empty model /// @brief Create empty model
@ -154,24 +154,28 @@ public:
QVariant data( const QModelIndex& index, int role ) const override; QVariant data( const QModelIndex& index, int role ) const override;
const CStringPair* item( int index ) const; const CStringPair* item( int index ) const;
QHash<int, QByteArray> roleNames() const override; QHash< int, QByteArray > roleNames() const override;
void setCurrentIndex(const int &index); void setCurrentIndex( const int& index );
int currentIndex() const; int currentIndex() const;
void setList(CStringPairList); void setList( CStringPairList );
inline int indexOf(const QString &key) inline int indexOf( const QString& key )
{ {
const auto it = std::find_if(m_list.constBegin(), m_list.constEnd(), [&](const CalamaresUtils::Locale::CStringPair *item) -> bool const auto it = std::find_if(
m_list.constBegin(), m_list.constEnd(), [&]( const CalamaresUtils::Locale::CStringPair* item ) -> bool {
return item->key() == key;
} );
if ( it != m_list.constEnd() )
{ {
return item->key() == key; return std::distance( m_list.constBegin(), it );
}
}); else
{
if(it != m_list.constEnd()) return -1;
return std::distance(m_list.constBegin(), it); }
else return -1;
} }