messagingapp/msgui/unifiedviewer/src/univiewerpixmapwidget.cpp
changeset 27 e4592d119491
child 34 84197e66a4bd
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/messagingapp/msgui/unifiedviewer/src/univiewerpixmapwidget.cpp	Fri May 14 15:49:35 2010 +0300
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description: This widget displays the pixmap content in viewer.
+ *
+ */
+
+#include "univiewerpixmapwidget.h"
+
+#include <HbTapGesture>
+#include <HbWidget>
+#include <HbInstantFeedback>
+#include <QPixmap>
+
+//---------------------------------------------------------------
+// UniViewerPixmapWidget::UniViewerPixmapWidget
+// @see header file
+//---------------------------------------------------------------
+UniViewerPixmapWidget::UniViewerPixmapWidget(QGraphicsItem *parent) :
+    HbIconItem(parent)
+{
+    mPixmapFile = QString("");
+    this->grabGesture(Qt::TapGesture);
+}
+
+//---------------------------------------------------------------
+// UniViewerPixmapWidget::~UniViewerPixmapWidget
+// @see header file
+//---------------------------------------------------------------
+UniViewerPixmapWidget::~UniViewerPixmapWidget()
+{
+}
+
+//---------------------------------------------------------------
+// UniViewerPixmapWidget::setPixmap
+// @see header file
+//---------------------------------------------------------------
+void UniViewerPixmapWidget::setPixmap(const QString &pixmapPath)
+{
+    mPixmapFile = pixmapPath;
+    QPixmap pixmap(pixmapPath);
+    this->setIcon(HbIcon(pixmap));
+}
+
+//---------------------------------------------------------------
+// UniViewerPixmapWidget::gestureEvent
+// @see header file
+//---------------------------------------------------------------
+void UniViewerPixmapWidget::gestureEvent(QGestureEvent *event)
+{
+    HbTapGesture *tapGesture = qobject_cast<HbTapGesture*> (event->gesture(Qt::TapGesture));
+    if (tapGesture) {
+        switch (tapGesture->state()) {
+        case Qt::GestureStarted:
+        {
+            // Trigger haptic feedback.
+            HbInstantFeedback::play(HbFeedback::Basic);
+            break;
+        }
+        case Qt::GestureUpdated:
+        {
+            if (HbTapGesture::TapAndHold == tapGesture->tapStyleHint()) {
+                // emit longtap
+            }
+            break;
+        }
+        case Qt::GestureFinished:
+        {
+            if (HbTapGesture::Tap == tapGesture->tapStyleHint()) {
+                // Emit short tap
+                emit shortTap(mPixmapFile);
+            }
+            break;
+        }
+        case Qt::GestureCanceled:
+        {
+            break;
+        }
+        }
+    }
+}
+
+// EOF