make zooming more smooth (zooming on background)
[makneto-zunavac1.git] / src / ui-mobile / notifications-model.h
blob08ddde103b8a1f86575d73dece9c032702e4409c
1 /*
2 * Copyright (C) 2011 Lukáš Karas <lukas.karas@centrum.cz>
3 *
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.
8 *
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 {
33 Q_OBJECT
34 Q_DISABLE_COPY(NotificationsModel)
35 Q_ENUMS(Role)
37 public:
38 enum Role {
39 // general roles
40 IdRole = Qt::UserRole,
41 TitleRole,
42 SessionIdRole,
43 SessionNameRole,
44 MessageRole,
45 IconRole,
46 TypeRole
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;
58 Q_SIGNALS:
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);
65 public
66 Q_SLOTS:
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);
72 private:
73 void removeNotification(NotificationItem *item, int id);
75 MaknetoBackend::TelepathyClient* _client;
76 QList<NotificationItem*> _items;
77 QMap<int, NotificationItem*> _itemsMap;
78 int lastId;
79 MainWindow *_window;
82 #endif /* NOTIFICATIONSMODEL_H */