PushContentController.cpp Example File
pushCollector/10.0/pushCollector/src/PushContentController.cpp
#include "PushContentController.hpp"
#include "vo/Push.hpp"
#include <bb/cascades/Image>
#include <QDebug>
PushContentController::PushContentController(QObject *parent)
: QObject(parent)
, m_contentType("plainText")
{
}
void PushContentController::setCurrentPush(const Push &push)
{
m_pushDateTime = QString::fromLatin1("%1 - %2").arg(push.pushDateAsString()).arg(push.pushTime());
if (push.contentType() == CONTENT_TYPE_TEXT || push.fileExtension() == FILE_EXTENSION_XML) {
m_contentType = QLatin1String("plainText");
m_textContent = QString::fromUtf8(push.content().data());
} else if (push.contentType() == CONTENT_TYPE_IMAGE) {
m_contentType = QLatin1String("image");
m_imageContent = QVariant::fromValue(bb::cascades::Image(push.content()));
} else if (push.fileExtension() == FILE_EXTENSION_HTML) {
m_contentType = QLatin1String("richText");
m_textContent = QString::fromUtf8(push.content().data());
}
emit pushContentChanged();
}
QString PushContentController::pushDateTime() const
{
return m_pushDateTime;
}
QString PushContentController::contentType() const
{
return m_contentType;
}
QString PushContentController::textContent() const
{
return m_textContent;
}
QVariant PushContentController::imageContent() const
{
return m_imageContent;
}