[locale] Remove useless localeglobal

- Although ::init() was called, none of the actual functionality
   from localeglobal was still in use.
This commit is contained in:
Adriaan de Groot 2020-04-14 12:37:22 +02:00
parent 36d9e7d8f4
commit 4b65600c08
10 changed files with 7 additions and 201 deletions

View File

@ -20,7 +20,6 @@ calamares_add_plugin( locale
LocaleViewStep.cpp
SetTimezoneJob.cpp
timezonewidget/timezonewidget.cpp
timezonewidget/localeglobal.cpp
UI
RESOURCES
locale.qrc

View File

@ -209,7 +209,13 @@ Config::updateGlobalStorage()
const auto* location = currentLocation();
bool locationChanged = ( location->region() != gs->value( "locationRegion" ) )
|| ( location->zone() != gs->value( "locationZone" ) );
#ifdef DEBUG_TIMEZONES
if ( locationChanged )
{
cDebug() << "Location changed" << gs->value( "locationRegion" ) << ',' << gs->value( "locationZone" ) << "to"
<< location->region() << ',' << location->zone();
}
#endif
gs->insert( "locationRegion", location->region() );
gs->insert( "locationZone", location->zone() );

View File

@ -21,7 +21,6 @@
#define LOCALE_CONFIG_H
#include "LocaleConfiguration.h"
#include "timezonewidget/localeglobal.h"
#include "Job.h"
#include "locale/TimeZone.h"

View File

@ -21,7 +21,6 @@
#define LOCALEPAGE_H
#include "LocaleConfiguration.h"
#include "timezonewidget/localeglobal.h"
#include "Job.h"
#include "locale/TimeZone.h"

View File

@ -20,7 +20,6 @@
#include "LocaleViewStep.h"
#include "LocalePage.h"
#include "timezonewidget/localeglobal.h"
#include "widgets/WaitingWidget.h"
#include "GlobalStorage.h"
@ -225,7 +224,6 @@ LocaleViewStep::setConfigurationMap( const QVariantMap& configurationMap )
Calamares::RequirementsList
LocaleViewStep::checkRequirements()
{
LocaleGlobal::init();
if ( m_geoip && m_geoip->isValid() )
{
auto& network = CalamaresUtils::Network::Manager::instance();

View File

@ -1,126 +0,0 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2014-2016, Teo Mrnjavac <teo@kde.org>
*
* Originally from the Manjaro Installation Framework
* by Roland Singer <roland@manjaro.org>
* Copyright (C) 2007 Free Software Foundation, Inc.
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#include "localeglobal.h"
#include "locale/TimeZone.h"
#include <QTimeZone>
//###
//### Private variables
//###
QHash< QString, QHash< QString, QList< LocaleGlobal::Locale > > > LocaleGlobal::locales;
//###
//### Public methods
//###
void
LocaleGlobal::init()
{
// TODO: Error handling
initLocales();
}
QHash< QString, QHash< QString, QList< LocaleGlobal::Locale > > >
LocaleGlobal::getLocales()
{
return locales;
}
//###
//### Private methods
//###
void
LocaleGlobal::initLocales()
{
static const char LOCALESDIR[] = "/usr/share/i18n/locales";
locales.clear();
QStringList files = QDir( LOCALESDIR ).entryList( QDir::Files, QDir::Name );
for ( int i = 0; i < files.size(); ++i )
{
QString filename = files.at( i );
QFile file( QString( LOCALESDIR ) + "/" + filename );
if ( !file.open( QIODevice::ReadOnly | QIODevice::Text ) )
{
continue;
}
QTextStream in( &file );
QString commentChar = "%";
Locale locale;
QString lang, territory;
locale.locale = filename;
while ( !in.atEnd() )
{
QString line = in.readLine().trimmed();
QStringList split = line.split( commentChar, QString::KeepEmptyParts )
.first()
.split( QRegExp( " (?=[^\"]*(\"[^\"]*\"[^\"]*)*$)" ), QString::SkipEmptyParts );
if ( split.size() < 2 )
{
continue;
}
QString sub1 = QString( split.at( 0 ) ).remove( "\"" );
QString sub2 = QString( split.at( 1 ) ).remove( "\"" );
if ( sub1 == "comment_char" )
{
commentChar = sub2;
}
else if ( sub1 == "title" )
{
locale.description = sub2;
}
else if ( sub1 == "territory" )
{
territory = sub2;
}
else if ( sub1 == "language" )
{
lang = sub2;
}
}
if ( lang.isEmpty() || territory.isEmpty() )
{
continue;
}
locales[ lang ][ territory ].append( locale );
}
}

View File

@ -1,63 +0,0 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2014-2016, Teo Mrnjavac <teo@kde.org>
* Copyright 2019, Adriaan de Groot <groot@kde.org>
*
* Originally from the Manjaro Installation Framework
* by Roland Singer <roland@manjaro.org>
* Copyright (C) 2007 Free Software Foundation, Inc.
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LOCALEGLOBAL_H
#define LOCALEGLOBAL_H
#include <QDebug>
#include <QDir>
#include <QFile>
#include <QHash>
#include <QList>
#include <QMap>
#include <QRegExp>
#include <QString>
#include <QStringList>
#include <QTextStream>
namespace CalamaresUtils
{
namespace Locale
{
class TZZone;
}
} // namespace CalamaresUtils
class LocaleGlobal
{
public:
struct Locale
{
QString description, locale;
};
static void init();
static QHash< QString, QHash< QString, QList< LocaleGlobal::Locale > > > getLocales();
private:
static QHash< QString, QHash< QString, QList< LocaleGlobal::Locale > > > locales;
static void initLocales();
};
#endif // LOCALEGLOBAL_H

View File

@ -24,8 +24,6 @@
#ifndef TIMEZONEWIDGET_H
#define TIMEZONEWIDGET_H
#include "localeglobal.h"
#include "locale/TimeZone.h"
#include <QFile>

View File

@ -19,7 +19,6 @@ calamares_add_plugin( localeq
${_locale}/LocaleConfiguration.cpp
${_locale}/Config.cpp
${_locale}/SetTimezoneJob.cpp
${_locale}/timezonewidget/localeglobal.cpp
RESOURCES
localeq.qrc
LINK_PRIVATE_LIBRARIES

View File

@ -29,8 +29,6 @@
#include "utils/Variant.h"
#include "utils/Yaml.h"
#include "timezonewidget/localeglobal.h"
#include "Branding.h"
#include "modulesystem/ModuleManager.h"
#include <QQmlEngine>
@ -72,7 +70,6 @@ LocaleQmlViewStep::fetchGeoIpTimezone()
Calamares::RequirementsList LocaleQmlViewStep::checkRequirements()
{
LocaleGlobal::init();
if ( m_geoip && m_geoip->isValid() )
{
auto& network = CalamaresUtils::Network::Manager::instance();