wvuing/ImUtils/Src/CCATextQueryDialog.cpp
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 2006 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:  Text query dialog that accepts empty input
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "CCATextQueryDialog.h"
       
    22 
       
    23 
       
    24 // ============================ MEMBER FUNCTIONS ===============================
       
    25 
       
    26 // -----------------------------------------------------------------------------
       
    27 // CCATextQueryDialog::CCATextQueryDialog
       
    28 // C++ default constructor can NOT contain any code, that
       
    29 // might leave.
       
    30 // -----------------------------------------------------------------------------
       
    31 //
       
    32 EXPORT_C CCATextQueryDialog::CCATextQueryDialog( TDes& aDataText,
       
    33                                                  const TTone& aTone /*= ENoTone*/,
       
    34                                                  TBool aLeftSoftkeyAlwaysVisible /*= ETrue*/,
       
    35                                                  TBool aDomainSelectionQuery /*= EFalse*/ )
       
    36         : CAknTextQueryDialog( aDataText, aTone ),
       
    37         iLeftSoftkeyAlwaysVisible( aLeftSoftkeyAlwaysVisible ),
       
    38         iDomainSelectionQuery( aDomainSelectionQuery )
       
    39     {
       
    40     }
       
    41 
       
    42 // -----------------------------------------------------------------------------
       
    43 // CCATextQueryDialog::NewL
       
    44 // Two-phased constructor.
       
    45 // -----------------------------------------------------------------------------
       
    46 //
       
    47 EXPORT_C CCATextQueryDialog* CCATextQueryDialog::NewL( TDes& aDataText,
       
    48                                                        const TTone& aTone /*= ENoTone*/,
       
    49                                                        TBool aLeftSoftkeyAlwaysVisible /*= ETrue*/,
       
    50                                                        TBool aDomainSelectionQuery /*= EFalse*/ )
       
    51     {
       
    52     CCATextQueryDialog* self = new( ELeave ) CCATextQueryDialog(
       
    53         aDataText, aTone,
       
    54         aLeftSoftkeyAlwaysVisible,
       
    55         aDomainSelectionQuery );
       
    56     return self;
       
    57     }
       
    58 
       
    59 // -----------------------------------------------------------------------------
       
    60 //  Destructor
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 
       
    64 EXPORT_C CCATextQueryDialog::~CCATextQueryDialog()
       
    65     {
       
    66     }
       
    67 
       
    68 // -----------------------------------------------------------------------------
       
    69 // CCATextQueryDialog::UpdateLeftSoftKeyL
       
    70 // (other items were commented in a header).
       
    71 // -----------------------------------------------------------------------------
       
    72 //
       
    73 EXPORT_C void CCATextQueryDialog::UpdateLeftSoftKeyL()
       
    74     {
       
    75     if ( iLeftSoftkeyAlwaysVisible )
       
    76         {
       
    77         // do nothing so the left softkey is always visible
       
    78         return;
       
    79         }
       
    80     else
       
    81         {
       
    82         CAknTextQueryDialog::UpdateLeftSoftKeyL();
       
    83         }
       
    84     }
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 // CCATextQueryDialog::OfferKeyEventL
       
    88 // (other items were commented in a header).
       
    89 // -----------------------------------------------------------------------------
       
    90 //
       
    91 EXPORT_C TKeyResponse CCATextQueryDialog::OfferKeyEventL( const TKeyEvent& aKeyEvent,
       
    92                                                           TEventCode aType )
       
    93     {
       
    94     TInt oldLen = 0;
       
    95     CEikEdwin* edwin = NULL;
       
    96     // If this is launched after domain selection query
       
    97     // check editor state
       
    98     if ( iDomainSelectionQuery )
       
    99         {
       
   100         CCoeControl* ctrl = ControlOrNull( EGeneralQuery );
       
   101         if ( ctrl )
       
   102             {
       
   103             CAknQueryControl* query = static_cast<CAknQueryControl*>( ctrl );
       
   104             ctrl = query->ControlByLayoutOrNull( EDataLayout );
       
   105             if ( ctrl )
       
   106                 {
       
   107                 edwin = static_cast<CEikEdwin*>( ctrl );
       
   108                 oldLen = edwin->TextLength();
       
   109                 }
       
   110             }
       
   111         }
       
   112 
       
   113     TKeyResponse response =
       
   114         CAknTextQueryDialog::OfferKeyEventL( aKeyEvent, aType );
       
   115 
       
   116     if ( iDomainSelectionQuery && edwin
       
   117          && aKeyEvent.iCode != EKeyOK )
       
   118         {
       
   119         if ( oldLen > 0
       
   120              && response == EKeyWasConsumed
       
   121              && edwin->TextLength() == 0 )
       
   122             {
       
   123             // User has cleared editor -> exit dialog
       
   124             TryExitL( EAknSoftkeyExit );
       
   125             }
       
   126         }
       
   127 
       
   128     return response;
       
   129     }
       
   130 
       
   131 // -----------------------------------------------------------------------------
       
   132 // CCATextQueryDialog::OfferKeyEventL
       
   133 // (other items were commented in a header).
       
   134 // -----------------------------------------------------------------------------
       
   135 //
       
   136 EXPORT_C TBool CCATextQueryDialog::OkToExitL( TInt aButtonId )
       
   137     {
       
   138     if ( aButtonId == EAknSoftkeyExit && iDomainSelectionQuery )
       
   139         {
       
   140         return ETrue;
       
   141         }
       
   142     else
       
   143         {
       
   144         return CAknTextQueryDialog::OkToExitL( aButtonId );
       
   145         }
       
   146     }
       
   147 //  End of File