[welcome] Another find() overload

- Also find a specific locale
 - While here, apply Calamares coding style
This commit is contained in:
Adriaan de Groot 2019-04-19 09:39:19 +02:00
parent 314aee8d68
commit 0c868dbd17
2 changed files with 33 additions and 20 deletions

View file

@ -92,5 +92,17 @@ LocaleModel::find(std::function<bool (const LocaleLabel &)> predicate) const
int 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();
} );
} }

View file

@ -51,6 +51,7 @@ public:
*/ */
int find( std::function<bool( const QLocale& )> predicate ) const; int find( std::function<bool( const QLocale& )> predicate ) const;
int find( std::function<bool( const LocaleLabel& )> predicate ) const; int find( std::function<bool( const LocaleLabel& )> predicate ) const;
int find( const QLocale& ) const;
private: private:
QVector< LocaleLabel > m_locales; QVector< LocaleLabel > m_locales;