From bfbfeef253e109262e5d1ca380623f84209c6590 Mon Sep 17 00:00:00 2001 From: Laurent Montel Date: Tue, 30 Jan 2018 07:44:29 +0100 Subject: [PATCH] Const'ify. Clean forward declaration --- applets/appmenu/lib/appmenuapplet.cpp | 11 ++++++----- applets/appmenu/lib/appmenuapplet.h | 1 - applets/appmenu/plugin/appmenumodel.cpp | 4 ++-- applets/digital-clock/plugin/digitalclockplugin.h | 1 - applets/digital-clock/plugin/timezonemodel.cpp | 6 +++--- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/applets/appmenu/lib/appmenuapplet.cpp b/applets/appmenu/lib/appmenuapplet.cpp index 082ead3d4..60b84ba26 100644 --- a/applets/appmenu/lib/appmenuapplet.cpp +++ b/applets/appmenu/lib/appmenuapplet.cpp @@ -36,8 +36,9 @@ #include int AppMenuApplet::s_refs = 0; - -static const QString s_viewService(QStringLiteral("org.kde.kappmenuview")); +namespace { +QString viewService() { return QStringLiteral("org.kde.kappmenuview"); } +} AppMenuApplet::AppMenuApplet(QObject *parent, const QVariantList &data) : Plasma::Applet(parent, data) @@ -45,7 +46,7 @@ AppMenuApplet::AppMenuApplet(QObject *parent, const QVariantList &data) ++s_refs; //if we're the first, regster the service if (s_refs == 1) { - QDBusConnection::sessionBus().interface()->registerService(s_viewService, + QDBusConnection::sessionBus().interface()->registerService(viewService(), QDBusConnectionInterface::QueueService, QDBusConnectionInterface::DontAllowReplacement); } @@ -60,12 +61,12 @@ AppMenuApplet::AppMenuApplet(QObject *parent, const QVariantList &data) if (destroyed) { //if we were the last, unregister if (--s_refs == 0) { - QDBusConnection::sessionBus().interface()->unregisterService(s_viewService); + QDBusConnection::sessionBus().interface()->unregisterService(viewService()); } } else { //if we're the first, regster the service if (++s_refs == 1) { - QDBusConnection::sessionBus().interface()->registerService(s_viewService, + QDBusConnection::sessionBus().interface()->registerService(viewService(), QDBusConnectionInterface::QueueService, QDBusConnectionInterface::DontAllowReplacement); } diff --git a/applets/appmenu/lib/appmenuapplet.h b/applets/appmenu/lib/appmenuapplet.h index 8613b3b6d..53f87aa03 100644 --- a/applets/appmenu/lib/appmenuapplet.h +++ b/applets/appmenu/lib/appmenuapplet.h @@ -24,7 +24,6 @@ #include #include -class KDBusMenuImporter; class QQuickItem; class QMenu; class AppMenuModel; diff --git a/applets/appmenu/plugin/appmenumodel.cpp b/applets/appmenu/plugin/appmenumodel.cpp index 3b41ec6e2..0c5da77e2 100644 --- a/applets/appmenu/plugin/appmenumodel.cpp +++ b/applets/appmenu/plugin/appmenumodel.cpp @@ -221,8 +221,8 @@ void AppMenuModel::onActiveWindowChanged(WId id) QHash AppMenuModel::roleNames() const { QHash roleNames; - roleNames[MenuRole] = "activeMenu"; - roleNames[ActionRole] = "activeActions"; + roleNames[MenuRole] = QByteArrayLiteral("activeMenu"); + roleNames[ActionRole] = QByteArrayLiteral("activeActions"); return roleNames; } diff --git a/applets/digital-clock/plugin/digitalclockplugin.h b/applets/digital-clock/plugin/digitalclockplugin.h index 486ab05f5..1d5d678d3 100644 --- a/applets/digital-clock/plugin/digitalclockplugin.h +++ b/applets/digital-clock/plugin/digitalclockplugin.h @@ -22,7 +22,6 @@ #include -class QQmlEngine; class DigitalClockPlugin : public QQmlExtensionPlugin { Q_OBJECT diff --git a/applets/digital-clock/plugin/timezonemodel.cpp b/applets/digital-clock/plugin/timezonemodel.cpp index d19b3fbe6..1af838cb3 100644 --- a/applets/digital-clock/plugin/timezonemodel.cpp +++ b/applets/digital-clock/plugin/timezonemodel.cpp @@ -132,7 +132,7 @@ void TimeZoneModel::update() m_data.clear(); QTimeZone localZone = QTimeZone(QTimeZone::systemTimeZoneId()); - QStringList data = QString::fromUtf8(localZone.id()).split(QLatin1Char('/')); + const QStringList data = QString::fromUtf8(localZone.id()).split(QLatin1Char('/')); TimeZoneData local; local.id = QStringLiteral("Local"); @@ -146,7 +146,7 @@ void TimeZoneModel::update() QStringList cities; QHash zonesByCity; - QList systemTimeZones = QTimeZone::availableTimeZoneIds(); + const QList systemTimeZones = QTimeZone::availableTimeZoneIds(); for (auto it = systemTimeZones.constBegin(); it != systemTimeZones.constEnd(); ++it) { const QTimeZone zone(*it); @@ -170,7 +170,7 @@ void TimeZoneModel::update() comment = i18n(comment.toUtf8()); } - QStringList cityCountryContinent = key.split(QLatin1Char('|')); + const QStringList cityCountryContinent = key.split(QLatin1Char('|')); TimeZoneData newData; newData.id = timeZone.id();