[locale] Use TZRegionModel

- instead of populating combo box with texts, use the model
   read in from zone.tab
 - this **partly** deprecates the LocaleGlobal stuff
main
Adriaan de Groot 5 years ago
parent 2625bb18df
commit afb5430c42

@ -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 );

@ -24,9 +24,12 @@
#include "timezonewidget/localeglobal.h"
#include "Job.h"
#include "locale/TimeZone.h"
#include <QWidget>
#include <memory>
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;

Loading…
Cancel
Save