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() {
44QString MockNotification::getSummary() const {
48void MockNotification::setSummary(const QString &summary) {
49 if(p->summary != summary) {
51 Q_EMIT summaryChanged(p->summary);
52 Q_EMIT dataChanged(p->id);
56QString MockNotification::getBody() const {
60void MockNotification::setBody(const QString &body) {
63 Q_EMIT bodyChanged(p->body);
64 Q_EMIT dataChanged(p->id);
68int MockNotification::getID() const {
72void MockNotification::setID(const int id) {
76int MockNotification::getValue() const {
80void MockNotification::setValue(int value) {
81 if(p->value != value) {
83 Q_EMIT valueChanged(p->value);
84 Q_EMIT dataChanged(p->id);
88QString MockNotification::getIcon() const {
92void MockNotification::setIcon(const QString &icon) {
93 if (icon.startsWith(" ") || icon.size() == 0) {
99 if (icon.indexOf("/") == -1) {
100 p->icon.prepend("image://theme/");
104 Q_EMIT iconChanged(p->icon);
105 Q_EMIT dataChanged(p->id);
108QString MockNotification::getSecondaryIcon() const {
109 return p->secondaryIcon;
112void MockNotification::setSecondaryIcon(const QString &secondaryIcon) {
113 if (secondaryIcon.startsWith(" ") || secondaryIcon.size() == 0) {
114 p->secondaryIcon = nullptr;
117 p->secondaryIcon = secondaryIcon;
119 if (secondaryIcon.indexOf("/") == -1) {
120 p->secondaryIcon.prepend("image://theme/");
124 Q_EMIT secondaryIconChanged(p->secondaryIcon);
125 Q_EMIT dataChanged(p->id);
128MockNotification::Type MockNotification::getType() const {
132void MockNotification::setType(Type type) {
133 if(p->type != type) {
135 Q_EMIT typeChanged(p->type);
139ActionModel* MockNotification::getActions() const {
140 return p->actionsModel;
143QStringList MockNotification::rawActions() const {
147void MockNotification::setActions(const QStringList &actions) {
148 if(p->actions != actions) {
149 p->actions = actions;
150 Q_EMIT actionsChanged(p->actions);
152 for (int i = 0; i < p->actions.size(); i += 2) {
153 p->actionsModel->append(p->actions[i], p->actions[i+1]);
158QVariantMap MockNotification::getHints() const {
162void MockNotification::setHints(const QVariantMap& hints) {
163 if (p->hints != hints) {
165 Q_EMIT hintsChanged(p->hints);
169void MockNotification::invokeAction(const QString &action) {
170 for(int i=0; i<p->actions.size(); i++) {
171 if(p->actions[i] == action) {
172 Q_EMIT actionInvoked(action);
173 qDebug() << "Info: invoked action" << action;
177 fprintf(stderr, "Error: tried to invoke action not in actionList.\n");
180void MockNotification::close() {
181 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