ui/detailscustomwidget/detailscustomwidgets/glxdetailstextedit.cpp
changeset 62 36d93b4dc635
parent 58 383b67fbdb11
equal deleted inserted replaced
58:383b67fbdb11 62:36d93b4dc635
     1 /*
     1 /*
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3  * All rights reserved.
     4 * This component and the accompanying materials are made available
     4  * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5  * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6  * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     8  *
     9 * Initial Contributors:
     9  * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10  * Nokia Corporation - initial contribution.
    11 *
    11  *
    12 * Contributors:
    12  * Contributors:
    13 *
    13  *
    14 *  Description:   This is custom widget for details view in photos for displaying the description of image .
    14  *  Description:   This is custom widget for details view in photos for displaying the description of image .
    15 *
    15  *
    16 */
    16  */
    17  
       
    18 
    17 
       
    18 #include <QDebug>
       
    19 #include <QEvent>
       
    20 #include <QInputContext>
       
    21 #include <QGraphicsObject>
       
    22 
       
    23 #include <hbeditorinterface>
       
    24 #include <hbtapgesture.h>
       
    25 #include <hbapplication.h>
    19 
    26 
    20 #include "glxdetailstextedit.h"
    27 #include "glxdetailstextedit.h"
    21 #include <hbeditorinterface>
       
    22 #include <QEvent>
       
    23 
       
    24 
       
    25 
    28 
    26 //--------------------------------------------------------------------------------------------------------------------------------------------
    29 //--------------------------------------------------------------------------------------------------------------------------------------------
    27 //focusInEvent
    30 //gestureEvent
    28 //--------------------------------------------------------------------------------------------------------------------------------------------
    31 //--------------------------------------------------------------------------------------------------------------------------------------------
    29 void  GlxDetailsTextEdit::focusInEvent (QFocusEvent *event)
    32 void GlxDetailsTextEdit::gestureEvent(QGestureEvent* event)
    30     {
    33 {
    31     if(event->reason() == Qt::MouseFocusReason )
    34     HbLineEdit::gestureEvent(event);
    32         {
    35     HbTapGesture *tap = qobject_cast<HbTapGesture *> (event->gesture(Qt::TapGesture));
    33           event->setAccepted(TRUE);
    36     if (tap && (tap->state() == Qt::GestureFinished || tap->state() == Qt::GestureUpdated)) {
    34           emit labelPressed();
    37         QInputContext *ic = qApp->inputContext();
       
    38         if (ic) {
       
    39             QEvent *openEvent = new QEvent(QEvent::CloseSoftwareInputPanel);
       
    40             ic->filterEvent(openEvent);
       
    41             delete openEvent;
       
    42 
       
    43             if (!mEditorReadOnly && tap->state() == Qt::GestureFinished) {
       
    44                 //Only emit the signal in case of editor is not ready only
       
    45                 emit editorTapped();
       
    46             }
    35         }
    47         }
    36     
       
    37     }
    48     }
    38     
    49 }
    39     
       
    40 //--------------------------------------------------------------------------------------------------------------------------------------------
       
    41 //focusOutEvent
       
    42 //--------------------------------------------------------------------------------------------------------------------------------------------
       
    43 void  GlxDetailsTextEdit::focusOutEvent (QFocusEvent *event) 
       
    44     {
       
    45      event->setAccepted(TRUE);    
       
    46     }
       
    47 
       
    48 
    50 
    49 //--------------------------------------------------------------------------------------------------------------------------------------------
    51 //--------------------------------------------------------------------------------------------------------------------------------------------
    50 //GlxDetailsTextEdit
    52 //GlxDetailsTextEdit
    51 //--------------------------------------------------------------------------------------------------------------------------------------------
    53 //--------------------------------------------------------------------------------------------------------------------------------------------
    52 GlxDetailsTextEdit::GlxDetailsTextEdit(QGraphicsItem *parent) : HbTextEdit( parent )
    54 GlxDetailsTextEdit::GlxDetailsTextEdit(QGraphicsItem *parent) :
       
    55     HbLineEdit(parent), mEditorReadOnly(0)
    53 {
    56 {
    54    setAlignment(Qt::AlignLeft);
    57     setAlignment(Qt::AlignLeft);
    55    mDesc = new HbEditorInterface(this);
    58     clearContextMenuFlag(Hb::ShowTextContextMenuOnLongPress);
    56    clearContextMenuFlag(Hb::ShowTextContextMenuOnLongPress);
    59     grabGesture(Qt::TapGesture);
    57    mDesc->setInputConstraints (HbEditorConstraintIgnoreFocus);
       
    58 }
    60 }
    59 
    61 
    60 //--------------------------------------------------------------------------------------------------------------------------------------------
    62 //--------------------------------------------------------------------------------------------------------------------------------------------
    61 //~GlxDetailsTextEdit
    63 //~GlxDetailsTextEdit
    62 //--------------------------------------------------------------------------------------------------------------------------------------------
    64 //--------------------------------------------------------------------------------------------------------------------------------------------
    63 GlxDetailsTextEdit::~GlxDetailsTextEdit()
    65 GlxDetailsTextEdit::~GlxDetailsTextEdit()
    64 {
    66 {
    65   delete mDesc;
    67     mEditorReadOnly = FALSE;
    66    mDesc = NULL;
       
    67 }
    68 }
    68 
    69 
    69 //--------------------------------------------------------------------------------------------------------------------------------------------
    70 //--------------------------------------------------------------------------------------------------------------------------------------------
    70 //setItemText
    71 //setItemText
    71 //--------------------------------------------------------------------------------------------------------------------------------------------
    72 //--------------------------------------------------------------------------------------------------------------------------------------------
    72 void GlxDetailsTextEdit::setItemText( const QString &text )
    73 void GlxDetailsTextEdit::setItemText(const QString &text)
    73 {
    74 {
    74     setPlainText( text );
    75     setPlainText(text);
    75 }
    76 }
       
    77 
       
    78 //--------------------------------------------------------------------------------------------------------------------------------------------
       
    79 //setTextItemReadOnly
       
    80 //--------------------------------------------------------------------------------------------------------------------------------------------
       
    81 void GlxDetailsTextEdit::setTextItemReadOnly(bool value)
       
    82 {
       
    83     mEditorReadOnly = value;
       
    84 }