2 * Copyright (C) 2011 Lukáš Karas <lukas.karas@centrum.cz>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #include <QAbstractListModel>
22 #include "../backend/telepathy-client.h"
24 #include "session-model-item.h"
25 #include "notification-item.h"
26 #include "main-window.h"
28 #ifndef NOTIFICATIONSMODEL_H
29 #define NOTIFICATIONSMODEL_H
31 class NotificationsModel
: public QAbstractListModel
{
34 Q_DISABLE_COPY(NotificationsModel
)
40 IdRole
= Qt::UserRole
,
49 NotificationsModel(MaknetoBackend::TelepathyClient
* client
, MainWindow
*window
, QObject
*parent
= 0);
50 virtual ~NotificationsModel();
51 bool containsNotification(const QString
&sessionId
, NotificationItem::NotificationType type
);
53 Q_INVOKABLE QVariant
data(int row
, int role
); // ivokable, for QML
55 virtual int rowCount(const QModelIndex
& index
) const;
56 virtual QVariant
data(const QModelIndex
& index
, int role
) const;
59 void acceptCall(const QString
&sessionId
);
60 void rejectCall(const QString
&sessionId
);
61 void acceptChat(const QString
&sessionId
);
62 void rejectChat(const QString
&sessionId
);
63 void notificationRemoved(const QString
&sessionId
, NotificationItem::NotificationType type
);
67 void addNotification(MaknetoBackend::Session
*session
, NotificationItem::NotificationType type
, QString msg
= QString());
68 Q_INVOKABLE
void acceptNotification(int id
);
69 Q_INVOKABLE
void declineNotification(int id
);
70 void onNotificationExpired(int id
);
73 void removeNotification(NotificationItem
*item
, int id
);
75 MaknetoBackend::TelepathyClient
* _client
;
76 QList
<NotificationItem
*> _items
;
77 QMap
<int, NotificationItem
*> _itemsMap
;
82 #endif /* NOTIFICATIONSMODEL_H */