[libcalamares] Use namespace Calamares

The distinction CalamaresUtils and Calamares is old-fashioned,
since we can use nested namespaces (and already do) for a lot
of things; make libcalamares/locale/ a bit more consistent
by using namespace Calamares::Locale for everything.
This commit is contained in:
Adriaan de Groot 2022-07-02 23:18:38 +02:00
parent d7e35d2ad2
commit 18a3092aa1
14 changed files with 34 additions and 34 deletions

View File

@ -12,7 +12,7 @@
#include "CountryData_p.cpp"
namespace CalamaresUtils
namespace Calamares
{
namespace Locale
{
@ -95,4 +95,4 @@ languageForCountry( QLocale::Country country )
}
} // namespace Locale
} // namespace CalamaresUtils
} // namespace Calamares

View File

@ -16,7 +16,7 @@
#include <QLocale>
#include <QPair>
namespace CalamaresUtils
namespace Calamares
{
namespace Locale
{
@ -42,6 +42,6 @@ DLLEXPORT QPair< QLocale::Country, QLocale::Language > countryData( const QStrin
/// @brief Get a likely locale for a 2-letter country code
DLLEXPORT QLocale countryLocale( const QString& code );
} // namespace Locale
} // namespace CalamaresUtils
} // namespace Calamares
#endif

View File

@ -72,7 +72,7 @@ LocaleTests::initTestCase()
void
LocaleTests::testLanguageModelCount()
{
const auto* m = CalamaresUtils::Locale::availableTranslations();
const auto* m = Calamares::Locale::availableTranslations();
QVERIFY( m );
QVERIFY( m->rowCount( QModelIndex() ) > 1 );
@ -91,7 +91,7 @@ LocaleTests::testLanguageModelCount()
void
LocaleTests::testLanguageScripts()
{
const auto* m = CalamaresUtils::Locale::availableTranslations();
const auto* m = Calamares::Locale::availableTranslations();
QVERIFY( m );

View File

@ -128,7 +128,7 @@ specialCaseSystemLanguage()
return ( it != std::cend( special_cases ) ) ? QString::fromLatin1( it->id ) : QString();
}
namespace CalamaresUtils
namespace Calamares
{
namespace Locale
{
@ -187,4 +187,4 @@ Translation::getLocale( const Id& localeId )
}
} // namespace Locale
} // namespace CalamaresUtils
} // namespace Calamares

View File

@ -18,7 +18,7 @@
#include <QObject>
#include <QString>
namespace CalamaresUtils
namespace Calamares
{
namespace Locale
{
@ -124,6 +124,6 @@ operator==( const Translation::Id& lhs, const Translation::Id& rhs )
}
} // namespace Locale
} // namespace CalamaresUtils
} // namespace Calamares
#endif

View File

@ -15,7 +15,7 @@
#include "CalamaresTranslations.h" // For the list of translations
namespace CalamaresUtils
namespace Calamares
{
namespace Locale
{
@ -144,4 +144,4 @@ availableTranslations()
}
} // namespace Locale
} // namespace CalamaresUtils
} // namespace Calamares

View File

@ -19,7 +19,7 @@
#include <QVector>
namespace CalamaresUtils
namespace Calamares
{
namespace Locale
{
@ -85,5 +85,5 @@ private:
*/
DLLEXPORT TranslationsModel* availableTranslations();
} // namespace Locale
} // namespace CalamaresUtils
} // namespace Calamares
#endif

View File

