Notification.cpp
1.43 KB
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
78
79
80
81
82
83
84
#include "Notification.h"
#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0))
Notification::Notification() : QJsonDocument()
{
}
Notification::Notification(const Notification& other) : QJsonDocument(other)
{
}
Notification::~Notification()
{
}
#include <QDebug>
Notification Notification::parse(const char *data)
{
Notification info = Notification();
if (data)
{
QByteArray dataBytes = QByteArray(data);
info = (Notification&)QJsonDocument::fromJson(dataBytes);
}
return info;
}
QString Notification::getStringValue(const char *key)
{
return this->object().find(key).value().toString();
}
Notification &Notification::operator=(const Notification &other)
{
this->setObject(other.object());
return *this;
}
int Notification::getIntValue(const char *key)
{
return this->object().find(key).value().toDouble();
}
#else
Notification::Notification() : Json::Value()
{
}
Notification::Notification(const Notification& other) : Json::Value(other)
{
}
Notification::~Notification()
{
}
Notification Notification::parse(const char *data)
{
Json::Reader reader;
Notification info = Notification();
if (data)
reader.parse(data, info, false);
return info;
}
QString Notification::getStringValue(const char *key) const
{
return QString::fromUtf8(this->get(key, "").asCString());
}
int Notification::getIntValue(const char *key) const
{
return this->get(key, 0).asInt();
}
#endif