--- a/messagingapp/msgui/unifiedviewer/src/univiewerbodywidget.cpp Tue Jul 06 14:12:40 2010 +0300
+++ b/messagingapp/msgui/unifiedviewer/src/univiewerbodywidget.cpp Wed Aug 18 09:45:25 2010 +0300
@@ -21,6 +21,7 @@
#include <QFile>
#include <HbTextItem>
#include <HbMainWindow>
+#include <HbIconItem>
// USER INCLUDES
#include "univiewertextitem.h"
@@ -33,13 +34,15 @@
const QString VIDEO_MIMETYPE("video");
const QString TEXT_MIMETYPE("text");
+static const char VIDEO_ICON[] = "qtg_large_video_player";
+
//---------------------------------------------------------------
//UniViewerBodyWidget::UniViewerBodyWidget
// @see header file
//---------------------------------------------------------------
UniViewerBodyWidget::UniViewerBodyWidget(QGraphicsItem *parent) :
HbWidget(parent), mHasText(false), mHasPixmap(false), mTextItem(0), mSlideCounter(0),
- mPixmapItem(0), mAudioItem(0)
+ mPixmapItem(0), mAudioItem(0), mOverlayItem(0)
{
this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
}
@@ -53,95 +56,6 @@
}
//---------------------------------------------------------------
-//UniViewerBodyWidget::setImage
-// @see header file
-//---------------------------------------------------------------
-void UniViewerBodyWidget::setPixmap(UniMessageInfo *info)
-{
- setHasPixmap(true);
- //create image item instance
- if (!mPixmapItem) {
- mPixmapItem = new UniViewerPixmapWidget(this);
- HbStyle::setItemName(mPixmapItem, "pixmap");
- }
- mPixmapItem->hide();
- mPixmapItem->populate(info);
-
- this->repolish();
-}
-
-//---------------------------------------------------------------
-//UniViewerBodyWidget::setAudio
-// @see header file
-//---------------------------------------------------------------
-void UniViewerBodyWidget::setAudio(UniMessageInfo *info)
-{
- if (!mAudioItem) {
- mAudioItem = new UniViewerAudioWidget(this);
- HbStyle::setItemName(mAudioItem, "audioItem");
- }
- mAudioItem->hide();
- mAudioItem->populate(info);
-
- this->repolish();
-}
-
-//---------------------------------------------------------------
-//UniViewerBodyWidget::setVideo
-// @see header file
-//---------------------------------------------------------------
-void UniViewerBodyWidget::setVideo(UniMessageInfo *info)
-{
- setHasPixmap(true);
- //create image item instance
- if (!mPixmapItem) {
- mPixmapItem = new UniViewerPixmapWidget(this);
- HbStyle::setItemName(mPixmapItem, "pixmap");
- }
- mPixmapItem->hide();
- mPixmapItem->populate(info);
-
- this->repolish();
-}
-
-//---------------------------------------------------------------
-//UniViewerBodyWidget::setText
-// @see header file
-//---------------------------------------------------------------
-void UniViewerBodyWidget::setText(QString text)
-{
- setHasText(true);
-
- if (!mTextItem) {
- mTextItem = new UniViewerTextItem(this);
- HbStyle::setItemName(mTextItem, "textItem");
- connect(mTextItem, SIGNAL(sendMessage(const QString&)), this,
- SIGNAL(sendMessage(const QString&)));
- }
- mTextItem->hide();
- text.replace(QChar::ParagraphSeparator, QChar::LineSeparator);
- text.replace('\r', QChar::LineSeparator);
- mTextItem->setText(text);
- this->repolish();
-}
-
-//---------------------------------------------------------------
-// UniViewerBodyWidget::setSlideCounter
-// @see header file
-//---------------------------------------------------------------
-void UniViewerBodyWidget::setSlideCounter(QString &slideCounter)
-{
- if (!mSlideCounter) {
- mSlideCounter = new HbTextItem(this);
- HbStyle::setItemName(mSlideCounter, "slideCounter");
- }
-
- mSlideCounter->hide();
- mSlideCounter->setText(slideCounter);
- this->repolish();
-}
-
-//---------------------------------------------------------------
// UniViewerBodyWidget::setHasText
// @see header file
//---------------------------------------------------------------
@@ -195,7 +109,16 @@
if (mimeType.contains(TEXT_MIMETYPE)) {
QFile file(info->path());
if (file.open(QIODevice::ReadOnly)) {
- QString textContent(file.readAll());
+ QString textContent;
+ QByteArray textArray;
+ textArray = file.readAll();
+ char *data = new char[textArray.size()+1];
+ strcpy(data,textArray.data());
+ //This is needed since MMS text content
+ //is stored in UTF8 format
+ textContent = textContent.fromUtf8(data,strlen(data));
+ file.close();
+ delete []data;
setText(textContent);
}
}
@@ -214,7 +137,7 @@
}
//---------------------------------------------------------------
-//UniViewerBodyWidget :: clearContent
+// UniViewerBodyWidget :: clearContent
// @see header file
//---------------------------------------------------------------
void UniViewerBodyWidget::clearContent()
@@ -238,12 +161,41 @@
mTextItem = NULL;
}
+ if (mOverlayItem) {
+ mOverlayItem->setParent(NULL);
+ delete mOverlayItem;
+ mOverlayItem = NULL;
+ }
+
setHasText(false);
setHasPixmap(false);
repolish();
}
//---------------------------------------------------------------
+// UniViewerBodyWidget::setText
+// @see header file
+//---------------------------------------------------------------
+void UniViewerBodyWidget::setText(QString text)
+{
+ setHasText(true);
+
+ if (!mTextItem) {
+ mTextItem = new UniViewerTextItem(this);
+ mTextItem->setObjectName("textItem");
+ HbStyle::setItemName(mTextItem, "textItem");
+ connect(mTextItem, SIGNAL(sendMessage(const QString&)), this,
+ SIGNAL(sendMessage(const QString&)));
+ }
+ mTextItem->hide();
+ text.replace(QChar::ParagraphSeparator, QChar::LineSeparator);
+ text.replace('\r', QChar::LineSeparator);
+ mTextItem->setText(text);
+
+ this->repolish();
+}
+
+//---------------------------------------------------------------
//UniViewerBodyWidget::sizeHint
// @see header file
//---------------------------------------------------------------
@@ -360,6 +312,10 @@
mPixmapItem->show();
}
+ if (mOverlayItem) {
+ mOverlayItem->show();
+ }
+
// Calculate the size hint to be returned.
szHint.setHeight(0);
@@ -389,4 +345,115 @@
return szHint;
}
+//---------------------------------------------------------------
+//UniViewerBodyWidget::setPixmap
+// @see header file
+//---------------------------------------------------------------
+void UniViewerBodyWidget::setPixmap(UniMessageInfo *info)
+{
+ setHasPixmap(true);
+ //create image item instance
+ if (!mPixmapItem) {
+ mPixmapItem = new UniViewerPixmapWidget(this);
+ HbStyle::setItemName(mPixmapItem, "pixmap");
+ }
+ mPixmapItem->hide();
+ mPixmapItem->populate(info);
+
+ this->repolish();
+}
+
+//---------------------------------------------------------------
+//UniViewerBodyWidget::setAudio
+// @see header file
+//---------------------------------------------------------------
+void UniViewerBodyWidget::setAudio(UniMessageInfo *info)
+{
+ if (!mAudioItem) {
+ mAudioItem = new UniViewerAudioWidget(this);
+ HbStyle::setItemName(mAudioItem, "audioItem");
+ }
+ mAudioItem->hide();
+ mAudioItem->populate(info);
+
+ this->repolish();
+}
+
+//---------------------------------------------------------------
+//UniViewerBodyWidget::setVideo
+// @see header file
+//---------------------------------------------------------------
+void UniViewerBodyWidget::setVideo(UniMessageInfo *info)
+{
+ setHasPixmap(true);
+ //create image item instance
+ if (!mPixmapItem) {
+ mPixmapItem = new UniViewerPixmapWidget(this);
+ HbStyle::setItemName(mPixmapItem, "pixmap");
+ connect(mPixmapItem, SIGNAL(thumbnailFound(bool, UniMessageInfo*)), this,
+ SLOT(onThumbnailFound(bool, UniMessageInfo*)));
+ }
+ mPixmapItem->hide();
+ mPixmapItem->populate(info);
+
+ this->repolish();
+}
+
+//---------------------------------------------------------------
+// UniViewerBodyWidget::setSlideCounter
+// @see header file
+//---------------------------------------------------------------
+void UniViewerBodyWidget::setSlideCounter(QString &slideCounter)
+{
+ if (!mSlideCounter) {
+ mSlideCounter = new HbTextItem(this);
+ HbStyle::setItemName(mSlideCounter, "slideCounter");
+ }
+
+ mSlideCounter->hide();
+ mSlideCounter->setText(slideCounter);
+
+ this->repolish();
+}
+
+//---------------------------------------------------------------
+// UniViewerBodyWidget::setOverlayIcon
+// @see header file
+//---------------------------------------------------------------
+void UniViewerBodyWidget::setOverlayIcon(const QString &iconName)
+{
+ if (!mOverlayItem) {
+ mOverlayItem = new HbIconItem(this);
+ HbStyle::setItemName(mOverlayItem, "overlayItem");
+ }
+
+ mOverlayItem->hide();
+ mOverlayItem->setIconName(iconName);
+
+ this->repolish();
+}
+
+//---------------------------------------------------------------
+// UniViewerBodyWidget::onThumbnailFound
+// @see header file
+//---------------------------------------------------------------
+void UniViewerBodyWidget::onThumbnailFound(bool result, UniMessageInfo *info)
+{
+ if (result) {
+ // Thumbnail generation success
+ setOverlayIcon(VIDEO_ICON);
+ }
+ else {
+ // Show video content in audio widget.
+ setAudio(info);
+
+ // Remove the pixmap widget.
+ setHasPixmap(false);
+ if (mPixmapItem) {
+ HbStyle::setItemName(mPixmapItem, "");
+ mPixmapItem->hide();
+ }
+ }
+}
+
// EOF