accesspointcontrol/apcontrollistplugin/src/apcontrollistbox.cpp
branchRCL_3
changeset 58 83ca720e2b9a
parent 0 5a93021fdf25
equal deleted inserted replaced
57:05bc53fe583b 58:83ca720e2b9a
       
     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:  Implementation of ApControlListbox.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 
       
    21 #include <eikclbd.h>
       
    22 #include <avkon.mbg>
       
    23 #include <aknkeys.h>
       
    24 #include <apcontrollistpluginrsc.rsg>
       
    25 #include <AknsUtils.h>
       
    26 #include <data_caging_path_literals.hrh>
       
    27 #include <StringLoader.h>
       
    28 
       
    29 #include "apcontrollistbox.h"
       
    30 #include "apcontrollistboxmodel.h"
       
    31 #include "apcontrollistpluginlogger.h"
       
    32 #include "apcontrollistplugin.h"
       
    33 #include "apcontrollistapiwrapper.h"
       
    34 
       
    35 // ================= MEMBER FUNCTIONS =======================
       
    36 
       
    37 
       
    38 // ---------------------------------------------------------
       
    39 // CApControlListbox::CApControlListbox
       
    40 // ---------------------------------------------------------
       
    41 //
       
    42 CApControlListbox::CApControlListbox() 
       
    43     {
       
    44     CLOG( ( ESelector, 0, 
       
    45         _L( "<-> CApControlListbox::CApControlListbox" ) ) );
       
    46     }
       
    47 
       
    48 
       
    49 // ---------------------------------------------------------
       
    50 // CApControlListbox::~CApControlListbox
       
    51 // ---------------------------------------------------------
       
    52 //
       
    53 CApControlListbox::~CApControlListbox()
       
    54     {
       
    55     CLOG( ( ESelector, 0, 
       
    56         _L( "<-> CApControlListbox::~CApControlListbox" ) ) );
       
    57     }
       
    58 
       
    59 
       
    60 // ---------------------------------------------------------
       
    61 // CApControlListbox::OfferKeyEventL
       
    62 // ---------------------------------------------------------
       
    63 //
       
    64 TKeyResponse CApControlListbox::OfferKeyEventL
       
    65 ( const TKeyEvent& aKeyEvent, TEventCode aType )
       
    66     {
       
    67     CLOG( ( ESelector, 0, _L( "-> CApControlListbox::OfferKeyEventL" ) ) );
       
    68 
       
    69     TKeyResponse retval ( EKeyWasConsumed );
       
    70 
       
    71     if (    aKeyEvent.iCode == EKeyOK &&
       
    72             !( aKeyEvent.iModifiers & EModifierShift )
       
    73        )
       
    74         {
       
    75         // Enter pressed (not Shift-Enter). This will report an
       
    76         // EEnterKeyPressed event sent to the observer (the view), which may
       
    77         // delete this listbox. The code which processes keypresses by
       
    78         // default, will continue (on the already deleted listbox), and
       
    79         // will crash. So we grab this keypress here, and generate the
       
    80         // same event, but after that, quit immediately.
       
    81         ReportListBoxEventL( MEikListBoxObserver::EEventEnterKeyPressed );
       
    82         // By now the listbox may have been deleted.
       
    83         // Do not access it after this point.
       
    84         }
       
    85     else if (    aKeyEvent.iCode == EKeyBackspace )
       
    86         {
       
    87         static_cast<CAPControlListPlugin*>(iListBoxObserver)->APIWrapper()->
       
    88             RemoveAPN();
       
    89         }
       
    90     else
       
    91         {
       
    92         retval = CAknSingleStyleListBox::OfferKeyEventL
       
    93                             ( aKeyEvent, aType );
       
    94         }
       
    95 
       
    96     CLOG( ( ESelector, 0, _L( "<- CApControlListbox::OfferKeyEventL" ) ) );
       
    97 
       
    98     return retval;
       
    99     }
       
   100 
       
   101 
       
   102 
       
   103 // ---------------------------------------------------------
       
   104 // CApControlListbox::FocusChanged
       
   105 // ---------------------------------------------------------
       
   106 //
       
   107 void CApControlListbox::FocusChanged( TDrawNow aDrawNow )
       
   108     {
       
   109     CLOG( ( ESelector, 0, _L( "-> CApControlListbox::FocusChanged" ) ) );
       
   110 
       
   111     // Do nothing until the listbox is fully constructed
       
   112     // The dialogpage sets the focus before calling ConstructL
       
   113     if ( iView )
       
   114         {
       
   115         CAknSingleStyleListBox::FocusChanged( aDrawNow );
       
   116         }
       
   117 
       
   118     CLOG( ( ESelector, 0, _L( "<- CApControlListbox::FocusChanged" ) ) );
       
   119     }
       
   120 
       
   121 
       
   122 // ---------------------------------------------------------
       
   123 // CApControlListbox::HandleResourceChange
       
   124 // ---------------------------------------------------------
       
   125 //
       
   126 void CApControlListbox::HandleResourceChange(TInt aType)
       
   127     {
       
   128     CLOG( ( ESelector, 0, _L( 
       
   129     				"-> CApControlListbox::HandleResourceChange" ) ) );
       
   130     if ( aType == KAknsMessageSkinChange )
       
   131         {        CAknSingleStyleListBox::HandleResourceChange( aType );
       
   132         SizeChanged();
       
   133         }    
       
   134         
       
   135     CAknSingleStyleListBox::HandleResourceChange( aType );
       
   136     CLOG( ( ESelector, 0, _L( 
       
   137     				"<- CApControlListbox::HandleResourceChange" ) ) );
       
   138     }
       
   139 // ---------------------------------------------------------
       
   140 // CApControlListbox::AddToListBoxL
       
   141 // ---------------------------------------------------------
       
   142 //
       
   143 void CApControlListbox::SetListEmptyTextL()
       
   144     {
       
   145     CLOG( ( ESelector, 0, _L( 
       
   146         "-> CApControlListbox::SetListEmptyTextL" ) ) );
       
   147     HBufC* primary = 
       
   148               iEikonEnv->AllocReadResourceLC( R_QTN_ACL_EMPTY_VIEW_PRIMARY );
       
   149 //    _LIT( KCmNewLine, "\n" );    
       
   150 //    primary->Des().Append( KCmNewLine );    
       
   151     HBufC* secondary = 
       
   152               iEikonEnv->AllocReadResourceLC( R_QTN_ACL_EMPTY_VIEW_SECONDARY );
       
   153     CDesCArrayFlat* items = new (ELeave) CDesCArrayFlat(2);
       
   154     CleanupStack::PushL(items);
       
   155     items->AppendL(primary->Des()); 
       
   156     items->AppendL(secondary->Des());      
       
   157     HBufC* emptyText = 
       
   158           StringLoader::LoadLC( R_TWO_STRING_FOR_EMPTY_VIEW , *items);              
       
   159     View()->SetListEmptyTextL( *emptyText );    
       
   160     CleanupStack::PopAndDestroy( emptyText );
       
   161     CleanupStack::PopAndDestroy( items );
       
   162     CleanupStack::PopAndDestroy( secondary );
       
   163     CleanupStack::PopAndDestroy( primary );
       
   164     
       
   165     CLOG( ( ESelector, 0, _L( 
       
   166         "<- CApControlListbox::SetListEmptyTextL" ) ) );
       
   167     }
       
   168 
       
   169 // End of File