@ -178,7 +178,7 @@ static QTranslator* s_tztranslator = nullptr;
static QString s_translatorLocaleName;
void
installTranslator( const CalamaresUtils::Locale::Translation::Id& locale, const QString& brandingTranslationsPrefix )
installTranslator( const Calamares::Locale::Translation::Id& locale, const QString& brandingTranslationsPrefix )
{
s_translatorLocaleName = locale.name;
@ -190,17 +190,17 @@ installTranslator( const CalamaresUtils::Locale::Translation::Id& locale, const
void
installTranslator()
{
installTranslator( CalamaresUtils::Locale::Translation().id(), QString() );
installTranslator( Calamares::Locale::Translation().id(), QString() );
}
CalamaresUtils::Locale::Translation::Id
Calamares::Locale::Translation::Id
translatorLocaleName()
{
return { s_translatorLocaleName };
}
bool
loadTranslator( const CalamaresUtils::Locale::Translation::Id& locale, const QString& prefix, QTranslator* translator )
loadTranslator( const Calamares::Locale::Translation::Id& locale, const QString& prefix, QTranslator* translator )
{
return ::tryLoad( translator, prefix, locale.name );
}

View File

@ -29,7 +29,7 @@ namespace CalamaresUtils
* @param locale the new locale (names as defined by Calamares).
* @param brandingTranslationsPrefix the branding path prefix, from Calamares::Branding.
*/
DLLEXPORT void installTranslator( const CalamaresUtils::Locale::Translation::Id& locale,
DLLEXPORT void installTranslator( const Calamares::Locale::Translation::Id& locale,
const QString& brandingTranslationsPrefix );
/** @brief Initializes the translations with the current system settings
@ -42,7 +42,7 @@ DLLEXPORT void installTranslator();
* QLocale passed in, because Calamares will munge some names and
* may remap translations.
*/
DLLEXPORT CalamaresUtils::Locale::Translation::Id translatorLocaleName();
DLLEXPORT Calamares::Locale::Translation::Id translatorLocaleName();
/** @brief Loads <prefix><locale> translations into the given @p translator
*
@ -58,7 +58,7 @@ DLLEXPORT CalamaresUtils::Locale::Translation::Id translatorLocaleName();
* @returns @c true on success
*/
DLLEXPORT bool
loadTranslator( const CalamaresUtils::Locale::Translation::Id& locale, const QString& prefix, QTranslator* translator );
loadTranslator( const Calamares::Locale::Translation::Id& locale, const QString& prefix, QTranslator* translator );
/** @brief Set @p allow to true to load translations from current dir.
*

View File

@ -399,7 +399,7 @@ Config::currentTimezoneName() const
static inline QString
localeLabel( const QString& s )
{
using CalamaresUtils::Locale::Translation;
using Calamares::Locale::Translation;
Translation lang( { s }, Translation::LabelFormat::AlwaysWithCountry );
return lang.label();

View File

@ -26,7 +26,7 @@
Config::Config( QObject* parent )
: QObject( parent )
, m_languages( CalamaresUtils::Locale::availableTranslations() )
, m_languages( Calamares::Locale::availableTranslations() )
, m_filtermodel( std::make_unique< QSortFilterProxyModel >() )
, m_requirementsChecker( std::make_unique< GeneralRequirements >( this ) )
{
@ -84,7 +84,7 @@ Config::retranslate()
emit warningMessageChanged( m_warningMessage );
}
CalamaresUtils::Locale::TranslationsModel*
Calamares::Locale::TranslationsModel*
Config::languagesModel() const
{
return m_languages;
@ -120,7 +120,7 @@ void
Config::initLanguages()
{
// Find the best initial translation
CalamaresUtils::Locale::Translation defaultTranslation;
Calamares::Locale::Translation defaultTranslation;
cDebug() << "Trying to match locale" << defaultTranslation.id();
int matchedLocaleIndex = m_languages->find( defaultTranslation.id() );
@ -172,7 +172,7 @@ void
Config::setCountryCode( const QString& countryCode )
{
m_countryCode = countryCode;
setLocaleIndex( CalamaresUtils::Locale::availableTranslations()->find( m_countryCode ) );
setLocaleIndex( Calamares::Locale::availableTranslations()->find( m_countryCode ) );
emit countryCodeChanged( m_countryCode );
}
@ -186,7 +186,7 @@ Config::setLanguageIcon( const QString& languageIcon )
void
Config::setLocaleIndex( int index )
{
if ( index == m_localeIndex || index > CalamaresUtils::Locale::availableTranslations()->rowCount( QModelIndex() )
if ( index == m_localeIndex || index > Calamares::Locale::availableTranslations()->rowCount( QModelIndex() )
|| index < 0 )
{
return;
@ -347,7 +347,7 @@ setCountry( Config* config, const QString& countryCode, CalamaresUtils::GeoIP::H
return;
}
auto c_l = CalamaresUtils::Locale::countryData( countryCode );
auto c_l = Calamares::Locale::countryData( countryCode );
if ( c_l.first == QLocale::Country::AnyCountry )
{
cDebug() << "Unusable country code" << countryCode;
@ -356,7 +356,7 @@ setCountry( Config* config, const QString& countryCode, CalamaresUtils::GeoIP::H
}
else
{
int r = CalamaresUtils::Locale::availableTranslations()->find( countryCode );
int r = Calamares::Locale::availableTranslations()->find( countryCode );
if ( r < 0 )
{
cDebug() << "Unusable country code" << countryCode << "(no suitable translation)";

View File

@ -28,7 +28,7 @@ class Config : public QObject
* This is a list-model, with names and descriptions for the translations
* available to Calamares.
*/
Q_PROPERTY( CalamaresUtils::Locale::TranslationsModel* languagesModel READ languagesModel CONSTANT FINAL )
Q_PROPERTY( Calamares::Locale::TranslationsModel* languagesModel READ languagesModel CONSTANT FINAL )
/** @brief The requirements (from modules) and their checked-status
*
* The model grows rows over time as each module is checked and its
@ -95,7 +95,7 @@ public:
QString warningMessage() const;
public slots:
CalamaresUtils::Locale::TranslationsModel* languagesModel() const;
Calamares::Locale::TranslationsModel* languagesModel() const;
void retranslate();
///@brief The **global** requirements model, from ModuleManager
@ -122,7 +122,7 @@ signals:
private:
void initLanguages();
CalamaresUtils::Locale::TranslationsModel* m_languages = nullptr;
Calamares::Locale::TranslationsModel* m_languages = nullptr;
std::unique_ptr< QSortFilterProxyModel > m_filtermodel;
std::unique_ptr< GeneralRequirements > m_requirementsChecker;

View File

@ -222,5 +222,5 @@ LocaleTwoColumnDelegate::paint( QPainter* painter, const QStyleOptionViewItem& o
Qt::AlignRight | Qt::AlignVCenter,
option.palette,
false,
index.data( CalamaresUtils::Locale::TranslationsModel::EnglishLabelRole ).toString() );
index.data( Calamares::Locale::TranslationsModel::EnglishLabelRole ).toString() );
}

View File

@ -63,7 +63,7 @@ private:
Ui::WelcomePage* ui;
CheckerContainer* m_checkingWidget;
CalamaresUtils::Locale::TranslationsModel* m_languages;
Calamares::Locale::TranslationsModel* m_languages;
Config* m_conf;
};