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"
22struct MockNotificationPrivate {
27 MockNotification::Type type;
29 QString secondaryIcon;
31 ActionModel* actionsModel;
35MockNotification::MockNotification(QObject *parent) : QObject(parent), p(new MockNotificationPrivate()) {
36 p->actionsModel = new ActionModel();
39MockNotification::~MockNotification() {
42QString MockNotification::getSummary() const {
46void MockNotification::setSummary(const QString &summary) {
47 if(p->summary != summary) {
49 Q_EMIT summaryChanged(p->summary);
50 Q_EMIT dataChanged(p->id);
54QString MockNotification::getBody() const {
58void MockNotification::setBody(const QString &body) {
61 Q_EMIT bodyChanged(p->body);
62 Q_EMIT dataChanged(p->id);
66unsigned int MockNotification::getID() const {
70void MockNotification::setID(const unsigned int id) {
74int MockNotification::getValue() const {
78void MockNotification::setValue(int value) {
79 if(p->value != value) {
81 Q_EMIT valueChanged(p->value);
82 Q_EMIT dataChanged(p->id);
86QString MockNotification::getIcon() const {
90void MockNotification::setIcon(const QString &icon) {
91 if (icon.startsWith(" ") || icon.size() == 0) {
97 if (icon.indexOf("/") == -1) {
98 p->icon.prepend("image://theme/");
102 Q_EMIT iconChanged(p->icon);
103 Q_EMIT dataChanged(p->id);
106QString MockNotification::getSecondaryIcon() const {
107 return p->secondaryIcon;
110void MockNotification::setSecondaryIcon(const QString &secondaryIcon) {
111 if (secondaryIcon.startsWith(" ") || secondaryIcon.size() == 0) {
112 p->secondaryIcon = nullptr;
115 p->secondaryIcon = secondaryIcon;
117 if (secondaryIcon.indexOf("/") == -1) {
118 p->secondaryIcon.prepend("image://theme/");
122 Q_EMIT secondaryIconChanged(p->secondaryIcon);
123 Q_EMIT dataChanged(p->id);
126MockNotification::Type MockNotification::getType() const {
130void MockNotification::setType(Type type) {
131 if(p->type != type) {
133 Q_EMIT typeChanged(p->type);
137ActionModel* MockNotification::getActions() const {
138 return p->actionsModel;
141void MockNotification::setActions(const QStringList &actions) {
142 if(p->actions != actions) {
143 p->actions = actions;
144 Q_EMIT actionsChanged(p->actions);
146 for (int i = 0; i < p->actions.size(); i += 2) {
147 p->actionsModel->insertAction(p->actions[i], p->actions[i+1]);
152QVariantMap MockNotification::getHints() const {
156void MockNotification::setHints(const QVariantMap& hints) {
157 if (p->hints != hints) {
159 Q_EMIT hintsChanged(p->hints);
163void MockNotification::invokeAction(const QString &action) {
164 for(int i=0; i<p->actions.size(); i++) {
165 if(p->actions[i] == action) {
166 Q_EMIT completed(p->id);
170 fprintf(stderr, "Error: tried to invoke action not in actionList.\n");
173void MockNotification::close() {
174 Q_EMIT completed(p->id);
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