summaryrefslogtreecommitdiff
path: root/testnotification/testnotificationprovider.cpp
blob: 687780b9c6f2574b6c4a8f6f63d7466d41d4eca5 (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
#include "testnotification.h"
#include "testnotificationprovider.h"

using namespace sowatch;

int TestNotificationProvider::_counter = 1;

TestNotificationProvider::TestNotificationProvider(QObject *parent) :
    NotificationProvider(parent),
    _timer(new QTimer(this))
{
	const int initial_delay = 2000;
	const int burst_num = 0;
	const int burst_delay = 500;
	const int extra_delay = 100 * 1000;
	QTimer::singleShot(initial_delay, this, SLOT(generateInitialNotification()));
	for (int i = 0; i < burst_num; i++) {
		QTimer::singleShot(initial_delay + burst_delay * (i+1), this, SLOT(generateNotification()));
	}
	connect(_timer, SIGNAL(timeout()), SLOT(generateNotification()));
	_timer->setInterval(extra_delay);
	_timer->start();
}

TestNotificationProvider::~TestNotificationProvider()
{
}

void TestNotificationProvider::generateInitialNotification()
{
	TestNotification *n = new TestNotification(Notification::EmailNotification,
	                                           "A friend",
	                                           "This is a test email notification");
	emit incomingNotification(n);
}

void TestNotificationProvider::generateNotification()
{
	TestNotification *n = new TestNotification(Notification::ImNotification,
	                                           QString("Friend %1").arg(_counter++),
	                                           "Lorem ipsum dolor sit amet. "
	                                           "Consectetur adipiscing elit. "
	                                           "Donec non congue augue.");
	emit incomingNotification(n);
}