doc and some asserts

This commit is contained in:
Patrick von Reth 2015-07-08 12:21:20 +02:00
parent 889eab6f38
commit 608a1be3d4
3 changed files with 13 additions and 13 deletions

View File

@ -18,13 +18,14 @@
#include "application.h" #include "application.h"
#include "application_p.h" #include "application_p.h"
#include "snore_p.h"
#include <QApplication> #include <QApplication>
using namespace Snore; using namespace Snore;
Application::Application(): Application::Application():
d(NULL) d(nullptr)
{} {}
Application::Application(const QString &name, const Icon &icon) : Application::Application(const QString &name, const Icon &icon) :
@ -52,6 +53,8 @@ Application::~Application()
void Application::addAlert(const Alert &alert) void Application::addAlert(const Alert &alert)
{ {
Q_ASSERT_X(!SnoreCore::instance().aplications().contains(name()), Q_FUNC_INFO,
"Alerts must be added before the application is Registered." );
d->m_alerts.insert(alert.name().toUtf8(), alert); d->m_alerts.insert(alert.name().toUtf8(), alert);
} }

View File

@ -64,7 +64,8 @@ public:
~Application(); ~Application();
/** /**
* Add an alert to the Application * Add an alert to the Application.
* Alerts must be added before the application is registered.
* @param alert the Alert * @param alert the Alert
*/ */
void addAlert(const Alert &alert); void addAlert(const Alert &alert);

View File

@ -114,10 +114,6 @@ void SnoreCore::broadcastNotification(Notification notification)
{ {
Q_D(SnoreCore); Q_D(SnoreCore);
Q_ASSERT_X(!notification.data()->isBroadcasted(), Q_FUNC_INFO, "Notification was already broadcasted."); Q_ASSERT_X(!notification.data()->isBroadcasted(), Q_FUNC_INFO, "Notification was already broadcasted.");
if (notification.data()->isBroadcasted()) {
snoreDebug(SNORE_WARNING) << "Notification" << notification << "was already broadcasted.";
return;
}
snoreDebug(SNORE_DEBUG) << "Broadcasting" << notification << "timeout:" << notification.timeout(); snoreDebug(SNORE_DEBUG) << "Broadcasting" << notification << "timeout:" << notification.timeout();
if (d->m_notificationBackend != nullptr) { if (d->m_notificationBackend != nullptr) {
if (notification.isUpdate() && !d->m_notificationBackend->canUpdateNotification()) { if (notification.isUpdate() && !d->m_notificationBackend->canUpdateNotification()) {
@ -131,11 +127,11 @@ void SnoreCore::broadcastNotification(Notification notification)
void SnoreCore::registerApplication(const Application &application) void SnoreCore::registerApplication(const Application &application)
{ {
Q_D(SnoreCore); Q_D(SnoreCore);
if (!d->m_applications.contains(application.name())) { Q_ASSERT_X(!d->m_applications.contains(application.name()), Q_FUNC_INFO,
"Applications mus be registered only once.");
snoreDebug(SNORE_DEBUG) << "Registering Application:" << application; snoreDebug(SNORE_DEBUG) << "Registering Application:" << application;
d->m_applications.insert(application.name(), application); d->m_applications.insert(application.name(), application);
emit d->applicationRegistered(application); emit d->applicationRegistered(application);
}
} }
void SnoreCore::deregisterApplication(const Application &application) void SnoreCore::deregisterApplication(const Application &application)