Commit bdfee8ae authored by Laurent Montel's avatar Laurent Montel 😁

Coding style

parent 23ef443b
......@@ -36,7 +36,6 @@ class GrantleeThemeManagerTest : public QObject
private Q_SLOTS:
void initTestCase();
void updateActionList();
};
void GrantleeThemeManagerTest::initTestCase()
......
......@@ -39,7 +39,6 @@ GrantleeThemeTest::GrantleeThemeTest(QObject *parent)
GrantleeThemeTest::~GrantleeThemeTest()
{
}
void GrantleeThemeTest::shouldHaveDefaultValue()
......
......@@ -37,8 +37,7 @@ GrantleeKi18nLocalizer::~GrantleeKi18nLocalizer()
{
}
QString GrantleeKi18nLocalizer::processArguments(const KLocalizedString &kstr,
const QVariantList &arguments) const
QString GrantleeKi18nLocalizer::processArguments(const KLocalizedString &kstr, const QVariantList &arguments) const
{
KLocalizedString str = kstr;
for (auto iter = arguments.cbegin(), end = arguments.cend(); iter != end; ++iter) {
......@@ -94,15 +93,13 @@ QString GrantleeKi18nLocalizer::localizeString(const QString &string, const QVar
return processArguments(str, arguments);
}
QString GrantleeKi18nLocalizer::localizePluralContextString(const QString &string, const QString &pluralForm,
const QString &context, const QVariantList &arguments) const
QString GrantleeKi18nLocalizer::localizePluralContextString(const QString &string, const QString &pluralForm, const QString &context, const QVariantList &arguments) const
{
const KLocalizedString str = kxi18ncp(qPrintable(context), qPrintable(string), qPrintable(pluralForm));
return processArguments(str, arguments);
}
QString GrantleeKi18nLocalizer::localizePluralString(const QString &string, const QString &pluralForm,
const QVariantList &arguments) const
QString GrantleeKi18nLocalizer::localizePluralString(const QString &string, const QString &pluralForm, const QVariantList &arguments) const
{
const KLocalizedString str = kxi18np(qPrintable(string), qPrintable(pluralForm));
return processArguments(str, arguments);
......
......@@ -27,8 +27,7 @@
#include <QVariantHash>
class KLocalizedString;
namespace GrantleeTheme
{
namespace GrantleeTheme {
class GRANTLEETHEME_EXPORT GrantleeKi18nLocalizer : public Grantlee::QtLocalizer
{
public:
......@@ -37,13 +36,10 @@ public:
// Only reimplement string localization to use KLocalizedString instead of
// tr(), the remaining methods use QLocale internally, so we can reuse them
QString localizeContextString(const QString &string, const QString &context,
const QVariantList &arguments) const override;
QString localizeContextString(const QString &string, const QString &context, const QVariantList &arguments) const override;
QString localizeString(const QString &string, const QVariantList &arguments) const override;
QString localizePluralContextString(const QString &string, const QString &pluralForm,
const QString &context, const QVariantList &arguments) const override;
QString localizePluralString(const QString &string, const QString &pluralForm,
const QVariantList &arguments) const override;
QString localizePluralContextString(const QString &string, const QString &pluralForm, const QString &context, const QVariantList &arguments) const override;
QString localizePluralString(const QString &string, const QString &pluralForm, const QVariantList &arguments) const override;
// Only exception, Grantlee's implementation is not using QLocale for this
// for some reason
......@@ -51,11 +47,9 @@ public:
QString currentLocale() const override;
void setApplicationDomain(const QByteArray &domain);
private:
QString processArguments(const KLocalizedString &str,
const QVariantList &arguments) const;
QString processArguments(const KLocalizedString &str, const QVariantList &arguments) const;
QByteArray mApplicationDomain;
};
}
......
......@@ -88,23 +88,21 @@ Grantlee::Context ThemePrivate::createContext(const QVariantHash &data, const QB
return ctx;
}
QString ThemePrivate::errorTemplate(const QString &reason,
const QString &origTemplateName,
const Grantlee::Template &failedTemplate)
QString ThemePrivate::errorTemplate(const QString &reason, const QString &origTemplateName, const Grantlee::Template &failedTemplate)
{
Grantlee::Template tpl = sEngine->newTemplate(
QStringLiteral("<h1>{{ error }}</h1>\n"
"<b>%1:</b> {{ templateName }}<br>\n"
"<b>%2:</b> {{ errorMessage }}")
.arg(i18n("Template"), i18n("Error message")),
QStringLiteral("TemplateError"));
QStringLiteral("<h1>{{ error }}</h1>\n"
"<b>%1:</b> {{ templateName }}<br>\n"
"<b>%2:</b> {{ errorMessage }}")
.arg(i18n("Template"), i18n("Error message")),
QStringLiteral("TemplateError"));
Grantlee::Context ctx = createContext();
ctx.insert(QStringLiteral("error"), reason);
ctx.insert(QStringLiteral("templateName"), origTemplateName);
const QString errorString = failedTemplate
? failedTemplate->errorString()
: i18n("(null template)");
? failedTemplate->errorString()
: i18n("(null template)");
ctx.insert(QStringLiteral("errorMessage"), errorString);
return tpl->render(&ctx);
}
......
......@@ -26,9 +26,7 @@
class GrantleeThemeTest;
namespace GrantleeTheme
{
namespace GrantleeTheme {
class ThemeManager;
class ThemePrivate;
......
......@@ -25,9 +25,7 @@
#include <grantlee/templateloader.h>
#include <grantlee/engine.h>
namespace GrantleeTheme
{
namespace GrantleeTheme {
class GRANTLEETHEME_NO_EXPORT ThemePrivate : public QSharedData
{
public:
......@@ -38,9 +36,7 @@ public:
static void setupEngine();
void setupLoader();
Grantlee::Context createContext(const QVariantHash &data = QVariantHash(), const QByteArray &applicationDomain = QByteArray());
QString errorTemplate(const QString &reason,
const QString &templateName,
const Grantlee::Template &errorTemplate);
QString errorTemplate(const QString &reason, const QString &templateName, const Grantlee::Template &errorTemplate);
QStringList displayExtraVariables;
QString themeFileName;
......@@ -56,7 +52,6 @@ public:
static QSharedPointer<GrantleeKi18nLocalizer> sLocalizer;
static Grantlee::Engine *sEngine;
};
}
#endif
......@@ -36,7 +36,6 @@ public:
QWeakPointer<GrantleeKi18nLocalizer> localizer;
};
Engine::Engine(QObject *parent)
: Grantlee::Engine(parent)
, d(new GrantleeTheme::EnginePrivate)
......
......@@ -24,7 +24,6 @@
#include "grantleetheme_export.h"
namespace GrantleeTheme {
class GrantleeKi18nLocalizer;
class EnginePrivate;
class GRANTLEETHEME_EXPORT Engine : public Grantlee::Engine
......@@ -40,7 +39,6 @@ public:
private:
EnginePrivate *const d;
};
}
#endif
......@@ -40,16 +40,13 @@ using namespace GrantleeTheme;
class Q_DECL_HIDDEN ThemeManager::Private
{
public:
Private(const QString &type,
const QString &desktopFileName,
KActionCollection *ac,
const QString &relativePath, ThemeManager *qq)
: applicationType(type),
defaultDesktopFileName(desktopFileName),
actionGroup(0),
menu(0),
actionCollection(ac),
q(qq)
Private(const QString &type, const QString &desktopFileName, KActionCollection *ac, const QString &relativePath, ThemeManager *qq)
: applicationType(type)
, defaultDesktopFileName(desktopFileName)
, actionGroup(0)
, menu(0)
, actionCollection(ac)
, q(qq)
{
watch = new KDirWatch(q);
initThemesDirectories(relativePath);
......@@ -249,7 +246,6 @@ public:
void initThemesDirectories(const QString &themesRelativePath)
{
if (!themesRelativePath.isEmpty()) {
themesDirectories = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, themesRelativePath, QStandardPaths::LocateDirectory);
if (themesDirectories.count() < 2) {
//Make sure to add local directory
......@@ -260,6 +256,7 @@ public:
}
}
}
QString applicationType;
QString defaultDesktopFileName;
QString downloadConfigFileName;
......@@ -277,11 +274,7 @@ public:
ThemeManager *q;
};
ThemeManager::ThemeManager(const QString &applicationType,
const QString &defaultDesktopFileName,
KActionCollection *actionCollection,
const QString &path,
QObject *parent)
ThemeManager::ThemeManager(const QString &applicationType, const QString &defaultDesktopFileName, KActionCollection *actionCollection, const QString &path, QObject *parent)
: QObject(parent)
, d(new Private(applicationType, defaultDesktopFileName, actionCollection, path, this))
{
......@@ -340,9 +333,7 @@ void ThemeManager::setDownloadNewStuffConfigFile(const QString &configFileName)
d->downloadConfigFileName = configFileName;
}
QString ThemeManager::pathFromThemes(const QString &themesRelativePath,
const QString &themeName,
const QString &defaultDesktopFileName)
QString ThemeManager::pathFromThemes(const QString &themesRelativePath, const QString &themeName, const QString &defaultDesktopFileName)
{
QStringList themesDirectories;
if (!themesRelativePath.isEmpty()) {
......@@ -371,9 +362,7 @@ QString ThemeManager::pathFromThemes(const QString &themesRelativePath,
return QString();
}
GrantleeTheme::Theme ThemeManager::loadTheme(const QString &themePath,
const QString &dirName,
const QString &defaultDesktopFileName)
GrantleeTheme::Theme ThemeManager::loadTheme(const QString &themePath, const QString &dirName, const QString &defaultDesktopFileName)
{
const GrantleeTheme::Theme theme(themePath, dirName, defaultDesktopFileName);
return theme;
......
......@@ -27,17 +27,12 @@ class KActionCollection;
class KToggleAction;
class KActionMenu;
namespace GrantleeTheme
{
namespace GrantleeTheme {
class GRANTLEETHEME_EXPORT ThemeManager : public QObject
{
Q_OBJECT
public:
explicit ThemeManager(const QString &themeType,
const QString &defaultDesktopFileName,
KActionCollection *actionCollection = nullptr,
const QString &path = QString(),
QObject *parent = nullptr);
explicit ThemeManager(const QString &themeType, const QString &defaultDesktopFileName, KActionCollection *actionCollection = nullptr, const QString &path = QString(), QObject *parent = nullptr);
~ThemeManager();
QMap<QString, GrantleeTheme::Theme> themes() const;
......@@ -57,11 +52,8 @@ public:
QString configuredThemeName() const;
static QString configuredThemeName(const QString &themeType);
static QString pathFromThemes(const QString &path, const QString &themeName,
const QString &defaultDesktopFilename);
static GrantleeTheme::Theme loadTheme(const QString &themePath,
const QString &dirName,
const QString &defaultDesktopFilename);
static QString pathFromThemes(const QString &path, const QString &themeName, const QString &defaultDesktopFilename);
static GrantleeTheme::Theme loadTheme(const QString &themePath, const QString &dirName, const QString &defaultDesktopFilename);
Q_SIGNALS:
void themesChanged();
......
......@@ -23,7 +23,6 @@
#include <grantlee/parser.h>
#include <grantlee/variable.h>
#include <KIconLoader>
IconTag::IconTag(QObject *parent)
......@@ -40,19 +39,18 @@ Grantlee::Node *IconTag::getNode(const QString &tagContent, Grantlee::Parser *p)
Q_UNUSED(p);
static QHash<QString, int> sizeOrGroupLookup
= { { QStringLiteral("desktop"), KIconLoader::Desktop },
{ QStringLiteral("toolbar"), KIconLoader::Toolbar },
{ QStringLiteral("maintoolbar"), KIconLoader::MainToolbar },
{ QStringLiteral("small"), KIconLoader::Small },
{ QStringLiteral("panel"), KIconLoader::Panel },
{ QStringLiteral("dialog"), KIconLoader::Dialog },
{ QStringLiteral("sizesmall"), KIconLoader::SizeSmall },
{ QStringLiteral("sizesmallmedium"), KIconLoader::SizeSmallMedium },
{ QStringLiteral("sizemedium"), KIconLoader::SizeMedium },
{ QStringLiteral("sizelarge"), KIconLoader::SizeLarge },
{ QStringLiteral("sizehuge"), KIconLoader::SizeHuge },
{ QStringLiteral("sizeenormous"), KIconLoader::SizeEnormous }
};
= { { QStringLiteral("desktop"), KIconLoader::Desktop },
{ QStringLiteral("toolbar"), KIconLoader::Toolbar },
{ QStringLiteral("maintoolbar"), KIconLoader::MainToolbar },
{ QStringLiteral("small"), KIconLoader::Small },
{ QStringLiteral("panel"), KIconLoader::Panel },
{ QStringLiteral("dialog"), KIconLoader::Dialog },
{ QStringLiteral("sizesmall"), KIconLoader::SizeSmall },
{ QStringLiteral("sizesmallmedium"), KIconLoader::SizeSmallMedium },
{ QStringLiteral("sizemedium"), KIconLoader::SizeMedium },
{ QStringLiteral("sizelarge"), KIconLoader::SizeLarge },
{ QStringLiteral("sizehuge"), KIconLoader::SizeHuge },
{ QStringLiteral("sizeenormous"), KIconLoader::SizeEnormous }};
const QStringList parts = smartSplit(tagContent);
const int partsSize = parts.size();
......@@ -139,8 +137,8 @@ void IconNode::render(Grantlee::OutputStream *stream, Grantlee::Context *c) cons
const QString html = QStringLiteral("<img src=\"file://%1\" align=\"top\" height=\"%2\" width=\"%2\" alt=\"%3\" title=\"%4\" />")
.arg(KIconLoader::global()->iconPath(iconName, mSizeOrGroup < KIconLoader::LastGroup ? mSizeOrGroup : -mSizeOrGroup))
.arg(mSizeOrGroup < KIconLoader::LastGroup ?
IconSize(static_cast<KIconLoader::Group>(mSizeOrGroup))
.arg(mSizeOrGroup < KIconLoader::LastGroup
? IconSize(static_cast<KIconLoader::Group>(mSizeOrGroup))
: mSizeOrGroup)
.arg(altText.isEmpty() ? iconName : altText, altText); // title is intentionally blank if no alt is provided
(*stream) << Grantlee::SafeString(html, Grantlee::SafeString::IsSafe);
......
......@@ -22,8 +22,7 @@
#include <grantlee/taglibraryinterface.h>
class KDEGrantleePlugin : public QObject
, public Grantlee::TagLibraryInterface
class KDEGrantleePlugin : public QObject, public Grantlee::TagLibraryInterface
{
Q_OBJECT
Q_INTERFACES(Grantlee::TagLibraryInterface)
......@@ -33,7 +32,7 @@ public:
explicit KDEGrantleePlugin(QObject *parent = nullptr);
~KDEGrantleePlugin();
QHash<QString, Grantlee::Filter *> filters(const QString &name) override;
QHash<QString, Grantlee::Filter *> filters(const QString &name) override;
QHash<QString, Grantlee::AbstractNodeFactory *> nodeFactories(const QString &name) override;
};
......
......@@ -17,7 +17,6 @@
*
*/
#include "qtresourcetemplateloader.h"
#include <QFile>
......@@ -29,7 +28,6 @@ using namespace GrantleeTheme;
QtResourceTemplateLoader::QtResourceTemplateLoader(const QSharedPointer<Grantlee::AbstractLocalizer> localizer)
: Grantlee::FileSystemTemplateLoader(localizer)
{
}
Grantlee::Template QtResourceTemplateLoader::loadByName(const QString &fileName, const Grantlee::Engine *engine) const
......
......@@ -21,8 +21,7 @@
#define QTRESOURCETEMPLATELOADER_H
#include "grantlee/templateloader.h"
#include "grantleetheme_export.h"
namespace GrantleeTheme
{
namespace GrantleeTheme {
class GRANTLEETHEME_EXPORT QtResourceTemplateLoader : public Grantlee::FileSystemTemplateLoader
{
public:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment