telutils/dialpad/src/dialpadhasheventfilter.cpp
branchRCL_3
changeset 20 987c9837762f
parent 19 7d48bed6ce0c
child 21 0a6dd2dc9970
equal deleted inserted replaced
19:7d48bed6ce0c 20:987c9837762f
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 #include <qtimer>
       
    18 #include <hblineedit.h>
       
    19 #include <hbnotificationdialog.h>
       
    20 #include "dialpadhasheventfilter.h"
       
    21 #include "dialpadsymbianwrapper.h"
       
    22 #include "dialpad.h"
       
    23 #include "qtphonesrvlog.h"
       
    24 
       
    25 const QString HashCharacter("#");
       
    26 
       
    27 DialpadHashEventFilter::DialpadHashEventFilter(Dialpad* dialpad, QObject* parent) :
       
    28     DialpadMailboxEventFilterBase(dialpad, parent)
       
    29 {
       
    30 }
       
    31 
       
    32 DialpadHashEventFilter::~DialpadHashEventFilter()
       
    33 {
       
    34 }
       
    35 
       
    36 bool DialpadHashEventFilter::eventFilter(QObject *watched, QEvent *event)
       
    37 {
       
    38     Q_UNUSED(watched)
       
    39     bool keyEventEaten(false);
       
    40 
       
    41     if (event->type() == QEvent::KeyPress) {
       
    42         QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);        
       
    43         if ((isLongKeyPressSupported(keyEvent->key())) &&
       
    44             !(mDialpad->editor().text().length() >= 1)) {
       
    45             //Check that there is only one item in dialpad, if there is more than one
       
    46             //do not handle long key press.
       
    47             mLongPressTimer->stop();
       
    48             mLongPressTimer->start(DialpadLongKeyPressTimeOut);
       
    49         }
       
    50     } else if (event->type() == QEvent::KeyRelease) {
       
    51         QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
       
    52         if (isLongKeyPressSupported(keyEvent->key())){
       
    53             mLongPressTimer->stop();
       
    54         }
       
    55     }
       
    56 
       
    57     return keyEventEaten;
       
    58 }
       
    59 
       
    60 void DialpadHashEventFilter::handleLongKeyPress()
       
    61 {
       
    62     PHONE_TRACE;
       
    63     switch(mKeyEvent) {
       
    64     case Qt::Key_NumberSign:{
       
    65        handleMailboxOperation();
       
    66        break;
       
    67        }
       
    68    default:
       
    69        // Do nothing.
       
    70        break;
       
    71     }
       
    72 
       
    73     // Reset key code.
       
    74     mKeyEvent = NULL;
       
    75 }
       
    76 
       
    77 bool DialpadHashEventFilter::handleCallButtonPress()
       
    78 {
       
    79     // not supported
       
    80     return EFalse;
       
    81 }
       
    82 
       
    83 void DialpadHashEventFilter::handleMailboxOperation()
       
    84 {
       
    85     PHONE_TRACE;
       
    86     // change KCRUidProfileEngine KProEngSilenceMode value and show note  
       
    87     if (mSymbianWrapper->changeSilentModeState()) {
       
    88         HbNotificationDialog::launchDialog( 
       
    89                 hbTrId( "txt_dialer_dpopinfo_silent_mode_activated" ) );
       
    90     }
       
    91     else {
       
    92         HbNotificationDialog::launchDialog( 
       
    93                 hbTrId( "txt_dialer_dpopinfo_silent_mode_deactivated" ) );
       
    94     }
       
    95     clearEditor();
       
    96 }