summaryrefslogtreecommitdiff
path: root/libsowatch/notificationsmodel.cpp
blob: 2eba9a0a1ae9e76bdbcd2c7e2d1b533ab1da3436 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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;
}