phoneapp/phoneuiview/src/cphonelistquerydialog.cpp
changeset 0 5f000ab63145
equal deleted inserted replaced
-1:000000000000 0:5f000ab63145
       
     1 /*
       
     2 * Copyright (c) 2007 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:  ListQueryDialog
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDES
       
    20 
       
    21 #include "cphonelistquerydialog.h"
       
    22 #include "mphonequeryobserver.h"
       
    23 #include "phoneui.hrh"
       
    24 
       
    25 
       
    26 // ======== MEMBER FUNCTIONS ========
       
    27 
       
    28 // ---------------------------------------------------------------------------
       
    29 // Constructor
       
    30 // ---------------------------------------------------------------------------
       
    31 //
       
    32 CPhoneListQueryDialog::CPhoneListQueryDialog(
       
    33     MEikCommandObserver& aCommandObserver,
       
    34     MPhoneQueryObserver& aQueryObserver, 
       
    35     const RArray<TInt>& aCommands ) :
       
    36     CAknListQueryDialog( &iIndex ), 
       
    37     iCommandObserver( aCommandObserver ),
       
    38     iQueryObserver ( aQueryObserver ) 
       
    39     {
       
    40     for ( TInt i( 0 ); i < aCommands.Count(); i++ )
       
    41         {
       
    42         iCommands.Append( aCommands[i] );
       
    43         }
       
    44     }
       
    45 
       
    46 // ---------------------------------------------------------------------------
       
    47 // Destructor
       
    48 // ---------------------------------------------------------------------------
       
    49 //
       
    50 CPhoneListQueryDialog::~CPhoneListQueryDialog()
       
    51     {
       
    52     iCommands.Close(); 
       
    53     iQueryObserver.SetQueryDeletedFlag( ETrue );
       
    54     }
       
    55     
       
    56 // ---------------------------------------------------------------------------
       
    57 // CPhoneListQueryDialog::OfferKeyEventL
       
    58 // ---------------------------------------------------------------------------
       
    59 //
       
    60 TKeyResponse CPhoneListQueryDialog::OfferKeyEventL( const TKeyEvent& aKeyEvent,
       
    61                                                           TEventCode aType )
       
    62     {
       
    63     TKeyResponse ret = EKeyWasNotConsumed;
       
    64     if ( aType == EEventKey &&
       
    65         ( aKeyEvent.iScanCode == EStdKeyNo || aKeyEvent.iCode == EKeyNo ) )
       
    66         {
       
    67         OkToExitL( EPhoneCmdWaitNoteOk );
       
    68         }       
       
    69     else if ( aKeyEvent.iScanCode == EStdKeyYes )
       
    70         {
       
    71         ret =  EKeyWasConsumed;        
       
    72         }    
       
    73     else 
       
    74         {
       
    75         ret = CAknListQueryDialog::OfferKeyEventL( aKeyEvent, aType );              
       
    76         }
       
    77     
       
    78     return ret;
       
    79   
       
    80     }    
       
    81 // ---------------------------------------------------------------------------
       
    82 // CPhoneListQueryDialog::PostLayoutDynInitL
       
    83 // 
       
    84 // 
       
    85 // ---------------------------------------------------------------------------
       
    86 //
       
    87 void CPhoneListQueryDialog::PostLayoutDynInitL()
       
    88     {
       
    89     CAknListQueryDialog::PostLayoutDynInitL();
       
    90     }
       
    91 
       
    92 // ---------------------------------------------------------------------------
       
    93 // CPhoneListQueryDialog::OkToExitL
       
    94 // ---------------------------------------------------------------------------
       
    95 //
       
    96 TBool CPhoneListQueryDialog::OkToExitL( TInt aKeyCode )
       
    97     {    
       
    98     if ( aKeyCode == EEikBidOk )
       
    99         { 
       
   100         if( !ListBox() )
       
   101             {
       
   102             User::Leave( KErrNotFound );
       
   103             }
       
   104         
       
   105         TInt itemIndex = ListBox()->CurrentItemIndex();
       
   106         
       
   107         if( itemIndex >= iCommands.Count() || itemIndex < 0 )
       
   108             {
       
   109             User::Leave( KErrNotFound );
       
   110             }
       
   111         
       
   112         iQueryObserver.ReportQueryCompleteAsync( iCommands [itemIndex] );        
       
   113         }    
       
   114     else if ( aKeyCode == EPhoneCmdWaitNoteOk )  
       
   115         {
       
   116         iQueryObserver.ReportQueryCompleteAsync( EPhoneCmdWaitNoteOk ); 
       
   117         }
       
   118     
       
   119     return ETrue;
       
   120     }
       
   121     
       
   122 //  End of File