Make Application::alerts use a Qstring as key again

This commit is contained in:
Patrick von Reth 2015-07-08 15:36:44 +02:00
parent 608a1be3d4
commit 1a1e675745
5 changed files with 15 additions and 11 deletions

View File

@ -20,8 +20,6 @@
#include "application_p.h" #include "application_p.h"
#include "snore_p.h" #include "snore_p.h"
#include <QApplication>
using namespace Snore; using namespace Snore;
Application::Application(): Application::Application():
@ -32,7 +30,6 @@ Application::Application(const QString &name, const Icon &icon) :
d(new ApplicationData(name, icon)) d(new ApplicationData(name, icon))
{ {
addAlert(Alert(qApp->translate("Default Alert", "Default"), icon));
} }
Application::Application(const Application &other): Application::Application(const Application &other):
@ -55,7 +52,7 @@ void Application::addAlert(const Alert &alert)
{ {
Q_ASSERT_X(!SnoreCore::instance().aplications().contains(name()), Q_FUNC_INFO, Q_ASSERT_X(!SnoreCore::instance().aplications().contains(name()), Q_FUNC_INFO,
"Alerts must be added before the application is Registered." ); "Alerts must be added before the application is Registered." );
d->m_alerts.insert(alert.name().toUtf8(), alert); d->m_alerts.insert(alert.name(), alert);
} }
QString Application::name() const QString Application::name() const
@ -68,14 +65,14 @@ const Icon &Application::icon()const
return d->m_icon; return d->m_icon;
} }
const QHash<QByteArray, Alert> &Application::alerts() const const QHash<QString, Alert> &Application::alerts() const
{ {
return d->m_alerts; return d->m_alerts;
} }
const Alert Application::defaultAlert() const const Alert Application::defaultAlert() const
{ {
return d->m_alerts.value("Default"); return d->m_defaultAlert;
} }
bool Application::isValid() const bool Application::isValid() const

View File

@ -86,7 +86,7 @@ public:
* *
* @return a QHash with the Alers registered with this Application. * @return a QHash with the Alers registered with this Application.
*/ */
const QHash<QByteArray, Alert> &alerts() const; const QHash<QString, Alert> &alerts() const;
/** /**
* *

View File

@ -19,13 +19,18 @@
#include "application_p.h" #include "application_p.h"
#include "snore_p.h" #include "snore_p.h"
#include <QApplication>
using namespace Snore; using namespace Snore;
ApplicationData::ApplicationData(const QString &name, const Icon &icon): ApplicationData::ApplicationData(const QString &name, const Icon &icon):
m_name(name), m_name(name),
m_icon(icon) m_icon(icon),
m_defaultAlert(qApp->translate("Default Alert", "Default"), icon)
{ {
Q_ASSERT_X(!name.isEmpty(), Q_FUNC_INFO, "invalid name detected"); Q_ASSERT_X(!name.isEmpty(), Q_FUNC_INFO, "invalid name detected");
m_alerts.insert(m_defaultAlert.name(), m_defaultAlert);
m_hint.setValue("pushover-token", QLatin1String("aFB1TPCyZkkr7mubCGEKy5vJEWak9t")); m_hint.setValue("pushover-token", QLatin1String("aFB1TPCyZkkr7mubCGEKy5vJEWak9t"));
m_hint.setValue("use-markup", false); m_hint.setValue("use-markup", false);
m_hint.setValue("silent", SnoreCore::instance().settingsValue(QLatin1String("Silent"), LOCAL_SETTING)); m_hint.setValue("silent", SnoreCore::instance().settingsValue(QLatin1String("Silent"), LOCAL_SETTING));

View File

@ -34,8 +34,10 @@ public:
QString m_name; QString m_name;
Icon m_icon; Icon m_icon;
QHash<QByteArray, Alert> m_alerts; QHash<QString, Alert> m_alerts;
Hint m_hint; Hint m_hint;
Alert m_defaultAlert;
}; };
} }

View File

@ -102,8 +102,8 @@ void Parser::parse(Notification &sNotification, const QString &msg, QTcpSocket *
} }
if (!alertName.isEmpty() && app.isValid()) { if (!alertName.isEmpty() && app.isValid()) {
if (app.alerts().contains(alertName.toLatin1())) { if (app.alerts().contains(alertName)) {
alert = app.alerts().value(alertName.toLatin1()); alert = app.alerts().value(alertName);
} }
} }