[locale] Use TZRegionModel
- instead of populating combo box with texts, use the model read in from zone.tab - this **partly** deprecates the LocaleGlobal stuff
This commit is contained in:
parent
2625bb18df
commit
afb5430c42
@ -28,6 +28,7 @@
|
|||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
|
|
||||||
#include "locale/Label.h"
|
#include "locale/Label.h"
|
||||||
|
#include "locale/TimeZone.h"
|
||||||
#include "utils/CalamaresUtilsGui.h"
|
#include "utils/CalamaresUtilsGui.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "utils/Retranslator.h"
|
#include "utils/Retranslator.h"
|
||||||
@ -143,8 +144,8 @@ containsLocation( const QList< LocaleGlobal::Location >& locations, const QStrin
|
|||||||
void
|
void
|
||||||
LocalePage::init( const QString& initialRegion, const QString& initialZone, const QString& localeGenPath )
|
LocalePage::init( const QString& initialRegion, const QString& initialZone, const QString& localeGenPath )
|
||||||
{
|
{
|
||||||
m_regionCombo->blockSignals( true );
|
m_regionModel.reset( new CalamaresUtils::Locale::TZRegionModel );
|
||||||
m_zoneCombo->blockSignals( true );
|
m_regionCombo->setModel( m_regionModel.get() );
|
||||||
|
|
||||||
// Setup locations
|
// Setup locations
|
||||||
QHash< QString, QList< LocaleGlobal::Location > > regions = LocaleGlobal::getLocations();
|
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();
|
QStringList keys = regions.keys();
|
||||||
keys.sort();
|
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() );
|
m_regionCombo->currentIndexChanged( m_regionCombo->currentIndex() );
|
||||||
|
|
||||||
if ( keys.contains( initialRegion ) && containsLocation( regions.value( initialRegion ), initialZone ) )
|
if ( keys.contains( initialRegion ) && containsLocation( regions.value( initialRegion ), initialZone ) )
|
||||||
@ -402,13 +395,14 @@ LocalePage::updateGlobalStorage()
|
|||||||
updateLocaleLabels();
|
updateLocaleLabels();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
LocalePage::regionChanged( int currentIndex )
|
LocalePage::regionChanged( int currentIndex )
|
||||||
{
|
{
|
||||||
Q_UNUSED( currentIndex )
|
Q_UNUSED( currentIndex )
|
||||||
|
QString selectedRegion = m_regionCombo->currentData().toString();
|
||||||
|
|
||||||
QHash< QString, QList< LocaleGlobal::Location > > regions = LocaleGlobal::getLocations();
|
QHash< QString, QList< LocaleGlobal::Location > > regions = LocaleGlobal::getLocations();
|
||||||
if ( !regions.contains( m_regionCombo->currentData().toString() ) )
|
if ( !regions.contains( selectedRegion ) )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -417,7 +411,7 @@ LocalePage::regionChanged( int currentIndex )
|
|||||||
|
|
||||||
m_zoneCombo->clear();
|
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 )
|
for ( const LocaleGlobal::Location& zone : zones )
|
||||||
{
|
{
|
||||||
m_zoneCombo->addItem( LocaleGlobal::Location::pretty( zone.zone ), zone.zone );
|
m_zoneCombo->addItem( LocaleGlobal::Location::pretty( zone.zone ), zone.zone );
|
||||||
|
@ -24,9 +24,12 @@
|
|||||||
#include "timezonewidget/localeglobal.h"
|
#include "timezonewidget/localeglobal.h"
|
||||||
|
|
||||||
#include "Job.h"
|
#include "Job.h"
|
||||||
|
#include "locale/TimeZone.h"
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
class QComboBox;
|
class QComboBox;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
@ -71,6 +74,8 @@ private:
|
|||||||
void changeLocale();
|
void changeLocale();
|
||||||
void changeFormats();
|
void changeFormats();
|
||||||
|
|
||||||
|
std::unique_ptr< CalamaresUtils::Locale::TZRegionModel > m_regionModel;
|
||||||
|
|
||||||
TimeZoneWidget* m_tzWidget;
|
TimeZoneWidget* m_tzWidget;
|
||||||
QComboBox* m_regionCombo;
|
QComboBox* m_regionCombo;
|
||||||
QComboBox* m_zoneCombo;
|
QComboBox* m_zoneCombo;
|
||||||
|
Loading…
Reference in New Issue
Block a user