2 * Copyright 2015 Canonical Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 * Mirco Mueller <mirco.mueller@canonical.com>
20#include "MockNotification.h"
24struct MockNotificationPrivate {
29 MockNotification::Type type;
31 QString secondaryIcon;
33 ActionModel* actionsModel;
35 bool fullscreen = false;
38MockNotification::MockNotification(QObject *parent) : QObject(parent), p(new MockNotificationPrivate()) {
39 p->actionsModel = new ActionModel();
42MockNotification::~MockNotification() {
43 delete p->actionsModel;
46QString MockNotification::getSummary() const {
50void MockNotification::setSummary(const QString &summary) {
51 if(p->summary != summary) {
53 Q_EMIT summaryChanged(p->summary);
54 Q_EMIT dataChanged(p->id);
58QString MockNotification::getBody() const {
62void MockNotification::setBody(const QString &body) {
65 Q_EMIT bodyChanged(p->body);
66 Q_EMIT dataChanged(p->id);
70int MockNotification::getID() const {
74void MockNotification::setID(const int id) {
78int MockNotification::getValue() const {
82void MockNotification::setValue(int value) {
83 if(p->value != value) {
85 Q_EMIT valueChanged(p->value);
86 Q_EMIT dataChanged(p->id);
90QString MockNotification::getIcon() const {
94void MockNotification::setIcon(const QString &icon) {
95 if (icon.startsWith(" ") || icon.size() == 0) {
101 if (icon.indexOf("/") == -1) {
102 p->icon.prepend("image://theme/");
106 Q_EMIT iconChanged(p->icon);
107 Q_EMIT dataChanged(p->id);
110QString MockNotification::getSecondaryIcon() const {
111 return p->secondaryIcon;
114void MockNotification::setSecondaryIcon(const QString &secondaryIcon) {
115 if (secondaryIcon.startsWith(" ") || secondaryIcon.size() == 0) {
116 p->secondaryIcon = nullptr;
119 p->secondaryIcon = secondaryIcon;
121 if (secondaryIcon.indexOf("/") == -1) {
122 p->secondaryIcon.prepend("image://theme/");
126 Q_EMIT secondaryIconChanged(p->secondaryIcon);
127 Q_EMIT dataChanged(p->id);
130MockNotification::Type MockNotification::getType() const {
134void MockNotification::setType(Type type) {
135 if(p->type != type) {
137 Q_EMIT typeChanged(p->type);
141ActionModel* MockNotification::getActions() const {
142 return p->actionsModel;
145QStringList MockNotification::rawActions() const {
149void MockNotification::setActions(const QStringList &actions) {
150 if(p->actions != actions) {
151 p->actions = actions;
152 Q_EMIT actionsChanged(p->actions);
154 for (int i = 0; i < p->actions.size(); i += 2) {
155 p->actionsModel->append(p->actions[i], p->actions[i+1]);
160QVariantMap MockNotification::getHints() const {
164void MockNotification::setHints(const QVariantMap& hints) {
165 if (p->hints != hints) {
167 Q_EMIT hintsChanged(p->hints);
171void MockNotification::invokeAction(const QString &action) {
172 for(int i=0; i<p->actions.size(); i++) {
173 if(p->actions[i] == action) {
174 Q_EMIT actionInvoked(action);
175 qDebug() << "Info: invoked action" << action;
179 fprintf(stderr, "Error: tried to invoke action not in actionList.\n");
182void MockNotification::close() {
183 Q_EMIT completed(p->id);
186bool MockNotification::fullscreen() const
188 return p->fullscreen;
191void MockNotification::setFullscreen(bool fullscreen)
193 if (p->fullscreen == fullscreen)
196 p->fullscreen = fullscreen;
197 Q_EMIT fullscreenChanged(fullscreen);
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list