59 lines
1.3 KiB
C++
59 lines
1.3 KiB
C++
#include "NotificationService.h"
|
|
|
|
namespace {
|
|
|
|
class registerMetaTypes {
|
|
public:
|
|
registerMetaTypes()
|
|
{
|
|
qRegisterMetaType<NotificationSeverity>();
|
|
qRegisterMetaType<Notification>();
|
|
}
|
|
} registerMetaTypes_instance;
|
|
|
|
}
|
|
|
|
std::shared_ptr<NotificationService> NotificationService::s_instance;
|
|
|
|
std::shared_ptr<NotificationService> NotificationService::instance()
|
|
{
|
|
if (!s_instance) {
|
|
s_instance = std::make_shared<NotificationService>();
|
|
}
|
|
return s_instance;
|
|
}
|
|
|
|
NotificationService::NotificationService()
|
|
{
|
|
}
|
|
|
|
void NotificationService::addInformational(const QString &msg, const QString &detail)
|
|
{
|
|
add(NotificationSeverity::Informational, msg, detail);
|
|
}
|
|
|
|
void NotificationService::addWarning(const QString &msg, const QString &detail)
|
|
{
|
|
add(NotificationSeverity::Warning, msg, detail);
|
|
}
|
|
|
|
void NotificationService::addError(const QString &msg, const QString &detail)
|
|
{
|
|
add(NotificationSeverity::Error, msg, detail);
|
|
}
|
|
|
|
void NotificationService::add(NotificationSeverity severity, const QString &msg, const QString &detail)
|
|
{
|
|
m_notifications.push_back({ severity, msg, detail });
|
|
}
|
|
|
|
int NotificationService::count() const
|
|
{
|
|
return m_notifications.size();
|
|
}
|
|
|
|
const Notification& NotificationService::notification(int index)
|
|
{
|
|
return m_notifications.at(index);
|
|
}
|
|
|