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
#ifndef MOCK_NOTIFICATION_MODEL_H
21
#define MOCK_NOTIFICATION_MODEL_H
23
#include <QAbstractListModel>
24
#include <QSharedPointer>
25
#include <QScopedPointer>
26
#include "MockNotification.h"
28
class MockNotification;
30
class MockNotificationModel : public QAbstractListModel {
32
Q_PROPERTY(int count READ getCount)
35
MockNotificationModel(QObject *parent=nullptr);
36
virtual ~MockNotificationModel();
38
virtual int rowCount(const QModelIndex &parent) const;
39
virtual QVariant data(const QModelIndex &index, int role) const;
40
virtual QHash<int, QByteArray> roleNames() const;
42
Q_INVOKABLE void append(MockNotification* n);
43
MockNotification* getNotification(int id) const;
45
// getRaw() is only meant to be used from QML, since QML cannot handle
46
// QSharedPointers... on C++-side only use getNotification()
47
Q_INVOKABLE MockNotification* getRaw(const int notificationId) const;
49
Q_INVOKABLE int queued() const;
50
Q_INVOKABLE void remove(const int id);
51
Q_INVOKABLE void removeSecond();
56
void actionInvoked(const QString &action);
59
void onCompleted(int id);
62
void onDataChanged(int id);
65
void queueSizeChanged(int newSize);
68
QList<MockNotification*> m_queue;
69
void removeInternal(int loc);