Commit 6deec342 authored by Albert Vaca Cintora's avatar Albert Vaca Cintora
Browse files

Use id instead of a pointer in the dismissRequested signal and slot.

Also changed connection to the Qt5 way.
parent 4574aa36
......@@ -25,7 +25,7 @@
Notification::Notification(const NetworkPackage& np, const QString& iconPath, QObject* parent)
: QObject(parent)
{
mId = np.get<QString>("id");
mInternalId = np.get<QString>("id");
mAppName = np.get<QString>("appName");
mTicker = np.get<QString>("ticker");
mDismissable = np.get<bool>("isClearable");
......@@ -40,7 +40,7 @@ Notification::~Notification()
void Notification::dismiss()
{
if (mDismissable) {
Q_EMIT dismissRequested(this);
Q_EMIT dismissRequested(mInternalId);
}
}
......@@ -41,7 +41,7 @@ public:
Notification(const NetworkPackage& np, const QString& iconPath, QObject* parent);
virtual ~Notification();
QString internalId() const { return mId; }
QString internalId() const { return mInternalId; }
QString appName() const { return mAppName; }
QString ticker() const { return mTicker; }
QString iconPath() const { return mIconPath; }
......@@ -51,10 +51,10 @@ public Q_SLOTS:
Q_SCRIPTABLE void dismiss();
Q_SIGNALS:
void dismissRequested(Notification* self);
void dismissRequested(const QString& mInternalId);
private:
QString mId;
QString mInternalId;
QString mAppName;
QString mTicker;
QString mIconPath;
......
......@@ -98,8 +98,8 @@ void NotificationsDbusInterface::addNotification(Notification* noti)
removeNotification(internalId);
}
connect(noti, SIGNAL(dismissRequested(Notification*)),
this, SLOT(dismissRequested(Notification*)));
connect(noti, &Notification::dismissRequested,
this, &NotificationsDbusInterface::dismissRequested);
const QString& publicId = newId();
mNotifications[publicId] = noti;
......@@ -133,10 +133,8 @@ void NotificationsDbusInterface::removeNotification(const QString& internalId)
Q_EMIT notificationRemoved(publicId);
}
void NotificationsDbusInterface::dismissRequested(Notification* notification)
void NotificationsDbusInterface::dismissRequested(const QString& internalId)
{
const QString& internalId = notification->internalId();
NetworkPackage np(PACKAGE_TYPE_NOTIFICATION);
np.set<QString>("cancel", internalId);
mPlugin->sendPackage(np);
......
......@@ -44,7 +44,7 @@ public:
void processPackage(const NetworkPackage& np);
void clearNotifications();
void dismissRequested(Notification* notification);
void dismissRequested(const QString& notification);
public Q_SLOTS:
Q_SCRIPTABLE QStringList activeNotifications();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment