summaryrefslogtreecommitdiff
path: root/libsowatch/notificationsmodel.cpp
diff options
context:
space:
mode:
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;
+}