src/hbcore/inputfw/hbinputcontextproxy.cpp
changeset 1 f7ac710697a9
parent 0 16d8024aca5e
child 5 627c4a0fd0e7
equal deleted inserted replaced
0:16d8024aca5e 1:f7ac710697a9
    32 
    32 
    33 /*!
    33 /*!
    34 @alpha
    34 @alpha
    35 @hbcore
    35 @hbcore
    36 \class HbInputContextProxy
    36 \class HbInputContextProxy
    37 \brief A proxy class forwarding class from QInputContext to HbInputMethod
    37 \brief A proxy class forwarding calls from QInputContext to HbInputMethod
    38 
    38 
    39 This class is needed because Qt's input context system assumes the ownership
    39 This class is needed because Qt's input context system assumes the ownership
    40 of the installed context and deletes the old one when a new context is installed.
    40 of the installed context and deletes the old one when a new context is installed.
    41 HbInput framework wants to cache active input context entities to its local
    41 HbInput framework wants to cache active input methods and keep the ownership of those
    42 memory structures and keep the ownership of those objects. That's why a proxy object
    42 objects. The proxy sits between QInputContext and HbInputMethod and is the one that
    43 is installed between QInputContext and HbInputMehod classes. When Qt's
    43 is deleted when Qt level input context is switched.
    44 input context system deletes old context, it will delete the proxy instead of
       
    45 real implementation.
    44 real implementation.
    46 
    45 
    47 We also handle certain common events (such as Qt's input panel events) on this level.
    46 Also a set of common events (such as Qt's input panel events) are handled on this level.
    48 This class is not needed outside of framework code.
    47 This class is not needed outside of framework code.
    49 
    48 
    50 \sa QInputContext
    49 \sa QInputContext
    51 \sa HbInputMethod
    50 \sa HbInputMethod
    52 */
    51 */
   111 {
   110 {
   112     if (mTarget) {
   111     if (mTarget) {
   113 #if QT_VERSION >= 0x040600
   112 #if QT_VERSION >= 0x040600
   114         if (event->type() == QEvent::CloseSoftwareInputPanel) {
   113         if (event->type() == QEvent::CloseSoftwareInputPanel) {
   115             setInputFrameworkFocus(0);
   114             setInputFrameworkFocus(0);
   116             return true;
   115             return true;            
   117         } else if (event->type() == QEvent::RequestSoftwareInputPanel) {
   116         } else if (event->type() == QEvent::RequestSoftwareInputPanel) {           
   118             if(QWidget * focusedWidget =  qApp->focusWidget()) {
   117             if(QWidget * focusedWidget =  qApp->focusWidget()) {              
   119                 // see if the focused widget is graphics view, if so get the focused graphics item in the view
   118                 // see if the focused widget is graphics view, if so get the focused graphics item in the view
   120                 // and acivate inputmethod for the focused graphics item
   119                 // and acivate inputmethod for the focused graphics item
   121                 if(QGraphicsView * graphicsView = qobject_cast<QGraphicsView*>(focusedWidget)) {
   120                 if(QGraphicsView * graphicsView = qobject_cast<QGraphicsView*>(focusedWidget)) {
   122                     if(QGraphicsScene * scene = graphicsView->scene()) {
   121                     if(QGraphicsScene * scene = graphicsView->scene()) {
   123                         if(QGraphicsItem * focusingWidget = scene->focusItem()) {
   122                         if(QGraphicsItem * focusingWidget = scene->focusItem()) {
   146                 // We let it pass here untouched.
   145                 // We let it pass here untouched.
   147                 if (mTarget) {
   146                 if (mTarget) {
   148                     mTarget->reset();
   147                     mTarget->reset();
   149                 }
   148                 }
   150                 return false;
   149                 return false;
   151             }
   150 			}
   152         } 
   151 		} 
   153 #endif
   152 #endif
   154 
   153 		if(event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease) {
   155         return mTarget->filterEvent(event);
   154 			const QKeyEvent *keyEvent = static_cast<const QKeyEvent *>(event);
   156     }
   155 			if (Qt::Key_unknown == keyEvent->key()) {
   157 
   156 				return false;
   158     return false;
   157 			}
       
   158 		}
       
   159 		return mTarget->filterEvent(event);
       
   160 	}
       
   161 
       
   162 	return false;
   159 }
   163 }
   160 
   164 
   161 /*!
   165 /*!
   162 \internal
   166 \internal
   163 \reimp
   167 \reimp