ui/detailscustomwidget/detailscustomwidgets/glxdetailstextedit.cpp
changeset 67 199e6e1e0b54
parent 61 743eb0b9959e
--- a/ui/detailscustomwidget/detailscustomwidgets/glxdetailstextedit.cpp	Thu Sep 02 20:26:45 2010 +0300
+++ b/ui/detailscustomwidget/detailscustomwidgets/glxdetailstextedit.cpp	Fri Sep 17 08:29:24 2010 +0300
@@ -1,60 +1,62 @@
 /*
-* 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 is custom widget for details view in photos for displaying the description of image .
-*
-*/
- 
+ * 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 is custom widget for details view in photos for displaying the description of image .
+ *
+ */
 
+#include <QDebug>
+#include <QEvent>
+#include <QInputContext>
+#include <QGraphicsObject>
+
+#include <hbeditorinterface>
+#include <hbtapgesture.h>
+#include <hbapplication.h>
 
 #include "glxdetailstextedit.h"
-#include <hbeditorinterface>
-#include <QEvent>
-
-
 
 //--------------------------------------------------------------------------------------------------------------------------------------------
-//focusInEvent
+//gestureEvent
 //--------------------------------------------------------------------------------------------------------------------------------------------
-void  GlxDetailsTextEdit::focusInEvent (QFocusEvent *event)
-    {
-    if(event->reason() == Qt::MouseFocusReason )
-        {
-          event->setAccepted(TRUE);
-          emit labelPressed();
+void GlxDetailsTextEdit::gestureEvent(QGestureEvent* event)
+{
+    HbLineEdit::gestureEvent(event);
+    HbTapGesture *tap = qobject_cast<HbTapGesture *> (event->gesture(Qt::TapGesture));
+    if (tap && (tap->state() == Qt::GestureFinished || tap->state() == Qt::GestureUpdated)) {
+        QInputContext *ic = qApp->inputContext();
+        if (ic) {
+            QEvent *openEvent = new QEvent(QEvent::CloseSoftwareInputPanel);
+            ic->filterEvent(openEvent);
+            delete openEvent;
+
+            if (!mEditorReadOnly && tap->state() == Qt::GestureFinished) {
+                //Only emit the signal in case of editor is not ready only
+                emit editorTapped();
+            }
         }
-    
     }
-    
-    
-//--------------------------------------------------------------------------------------------------------------------------------------------
-//focusOutEvent
-//--------------------------------------------------------------------------------------------------------------------------------------------
-void  GlxDetailsTextEdit::focusOutEvent (QFocusEvent *event) 
-    {
-     event->setAccepted(TRUE);    
-    }
-
+}
 
 //--------------------------------------------------------------------------------------------------------------------------------------------
 //GlxDetailsTextEdit
 //--------------------------------------------------------------------------------------------------------------------------------------------
-GlxDetailsTextEdit::GlxDetailsTextEdit(QGraphicsItem *parent) : HbTextEdit( parent )
+GlxDetailsTextEdit::GlxDetailsTextEdit(QGraphicsItem *parent) :
+    HbLineEdit(parent), mEditorReadOnly(0)
 {
-   setAlignment(Qt::AlignLeft);
-   mDesc = new HbEditorInterface(this);
-   clearContextMenuFlag(Hb::ShowTextContextMenuOnLongPress);
-   mDesc->setInputConstraints (HbEditorConstraintIgnoreFocus);
+    setAlignment(Qt::AlignLeft);
+    clearContextMenuFlag(Hb::ShowTextContextMenuOnLongPress);
+    grabGesture(Qt::TapGesture);
 }
 
 //--------------------------------------------------------------------------------------------------------------------------------------------
@@ -62,14 +64,21 @@
 //--------------------------------------------------------------------------------------------------------------------------------------------
 GlxDetailsTextEdit::~GlxDetailsTextEdit()
 {
-  delete mDesc;
-   mDesc = NULL;
+    mEditorReadOnly = FALSE;
 }
 
 //--------------------------------------------------------------------------------------------------------------------------------------------
 //setItemText
 //--------------------------------------------------------------------------------------------------------------------------------------------
-void GlxDetailsTextEdit::setItemText( const QString &text )
+void GlxDetailsTextEdit::setItemText(const QString &text)
 {
-    setPlainText( text );
+    setPlainText(text);
 }
+
+//--------------------------------------------------------------------------------------------------------------------------------------------
+//setTextItemReadOnly
+//--------------------------------------------------------------------------------------------------------------------------------------------
+void GlxDetailsTextEdit::setTextItemReadOnly(bool value)
+{
+    mEditorReadOnly = value;
+}