[libcalamares] Offer translation lookup of regions
This commit is contained in:
parent
ad3c0de936
commit
21f97db8fd
@ -268,6 +268,18 @@ RegionsModel::roleNames() const
|
||||
return { { NameRole, "name" }, { KeyRole, "key" } };
|
||||
}
|
||||
|
||||
QString
|
||||
RegionsModel::tr( const QString& region ) const
|
||||
{
|
||||
for ( const auto* p : m_private->m_regions )
|
||||
{
|
||||
if ( p->key() == region )
|
||||
{
|
||||
return p->tr();
|
||||
}
|
||||
}
|
||||
return region;
|
||||
}
|
||||
|
||||
ZonesModel::ZonesModel( QObject* parent )
|
||||
: QAbstractListModel( parent )
|
||||
|
@ -47,6 +47,9 @@ class TimeZoneData : public QObject, TranslatableString
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY( QString region READ region CONSTANT )
|
||||
Q_PROPERTY( QString zone READ zone CONSTANT )
|
||||
Q_PROPERTY( QString name READ tr CONSTANT )
|
||||
Q_PROPERTY( QString countryCode READ country CONSTANT )
|
||||
|
||||
public:
|
||||
TimeZoneData( const QString& region,
|
||||
@ -98,6 +101,14 @@ public:
|
||||
|
||||
QHash< int, QByteArray > roleNames() const override;
|
||||
|
||||
public Q_SLOTS:
|
||||
/** @brief Provides a human-readable version of the region
|
||||
*
|
||||
* Returns @p region unchanged if there is no such region
|
||||
* or no translation for the region's name.
|
||||
*/
|
||||
QString tr( const QString& region ) const;
|
||||
|
||||
private:
|
||||
Private* m_private;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user