Commit ce776f82 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Modernize code

parent 172b1271
Pipeline #100492 passed with stage
in 3 minutes and 36 seconds
......@@ -43,8 +43,7 @@ void GrantleeThemeManagerTest::initTestCase()
void GrantleeThemeManagerTest::updateActionList()
{
KActionCollection coll(this);
GrantleeTheme::ThemeManager *manager(
new GrantleeTheme::ThemeManager(QStringLiteral("Stuff"), QStringLiteral("filename.testdesktop"), &coll, QStringLiteral("themes")));
auto manager(new GrantleeTheme::ThemeManager(QStringLiteral("Stuff"), QStringLiteral("filename.testdesktop"), &coll, QStringLiteral("themes")));
QCOMPARE(manager->themes().count(), 2);
QVERIFY(!manager->actionForTheme()); // Bug? No "default" theme.
......@@ -68,8 +67,7 @@ void GrantleeThemeManagerTest::updateActionList()
void GrantleeThemeManagerTest::destructionOrderTest()
{
KActionCollection coll(this);
GrantleeTheme::ThemeManager *manager(
new GrantleeTheme::ThemeManager(QStringLiteral("Stuff"), QStringLiteral("filename.testdesktop"), &coll, QStringLiteral("themes")));
auto manager(new GrantleeTheme::ThemeManager(QStringLiteral("Stuff"), QStringLiteral("filename.testdesktop"), &coll, QStringLiteral("themes")));
QCOMPARE(manager->themes().count(), 2);
QVERIFY(!manager->actionForTheme()); // Bug? No "default" theme.
......
......@@ -27,9 +27,7 @@ GrantleeThemeTest::GrantleeThemeTest(QObject *parent)
qputenv("XDG_DATA_DIRS", GRANTLEETHEME_DATA_DIR);
}
GrantleeThemeTest::~GrantleeThemeTest()
{
}
GrantleeThemeTest::~GrantleeThemeTest() = default;
void GrantleeThemeTest::shouldHaveDefaultValue()
{
......
......@@ -20,9 +20,7 @@ GrantleeKi18nLocalizer::GrantleeKi18nLocalizer()
{
}
GrantleeKi18nLocalizer::~GrantleeKi18nLocalizer()
{
}
GrantleeKi18nLocalizer::~GrantleeKi18nLocalizer() = default;
QString GrantleeKi18nLocalizer::processArguments(const KLocalizedString &kstr, const QVariantList &arguments) const
{
......
......@@ -29,22 +29,10 @@ ThemePrivate::ThemePrivate()
}
ThemePrivate::ThemePrivate(const ThemePrivate &other)
: QSharedData(other)
, displayExtraVariables(other.displayExtraVariables)
, themeFileName(other.themeFileName)
, description(other.description)
, name(other.name)
, dirName(other.dirName)
, absolutePaths(other.absolutePaths)
, author(other.author)
, email(other.email)
, loader(other.loader)
{
}
ThemePrivate::~ThemePrivate()
{
}
= default;
ThemePrivate::~ThemePrivate() = default;
void ThemePrivate::setupEngine()
{
......@@ -121,13 +109,10 @@ Theme::Theme(const QString &themePath, const QString &dirName, const QString &de
}
Theme::Theme(const Theme &other)
: d(other.d)
{
}
Theme::~Theme()
{
}
= default;
Theme::~Theme() = default;
bool Theme::operator==(const Theme &other) const
{
......@@ -206,7 +191,7 @@ QString Theme::render(const QString &templateName, const QVariantHash &data, con
if (!d->loader->canLoadTemplate(templateName)) {
qCWarning(GRANTLEETHEME_LOG) << "Cannot load template" << templateName
<< ", please check your installation. Tried in these dirs:" << d->loader->templateDirs();
return QString();
return {};
}
Grantlee::Template tpl = d->loader->loadByName(templateName, ThemePrivate::sEngine);
......
......@@ -14,13 +14,9 @@ using namespace GrantleeTheme;
class GrantleeTheme::EnginePrivate
{
public:
EnginePrivate()
{
}
EnginePrivate() = default;
~EnginePrivate()
{
}
~EnginePrivate() = default;
QWeakPointer<GrantleeKi18nLocalizer> localizer;
};
......
......@@ -176,7 +176,7 @@ public:
while (i.hasNext()) {
i.next();
GrantleeTheme::Theme theme = i.value();
KToggleAction *act = new KToggleAction(theme.name(), q);
auto act = new KToggleAction(theme.name(), q);
act->setToolTip(theme.description());
act->setData(theme.dirName());
if (theme.dirName() == themeActivated) {
......@@ -316,7 +316,7 @@ QStringList ThemeManager::displayExtraVariables(const QString &themename) const
return i.value().displayExtraVariables();
}
}
return QStringList();
return {};
}
GrantleeTheme::Theme ThemeManager::theme(const QString &themeName)
......@@ -355,7 +355,7 @@ QString ThemeManager::pathFromThemes(const QString &themesRelativePath, const QS
}
}
}
return QString();
return {};
}
GrantleeTheme::Theme ThemeManager::loadTheme(const QString &themePath, const QString &dirName, const QString &defaultDesktopFileName)
......
......@@ -18,9 +18,7 @@ IconTag::IconTag(QObject *parent)
{
}
IconTag::~IconTag()
{
}
IconTag::~IconTag() = default;
Grantlee::Node *IconTag::getNode(const QString &tagContent, Grantlee::Parser *p) const
{
......@@ -86,9 +84,7 @@ IconNode::IconNode(const QString &iconName, int sizeOrGroup, const QString &altT
{
}
IconNode::~IconNode()
{
}
IconNode::~IconNode() = default;
void IconNode::render(Grantlee::OutputStream *stream, Grantlee::Context *c) const
{
......
......@@ -20,9 +20,7 @@ KDEGrantleePlugin::KDEGrantleePlugin(QObject *parent)
Palette::registerMetaType();
}
KDEGrantleePlugin::~KDEGrantleePlugin()
{
}
KDEGrantleePlugin::~KDEGrantleePlugin() = default;
QHash<QString, Grantlee::AbstractNodeFactory *> KDEGrantleePlugin::nodeFactories(const QString &name)
{
......
......@@ -25,7 +25,7 @@ Grantlee::Template QtResourceTemplateLoader::loadByName(const QString &fileName,
QFile file;
file.setFileName(fileName);
if (!file.exists() || !file.open(QIODevice::ReadOnly | QIODevice::Text)) {
return Grantlee::Template();
return {};
}
QTextStream fstream(&file);
......
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