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;
37MockNotification::MockNotification(QObject *parent) : QObject(parent), p(new MockNotificationPrivate()) {
38 p->actionsModel = new ActionModel();
41MockNotification::~MockNotification() {
42 delete p->actionsModel;
45QString MockNotification::getSummary() const {
49void MockNotification::setSummary(const QString &summary) {
50 if(p->summary != summary) {
52 Q_EMIT summaryChanged(p->summary);
53 Q_EMIT dataChanged(p->id);
57QString MockNotification::getBody() const {
61void MockNotification::setBody(const QString &body) {
64 Q_EMIT bodyChanged(p->body);
65 Q_EMIT dataChanged(p->id);
69int MockNotification::getID() const {
73void MockNotification::setID(const int id) {
77int MockNotification::getValue() const {
81void MockNotification::setValue(int value) {
82 if(p->value != value) {
84 Q_EMIT valueChanged(p->value);
85 Q_EMIT dataChanged(p->id);
89QString MockNotification::getIcon() const {
93void MockNotification::setIcon(const QString &icon) {
94 if (icon.startsWith(" ") || icon.size() == 0) {
100 if (icon.indexOf("/") == -1) {
101 p->icon.prepend("image://theme/");
105 Q_EMIT iconChanged(p->icon);
106 Q_EMIT dataChanged(p->id);
109QString MockNotification::getSecondaryIcon() const {
110 return p->secondaryIcon;
113void MockNotification::setSecondaryIcon(const QString &secondaryIcon) {
114 if (secondaryIcon.startsWith(" ") || secondaryIcon.size() == 0) {
115 p->secondaryIcon = nullptr;
118 p->secondaryIcon = secondaryIcon;
120 if (secondaryIcon.indexOf("/") == -1) {
121 p->secondaryIcon.prepend("image://theme/");
125 Q_EMIT secondaryIconChanged(p->secondaryIcon);
126 Q_EMIT dataChanged(p->id);
129MockNotification::Type MockNotification::getType() const {
133void MockNotification::setType(Type type) {
134 if(p->type != type) {
136 Q_EMIT typeChanged(p->type);
140ActionModel* MockNotification::getActions() const {
141 return p->actionsModel;
144QStringList MockNotification::rawActions() const {
148void MockNotification::setActions(const QStringList &actions) {
149 if(p->actions != actions) {
150 p->actions = actions;
151 Q_EMIT actionsChanged(p->actions);
153 for (int i = 0; i < p->actions.size(); i += 2) {
154 p->actionsModel->append(p->actions[i], p->actions[i+1]);
159QVariantMap MockNotification::getHints() const {
163void MockNotification::setHints(const QVariantMap& hints) {
164 if (p->hints != hints) {
166 Q_EMIT hintsChanged(p->hints);
170void MockNotification::invokeAction(const QString &action) {
171 for(int i=0; i<p->actions.size(); i++) {
172 if(p->actions[i] == action) {
173 Q_EMIT actionInvoked(action);
174 qDebug() << "Info: invoked action" << action;
178 fprintf(stderr, "Error: tried to invoke action not in actionList.\n");
181void MockNotification::close() {
182 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