[welcome] Another find() overload
- Also find a specific locale - While here, apply Calamares coding style
This commit is contained in:
parent
314aee8d68
commit
0c868dbd17
@ -18,7 +18,7 @@
|
||||
|
||||
#include "LocaleModel.h"
|
||||
|
||||
LocaleModel::LocaleModel(const QStringList& locales, QObject* parent)
|
||||
LocaleModel::LocaleModel( const QStringList& locales, QObject* parent )
|
||||
: QAbstractTableModel( parent )
|
||||
{
|
||||
Q_ASSERT( locales.count() > 0 );
|
||||
@ -66,7 +66,7 @@ LocaleModel::data( const QModelIndex& index, int role ) const
|
||||
}
|
||||
|
||||
const CalamaresUtils::LocaleLabel&
|
||||
LocaleModel::locale(int row)
|
||||
LocaleModel::locale( int row )
|
||||
{
|
||||
if ( ( row < 0 ) || ( row >= m_locales.count() ) )
|
||||
{
|
||||
@ -79,7 +79,7 @@ LocaleModel::locale(int row)
|
||||
}
|
||||
|
||||
int
|
||||
LocaleModel::find(std::function<bool (const LocaleLabel &)> predicate) const
|
||||
LocaleModel::find( std::function<bool ( const LocaleLabel& )> predicate ) const
|
||||
{
|
||||
for ( int row = 0; row < m_locales.count() ; ++row )
|
||||
{
|
||||
@ -90,7 +90,19 @@ LocaleModel::find(std::function<bool (const LocaleLabel &)> predicate) const
|
||||
}
|
||||
|
||||
int
|
||||
LocaleModel::find(std::function<bool (const QLocale &)> predicate) const
|
||||
LocaleModel::find( std::function<bool ( const QLocale& )> predicate ) const
|
||||
{
|
||||
return find( [&]( const LocaleLabel& l ){ return predicate( l.locale() ); } );
|
||||
return find( [&]( const LocaleLabel& l )
|
||||
{
|
||||
return predicate( l.locale() );
|
||||
} );
|
||||
}
|
||||
|
||||
int
|
||||
LocaleModel::find( const QLocale& locale ) const
|
||||
{
|
||||
return find( [&]( const LocaleLabel& l )
|
||||
{
|
||||
return locale == l.locale();
|
||||
} );
|
||||
}
|
||||
|
@ -49,8 +49,9 @@ public:
|
||||
*
|
||||
* Returns the row number of the first match, or -1 if there isn't one.
|
||||
*/
|
||||
int find( std::function<bool(const QLocale&)> predicate) const;
|
||||
int find( std::function<bool(const LocaleLabel&)> predicate) const;
|
||||
int find( std::function<bool( const QLocale& )> predicate ) const;
|
||||
int find( std::function<bool( const LocaleLabel& )> predicate ) const;
|
||||
int find( const QLocale& ) const;
|
||||
|
||||
private:
|
||||
QVector< LocaleLabel > m_locales;
|
||||
|
Loading…
Reference in New Issue
Block a user