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 "MockNotificationModel.h"
21#include "MockNotification.h"
23#include <unity/shell/notifications/ModelInterface.h>
29#include <QStringListModel>
32using namespace unity::shell::notifications;
34MockNotificationModel::MockNotificationModel(QObject *parent) : QAbstractListModel(parent) {
37MockNotificationModel::~MockNotificationModel() {
40int MockNotificationModel::rowCount(const QModelIndex &) const {
41 return m_queue.size();
44int MockNotificationModel::getCount() const {
45 return m_queue.size();
48QVariant MockNotificationModel::data(const QModelIndex &index, int role) const {
53 case ModelInterface::RoleType:
54 return QVariant(m_queue[index.row()]->getType());
56 case ModelInterface::RoleId:
57 return QVariant(m_queue[index.row()]->getID());
59 case ModelInterface::RoleSummary:
60 return QVariant(m_queue[index.row()]->getSummary());
62 case ModelInterface::RoleBody:
63 return QVariant(m_queue[index.row()]->getBody());
65 case ModelInterface::RoleValue:
66 return QVariant(m_queue[index.row()]->getValue());
68 case ModelInterface::RoleIcon:
69 return QVariant(m_queue[index.row()]->getIcon());
71 case ModelInterface::RoleSecondaryIcon:
72 return QVariant(m_queue[index.row()]->getSecondaryIcon());
74 case ModelInterface::RoleActions:
75 return QVariant::fromValue(m_queue[index.row()]->getActions());
77 case ModelInterface::RoleHints:
78 return QVariant(m_queue[index.row()]->getHints());
80 case ModelInterface::RoleNotification:
81 return QVariant::fromValue(m_queue[index.row()]);
88void MockNotificationModel::append(MockNotification* n) {
89 int location = m_queue.size();
90 QModelIndex insertionPoint = QModelIndex();
91 beginInsertRows(insertionPoint, location, location);
92 m_queue.insert(location, n);
96MockNotification* MockNotificationModel::getNotification(int id) const {
97 for(int i=0; i < m_queue.size(); i++) {
98 if(m_queue[i]->getID() == id) {
106void MockNotificationModel::remove(const int id) {
107 for(int i = 0; i < m_queue.size(); i++) {
108 if(m_queue[i]->getID() == id) {
115void MockNotificationModel::removeSecond() {
116 if(m_queue.size() < 2)
121void MockNotificationModel::removeInternal(int loc) {
122 QModelIndex deletePoint = QModelIndex();
123 beginRemoveRows(deletePoint, loc, loc);
124 m_queue.erase(m_queue.begin() + loc);
128MockNotification* MockNotificationModel::getRaw(const int notificationId) const {
129 for(int i = 0; i < m_queue.size(); i++) {
130 if(m_queue[i]->getID() == notificationId) {
131 MockNotification* n = m_queue[i];
139int MockNotificationModel::queued() const {
140 return m_queue.size();
143QHash<int, QByteArray> MockNotificationModel::roleNames() const {
144 QHash<int, QByteArray> roles;
146 roles.insert(ModelInterface::RoleType, "type");
147 roles.insert(ModelInterface::RoleUrgency, "urgency");
148 roles.insert(ModelInterface::RoleId, "id");
149 roles.insert(ModelInterface::RoleSummary, "summary");
150 roles.insert(ModelInterface::RoleBody, "body");
151 roles.insert(ModelInterface::RoleValue, "value");
152 roles.insert(ModelInterface::RoleIcon, "icon");
153 roles.insert(ModelInterface::RoleSecondaryIcon, "secondaryIcon");
154 roles.insert(ModelInterface::RoleActions, "actions");
155 roles.insert(ModelInterface::RoleHints, "hints");
156 roles.insert(ModelInterface::RoleNotification, "notification");
161void MockNotificationModel::onCompleted(int id) {
165void MockNotificationModel::onDataChanged(int id) {
166 for(int i = 0; i < m_queue.size(); i++) {
167 if(m_queue[i]->getID() == id) {
168 Q_EMIT dataChanged(index(i, 0), index(i, 0));
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