improved priority handling

This commit is contained in:
Patrick von Reth 2011-07-19 00:38:24 +02:00
parent 120245cb41
commit 212d56dc2c
3 changed files with 15 additions and 10 deletions

View File

@ -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<int,Action*> _actions;
QVariantHash _hints;
@ -83,7 +83,7 @@ Notification::Notification ( uint id )
d = QSharedPointer<NotificationData>(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<NotificationData>(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;
}

View File

@ -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<int,Action*> &actions() const;
void addAction(Action *a);
const closeReasons &closeReason();

View File

@ -85,7 +85,7 @@ void Snarl_Backend::unregisterApplication(Application *application){
int Snarl_Backend::notify(Notification notification){
SnarlInterface *snarlInterface = _applications.value(notification.application());
qDebug()<<notification.application();
qDebug()<<"Snarl using the notification instance of:"<<notification.application();
if(snarlInterface == NULL){
qDebug()<<notification.application()<<"not in snarl interfaces, defaulting";
qDebug()<<_applications.keys();
@ -98,7 +98,7 @@ int Snarl_Backend::notify(Notification notification){
Notification::toPlainText(notification.text()).toUtf8().constData(),
notification.timeout(),
notification.icon().isEmpty()?0:notification.icon().toUtf8().constData(),
0,notification.priority()-2);
0,notification.priority());
foreach(const Action *a, notification.actions()){
qDebug()<<"snarl add action"<<a->id<<a->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;
}