[locale] Use model functions from locale service
- drop the home-grown combo-box filling, use model
This commit is contained in:
parent
c75e870073
commit
226530cf6f
@ -152,14 +152,6 @@ LocalePage::init( const QString& initialRegion, const QString& initialZone, cons
|
|||||||
m_regionList = TZRegion::fromZoneTab();
|
m_regionList = TZRegion::fromZoneTab();
|
||||||
m_regionModel = std::make_unique< CStringListModel >( m_regionList );
|
m_regionModel = std::make_unique< CStringListModel >( m_regionList );
|
||||||
m_regionCombo->setModel( m_regionModel.get() );
|
m_regionCombo->setModel( m_regionModel.get() );
|
||||||
|
|
||||||
|
|
||||||
// Setup locations
|
|
||||||
QHash< QString, QList< LocaleGlobal::Location > > regions = LocaleGlobal::getLocations();
|
|
||||||
|
|
||||||
QStringList keys = regions.keys();
|
|
||||||
keys.sort();
|
|
||||||
|
|
||||||
m_regionCombo->currentIndexChanged( m_regionCombo->currentIndex() );
|
m_regionCombo->currentIndexChanged( m_regionCombo->currentIndex() );
|
||||||
|
|
||||||
auto* region = m_regionList.find< TZRegion >( initialRegion );
|
auto* region = m_regionList.find< TZRegion >( initialRegion );
|
||||||
@ -406,29 +398,20 @@ LocalePage::updateGlobalStorage()
|
|||||||
void
|
void
|
||||||
LocalePage::regionChanged( int currentIndex )
|
LocalePage::regionChanged( int currentIndex )
|
||||||
{
|
{
|
||||||
|
using namespace CalamaresUtils::Locale;
|
||||||
|
|
||||||
Q_UNUSED( currentIndex )
|
Q_UNUSED( currentIndex )
|
||||||
QString selectedRegion = m_regionCombo->currentData().toString();
|
QString selectedRegion = m_regionCombo->currentData().toString();
|
||||||
|
|
||||||
QHash< QString, QList< LocaleGlobal::Location > > regions = LocaleGlobal::getLocations();
|
TZRegion* region = m_regionList.find< TZRegion >( selectedRegion );
|
||||||
if ( !regions.contains( selectedRegion ) )
|
if ( !region )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_zoneCombo->blockSignals( true );
|
m_zoneCombo->blockSignals( true );
|
||||||
|
m_zoneCombo->setModel( new CStringListModel( region->zones() ) );
|
||||||
m_zoneCombo->clear();
|
|
||||||
|
|
||||||
const QList< LocaleGlobal::Location > zones = regions.value( selectedRegion );
|
|
||||||
for ( const LocaleGlobal::Location& zone : zones )
|
|
||||||
{
|
|
||||||
m_zoneCombo->addItem( LocaleGlobal::Location::pretty( zone.zone ), zone.zone );
|
|
||||||
}
|
|
||||||
|
|
||||||
m_zoneCombo->model()->sort( 0 );
|
|
||||||
|
|
||||||
m_zoneCombo->blockSignals( false );
|
m_zoneCombo->blockSignals( false );
|
||||||
|
|
||||||
m_zoneCombo->currentIndexChanged( m_zoneCombo->currentIndex() );
|
m_zoneCombo->currentIndexChanged( m_zoneCombo->currentIndex() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user