summaryrefslogtreecommitdiff
path: root/libsowatch/notificationsmodel.cpp
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2012-08-13 21:31:52 +0200
committerJavier S. Pedro <maemo@javispedro.com>2012-08-13 21:31:52 +0200
commitabdf3b1eaba8151f1b8e862750c38cb7a5411d2a (patch)
tree69e314d80a332295dd5475fc91f45c2078eaead5 /libsowatch/notificationsmodel.cpp
parent51701e30d710ad016ddf2d306cdd7be122ddf25b (diff)
downloadsowatch-abdf3b1eaba8151f1b8e862750c38cb7a5411d2a.tar.gz
sowatch-abdf3b1eaba8151f1b8e862750c38cb7a5411d2a.zip
make watchsimulator work again
Diffstat (limited to 'libsowatch/notificationsmodel.cpp')
-rw-r--r--libsowatch/notificationsmodel.cpp70
1 files changed, 70 insertions, 0 deletions
diff --git a/libsowatch/notificationsmodel.cpp b/libsowatch/notificationsmodel.cpp
new file mode 100644
index 0000000..2eba9a0
--- /dev/null
+++ b/libsowatch/notificationsmodel.cpp
@@ -0,0 +1,70 @@
+#include "notificationsmodel.h"
+
+using namespace sowatch;
+
+#define FOREACH_TYPE_FROM_TO(x, from, to) \
+ for(Notification::Type x = from; x < to; x = static_cast<Notification::Type>(x + 1))
+
+#define FOREACH_TYPE_UNTIL(x, to) FOREACH_TYPE_FROM_TO(x, Notification::OtherNotification, to)
+
+#define FOREACH_TYPE(x) FOREACH_TYPE_FROM_TO(x, Notification::OtherNotification, Notification::TypeCount)
+
+NotificationsModel::NotificationsModel(QObject *parent) :
+ QAbstractListModel(parent)
+{
+}
+
+int NotificationsModel::rowCount(const QModelIndex &parent) const
+{
+ int count = 0;
+ Q_UNUSED(parent);
+ FOREACH_TYPE(type) {
+ count += _list[type].count();
+ }
+ return count;
+}
+
+QVariant NotificationsModel::data(const QModelIndex &index, int role) const
+{
+}
+
+void NotificationsModel::add(Notification *n)
+{
+}
+
+void NotificationsModel::remove(Notification *n)
+{
+
+}
+
+int NotificationsModel::fullCount() const
+{
+ int count = 0;
+ FOREACH_TYPE(type) {
+ count += fullCountByType(type);
+ }
+ return count;
+}
+
+int NotificationsModel::fullCountByType(Notification::Type type) const
+{
+ int count = 0;
+ Q_FOREACH(const Notification *n, _list[type]) {
+ count += n->count();
+ }
+ return count;
+}
+
+bool NotificationsModel::removeDeletedNotification(Notification *n)
+{
+ // Can't call any methods of 'n'
+}
+
+int NotificationsModel::getOffsetForType(Notification::Type type)
+{
+ int count = 0;
+ FOREACH_TYPE_UNTIL(t, type) {
+ count += _list[type].count();
+ }
+ return count;
+}