From 212d56dc2c051bfbae2b5a2d63291b4d5f5a7bfa Mon Sep 17 00:00:00 2001 From: Patrick von Reth Date: Tue, 19 Jul 2011 00:38:24 +0200 Subject: [PATCH] improved priority handling --- src/core/notification.cpp | 10 +++++----- src/core/notification.h | 9 +++++++-- src/plugins/snarl/snarl_backend.cpp | 6 +++--- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/core/notification.cpp b/src/core/notification.cpp index 9c46f2b..82c7c89 100644 --- a/src/core/notification.cpp +++ b/src/core/notification.cpp @@ -32,10 +32,10 @@ public: _timeout ( 10 ), _source ( NULL ), _closeReason(Notification::NONE), - _priority(0) + _priority(Notification::NORMAL) {}; - NotificationData ( Notification_Frontend *source,const QString &application,const QString &alert,const QString &title,const QString &text,const QString &icon,int timeout,uint id,int priority ): + NotificationData ( Notification_Frontend *source,const QString &application,const QString &alert,const QString &title,const QString &text,const QString &icon,int timeout,uint id,Notification::prioritys priority ): _id ( id ), _timeout ( timeout ), _source ( source ), @@ -62,7 +62,7 @@ public: QString _title; QString _text; QString _icon; - int _priority; + Notification::prioritys _priority; Notification::closeReasons _closeReason; QMap _actions; QVariantHash _hints; @@ -83,7 +83,7 @@ Notification::Notification ( uint id ) d = QSharedPointer(new NotificationData(id)); } -Notification::Notification ( Notification_Frontend *source, const QString &application, const QString &alert, const QString &title, const QString &text, const QString &icon, int timeout, uint id, int priority ) +Notification::Notification ( Notification_Frontend *source, const QString &application, const QString &alert, const QString &title, const QString &text, const QString &icon, int timeout, uint id, Notification::prioritys priority ) { d = QSharedPointer(new NotificationData(source,application,alert,title,text,icon,timeout,id,priority)); } @@ -168,7 +168,7 @@ const QString &Notification::alert() const return d->_alert; } -const int &Notification::priority() const +const Notification::prioritys &Notification::priority() const { return d->_priority; } diff --git a/src/core/notification.h b/src/core/notification.h index 9cf29d7..d8b7eaf 100644 --- a/src/core/notification.h +++ b/src/core/notification.h @@ -37,6 +37,11 @@ class SNORE_EXPORT Notification public: static int DefaultTimeout; static QString toPlainText ( const QString &string ); + enum prioritys{ + LOW=-1, + NORMAL, + HIGH + }; enum closeReason { NONE, @@ -47,7 +52,7 @@ public: Q_DECLARE_FLAGS(closeReasons, closeReason) public: Notification ( uint id=0 ); - Notification ( class Notification_Frontend *source,const QString &application,const QString &alert,const QString &title,const QString &text,const QString &icon,int timeout=10,uint id=0, int priority = 0 ); + Notification ( class Notification_Frontend *source,const QString &application,const QString &alert,const QString &title,const QString &text,const QString &icon,int timeout=10,uint id=0, Notification::prioritys priority = Notification::NORMAL ); Notification ( const Notification &other ); ~Notification(); Notification &operator=(const Notification& other); @@ -68,7 +73,7 @@ public: const QString &text() const; const QString &icon() const; const QString &alert() const; - const int &priority() const; + const prioritys &priority() const; const QMap &actions() const; void addAction(Action *a); const closeReasons &closeReason(); diff --git a/src/plugins/snarl/snarl_backend.cpp b/src/plugins/snarl/snarl_backend.cpp index 97182a3..74215fd 100644 --- a/src/plugins/snarl/snarl_backend.cpp +++ b/src/plugins/snarl/snarl_backend.cpp @@ -85,7 +85,7 @@ void Snarl_Backend::unregisterApplication(Application *application){ int Snarl_Backend::notify(Notification notification){ SnarlInterface *snarlInterface = _applications.value(notification.application()); - qDebug()<id<name; @@ -114,7 +114,7 @@ int Snarl_Backend::notify(Notification notification){ Notification::toPlainText(notification.text()).toUtf8().constData(), notification.timeout(), notification.icon().toUtf8().constData(), - 0,notification.priority()-2); + 0,notification.priority()); } return id; }