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

Use QStringLiteral/nullptr/explicit

parent 935b6190
......@@ -54,11 +54,11 @@ QVariantMap createActionItem(const QString &label, const QString &actionId, cons
{
QVariantMap map;
map["text"] = label;
map["actionId"] = actionId;
map[QStringLiteral("text")] = label;
map[QStringLiteral("actionId")] = actionId;
if (argument.isValid()) {
map["actionArgument"] = argument;
map[QStringLiteral("actionArgument")] = argument;
}
return map;
......@@ -68,8 +68,8 @@ QVariantMap createTitleActionItem(const QString &label)
{
QVariantMap map;
map["text"] = label;
map["type"] = "title";
map[QStringLiteral("text")] = label;
map[QStringLiteral("type")] = QStringLiteral("title");
return map;
}
......@@ -78,7 +78,7 @@ QVariantMap createSeparatorActionItem()
{
QVariantMap map;
map["type"] = "separator";
map[QStringLiteral("type")] = QStringLiteral("separator");
return map;
}
......@@ -87,15 +87,15 @@ QVariantList createActionListForFileItem(const KFileItem &fileItem)
{
QVariantList list;
KService::List services = KMimeTypeTrader::self()->query(fileItem.mimetype(), "Application");
KService::List services = KMimeTypeTrader::self()->query(fileItem.mimetype(), QStringLiteral("Application"));
if (!services.isEmpty()) {
list << createTitleActionItem(i18n("Open with:"));
foreach (const KService::Ptr service, services) {
const QString text = service->name().replace('&', "&&");
QVariantMap item = createActionItem(text, "_kicker_fileItem_openWith", service->entryPath());
item["icon"] = service->icon();
const QString text = service->name().replace(QLatin1Char('&'), QStringLiteral("&&"));
QVariantMap item = createActionItem(text, QStringLiteral("_kicker_fileItem_openWith"), service->entryPath());
item[QStringLiteral("icon")] = service->icon();
list << item;
}
......@@ -103,14 +103,14 @@ QVariantList createActionListForFileItem(const KFileItem &fileItem)
list << createSeparatorActionItem();
}
list << createActionItem(i18n("Properties"), "_kicker_fileItem_properties");
list << createActionItem(i18n("Properties"), QStringLiteral("_kicker_fileItem_properties"));
return list;
}
bool handleFileItemAction(const KFileItem &fileItem, const QString &actionId, const QVariant &argument, bool *close)
{
if (actionId == "_kicker_fileItem_properties") {
if (actionId == QLatin1String("_kicker_fileItem_properties")) {
KPropertiesDialog *dlg = new KPropertiesDialog(fileItem, QApplication::activeWindow());
dlg->setAttribute(Qt::WA_DeleteOnClose);
dlg->show();
......@@ -120,7 +120,7 @@ bool handleFileItemAction(const KFileItem &fileItem, const QString &actionId, co
return true;
}
if (actionId == "_kicker_fileItem_openWith") {
if (actionId == QLatin1String("_kicker_fileItem_openWith")) {
const QString path = argument.toString();
const KService::Ptr service = KService::serviceByDesktopPath(path);
......@@ -146,15 +146,15 @@ QVariantList createAddLauncherActionList(QObject *appletInterface, const KServic
}
if (ContainmentInterface::mayAddLauncher(appletInterface, ContainmentInterface::Desktop)) {
actionList << Kicker::createActionItem(i18n("Add to Desktop"), "addToDesktop");
actionList << Kicker::createActionItem(i18n("Add to Desktop"), QStringLiteral("addToDesktop"));
}
if (ContainmentInterface::mayAddLauncher(appletInterface, ContainmentInterface::Panel)) {
actionList << Kicker::createActionItem(i18n("Add to Panel (Widget)"), "addToPanel");
actionList << Kicker::createActionItem(i18n("Add to Panel (Widget)"), QStringLiteral("addToPanel"));
}
if (service && ContainmentInterface::mayAddLauncher(appletInterface, ContainmentInterface::TaskManager, service->entryPath())) {
actionList << Kicker::createActionItem(i18n("Pin to Task Manager"), "addToTaskManager");
actionList << Kicker::createActionItem(i18n("Pin to Task Manager"), QStringLiteral("addToTaskManager"));
}
return actionList;
......@@ -190,7 +190,7 @@ QString storageIdFromService(KService::Ptr service)
{
QString storageId = service->storageId();
if (storageId.endsWith(".desktop")) {
if (storageId.endsWith(QLatin1String(".desktop"))) {
storageId = storageId.left(storageId.length() - 8);
}
......@@ -211,7 +211,7 @@ QVariantList jumpListActions(KService::Ptr service)
continue;
}
QVariantMap item = createActionItem(action.text(), "_kicker_jumpListAction", action.exec());
QVariantMap item = createActionItem(action.text(), QStringLiteral("_kicker_jumpListAction"), action.exec());
item[QStringLiteral("icon")] = action.icon();
list << item;
......@@ -260,12 +260,12 @@ QVariantList recentDocumentActions(KService::Ptr service)
continue;
}
if (list.count() == 0) {
if (list.isEmpty()) {
list << createTitleActionItem(i18n("Recent Documents"));
}
QVariantMap item = createActionItem(url.fileName(), "_kicker_recentDocument", resource);
item["icon"] = fileItem.iconName();
QVariantMap item = createActionItem(url.fileName(), QStringLiteral("_kicker_recentDocument"), resource);
item[QStringLiteral("icon")] = fileItem.iconName();
list << item;
......@@ -273,7 +273,7 @@ QVariantList recentDocumentActions(KService::Ptr service)
}
if (list.count()) {
list << createActionItem(i18n("Forget Recent Documents"), "_kicker_forgetRecentDocuments");
list << createActionItem(i18n("Forget Recent Documents"), QStringLiteral("_kicker_forgetRecentDocuments"));
}
return list;
......@@ -285,7 +285,7 @@ bool handleRecentDocumentAction(KService::Ptr service, const QString &actionId,
return false;
}
if (actionId == "_kicker_forgetRecentDocuments") {
if (actionId == QLatin1String("_kicker_forgetRecentDocuments")) {
const QString storageId = storageIdFromService(service);
if (storageId.isEmpty()) {
......@@ -329,8 +329,8 @@ QVariantList editApplicationAction(const KService::Ptr &service)
QVariantList actionList;
if (canEditApplication(service)) {
QVariantMap editAction = Kicker::createActionItem(i18n("Edit Application..."), "editApplication");
editAction["icon"] = "kmenuedit"; // TODO: Using the KMenuEdit icon might be misleading.
QVariantMap editAction = Kicker::createActionItem(i18n("Edit Application..."), QStringLiteral("editApplication"));
editAction[QStringLiteral("icon")] = QStringLiteral("kmenuedit"); // TODO: Using the KMenuEdit icon might be misleading.
actionList << editAction;
}
......@@ -340,7 +340,7 @@ QVariantList editApplicationAction(const KService::Ptr &service)
bool handleEditApplicationAction(const QString &actionId, const KService::Ptr &service)
{
if (service && actionId == "editApplication" && canEditApplication(service)) {
if (service && actionId ==QLatin1String("editApplication") && canEditApplication(service)) {
Kicker::editApplication(service->entryPath(), service->menuId());
return true;
......@@ -389,7 +389,7 @@ QVariantList appstreamActions(const KService::Ptr &service)
bool handleAppstreamActions(const QString &actionId, const QVariant &argument)
{
if (actionId == "manageApplication") {
if (actionId == QLatin1String("manageApplication")) {
return QDesktopServices::openUrl(QUrl(argument.toString()));
}
......
......@@ -89,7 +89,7 @@ bool AppEntry::isValid() const
QIcon AppEntry::icon() const
{
if (m_icon.isNull()) {
m_icon = QIcon::fromTheme(m_service->icon(), QIcon::fromTheme("unknown"));
m_icon = QIcon::fromTheme(m_service->icon(), QIcon::fromTheme(QStringLiteral("unknown")));
}
return m_icon;
}
......@@ -171,11 +171,11 @@ QVariantList AppEntry::actions() const
QQmlPropertyMap *appletConfig = qobject_cast<QQmlPropertyMap *>(appletInterface->property("configuration").value<QObject *>());
if (appletConfig && appletConfig->contains("hiddenApplications") && qobject_cast<AppsModel *>(m_owner)) {
const QStringList &hiddenApps = appletConfig->value("hiddenApplications").toStringList();
if (appletConfig && appletConfig->contains(QLatin1String("hiddenApplications")) && qobject_cast<AppsModel *>(m_owner)) {
const QStringList &hiddenApps = appletConfig->value(QLatin1String("hiddenApplications")).toStringList();
if (!hiddenApps.contains(m_service->menuId())) {
actionList << Kicker::createActionItem(i18n("Hide Application"), "hideApplication");
actionList << Kicker::createActionItem(i18n("Hide Application"), QStringLiteral("hideApplication"));
}
}
......@@ -200,8 +200,8 @@ bool AppEntry::run(const QString& actionId, const QVariant &argument)
// TODO Once we depend on KDE Frameworks 5.24 and D1902 is merged, use KRun::runApplication instead
KRun::runService(*m_service, {}, nullptr, true, {}, KStartupInfo::createNewStartupIdForTimestamp(timeStamp));
KActivities::ResourceInstance::notifyAccessed(QUrl("applications:" + m_service->storageId()),
"org.kde.plasma.kicker");
KActivities::ResourceInstance::notifyAccessed(QUrl(QStringLiteral("applications:") + m_service->storageId()),
QStringLiteral("org.kde.plasma.kicker"));
return true;
}
......@@ -214,7 +214,7 @@ bool AppEntry::run(const QString& actionId, const QVariant &argument)
return true;
} else if (Kicker::handleAppstreamActions(actionId, argument)) {
return true;
} else if (actionId == "_kicker_jumpListAction") {
} else if (actionId == QLatin1String("_kicker_jumpListAction")) {
return KRun::run(argument.toString(), {}, nullptr, m_service->name(), m_service->icon());
}
......@@ -249,7 +249,7 @@ KService::Ptr AppEntry::defaultAppByName(const QString& name)
if (browser.isEmpty()) {
return KMimeTypeTrader::self()->preferredService(QLatin1String("text/html"));
} else if (browser.startsWith('!')) {
} else if (browser.startsWith(QLatin1Char('!'))) {
browser = browser.mid(1);
}
......@@ -282,7 +282,7 @@ AppGroupEntry::AppGroupEntry(AppsModel *parentModel, KServiceGroup::Ptr group,
QIcon AppGroupEntry::icon() const
{
if (m_icon.isNull()) {
m_icon = QIcon::fromTheme(m_group->icon(), QIcon::fromTheme("unknown"));
m_icon = QIcon::fromTheme(m_group->icon(), QIcon::fromTheme(QStringLiteral("unknown")));
}
return m_icon;
}
......
......@@ -45,7 +45,7 @@ AppsModel::AppsModel(const QString &entryPath, bool paginate, int pageSize, bool
, m_description(i18n("Applications"))
, m_entryPath(entryPath)
, m_staticEntryList(false)
, m_changeTimer(0)
, m_changeTimer(nullptr)
, m_flat(flat)
, m_sorted(sorted)
, m_appNameFormat(AppEntry::NameOnly)
......@@ -69,7 +69,7 @@ AppsModel::AppsModel(const QList<AbstractEntry *> entryList, bool deleteEntriesO
, m_description(i18n("Applications"))
, m_entryPath(QString())
, m_staticEntryList(true)
, m_changeTimer(0)
, m_changeTimer(nullptr)
, m_flat(true)
, m_sorted(true)
, m_appNameFormat(AppEntry::NameOnly)
......@@ -162,13 +162,13 @@ QVariant AppsModel::data(const QModelIndex &index, int role) const
if (!m_hiddenEntries.isEmpty()) {
actionList << Kicker::createSeparatorActionItem();
actionList << Kicker::createActionItem(i18n("Unhide Applications in this Submenu"), "unhideSiblingApplications");
actionList << Kicker::createActionItem(i18n("Unhide Applications in this Submenu"), QStringLiteral("unhideSiblingApplications"));
}
const AppsModel *appsModel = qobject_cast<const AppsModel *>(entry->childModel());
if (appsModel && !appsModel->hiddenEntries().isEmpty()) {
actionList << Kicker::createActionItem(i18n("Unhide Applications in '%1'", entry->name()), "unhideChildApplications");
actionList << Kicker::createActionItem(i18n("Unhide Applications in '%1'", entry->name()), QStringLiteral("unhideChildApplications"));
}
return actionList;
......@@ -196,21 +196,21 @@ bool AppsModel::trigger(int row, const QString &actionId, const QVariant &argume
AbstractEntry *entry = m_entryList.at(row);
if (actionId == "hideApplication" && entry->type() == AbstractEntry::RunnableType) {
if (actionId == QLatin1String("hideApplication") && entry->type() == AbstractEntry::RunnableType) {
QObject *appletInterface = rootModel()->property("appletInterface").value<QObject *>();
QQmlPropertyMap *appletConfig = qobject_cast<QQmlPropertyMap *>(appletInterface->property("configuration").value<QObject *>());
if (appletConfig && appletConfig->contains("hiddenApplications")) {
QStringList hiddenApps = appletConfig->value("hiddenApplications").toStringList();
if (appletConfig && appletConfig->contains(QLatin1String("hiddenApplications"))) {
QStringList hiddenApps = appletConfig->value(QLatin1String("hiddenApplications")).toStringList();
KService::Ptr service = static_cast<const AppEntry *>(entry)->service();
if (!hiddenApps.contains(service->menuId())) {
hiddenApps << service->menuId();
appletConfig->insert("hiddenApplications", hiddenApps);
appletConfig->insert(QLatin1String("hiddenApplications"), hiddenApps);
QMetaObject::invokeMethod(appletConfig, "valueChanged", Qt::DirectConnection,
Q_ARG(QString, "hiddenApplications"),
Q_ARG(QString, QStringLiteral("hiddenApplications")),
Q_ARG(QVariant, hiddenApps));
refresh();
......@@ -220,20 +220,20 @@ bool AppsModel::trigger(int row, const QString &actionId, const QVariant &argume
}
return false;
} else if (actionId == "unhideSiblingApplications") {
} else if (actionId == QLatin1String("unhideSiblingApplications")) {
QObject *appletInterface = rootModel()->property("appletInterface").value<QObject *>();
QQmlPropertyMap *appletConfig = qobject_cast<QQmlPropertyMap *>(appletInterface->property("configuration").value<QObject *>());
if (appletConfig && appletConfig->contains("hiddenApplications")) {
QStringList hiddenApps = appletConfig->value("hiddenApplications").toStringList();
if (appletConfig && appletConfig->contains(QLatin1String("hiddenApplications"))) {
QStringList hiddenApps = appletConfig->value(QLatin1String("hiddenApplications")).toStringList();
foreach(const QString& app, m_hiddenEntries) {
hiddenApps.removeOne(app);
}
appletConfig->insert("hiddenApplications", hiddenApps);
appletConfig->insert(QStringLiteral("hiddenApplications"), hiddenApps);
QMetaObject::invokeMethod(appletConfig, "valueChanged", Qt::DirectConnection,
Q_ARG(QString, "hiddenApplications"),
Q_ARG(QString, QStringLiteral("hiddenApplications")),
Q_ARG(QVariant, hiddenApps));
m_hiddenEntries.clear();
......@@ -244,12 +244,12 @@ bool AppsModel::trigger(int row, const QString &actionId, const QVariant &argume
}
return false;
} else if (actionId == "unhideChildApplications") {
} else if (actionId == QLatin1String("unhideChildApplications")) {
QObject *appletInterface = rootModel()->property("appletInterface").value<QObject *>();
QQmlPropertyMap *appletConfig = qobject_cast<QQmlPropertyMap *>(appletInterface->property("configuration").value<QObject *>());
if (entry->type() == AbstractEntry::GroupType
&& appletConfig && appletConfig->contains("hiddenApplications")) {
&& appletConfig && appletConfig->contains(QLatin1String("hiddenApplications"))) {
const AppsModel *appsModel = qobject_cast<const AppsModel *>(entry->childModel());
......@@ -257,15 +257,15 @@ bool AppsModel::trigger(int row, const QString &actionId, const QVariant &argume
return false;
}
QStringList hiddenApps = appletConfig->value("hiddenApplications").toStringList();
QStringList hiddenApps = appletConfig->value(QLatin1String("hiddenApplications")).toStringList();
foreach(const QString& app, appsModel->hiddenEntries()) {
hiddenApps.removeOne(app);
}
appletConfig->insert("hiddenApplications", hiddenApps);
appletConfig->insert(QStringLiteral("hiddenApplications"), hiddenApps);
QMetaObject::invokeMethod(appletConfig, "valueChanged", Qt::DirectConnection,
Q_ARG(QString, "hiddenApplications"),
Q_ARG(QString, QStringLiteral("hiddenApplications")),
Q_ARG(QVariant, hiddenApps));
refresh();
......@@ -282,7 +282,7 @@ bool AppsModel::trigger(int row, const QString &actionId, const QVariant &argume
AbstractModel *AppsModel::modelForRow(int row)
{
if (row < 0 || row >= m_entryList.count()) {
return 0;
return nullptr;
}
return m_entryList.at(row)->childModel();
......@@ -622,8 +622,8 @@ void AppsModel::processServiceGroup(KServiceGroup::Ptr group)
QObject *appletInterface = rootModel()->property("appletInterface").value<QObject *>();
QQmlPropertyMap *appletConfig = qobject_cast<QQmlPropertyMap *>(appletInterface->property("configuration").value<QObject *>());
if (appletConfig && appletConfig->contains("hiddenApplications")) {
hiddenApps = appletConfig->value("hiddenApplications").toStringList();
if (appletConfig && appletConfig->contains(QLatin1String("hiddenApplications"))) {
hiddenApps = appletConfig->value(QLatin1String("hiddenApplications")).toStringList();
}
for (KServiceGroup::List::ConstIterator it = list.constBegin();
......@@ -703,7 +703,7 @@ void AppsModel::sortEntries()
void AppsModel::checkSycocaChanges(const QStringList &changes)
{
if (changes.contains("services") || changes.contains("apps") || changes.contains("xdgdata-apps")) {
if (changes.contains(QLatin1String("services")) || changes.contains(QLatin1String("apps")) || changes.contains(QLatin1String("xdgdata-apps"))) {
m_changeTimer->start();
}
}
......
......@@ -143,7 +143,7 @@ ComputerModel::ComputerModel(QObject *parent) : ForwardingModel(parent)
, m_appletInterface(nullptr)
{
connect(m_systemAppsModel, &SimpleFavoritesModel::favoritesChanged, this, &ComputerModel::systemApplicationsChanged);
m_systemAppsModel->setFavorites(QStringList() << "systemsettings.desktop");
m_systemAppsModel->setFavorites(QStringList() << QStringLiteral("systemsettings.desktop"));
m_concatProxy->addSourceModel(m_runCommandModel);
m_concatProxy->addSourceModel(m_systemAppsModel);
......
......@@ -65,7 +65,7 @@ QIcon ContactEntry::icon() const
return QIcon(photo);
}
return QIcon::fromTheme("unknown");
return QIcon::fromTheme(QStringLiteral("unknown"));
}
QString ContactEntry::name() const
......@@ -114,7 +114,7 @@ QVariantList ContactEntry::actions() const
{
QVariantList actionList;
actionList << Kicker::createActionItem(i18n("Show Contact Information..."), "showContactInfo");
actionList << Kicker::createActionItem(i18n("Show Contact Information..."), QStringLiteral("showContactInfo"));
return actionList;
}
......@@ -127,7 +127,7 @@ bool ContactEntry::run(const QString& actionId, const QVariant &argument)
return false;
}
if (actionId == "showContactInfo") {
if (actionId == QLatin1String("showContactInfo")) {
showPersonDetailsDialog(m_personData->personUri());
}
......@@ -135,7 +135,7 @@ bool ContactEntry::run(const QString& actionId, const QVariant &argument)
}
void ContactEntry::showPersonDetailsDialog(const QString &id) {
KPeople::PersonDetailsDialog *view = new KPeople::PersonDetailsDialog(0);
KPeople::PersonDetailsDialog *view = new KPeople::PersonDetailsDialog(nullptr);
KPeople::PersonData *data = new KPeople::PersonData(id, view);
view->setPerson(data);
view->setAttribute(Qt::WA_DeleteOnClose);
......
......@@ -82,7 +82,7 @@ bool ContainmentInterface::mayAddLauncher(QObject *appletInterface, ContainmentI
case TaskManager: {
if (!entryPath.isEmpty() && containment->pluginMetaData().pluginId() == QLatin1String("org.kde.panel"))
{
const Plasma::Applet *taskManager = 0;
const Plasma::Applet *taskManager = nullptr;
foreach(const Plasma::Applet *applet, containment->applets()) {
if (m_knownTaskManagers.contains(applet->pluginMetaData().pluginId())) {
......@@ -153,7 +153,7 @@ void ContainmentInterface::addLauncher(QObject *appletInterface, ContainmentInte
return;
}
QQuickItem *rootItem = 0;
QQuickItem *rootItem = nullptr;
foreach(QQuickItem *item, gObj->childItems()) {
if (item->objectName() == QStringLiteral("folder")) {
......@@ -167,7 +167,7 @@ void ContainmentInterface::addLauncher(QObject *appletInterface, ContainmentInte
QMetaObject::invokeMethod(rootItem, "addLauncher", Q_ARG(QVariant, QUrl::fromLocalFile(entryPath)));
}
} else {
containment->createApplet("org.kde.plasma.icon", QVariantList() << entryPath);
containment->createApplet(QStringLiteral("org.kde.plasma.icon"), QVariantList() << entryPath);
}
break;
......@@ -175,7 +175,7 @@ void ContainmentInterface::addLauncher(QObject *appletInterface, ContainmentInte
case Panel: {
if (containment->pluginMetaData().pluginId() == QLatin1String("org.kde.panel"))
{
containment->createApplet("org.kde.plasma.icon", QVariantList() << entryPath);
containment->createApplet(QStringLiteral("org.kde.plasma.icon"), QVariantList() << entryPath);
}
break;
......@@ -183,7 +183,7 @@ void ContainmentInterface::addLauncher(QObject *appletInterface, ContainmentInte
case TaskManager: {
if (containment->pluginMetaData().pluginId() == QLatin1String("org.kde.panel"))
{
const Plasma::Applet *taskManager = 0;
const Plasma::Applet *taskManager = nullptr;
foreach(const Plasma::Applet *applet, containment->applets()) {
if (m_knownTaskManagers.contains(applet->pluginMetaData().pluginId())) {
......@@ -247,6 +247,6 @@ bool ContainmentInterface::screenContainmentMutable(QObject *appletInterface)
void ContainmentInterface::ensureMutable(Plasma::Containment *containment)
{
if (containment && containment->immutability() != Plasma::Types::Mutable) {
containment->actions()->action("lock widgets")->trigger();
containment->actions()->action(QStringLiteral("lock widgets"))->trigger();
}
}
......@@ -26,15 +26,15 @@
#include <KWindowEffects>
#include <KWindowSystem>
DashboardWindow::DashboardWindow(QQuickItem *parent) : QQuickWindow(parent ? parent->window() : 0)
, m_mainItem(0)
, m_visualParentItem(0)
, m_visualParentWindow(0)
DashboardWindow::DashboardWindow(QQuickItem *parent) : QQuickWindow(parent ? parent->window() : nullptr)
, m_mainItem(nullptr)
, m_visualParentItem(nullptr)
, m_visualParentWindow(nullptr)
{
setClearBeforeRendering(true);
setFlags(Qt::FramelessWindowHint);
setIcon(QIcon::fromTheme("plasma"));
setIcon(QIcon::fromTheme(QStringLiteral("plasma")));
connect(&m_theme, &Plasma::Theme::themeChanged, this, &DashboardWindow::updateTheme);
}
......
......@@ -37,8 +37,8 @@ class DashboardWindow : public QQuickWindow
Q_CLASSINFO("DefaultProperty", "mainItem")
public:
DashboardWindow(QQuickItem *parent = 0);
~DashboardWindow();
explicit DashboardWindow(QQuickItem *parent = nullptr);
~DashboardWindow() override;
QQuickItem *mainItem() const;
void setMainItem(QQuickItem *item);
......
......@@ -45,10 +45,10 @@ bool FileEntry::isValid() const
QIcon FileEntry::icon() const
{
if (m_fileItem) {
return QIcon::fromTheme(m_fileItem->iconName(), QIcon::fromTheme("unknown"));
return QIcon::fromTheme(m_fileItem->iconName(), QIcon::fromTheme(QStringLiteral("unknown")));
}
return QIcon::fromTheme("unknown");
return QIcon::fromTheme(QStringLiteral("unknown"));
}
QString FileEntry::name() const
......
......@@ -44,9 +44,9 @@ namespace KAStats = KActivities::Stats;
using namespace KAStats;
using namespace KAStats::Terms;
#define AGENT_APPLICATIONS "org.kde.plasma.favorites.applications"
#define AGENT_CONTACTS "org.kde.plasma.favorites.contacts"
#define AGENT_DOCUMENTS "org.kde.plasma.favorites.documents"
#define AGENT_APPLICATIONS QStringLiteral("org.kde.plasma.favorites.applications")
#define AGENT_CONTACTS QStringLiteral("org.kde.plasma.favorites.contacts")
#define AGENT_DOCUMENTS QStringLiteral("org.kde.plasma.favorites.documents")
QString agentForUrl(const QString &url)
{
......@@ -99,7 +99,7 @@ public:
qCDebug(KICKER_DEBUG) << "Original id is: " << id << ", and the url is" << url;
// Preferred applications need special handling
if (entry->id().startsWith("preferred:")) {
if (entry->id().startsWith(QLatin1String("preferred:"))) {
m_id = entry->id();
return;
}
......@@ -107,7 +107,7 @@ public:
// If this is an application, use the applications:-format url
auto appEntry = dynamic_cast<AppEntry*>(entry);
if (appEntry && !appEntry->menuId().isEmpty()) {
m_id = "applications:" + appEntry->menuId();
m_id = QStringLiteral("applications:") + appEntry->menuId();
return;
}
......@@ -123,7 +123,7 @@ public:
}
// If this is a file, we should have already covered it
if (url.scheme() == "file") {
if (url.scheme() == QLatin1String("file")) {
return;
}
......@@ -158,14 +158,14 @@ public:
return new ContactEntry(q, resource);
} else if (agent == AGENT_DOCUMENTS) {
if (resource.startsWith("/")) {
if (resource.startsWith(QLatin1String("/"))) {
return new FileEntry(q, QUrl::fromLocalFile(resource));
} else {
return new FileEntry(q, QUrl(resource));
}
} else if (agent == AGENT_APPLICATIONS) {
if (resource.startsWith("applications:")) {
if (resource.startsWith(QLatin1String("applications:"))) {
return new AppEntry(q, resource.mid(13));
} else {
return new AppEntry(q, resource);
......@@ -205,15 +205,15 @@ public:
});
// Loading the items order
const auto cfg = KSharedConfig::openConfig("kactivitymanagerd-statsrc");
const auto cfg = KSharedConfig::openConfig(QStringLiteral("kactivitymanagerd-statsrc"));
// We want first to check whether we have an ordering for this activity.
// If not, we will try to get a global one for this applet
const QString thisGroupName =
"Favorites-" + clientId + "-" + m_activities.currentActivity();
QStringLiteral("Favorites-") + clientId + QStringLiteral("-") + m_activities.currentActivity();
const QString globalGroupName =
"Favorites-" + clientId + "-global";
QStringLiteral("Favorites-") + clientId + QStringLiteral("-global");
KConfigGroup thisCfgGroup(cfg, thisGroupName);
KConfigGroup globalCfgGroup(cfg, globalGroupName);
......@@ -271,7 +271,7 @@ public:
{
// We want even files to have a proper URL
const auto resource =
_resource.startsWith("/") ? QUrl::fromLocalFile(_resource).toString() : _resource;
_resource.startsWith(QLatin1Char('/')) ? QUrl::fromLocalFile(_resource).toString() : _resource;
qCDebug(KICKER_DEBUG) << "Adding result" << resource << "already present?" << m_itemEntries.contains(resource);
......@@ -421,18 +421,18 @@ public:
static void saveOrdering(const QStringList &ids, const QString &clientId, const QString &currentActivity)
{
const auto cfg = KSharedConfig::openConfig("kactivitymanagerd-statsrc");
const auto cfg = KSharedConfig::openConfig(QStringLiteral("kactivitymanagerd-statsrc"));
QStringList activities {
currentActivity,
"global"
QStringLiteral("global")
};
qCDebug(KICKER_DEBUG) << "Saving ordering for" << currentActivity << "and global" << ids;
for (const auto& activity: activities) {
const QString groupName =
"Favorites-" + clientId + "-" + activity;
QStringLiteral("Favorites-") + clientId + QStringLiteral("-") + activity;
KConfigGroup cfgGroup(cfg, groupName);
......@@ -546,7 +546,7 @@ void KAStatsFavoritesModel::portOldFavorites(const QStringList &ids)
if (!d) return;
qCDebug(KICKER_DEBUG) << "portOldFavorites" << ids;
const auto activityId = ":global";
const QString activityId = QStringLiteral(":global");
std::for_each(ids.begin(), ids.end(), [&] (const QString &id) {
addFavoriteTo(id, activityId);
});
......@@ -596,7 +596,7 @@ void KAStatsFavoritesModel::addFavoriteTo(const QString &id, const Activity &act
setDropPlaceholderIndex(-1);
QStringList matchers { d->m_activities.currentActivity(), ":global", ":current" };
QStringList matchers { d->m_activities.currentActivity(), QStringLiteral(":global"), QStringLiteral(":current") };
if (std::find_first_of(activity.values.cbegin(), activity.values.cend(),
matchers.cbegin(), matchers.cend()) != activity.values.cend()) {