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

@ -92,7 +92,7 @@ void SnoreCore::loadPlugins(SnorePlugin::PluginTypes types)
} }
} }
} }
break; break;
default: default:
snoreDebug(SNORE_WARNING) << "Plugin Cache corrupted\n" << info->file() << info->type(); snoreDebug(SNORE_WARNING) << "Plugin Cache corrupted\n" << info->file() << info->type();
continue; continue;
@ -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,
snoreDebug(SNORE_DEBUG) << "Registering Application:" << application; "Applications mus be registered only once.");
d->m_applications.insert(application.name(), application); snoreDebug(SNORE_DEBUG) << "Registering Application:" << application;
emit d->applicationRegistered(application); d->m_applications.insert(application.name(), application);
} emit d->applicationRegistered(application);
} }
void SnoreCore::deregisterApplication(const Application &application) void SnoreCore::deregisterApplication(const Application &application)
@ -246,7 +242,7 @@ void SnoreCore::displayExapleNotification()
{ {
Application app = SnoreCorePrivate::instance()->defaultApplication(); Application app = SnoreCorePrivate::instance()->defaultApplication();
QString text = QLatin1String("<i>") + tr("This is Snore") + QLatin1String("</i><br>") + QString text = QLatin1String("<i>") + tr("This is Snore") + QLatin1String("</i><br>") +
QLatin1String("<a href=\"https://github.com/Snorenotify/Snorenotify\">") + tr("Project Website") + QLatin1String("</a><br>"); QLatin1String("<a href=\"https://github.com/Snorenotify/Snorenotify\">") + tr("Project Website") + QLatin1String("</a><br>");
if (!app.constHints().value("use-markup").toBool()) { if (!app.constHints().value("use-markup").toBool()) {
text = Utils::normalizeMarkup(text, Utils::NO_MARKUP); text = Utils::normalizeMarkup(text, Utils::NO_MARKUP);
} }