fixed qt4 etc

This commit is contained in:
Patrick von Reth 2014-01-18 18:56:11 +01:00
parent 8b57c2a41b
commit 95075fe29a
5 changed files with 17 additions and 4 deletions

View File

@ -49,6 +49,18 @@ private:
};
template<typename Type>
inline Type myQVariantCast(const QVariant &dat)
{
return qobject_cast<Type>(qvariant_cast<QObject*>(dat));
}
template<typename Type>
inline QVariant myQVariantFromValue(const Type &dat)
{
return qVariantFromValue(qobject_cast<QObject*>(dat));
}
}

View File

@ -74,7 +74,7 @@ void SnorePlugin::startTimeout(Notification &notification)
return;
}
uint id = notification.id();
QTimer *timer = qvariant_cast<QTimer*>(notification.hints().privateValue(this, "timeout"));
QTimer *timer = myQVariantCast<QTimer*>(notification.hints().privateValue(this, "timeout"));
if(notification.updateID() != (uint)-1)
{
id = notification.updateID();
@ -88,6 +88,7 @@ void SnorePlugin::startTimeout(Notification &notification)
timer = new QTimer(this);
timer->setSingleShot(true);
timer->setProperty("notificationID", id);
notification.hints().setPrivateValue(this, "timeout", myQVariantFromValue(timer));
}
timer->setInterval(notification.timeout() * 1000);

View File

@ -138,7 +138,7 @@ uint FreedesktopFrontend::Notify(const QString &app_name, uint replaces_id,
}
snore()->broadcastNotification(noti);
startTimeout(noti.id(),noti.timeout());
startTimeout(noti);
return noti.id();
}

View File

@ -138,7 +138,7 @@ void Parser::parse(Notification &sNotification,const QString &msg,QTcpSocket* cl
}
sNotification = Notification(app,alert,title,text,icon,timeout);
sNotification.data()->setSource(snarl);
sNotification.hints().setPrivateValue(snarl, "clientSocket", qVariantFromValue(client));
sNotification.hints().setPrivateValue(snarl, "clientSocket", myQVariantFromValue(client));
break;
}
case ADD_CLASS:

View File

@ -129,7 +129,7 @@ void SnarlNetworkFrontend::handleMessages()
void SnarlNetworkFrontend::callback(Notification &sn, const QString msg)
{
QTcpSocket *client = qvariant_cast<QTcpSocket*>(sn.hints().privateValue(this, "clientSocket"));
QTcpSocket *client = myQVariantCast<QTcpSocket*>(sn.hints().privateValue(this, "clientSocket"));
if(client && !msg.isEmpty())
{
write(client, QString("%1%2\r\n").arg(msg, QString::number(sn.id())));