summaryrefslogtreecommitdiff
path: root/libsowatch/notification.h
blob: 8bae4ff1e85960b56a3a11e59008cb90ffe2076e (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
71
72
73
74
75
76
77
#ifndef SOWATCH_NOTIFICATION_H
#define SOWATCH_NOTIFICATION_H

#include <QtCore/QString>
#include <QtCore/QDateTime>
#include <QtGui/QImage>
#include <QtDeclarative/QtDeclarative>
#include "sowatch_global.h"

namespace sowatch
{

class SOWATCH_EXPORT Notification : public QObject
{
	Q_OBJECT
	Q_ENUMS(Type)
	Q_PROPERTY(Type type READ type CONSTANT)
	Q_PROPERTY(uint count READ count NOTIFY countChanged)
	Q_PROPERTY(QDateTime dateTime READ dateTime NOTIFY dateTimeChanged)
	Q_PROPERTY(QString displayTime READ displayTime NOTIFY displayTimeChanged STORED false)
	Q_PROPERTY(QString title READ title NOTIFY titleChanged)
	Q_PROPERTY(QString body READ body NOTIFY bodyChanged)
	Q_PROPERTY(QImage image READ image NOTIFY imageChanged)

public:
	enum Type {
		OtherNotification = 0,
		CallNotification,
		MissedCallNotification,
		SmsNotification,
		MmsNotification,
		ImNotification,
		EmailNotification,
		CalendarNotification,
		WeatherNotification,
		TypeCount
	};

	explicit Notification(QObject *parent = 0);
	virtual ~Notification();

	virtual Type type() const = 0;
	virtual uint count() const = 0;
	virtual QDateTime dateTime() const = 0;
	virtual QString displayTime() const;
	virtual QString title() const = 0;
	virtual QString body() const = 0;
	virtual QImage image() const;

public slots:
	/** Do something on this notification; open the application that caused it, answer, etc. */
	virtual void activate() = 0;
	/** Dismiss this notification. */
	virtual void dismiss() = 0;

signals:
	/* For the convenience of QML users */
	void countChanged();
	void dateTimeChanged();
	void displayTimeChanged();
	void titleChanged();
	void bodyChanged();
	void imageChanged();

	/** Generic "changed" signal if any of the properties changes; can be batched. */
	void changed();

	/** The notification has been dismissed by the user or via dismiss(). */
	void dismissed();
	/* Provider of this notification object should delete it after dismissal. */
};

}

QML_DECLARE_TYPE(sowatch::Notification)

#endif // SOWATCH_NOTIFICATION_H