From ad55f76dc9990094f0ced13b1a9054e416a5c6e0 Mon Sep 17 00:00:00 2001 From: Patrick von Reth Date: Sun, 19 Jan 2014 20:46:46 +0100 Subject: [PATCH] extended logging --- src/core/application.cpp | 21 ++++++++++++++++++++- src/core/application.h | 16 +++------------- src/core/hint.cpp | 10 +++++----- src/core/hint.h | 9 +++++++++ src/core/notification/icon.cpp | 2 +- src/core/notification/icon.h | 9 +++++++-- src/core/notification/notification.cpp | 5 +++++ src/core/notification/notification.h | 5 +++-- 8 files changed, 53 insertions(+), 24 deletions(-) diff --git a/src/core/application.cpp b/src/core/application.cpp index 9322a2e..710c8f7 100644 --- a/src/core/application.cpp +++ b/src/core/application.cpp @@ -81,5 +81,24 @@ Hint &Application::hints() const Hint &Application::constHints() const { - return d->m_hint; + return d->m_hint; +} + + +QDebug operator<< ( QDebug debug, const Snore::Application &app ) +{ + if(app.isValid()) + { + debug << "Snore::Application(" << app.name() << ", "; + foreach(const Alert &a, app.alerts()) + { + debug << a << ", "; + } + debug << app.constHints() << ")" ; + } + else + { + debug << "Snore::Application(0x00)" ; + } + return debug.maybeSpace(); } diff --git a/src/core/application.h b/src/core/application.h index 1993928..cb29ad7 100644 --- a/src/core/application.h +++ b/src/core/application.h @@ -52,20 +52,10 @@ private: }; - -inline QDebug operator<< ( QDebug debug, const Snore::Application &app ) -{ - if(app.isValid()) - { - debug << "Snore::Application(" << app.name() << ", " << app.alerts() << ")";//," << app.hints() << ")" ; - } - else - { - debug << "Snore::Application(0x00)" ; - } - return debug.maybeSpace(); } -} +SNORE_EXPORT QDebug operator<< ( QDebug debug, const Snore::Application &app ); + + #endif // APPLICATION_H diff --git a/src/core/hint.cpp b/src/core/hint.cpp index dbbb297..90c68ee 100644 --- a/src/core/hint.cpp +++ b/src/core/hint.cpp @@ -51,11 +51,11 @@ bool Hint::contains(const QString &key) const return m_data.contains(key); } -//QDebug operator<<( QDebug debug, const Snore::Hint &hint ) -//{ -// debug << "Snore::Hint(" << hint.m_data << ")" ; -// return debug.maybeSpace(); -//} +QDebug operator<<( QDebug debug, const Snore::Hint &hint ) +{ + debug << "Snore::Hint(" << hint.m_data << ", " << hint.m_privateData << ")" ; + return debug.maybeSpace(); +} void Hint::setPrivateValue(const void *owner, const QString &key, const QVariant &value) diff --git a/src/core/hint.h b/src/core/hint.h index 7c56b17..b76c5d8 100644 --- a/src/core/hint.h +++ b/src/core/hint.h @@ -25,6 +25,13 @@ #include "snore_exports.h" +namespace Snore +{ + class Hint; +} + +SNORE_EXPORT QDebug operator<< ( QDebug, const Snore::Hint &); + namespace Snore { @@ -46,6 +53,8 @@ public: private: QVariantHash m_data; QHash, QVariant> m_privateData; + + friend SNORE_EXPORT QDebug (::operator<<) ( QDebug, const Snore::Hint &); }; diff --git a/src/core/notification/icon.cpp b/src/core/notification/icon.cpp index 78a583e..e86008c 100644 --- a/src/core/notification/icon.cpp +++ b/src/core/notification/icon.cpp @@ -92,6 +92,6 @@ bool Snore::Icon::isRemoteFile() const QDebug operator<< ( QDebug debug, const Snore::Icon &icon ) { - debug << "Snore::Icon(" << (icon.url().isEmpty()?icon.localUrl():icon.url()) << ")" ; + debug << "Snore::Icon(" << (icon.url().isEmpty()?icon.d->m_localUrl:icon.url()) << ")" ; return debug.maybeSpace(); } diff --git a/src/core/notification/icon.h b/src/core/notification/icon.h index 1e12d46..227150e 100644 --- a/src/core/notification/icon.h +++ b/src/core/notification/icon.h @@ -23,11 +23,17 @@ #include #include +namespace Snore{ + class Icon; +} + +SNORE_EXPORT QDebug operator<< ( QDebug, const Snore::Icon &); namespace Snore{ class IconData; + class SNORE_EXPORT Icon { public: @@ -49,11 +55,10 @@ public: private: QExplicitlySharedDataPointer d; + friend SNORE_EXPORT QDebug (::operator<<) ( QDebug, const Snore::Icon &); }; } -SNORE_EXPORT QDebug operator<< ( QDebug, const Snore::Icon &); - #endif // NOTIFICATION_ICON_H diff --git a/src/core/notification/notification.cpp b/src/core/notification/notification.cpp index 247a39a..72d01ad 100644 --- a/src/core/notification/notification.cpp +++ b/src/core/notification/notification.cpp @@ -151,6 +151,11 @@ Hint &Notification::hints() return d->m_hints; } +const Hint &Notification::constHints() const +{ + return d->m_hints; +} + void Notification::setSilent(bool silent) { d->m_hints.setValue("silent", silent); diff --git a/src/core/notification/notification.h b/src/core/notification/notification.h index 0f4ccff..02ac6c5 100644 --- a/src/core/notification/notification.h +++ b/src/core/notification/notification.h @@ -64,7 +64,8 @@ public: const QHash &actions() const; void addAction(const Action &a); const NotificationEnums::CloseReasons::closeReasons &closeReason(); - Hint &hints(); + Hint &hints(); + const Hint &constHints() const; void setSilent(bool silent); @@ -98,7 +99,7 @@ inline QDebug operator<< ( QDebug debug, const Snore::Notification ¬i ) { if(noti.isValid()) { - debug << "Snore::Notification(" << noti.title() << ", " << noti.text() << "," << noti.id() << ")" ; + debug << "Snore::Notification(" << noti.title() << ", " << noti.text() << "," << noti.id() << ", " << noti.constHints() << ")" ; } else {