removed the horrible enum header

This commit is contained in:
Patrick von Reth 2014-01-21 09:56:11 +01:00
parent a7b81ffe07
commit 5f22236693
15 changed files with 71 additions and 104 deletions

View File

@ -37,13 +37,13 @@ Notification::Notification () :
{
}
Notification::Notification(const Application &application, const Alert &alert, const QString &title, const QString &text, const Icon &icon, int timeout, NotificationEnums::Prioritys::prioritys priority):
Notification::Notification(const Application &application, const Alert &alert, const QString &title, const QString &text, const Icon &icon, int timeout, Notification::Prioritys priority):
d(new NotificationData(application,alert,title,text,icon,timeout,priority))
{
}
Notification::Notification(const Notification &old, const QString &title, const QString &text, const Icon &icon, int timeout, NotificationEnums::Prioritys::prioritys priority):
Notification::Notification(const Notification &old, const QString &title, const QString &text, const Icon &icon, int timeout, Notification::Prioritys priority):
d(new NotificationData(old,title,text,icon,timeout,priority))
{
}
@ -119,7 +119,7 @@ bool Notification::isSticky() const
}
NotificationEnums::Prioritys::prioritys Notification::priority() const
Notification::Prioritys Notification::priority() const
{
return d->m_priority;
}
@ -135,7 +135,7 @@ const QHash<int, Action> &Notification::actions() const
return d->m_actions;
}
const NotificationEnums::CloseReasons::closeReasons &Notification::closeReason(){
const Notification::CloseReasons &Notification::closeReason(){
return d->m_closeReason;
}

View File

@ -21,7 +21,6 @@
#define NOTIFICATION_H
#include "../snore_exports.h"
#include "icon.h"
#include "notificationenums.h"
#include "notificationaction.h"
#include "../hint.h"
#include "../application.h"
@ -46,6 +45,22 @@ class SNORE_EXPORT Notification
{
friend class NotificationData;
public:
enum CloseReason
{
NONE = 0x0,
TIMED_OUT = 0x1,
DISMISSED = 0x2,
CLOSED = 0x4
};
Q_DECLARE_FLAGS(CloseReasons, CloseReason)
enum Priority{
LOW = -1,
NORMAL = 0,
HIGH = +1
};
Q_DECLARE_FLAGS(Prioritys, Priority)
Notification();
/**
* Creates a new Notification.
@ -57,7 +72,7 @@ public:
* @param timeout the timeout
* @param priority the priority
*/
explicit Notification(const Application &application,const Alert &alert,const QString &title,const QString &text,const Icon &icon,int timeout = defaultTimeout(), NotificationEnums::Prioritys::prioritys priority = NotificationEnums::Prioritys::NORMAL );
explicit Notification(const Application &application,const Alert &alert,const QString &title,const QString &text,const Icon &icon,int timeout = defaultTimeout(), Notification::Prioritys priority = Notification::NORMAL );
/**
* Creates and update Notification replacing an existing Notification
@ -68,7 +83,7 @@ public:
* @param timeout the timeout
* @param priority the piority
*/
explicit Notification(const Notification &old,const QString &title,const QString &text,const Icon &icon,int timeout = defaultTimeout(), NotificationEnums::Prioritys::prioritys priority = NotificationEnums::Prioritys::NORMAL );
explicit Notification(const Notification &old, const QString &title, const QString &text, const Icon &icon, int timeout = defaultTimeout(), Snore::Notification::Prioritys priority = Notification::NORMAL );
/**
* The copy constructor
@ -142,7 +157,7 @@ public:
* Some backends support priorities to indicate the urgency of the Notification
* @return the priority
*/
NotificationEnums::Prioritys::prioritys priority() const;
Notification::Prioritys priority() const;
/**
*
@ -162,7 +177,7 @@ public:
*
* @return the close reason
*/
const NotificationEnums::CloseReasons::closeReasons &closeReason();
const Notification::CloseReasons &closeReason();
/**
*
@ -224,9 +239,12 @@ private:
};
}
Q_DECLARE_METATYPE(Snore::Notification)
Q_DECLARE_OPERATORS_FOR_FLAGS(Snore::Notification::CloseReasons)
Q_DECLARE_OPERATORS_FOR_FLAGS(Snore::Notification::Prioritys)
QDataStream &operator<< ( QDataStream & stream, const Snore::Notification & noti );
inline QDebug operator<< ( QDebug debug, const Snore::Notification &noti )

View File

@ -33,7 +33,7 @@ uint NotificationData::notificationCount = 0;
uint NotificationData::m_idCount = 1;
NotificationData::NotificationData (const Snore::Application &application, const Snore::Alert &alert, const QString &title, const QString &text, const Icon &icon,
int timeout, NotificationEnums::Prioritys::prioritys priority ):
int timeout, Notification::Prioritys priority ):
m_id ( m_idCount++ ),
m_timeout( timeout ),
m_source( NULL),
@ -43,13 +43,13 @@ NotificationData::NotificationData (const Snore::Application &application, const
m_text( text ),
m_icon( icon ),
m_priority(priority),
m_closeReason(NotificationEnums::CloseReasons::NONE)
m_closeReason(Notification::NONE)
{
notificationCount++;
snoreDebug( SNORE_DEBUG ) << "Creating Notification: ActiveNotifications" << notificationCount << "id" << m_id;
}
Snore::NotificationData::NotificationData(const Notification &old, const QString &title, const QString &text, const Icon &icon, int timeout, NotificationEnums::Prioritys::prioritys priority):
Snore::NotificationData::NotificationData(const Notification &old, const QString &title, const QString &text, const Icon &icon, int timeout, Notification::Prioritys priority):
m_id ( old.id() ),
m_timeout( timeout ),
m_source( NULL),
@ -59,7 +59,7 @@ Snore::NotificationData::NotificationData(const Notification &old, const QString
m_text( text ),
m_icon( icon ),
m_priority(priority),
m_closeReason(NotificationEnums::CloseReasons::NONE),
m_closeReason(Notification::NONE),
m_toReplace(old)
{
notificationCount++;
@ -97,7 +97,7 @@ SnoreFrontend *NotificationData::source() const
return m_source;
}
void NotificationData::setCloseReason(const NotificationEnums::CloseReasons::closeReasons &r)
void NotificationData::setCloseReason(Snore::Notification::CloseReasons r)
{
m_closeReason = r;
}

View File

@ -23,7 +23,6 @@
#include "icon.h"
#include "notification.h"
#include "notificationenums.h"
#include "../hint.h"
#include <QSharedData>
@ -38,9 +37,9 @@ class SNORE_EXPORT NotificationData : public QSharedData
friend class Notification;
public:
NotificationData ( const Application &application,const Alert &alert,const QString &title,const QString &text,const Icon &icon,
int timeout,NotificationEnums::Prioritys::prioritys priority );
int timeout,Notification::Prioritys priority );
NotificationData(const Notification &old,const QString &title,const QString &text,const Icon &icon,int timeout, NotificationEnums::Prioritys::prioritys priority);
NotificationData(const Notification &old,const QString &title,const QString &text,const Icon &icon,int timeout, Notification::Prioritys priority);
~NotificationData();
@ -52,7 +51,7 @@ public:
void setActionInvoked( const int &actionID);
void setCloseReason(const NotificationEnums::CloseReasons::closeReasons &r);
void setCloseReason(Notification::CloseReasons r);
QTimer *timeoutTimer();
@ -62,14 +61,14 @@ private:
uint m_id;
uint m_updateID;
int m_timeout;
SnoreFrontend *m_source;
SnoreFrontend *m_source;
Application m_application;
Alert m_alert;
QString m_title;
QString m_text;
Icon m_icon;
NotificationEnums::Prioritys::prioritys m_priority;
NotificationEnums::CloseReasons::closeReasons m_closeReason;
Notification::Prioritys m_priority;
Notification::CloseReasons m_closeReason;
Action m_actionInvoked;
QHash<int,Action> m_actions;
Hint m_hints;

View File

@ -1,51 +0,0 @@
/*
SnoreNotify is a Notification Framework based on Qt
Copyright (C) 2013-2014 Patrick von Reth <vonreth@kde.org>
SnoreNotify is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
SnoreNotify is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NOTIFICATIONENUMS_H
#define NOTIFICATIONENUMS_H
#include <QFlags>
namespace Snore{
namespace NotificationEnums{
namespace Prioritys{
enum priority{
LOW = -1,
NORMAL = 0,
HIGH = +1
};
Q_DECLARE_FLAGS(prioritys, priority)
Q_DECLARE_OPERATORS_FOR_FLAGS(prioritys)
}
namespace CloseReasons{
enum closeReason
{
NONE = 0,
TIMED_OUT,
DISMISSED,
CLOSED
};
Q_DECLARE_FLAGS(closeReasons, closeReason)
Q_DECLARE_OPERATORS_FOR_FLAGS(closeReasons)
}
}
}
#endif // NOTIFICATIONENUMS_H

View File

@ -67,7 +67,7 @@ bool SnoreBackend::initialize( SnoreCore *snore )
}
void SnoreBackend::requestCloseNotification ( Notification notification,NotificationEnums::CloseReasons::closeReasons reason )
void SnoreBackend::requestCloseNotification (Notification notification, Notification::CloseReasons reason )
{
if(canCloseNotification())
{
@ -75,7 +75,7 @@ void SnoreBackend::requestCloseNotification ( Notification notification,Notifica
}
}
void SnoreBackend::closeNotification(Notification n, NotificationEnums::CloseReasons::closeReasons reason)
void SnoreBackend::closeNotification(Notification n, Notification::CloseReasons reason)
{
if(!n.isValid())
{
@ -156,7 +156,7 @@ bool SnoreBackend::deinitialize()
{
foreach(Notification n,m_activeNotifications)
{
requestCloseNotification(n, NotificationEnums::CloseReasons::DISMISSED);
requestCloseNotification(n, Notification::DISMISSED);
}
@ -200,6 +200,6 @@ void SnoreBackend::notificationTimedOut()
if(n.isValid())
{
snoreDebug( SNORE_DEBUG ) << n;
snore()->requestCloseNotification(n,NotificationEnums::CloseReasons::TIMED_OUT);
snore()->requestCloseNotification(n,Notification::TIMED_OUT);
}
}

View File

@ -39,7 +39,7 @@ public:
virtual bool initialize(SnoreCore *snore);
virtual bool deinitialize();
void requestCloseNotification( Snore::Notification notification,NotificationEnums::CloseReasons::closeReasons reason );
void requestCloseNotification( Snore::Notification notification,Notification::CloseReasons reason );
Snore::Notification getActiveNotificationByID(uint id);
@ -61,7 +61,7 @@ private slots:
protected:
void startTimeout(Notification &notification);
void closeNotification(Snore::Notification,Snore::NotificationEnums::CloseReasons::closeReasons);
void closeNotification(Snore::Notification,Snore::Notification::CloseReasons);
void setSupportsRichtext(bool b);
private:

View File

@ -251,7 +251,7 @@ Notification SnoreCore::getActiveNotificationByID(uint id)
return d->m_notificationBackend->getActiveNotificationByID(id);
}
void SnoreCore::requestCloseNotification(Notification n, NotificationEnums::CloseReasons::closeReasons r)
void SnoreCore::requestCloseNotification(Notification n, Notification::CloseReasons r)
{
Q_D(SnoreCore);
d->m_notificationBackend->requestCloseNotification(n,r);

View File

@ -158,7 +158,7 @@ public:
* Try to close a Notification if the backend supports the action.
* @see SnoreBackend::canCloseNotification
*/
void requestCloseNotification(Notification,NotificationEnums::CloseReasons::closeReasons);
void requestCloseNotification(Notification,Notification::CloseReasons);
/**
*

View File

@ -49,7 +49,7 @@ bool Growl::initialize(SnoreCore *snore)
{
const Application &app = snore->d()->defaultApplication();
m_defaultGNTP = new gntp(app.name().toUtf8().constData(), app.icon().localUrl().toUtf8().constData());
std::vector<std::string> alerts;
alerts.push_back(app.alerts().begin()->name().toUtf8().constData());
try
@ -144,18 +144,18 @@ void Growl::gntpCallback(const int &id,const std::string &reason,const std::stri
{
// snoreDebug( SNORE_DEBUG ) << id << QString(reason.c_str()) << QString(data.c_str());
Notification n = s_instance->snore()->getActiveNotificationByID(id);
NotificationEnums::CloseReasons::closeReasons r = NotificationEnums::CloseReasons::NONE;
Notification::CloseReasons r = Notification::NONE;
if(reason == "TIMEDOUT")
{
r = NotificationEnums::CloseReasons::TIMED_OUT;
r = Notification::TIMED_OUT;
}
else if(reason == "CLOSED")
{
r = NotificationEnums::CloseReasons::DISMISSED;
r = Notification::DISMISSED;
}
else if(reason == "CLICK")
{
r = NotificationEnums::CloseReasons::CLOSED;
r = Notification::CLOSED;
s_instance->snore()->d()->notificationActionInvoked(n);
}
s_instance->closeNotification(n,r);

View File

@ -71,13 +71,13 @@ public:
notification = m_snarl->snore()->getActiveNotificationByID(m_snarl->m_idMap[ msg->lParam]);
}
NotificationEnums::CloseReasons::closeReasons reason = NotificationEnums::CloseReasons::NONE;
Notification::CloseReasons reason = Notification::NONE;
switch(action){
case SnarlEnums::CallbackInvoked:
reason = NotificationEnums::CloseReasons::CLOSED;
reason = Notification::CLOSED;
break;
case SnarlEnums::NotifyAction:
reason = NotificationEnums::CloseReasons::CLOSED;
reason = Notification::CLOSED;
if(notification.isValid())
{
notification.data()->setActionInvoked(data);
@ -85,10 +85,10 @@ public:
}
break;
case SnarlEnums::CallbackClosed:
reason = NotificationEnums::CloseReasons::DISMISSED;
reason = Notification::DISMISSED;
break;
case SnarlEnums::CallbackTimedOut:
reason = NotificationEnums::CloseReasons::TIMED_OUT;
reason = Notification::TIMED_OUT;
break;
//away stuff
case SnarlEnums::SnarlUserAway:
@ -209,13 +209,13 @@ void SnarlBackend::slotNotify(Notification notification){
Snarl::V42::SnarlEnums::MessagePriority priority = Snarl::V42::SnarlEnums::PriorityUndefined;
switch(notification.priority())
{
case NotificationEnums::Prioritys::LOW:
case Notification::LOW:
priority = Snarl::V42::SnarlEnums::PriorityLow;
break;
case NotificationEnums::Prioritys::NORMAL:
case Notification::NORMAL:
priority = Snarl::V42::SnarlEnums::PriorityNormal;
break;
case NotificationEnums::Prioritys::HIGH:
case Notification::HIGH:
priority = Snarl::V42::SnarlEnums::PriorityHigh;
break;
}

View File

@ -100,22 +100,22 @@ void SnoreToast::slotToastNotificationClosed(int code, QProcess::ExitStatus)
return;
}
NotificationEnums::CloseReasons::closeReason reason = NotificationEnums::CloseReasons::CLOSED;
Notification::CloseReasons reason = Notification::CLOSED;
switch(code)
{
case 0:
reason = NotificationEnums::CloseReasons::CLOSED;
reason = Notification::CLOSED;
snore()->d()->notificationActionInvoked(n);
break;
case 1:
//hidden;
break;
case 2:
reason = NotificationEnums::CloseReasons::DISMISSED;
reason = Notification::DISMISSED;
break;
case 3:
reason = NotificationEnums::CloseReasons::TIMED_OUT;
reason = Notification::TIMED_OUT;
break;
case -1:
//failed

View File

@ -87,7 +87,7 @@ void TrayIconNotifer::actionInvoked()
if(n.isValid())
{
snore()->d()->notificationActionInvoked(n);
closeNotification(n,NotificationEnums::CloseReasons::CLOSED);
closeNotification(n,Notification::CLOSED);
m_currentlyDisplaying = false;
displayNotification();
}

View File

@ -93,7 +93,7 @@ uint FreedesktopFrontend::Notify(const QString &app_name, uint replaces_id,
{
Icon icon;
Application app;
NotificationEnums::Prioritys::prioritys priotity = NotificationEnums::Prioritys::NORMAL;
Notification::Prioritys priotity = Notification::NORMAL;
if(hints.contains("image_data"))
{
@ -123,8 +123,9 @@ uint FreedesktopFrontend::Notify(const QString &app_name, uint replaces_id,
app = snore()->aplications()[app_name];
}
if (hints.contains("urgency")) {
priotity = NotificationEnums::Prioritys::prioritys(hints["urgency"].toInt()-1);
if (hints.contains("urgency"))
{
priotity = Notification::Prioritys(hints["urgency"].toInt()-1);
}
Notification noti;
@ -153,7 +154,7 @@ void FreedesktopFrontend::CloseNotification(uint id)
Notification noti = snore()->getActiveNotificationByID(id);
if(noti.isValid())
{
snore()->requestCloseNotification(noti,NotificationEnums::CloseReasons::TIMED_OUT);
snore()->requestCloseNotification(noti,Notification::TIMED_OUT);
}
}

View File

@ -84,7 +84,7 @@ void SnarlNetworkFrontend::actionInvoked(Snore::Notification notification)
}
void SnarlNetworkFrontend::notificationClosed(Snore::Notification notification)
{
if(notification.closeReason() == NotificationEnums::CloseReasons::TIMED_OUT)
if(notification.closeReason() == Notification::TIMED_OUT)
{
callback(notification, "SNP/1.1/303/Notification timed out/");
}