summaryrefslogtreecommitdiff
path: root/libsowatch/notificationsmodel.cpp
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2013-05-06 01:11:40 +0200
committerJavier S. Pedro <maemo@javispedro.com>2013-05-06 01:11:40 +0200
commitd83093df7602aa2896de71292b47948540c22a44 (patch)
tree5f0b2c86f8a75124aaa4ae03547ec8b9f4bc4376 /libsowatch/notificationsmodel.cpp
parent12cf6df3f1c90c6ccbab398f0ae03c946e4af638 (diff)
downloadsowatch-d83093df7602aa2896de71292b47948540c22a44.tar.gz
sowatch-d83093df7602aa2896de71292b47948540c22a44.zip
metawatch watchface in QML still a work in progress
Diffstat (limited to 'libsowatch/notificationsmodel.cpp')
-rw-r--r--libsowatch/notificationsmodel.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/libsowatch/notificationsmodel.cpp b/libsowatch/notificationsmodel.cpp
index 73d4ab6..259ac93 100644
--- a/libsowatch/notificationsmodel.cpp
+++ b/libsowatch/notificationsmodel.cpp
@@ -56,6 +56,8 @@ void NotificationsModel::add(Notification *n)
_list[type].append(n);
endInsertRows();
+ emit modelChanged();
+
connect(n, SIGNAL(changed()), SLOT(handleNotificationChanged()));
}
@@ -77,6 +79,8 @@ void NotificationsModel::remove(Notification::Type type, Notification *n)
beginRemoveRows(QModelIndex(), index, index);
_list[type].removeAt(subindex);
endRemoveRows();
+
+ emit modelChanged();
}
int NotificationsModel::fullCount() const
@@ -97,6 +101,28 @@ int NotificationsModel::fullCountByType(Notification::Type type) const
return count;
}
+int NotificationsModel::fullCountByType(int type) const
+{
+ Q_ASSERT(type >= 0 && type < Notification::TypeCount);
+ return fullCountByType(static_cast<Notification::Type>(type));
+}
+
+Notification* NotificationsModel::getMostRecentByType(Notification::Type type) const
+{
+ if (!_list[type].empty()) {
+ // TODO Actually get the most recent (sort by date)
+ return _list[type].first();
+ } else {
+ return 0;
+ }
+}
+
+Notification* NotificationsModel::getMostRecentByType(int type) const
+{
+ Q_ASSERT(type >= 0 && type < Notification::TypeCount);
+ return getMostRecentByType(static_cast<Notification::Type>(type));
+}
+
Notification::Type NotificationsModel::getTypeOfDeletedNotification(Notification *n) const
{
// Can't call any methods of 'n'
@@ -154,5 +180,6 @@ void NotificationsModel::handleNotificationChanged()
const int index = getIndexForNotification(n);
emit dataChanged(createIndex(index, 0), createIndex(index, 0));
+ emit modelChanged();
}
}