[locale] Add regions & zones models to Config

- The models are constant pointers, even if their contents aren't.
- Make the top-level (region) model point to the global TZ list.
This commit is contained in:
Adriaan de Groot 2020-07-20 16:13:08 +02:00
parent 51b7ec875f
commit 88d1d255f6
2 changed files with 16 additions and 0 deletions

View File

@ -142,6 +142,9 @@ loadLocales( const QString& localeGenPath )
Config::Config( QObject* parent )
: QObject( parent )
, m_regionModel( std::make_unique< CalamaresUtils::Locale::CStringListModel >(
CalamaresUtils::Locale::TZRegion::fromZoneTab() ) )
, m_zonesModel( std::make_unique< CalamaresUtils::Locale::CStringListModel >() )
{
}

View File

@ -21,12 +21,18 @@
#ifndef LOCALE_CONFIG_H
#define LOCALE_CONFIG_H
#include "locale/TimeZone.h"
#include <QObject>
#include <memory>
class Config : public QObject
{
Q_OBJECT
Q_PROPERTY( const QStringList& supportedLocales READ supportedLocales CONSTANT FINAL )
Q_PROPERTY( CalamaresUtils::Locale::CStringListModel* zonesModel READ zonesModel CONSTANT FINAL )
Q_PROPERTY( CalamaresUtils::Locale::CStringListModel* regionModel READ regionModel CONSTANT FINAL )
public:
Config( QObject* parent = nullptr );
@ -36,10 +42,17 @@ public:
public Q_SLOTS:
const QStringList& supportedLocales() const { return m_localeGenLines; }
CalamaresUtils::Locale::CStringListModel* regionModel() const { return m_regionModel.get(); }
CalamaresUtils::Locale::CStringListModel* zonesModel() const { return m_zonesModel.get(); }
private:
/// A list of supported locale identifiers (e.g. "en_US.UTF-8")
QStringList m_localeGenLines;
/// The regions (America, Asia, Europe ..)
std::unique_ptr< CalamaresUtils::Locale::CStringListModel > m_regionModel;
/// The zones for the current region (e.g. America/New_York)
std::unique_ptr< CalamaresUtils::Locale::CStringListModel > m_zonesModel;
};