Debian Codegraph @

tests/online-accounts-ui/mock/notification-mock.cpp

raw symbols SCIP
1 /*
2 * Copyright (C) 2014 Canonical Ltd.
3 *
4 * Contact: Alberto Mardegan <[email protected]>
5 *
6 * This file is part of lomiri-online-accounts-ui
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 3, as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include "notification-mock.h"
22
23 #include <QByteArray>
24 #include <QDebug>
25 #include <QString>
26
27 using namespace OnlineAccountsUi;
28
29 QList<Notification*> NotificationPrivate::allNotifications;
30
31 NotificationPrivate::NotificationPrivate(const QString &summary,
32 const QString &body,
33 Notification *notification):
34 QObject(notification),
35 m_summary(summary),
36 m_body(body),
37 q_ptr(notification)
38 {
39 allNotifications.append(notification);
40 }
41
42 NotificationPrivate::~NotificationPrivate()
43 {
44 allNotifications.removeAll(q_ptr);
45 }
46
47 void NotificationPrivate::invokeAction(const QString &action)
48 {
49 Q_Q(Notification);
50 Q_EMIT q->actionInvoked(action);
51 }
52
53 Notification::Notification(const QString &summary,
54 const QString &body,
55 QObject *parent):
56 QObject(parent),
57 d_ptr(new NotificationPrivate(summary, body, this))
58 {
59 }
60
61 Notification::~Notification()
62 {
63 }
64
65 void Notification::addAction(const QString &action, const QString &label)
66 {
67 Q_D(Notification);
68 d->m_actions.append(ActionPair(action, label));
69 }
70
71 void Notification::setSnapDecision(bool snapDecision)
72 {
73 Q_D(Notification);
74 d->m_isSnapDecision = snapDecision;
75 }
76
77 void Notification::show()
78 {
79 Q_D(Notification);
80 Q_EMIT d->showCalled();
81 }