From 758cec1a767c056aaf9da36fd411cdf4a8fba32e Mon Sep 17 00:00:00 2001 From: "Javier S. Pedro" Date: Tue, 14 Aug 2012 00:11:51 +0200 Subject: rewrite live notifications handling using models --- libsowatch/notificationsmodel.h | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'libsowatch/notificationsmodel.h') diff --git a/libsowatch/notificationsmodel.h b/libsowatch/notificationsmodel.h index 5e7e029..6aabf71 100644 --- a/libsowatch/notificationsmodel.h +++ b/libsowatch/notificationsmodel.h @@ -14,19 +14,32 @@ class NotificationsModel : public QAbstractListModel public: explicit NotificationsModel(QObject *parent = 0); + enum DataRoles { + ObjectRole = Qt::UserRole, + BodyRole, + CountRole + }; + int rowCount(const QModelIndex &parent) const; QVariant data(const QModelIndex &index, int role) const; void add(Notification *n); void remove(Notification *n); + void remove(Notification::Type type, Notification *n); int fullCount() const; int fullCountByType(Notification::Type type) const; - bool removeDeletedNotification(Notification *n); + Notification::Type getTypeOfDeletedNotification(Notification *n) const; private: - int getOffsetForType(Notification::Type type); + int getOffsetForType(Notification::Type type) const; + int getAppendOffsetForType(Notification::Type type) const; + int getIndexForNotification(Notification *n) const; + const Notification* getNotificationByIndex(int index) const; + +private slots: + void handleNotificationChanged(); private: QList _list[Notification::TypeCount]; @@ -34,4 +47,6 @@ private: } +QML_DECLARE_TYPE(sowatch::NotificationsModel) + #endif // SOWATCH_NOTIFICATIONSMODEL_H -- cgit v1.2.3