[libcalamares] Access list of locale Ids

- Make it easier to obtain locale-ids (from CALAMARES_TRANSLATION_LANGUAGES)
   so avoid splitting that string multiple times.
This commit is contained in:
Adriaan de Groot 2019-08-20 05:26:26 -04:00
parent d8af11adee
commit 7b699bfc76
2 changed files with 6 additions and 1 deletions

View File

@ -29,6 +29,7 @@ namespace Locale
LabelModel::LabelModel( const QStringList& locales, QObject* parent )
: QAbstractListModel( parent )
, m_localeIds( locales )
{
Q_ASSERT( locales.count() > 0 );
m_locales.reserve( locales.count() );
@ -132,7 +133,7 @@ LabelModel::find( const QString& countryCode ) const
LabelModel*
availableTranslations()
{
static LabelModel* model = new LabelModel( QString( CALAMARES_TRANSLATION_LANGUAGES ).split( ';' ) );
static LabelModel* model = new LabelModel( QStringLiteral( CALAMARES_TRANSLATION_LANGUAGES ).split( ';' ) );
return model;
}

View File

@ -54,6 +54,9 @@ public:
*/
const Label& locale( int row ) const;
/// @brief Returns all of the locale Ids (e.g. en_US) put into this model.
const QStringList& localeIds() const { return m_localeIds; }
/** @brief Searches for an item that matches @p predicate
*
* Returns the row number of the first match, or -1 if there isn't one.
@ -67,6 +70,7 @@ public:
private:
QVector< Label > m_locales;
QStringList m_localeIds;
};
/** @brief Returns a model with all available translations.