--- a/messagingapp/msgui/unifiedviewer/src/univiewerpixmapwidget.cpp Fri Jun 11 13:35:48 2010 +0300
+++ b/messagingapp/msgui/unifiedviewer/src/univiewerpixmapwidget.cpp Wed Jun 23 18:09:17 2010 +0300
@@ -24,22 +24,46 @@
#include <HbMenu>
#include <QPixmap>
#include <QTimer>
+#include <thumbnailmanager_qt.h>
// USER INCLUDES
#include "univiewerutils.h"
+#include "unidatamodelplugininterface.h"
// LOCAL CONSTANTS
#define LOC_OPEN hbTrId("txt_common_menu_open")
#define LOC_SAVE hbTrId("txt_common_menu_save")
+const QString PIXMAP_ICON("qtg_small_image");
+const QString CORRUPTED_PIXMAP_ICON("qtg_large_corrupted");
+const QString VIDEO_MIMETYPE("video");
+const QString MSG_VIDEO_ICON("qtg_large_video_player");
+
//---------------------------------------------------------------
// UniViewerPixmapWidget::UniViewerPixmapWidget
// @see header file
//---------------------------------------------------------------
UniViewerPixmapWidget::UniViewerPixmapWidget(QGraphicsItem *parent) :
- HbIconItem(parent), mViewerUtils(0)
+ HbIconItem(parent), mViewerUtils(0), mThumbnailManager(0)
{
this->grabGesture(Qt::TapGesture);
+ init();
+}
+
+//---------------------------------------------------------------
+// UniViewerPixmapWidget::init
+// @see header file
+//---------------------------------------------------------------
+void UniViewerPixmapWidget::init()
+{
+ mThumbnailManager = new ThumbnailManager(this);
+ mThumbnailManager->setMode(ThumbnailManager::Default);
+ mThumbnailManager->setQualityPreference(ThumbnailManager::OptimizeForQuality);
+ mThumbnailManager->setThumbnailSize(ThumbnailManager::ThumbnailLarge);
+
+ connect(mThumbnailManager, SIGNAL(thumbnailReady(QPixmap, void*, int, int)), this,
+ SLOT(thumbnailReady(QPixmap, void*, int, int)));
+
}
//---------------------------------------------------------------
@@ -54,12 +78,25 @@
// UniViewerPixmapWidget::setPixmap
// @see header file
//---------------------------------------------------------------
-void UniViewerPixmapWidget::populate(const QString &mimeType, const QString &pixmapPath)
+void UniViewerPixmapWidget::populate(UniMessageInfo *info)
{
- mMimeType = mimeType;
- mPixmapPath = pixmapPath;
- QPixmap pixmap(mPixmapPath);
- this->setIcon(HbIcon(pixmap));
+ mMimeType = info->mimetype();
+ mPixmapPath = info->path();
+ if (mMimeType.contains(VIDEO_MIMETYPE)) {
+ this->setIcon(MSG_VIDEO_ICON);
+ mThumbnailManager->getThumbnail(mPixmapPath);
+ this->ungrabGesture(Qt::TapGesture);
+ }
+ else if (info->isProtected()) {
+ this->setIconName(PIXMAP_ICON);
+ }
+ else if (info->isCorrupted()) {
+ this->setIconName(CORRUPTED_PIXMAP_ICON);
+ }
+ else {
+ QPixmap pixmap(mPixmapPath);
+ this->setIcon(HbIcon(pixmap));
+ }
}
//---------------------------------------------------------------
@@ -113,12 +150,12 @@
void UniViewerPixmapWidget::handleOpen()
{
this->ungrabGesture(Qt::TapGesture);
-
+
if (!mViewerUtils) {
mViewerUtils = new UniViewerUtils(this);
}
mViewerUtils->launchContentViewer(mMimeType, mPixmapPath);
-
+
//fire timer to regrab gesture after some delay.
QTimer::singleShot(300,this,SLOT(regrabGesture()));
}
@@ -167,4 +204,22 @@
{
this->grabGesture(Qt::TapGesture);
}
+
+//---------------------------------------------------------------
+// UniViewerPixmapWidget::thumbnailReady
+// @see header
+//---------------------------------------------------------------
+void UniViewerPixmapWidget::thumbnailReady(const QPixmap& pixmap, void *data, int id, int error)
+{
+ Q_UNUSED(data)
+ Q_UNUSED(id)
+ this->grabGesture(Qt::TapGesture);
+ if (!error) {
+ this->setIcon(HbIcon(pixmap));
+ this->hide();
+ // calling the sizeint forcefully as thumbnailReady is a async call
+ // by the time this call has come sizeint would have already been calculated.
+ this->parentWidget()->resize(-1, -1);
+ }
+}
// EOF