diff --git a/src/modules/locale/LocalePage.cpp b/src/modules/locale/LocalePage.cpp index fc715e3f3..402351acf 100644 --- a/src/modules/locale/LocalePage.cpp +++ b/src/modules/locale/LocalePage.cpp @@ -28,6 +28,7 @@ #include "Settings.h" #include "locale/Label.h" +#include "locale/TimeZone.h" #include "utils/CalamaresUtilsGui.h" #include "utils/Logger.h" #include "utils/Retranslator.h" @@ -143,8 +144,8 @@ containsLocation( const QList< LocaleGlobal::Location >& locations, const QStrin void LocalePage::init( const QString& initialRegion, const QString& initialZone, const QString& localeGenPath ) { - m_regionCombo->blockSignals( true ); - m_zoneCombo->blockSignals( true ); + m_regionModel.reset( new CalamaresUtils::Locale::TZRegionModel ); + m_regionCombo->setModel( m_regionModel.get() ); // Setup locations QHash< QString, QList< LocaleGlobal::Location > > regions = LocaleGlobal::getLocations(); @@ -152,14 +153,6 @@ LocalePage::init( const QString& initialRegion, const QString& initialZone, cons QStringList keys = regions.keys(); keys.sort(); - foreach ( const QString& key, keys ) - { - m_regionCombo->addItem( LocaleGlobal::Location::pretty( key ), key ); - } - - m_regionCombo->blockSignals( false ); - m_zoneCombo->blockSignals( false ); - m_regionCombo->currentIndexChanged( m_regionCombo->currentIndex() ); if ( keys.contains( initialRegion ) && containsLocation( regions.value( initialRegion ), initialZone ) ) @@ -402,13 +395,14 @@ LocalePage::updateGlobalStorage() updateLocaleLabels(); } - void LocalePage::regionChanged( int currentIndex ) { Q_UNUSED( currentIndex ) + QString selectedRegion = m_regionCombo->currentData().toString(); + QHash< QString, QList< LocaleGlobal::Location > > regions = LocaleGlobal::getLocations(); - if ( !regions.contains( m_regionCombo->currentData().toString() ) ) + if ( !regions.contains( selectedRegion ) ) { return; } @@ -417,7 +411,7 @@ LocalePage::regionChanged( int currentIndex ) m_zoneCombo->clear(); - const QList< LocaleGlobal::Location > zones = regions.value( m_regionCombo->currentData().toString() ); + const QList< LocaleGlobal::Location > zones = regions.value( selectedRegion ); for ( const LocaleGlobal::Location& zone : zones ) { m_zoneCombo->addItem( LocaleGlobal::Location::pretty( zone.zone ), zone.zone ); diff --git a/src/modules/locale/LocalePage.h b/src/modules/locale/LocalePage.h index 73097252b..f4d352ccf 100644 --- a/src/modules/locale/LocalePage.h +++ b/src/modules/locale/LocalePage.h @@ -24,9 +24,12 @@ #include "timezonewidget/localeglobal.h" #include "Job.h" +#include "locale/TimeZone.h" #include +#include + class QComboBox; class QLabel; class QPushButton; @@ -71,6 +74,8 @@ private: void changeLocale(); void changeFormats(); + std::unique_ptr< CalamaresUtils::Locale::TZRegionModel > m_regionModel; + TimeZoneWidget* m_tzWidget; QComboBox* m_regionCombo; QComboBox* m_zoneCombo;