diff --git a/applets/kicker/CMakeLists.txt b/applets/kicker/CMakeLists.txt --- a/applets/kicker/CMakeLists.txt +++ b/applets/kicker/CMakeLists.txt @@ -46,6 +46,11 @@ 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) diff --git a/applets/kicker/plugin/kastatsfavoritesmodel.cpp b/applets/kicker/plugin/kastatsfavoritesmodel.cpp --- a/applets/kicker/plugin/kastatsfavoritesmodel.cpp +++ b/applets/kicker/plugin/kastatsfavoritesmodel.cpp @@ -23,8 +23,8 @@ #include "contactentry.h" #include "fileentry.h" #include "actionlist.h" +#include "debug.h" -#include #include #include #include @@ -48,9 +48,6 @@ #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 @@ 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 @@ 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,23 +264,23 @@ [] (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) { // We want even files to have a proper URL 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 @@ return; } - DEBUG << "Removing result" << resource; + qCDebug(KICKER_DEBUG) << "Removing result" << resource; auto index = m_items.indexOf(normalizedId(resource)); @@ -405,7 +402,7 @@ 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 @@ 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 @@ "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 @@ 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 @@ { connect(m_activities, &KActivities::Consumer::currentActivityChanged, this, [&] (const QString ¤tActivity) { - 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 @@ void KAStatsFavoritesModel::initForClient(const QString &clientId) { - DEBUG << "initForClient" << clientId; + qCDebug(KICKER_DEBUG) << "initForClient" << clientId; setSourceModel(nullptr); delete d; @@ -547,7 +541,7 @@ 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,34 +554,34 @@ 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, std::bind(&KAStatsFavoritesModel::initForClient, this, clientId)); } 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 @@ 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 @@ 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 @@ { 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 @@ 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 @@ } if (url.isEmpty()) { - DEBUG << "The url for" << id << "is empty"; + qCDebug(KICKER_DEBUG) << "The url for" << id << "is empty"; return {}; } @@ -707,11 +701,11 @@ 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 {}; } diff --git a/applets/kicker/plugin/placeholdermodel.cpp b/applets/kicker/plugin/placeholdermodel.cpp --- a/applets/kicker/plugin/placeholdermodel.cpp +++ b/applets/kicker/plugin/placeholdermodel.cpp @@ -20,8 +20,8 @@ #include "placeholdermodel.h" #include "actionlist.h" +#include "debug.h" -#include #include PlaceholderModel::PlaceholderModel(QObject *parent) @@ -31,7 +31,7 @@ { connect(&m_triggerInhibitor, &QTimer::timeout, this, [&] { - qDebug() << "%%% Inhibit stopped"; + qCDebug(KICKER_DEBUG) << "%%% Inhibit stopped"; m_isTriggerInhibited = false; }); @@ -41,7 +41,7 @@ void PlaceholderModel::inhibitTriggering() { - qDebug() << "%%% Inhibit started"; + qCDebug(KICKER_DEBUG) << "%%% Inhibit started"; m_isTriggerInhibited = true; m_triggerInhibitor.start(); }