Commit 5a892dc8 authored by David Edmundson's avatar David Edmundson

Kicker: Use QtLoggingRules

Summary:
And remove custom DEBUG macro with formatting.
If a dev wants a QT_MESSAGE_PATTERN they should set one themselves,
otherwise we get double formatting.

Test Plan: compiles

Reviewers: #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D8611
parent f16eb331
......@@ -46,6 +46,11 @@ set(kickerplugin_SRCS
plugin/funnelmodel.cpp
)
ecm_qt_declare_logging_category(kickerplugin_SRCS
HEADER debug.h
IDENTIFIER KICKER_DEBUG
CATEGORY_NAME org.kde.plasma.kicker)
qt5_add_dbus_interface(kickerplugin_SRCS ${KRUNNERAPP_INTERFACE} krunner_interface)
qt5_add_dbus_interface(kickerplugin_SRCS ${KSMSERVER_DBUS_INTERFACE} ksmserver_interface)
......
......@@ -23,8 +23,8 @@
#include "contactentry.h"
#include "fileentry.h"
#include "actionlist.h"
#include "debug.h"
#include <QDebug>
#include <QFileInfo>
#include <QTimer>
#include <QSortFilterProxyModel>
......@@ -48,9 +48,6 @@ using namespace KAStats::Terms;
#define AGENT_CONTACTS "org.kde.plasma.favorites.contacts"
#define AGENT_DOCUMENTS "org.kde.plasma.favorites.documents"
#define DEBUG_PREFIX "\033[0;31m[KASTATSFAVS]\033[0;34m "
#define DEBUG qDebug() << DEBUG_PREFIX << (void*)q << ((void*)this) << m_clientId << "\033[0;0m "
QString agentForUrl(const QString &url)
{
return url.startsWith(QLatin1String("ktp:"))
......@@ -99,7 +96,7 @@ public:
const auto url = entry->url();
qDebug() << "Original id is: " << id << ", and the url is" << url;
qCDebug(KICKER_DEBUG) << "Original id is: " << id << ", and the url is" << url;
// Preferred applications need special handling
if (entry->id().startsWith("preferred:")) {
......@@ -225,14 +222,14 @@ public:
thisCfgGroup.readEntry("ordering", QStringList()) +
globalCfgGroup.readEntry("ordering", QStringList());
DEBUG << "Loading the ordering " << ordering;
qCDebug(KICKER_DEBUG) << "Loading the ordering " << ordering;
// Loading the results without emitting any model signals
DEBUG << "Query is" << m_query;
qCDebug(KICKER_DEBUG) << "Query is" << m_query;
ResultSet results(m_query);
for (const auto& result: results) {
DEBUG << "Got " << result.resource() << " -->";
qCDebug(KICKER_DEBUG) << "Got " << result.resource() << " -->";
addResult(result.resource(), -1, false);
}
......@@ -267,7 +264,7 @@ public:
[] (const NormalizedId &item) {
return item.value();
});
DEBUG << "After ordering: " << itemStrings;
qCDebug(KICKER_DEBUG) << "After ordering: " << itemStrings;
}
void addResult(const QString &_resource, int index, bool notifyModel = true)
......@@ -276,14 +273,14 @@ public:
const auto resource =
_resource.startsWith("/") ? QUrl::fromLocalFile(_resource).toString() : _resource;
DEBUG << "Adding result" << resource << "already present?" << m_itemEntries.contains(resource);
qCDebug(KICKER_DEBUG) << "Adding result" << resource << "already present?" << m_itemEntries.contains(resource);
if (m_itemEntries.contains(resource)) return;
auto entry = entryForResource(resource);
if (!entry || !entry->isValid()) {
DEBUG << "Entry is not valid!";
qCDebug(KICKER_DEBUG) << "Entry is not valid!";
return;
}
......@@ -325,7 +322,7 @@ public:
return;
}
DEBUG << "Removing result" << resource;
qCDebug(KICKER_DEBUG) << "Removing result" << resource;
auto index = m_items.indexOf(normalizedId(resource));
......@@ -405,7 +402,7 @@ public:
m_items.move(from, to);
q->endMoveRows();
DEBUG << "Save ordering (from Private::move) -->";
qCDebug(KICKER_DEBUG) << "Save ordering (from Private::move) -->";
saveOrdering();
}
}
......@@ -418,7 +415,7 @@ public:
ids << item.value();
}
DEBUG << "Save ordering (from Private::saveOrdering) -->";
qCDebug(KICKER_DEBUG) << "Save ordering (from Private::saveOrdering) -->";
saveOrdering(ids, m_clientId, m_activities.currentActivity());
}
......@@ -431,7 +428,7 @@ public:
"global"
};
qDebug() << "Saving ordering for" << currentActivity << "and global" << ids;
qCDebug(KICKER_DEBUG) << "Saving ordering for" << currentActivity << "and global" << ids;
for (const auto& activity: activities) {
const QString groupName =
......@@ -456,9 +453,6 @@ public:
QStringList m_ignoredItems;
};
#undef DEBUG
#define DEBUG qDebug() << DEBUG_PREFIX << ((void*)this) << ((void*)d) << (d ? d->m_clientId : QString("no client ID yet")) << "\033[0;0m "
KAStatsFavoritesModel::KAStatsFavoritesModel(QObject *parent)
: PlaceholderModel(parent)
, d(nullptr) // we have no client id yet
......@@ -468,7 +462,7 @@ KAStatsFavoritesModel::KAStatsFavoritesModel(QObject *parent)
{
connect(m_activities, &KActivities::Consumer::currentActivityChanged,
this, [&] (const QString &currentActivity) {
DEBUG << "Activity just got changed to" << currentActivity;
qCDebug(KICKER_DEBUG) << "Activity just got changed to" << currentActivity;
Q_UNUSED(currentActivity);
auto clientId = d->m_clientId;
initForClient(clientId);
......@@ -482,7 +476,7 @@ KAStatsFavoritesModel::~KAStatsFavoritesModel()
void KAStatsFavoritesModel::initForClient(const QString &clientId)
{
DEBUG << "initForClient" << clientId;
qCDebug(KICKER_DEBUG) << "initForClient" << clientId;
setSourceModel(nullptr);
delete d;
......@@ -547,7 +541,7 @@ bool KAStatsFavoritesModel::isFavorite(const QString &id) const
void KAStatsFavoritesModel::portOldFavorites(const QStringList &ids)
{
DEBUG << "portOldFavorites" << ids;
qCDebug(KICKER_DEBUG) << "portOldFavorites" << ids;
const auto activityId = ":global";
std::for_each(ids.begin(), ids.end(), [&] (const QString &id) {
......@@ -560,7 +554,7 @@ void KAStatsFavoritesModel::portOldFavorites(const QStringList &ids)
delete d;
d = nullptr;
DEBUG << "Save ordering (from portOldFavorites) -->";
qCDebug(KICKER_DEBUG) << "Save ordering (from portOldFavorites) -->";
Private::saveOrdering(ids, clientId, m_activities->currentActivity());
QTimer::singleShot(500,
......@@ -569,25 +563,25 @@ void KAStatsFavoritesModel::portOldFavorites(const QStringList &ids)
void KAStatsFavoritesModel::addFavorite(const QString &id, int index)
{
DEBUG << "addFavorite" << id << index << " -->";
qCDebug(KICKER_DEBUG) << "addFavorite" << id << index << " -->";
addFavoriteTo(id, QStringLiteral(":global"));
}
void KAStatsFavoritesModel::removeFavorite(const QString &id)
{
DEBUG << "removeFavorite" << id << " -->";
qCDebug(KICKER_DEBUG) << "removeFavorite" << id << " -->";
removeFavoriteFrom(id, QStringLiteral(":any"));
}
void KAStatsFavoritesModel::addFavoriteTo(const QString &id, const QString &activityId, int index)
{
DEBUG << "addFavoriteTo" << id << activityId << index << " -->";
qCDebug(KICKER_DEBUG) << "addFavoriteTo" << id << activityId << index << " -->";
addFavoriteTo(id, Activity(activityId), index);
}
void KAStatsFavoritesModel::removeFavoriteFrom(const QString &id, const QString &activityId)
{
DEBUG << "removeFavoriteFrom" << id << activityId << " -->";
qCDebug(KICKER_DEBUG) << "removeFavoriteFrom" << id << activityId << " -->";
removeFavoriteFrom(id, Activity(activityId));
}
......@@ -607,7 +601,7 @@ void KAStatsFavoritesModel::addFavoriteTo(const QString &id, const Activity &act
const auto url = d->normalizedId(id).value();
DEBUG << "addFavoriteTo" << id << activity << index << url << " (actual)";
qCDebug(KICKER_DEBUG) << "addFavoriteTo" << id << activity << index << url << " (actual)";
if (url.isEmpty()) return;
......@@ -621,7 +615,7 @@ void KAStatsFavoritesModel::removeFavoriteFrom(const QString &id, const Activity
Q_ASSERT(!activity.values.isEmpty());
DEBUG << "addFavoriteTo" << id << activity << url << " (actual)";
qCDebug(KICKER_DEBUG) << "addFavoriteTo" << id << activity << url << " (actual)";
if (url.isEmpty()) return;
......@@ -633,9 +627,9 @@ void KAStatsFavoritesModel::setFavoriteOn(const QString &id, const QString &acti
{
const auto url = d->normalizedId(id).value();
DEBUG << "setFavoriteOn" << id << activityId << url << " (actual)";
qCDebug(KICKER_DEBUG) << "setFavoriteOn" << id << activityId << url << " (actual)";
DEBUG << "%%%%%%%%%%% Activity is" << activityId;
qCDebug(KICKER_DEBUG) << "%%%%%%%%%%% Activity is" << activityId;
if (activityId.isEmpty() || activityId == ":any" ||
activityId == ":global" ||
activityId == m_activities->currentActivity()) {
......@@ -678,7 +672,7 @@ QString KAStatsFavoritesModel::activityNameForId(const QString &activityId) cons
QStringList KAStatsFavoritesModel::linkedActivitiesFor(const QString &id) const
{
if (!d) {
DEBUG << "Linked for" << id << "is empty, no Private instance";
qCDebug(KICKER_DEBUG) << "Linked for" << id << "is empty, no Private instance";
return {};
}
......@@ -689,7 +683,7 @@ QStringList KAStatsFavoritesModel::linkedActivitiesFor(const QString &id) const
}
if (url.isEmpty()) {
DEBUG << "The url for" << id << "is empty";
qCDebug(KICKER_DEBUG) << "The url for" << id << "is empty";
return {};
}
......@@ -707,11 +701,11 @@ QStringList KAStatsFavoritesModel::linkedActivitiesFor(const QString &id) const
ResultSet results(query);
for (const auto &result: results) {
DEBUG << "Returning" << result.linkedActivities() << "for" << id << url;
qCDebug(KICKER_DEBUG) << "Returning" << result.linkedActivities() << "for" << id << url;
return result.linkedActivities();
}
DEBUG << "Returning empty list of activities for" << id << url;
qCDebug(KICKER_DEBUG) << "Returning empty list of activities for" << id << url;
return {};
}
......@@ -20,8 +20,8 @@
#include "placeholdermodel.h"
#include "actionlist.h"
#include "debug.h"
#include <QDebug>
#include <QTimer>
PlaceholderModel::PlaceholderModel(QObject *parent)
......@@ -31,7 +31,7 @@ PlaceholderModel::PlaceholderModel(QObject *parent)
{
connect(&m_triggerInhibitor, &QTimer::timeout,
this, [&] {
qDebug() << "%%% Inhibit stopped";
qCDebug(KICKER_DEBUG) << "%%% Inhibit stopped";
m_isTriggerInhibited = false;
});
......@@ -41,7 +41,7 @@ PlaceholderModel::PlaceholderModel(QObject *parent)
void PlaceholderModel::inhibitTriggering()
{
qDebug() << "%%% Inhibit started";
qCDebug(KICKER_DEBUG) << "%%% Inhibit started";
m_isTriggerInhibited = true;
m_triggerInhibitor.start();
}
......
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