#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 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