From 88d1d255f6a61080ce45d86116c4b662bc78eca5 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 20 Jul 2020 16:13:08 +0200 Subject: [PATCH] [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. --- src/modules/locale/Config.cpp | 3 +++ src/modules/locale/Config.h | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/modules/locale/Config.cpp b/src/modules/locale/Config.cpp index d886f1eec..52378b0b4 100644 --- a/src/modules/locale/Config.cpp +++ b/src/modules/locale/Config.cpp @@ -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 >() ) { } diff --git a/src/modules/locale/Config.h b/src/modules/locale/Config.h index 34aa8b92f..a98ecc73d 100644 --- a/src/modules/locale/Config.h +++ b/src/modules/locale/Config.h @@ -21,12 +21,18 @@ #ifndef LOCALE_CONFIG_H #define LOCALE_CONFIG_H +#include "locale/TimeZone.h" + #include +#include + 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; };