Make the locale viewmodule load the initial timezone from config.

This commit is contained in:
Teo Mrnjavac 2014-07-15 11:35:05 +02:00
parent 0a8aa66d58
commit e3741c4d26
4 changed files with 48 additions and 5 deletions

View file

@ -122,7 +122,7 @@ LocalePage::LocalePage( QWidget* parent )
void
LocalePage::init()
LocalePage::init( const QString& initialRegion, const QString& initialZone )
{
m_regionCombo->blockSignals( true );
m_timezoneCombo->blockSignals( true );
@ -144,8 +144,26 @@ LocalePage::init()
m_regionCombo->currentIndexChanged( m_regionCombo->currentText() );
// Default location
// TODO: make configurable from module.conf
m_tzWidget->setCurrentLocation( "Europe", "Berlin" );
auto containsLocation = []( const QList< LocaleGlobal::Location >& locations,
const QString& zone ) -> bool
{
foreach ( const LocaleGlobal::Location& location, locations )
{
if ( location.zone == zone )
return true;
}
return false;
};
if ( keys.contains( initialRegion ) &&
containsLocation( regions.value( initialRegion ), initialZone ) )
{
m_tzWidget->setCurrentLocation( initialRegion, initialZone );
}
else
{
m_tzWidget->setCurrentLocation( "Europe", "Berlin" );
}
emit m_tzWidget->locationChanged( m_tzWidget->getCurrentLocation() );
}