presencesettingsui/src/psuigsplugincontainer.cpp
changeset 0 c8caa15ef882
child 12 e6a66db4e9d0
equal deleted inserted replaced
-1:000000000000 0:c8caa15ef882
       
     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:    Presence Settings UI GS plugin container implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include <psuigspluginrsc.rsg>
       
    23 #include <aknlists.h>
       
    24 #include <gsbasecontainer.h>
       
    25 #include "psuigsplugincontainer.h"
       
    26 #include "psuigspluginmodel.h"
       
    27 #include "psuigsplugin.h"
       
    28 #include "psuigspluginids.hrh"
       
    29 #include <csxhelp/pre.hlp.hrh>
       
    30 
       
    31 // ========================= MEMBER FUNCTIONS ================================
       
    32 
       
    33 // ---------------------------------------------------------------------------
       
    34 // CPSUIGSPluginContainer::CPSUIGSPluginContainer()
       
    35 // Default constructor.
       
    36 // ---------------------------------------------------------------------------
       
    37 //
       
    38 CPSUIGSPluginContainer::CPSUIGSPluginContainer( CPSUIGSPlugin* aView )
       
    39     : iView ( aView )
       
    40     {
       
    41     }
       
    42     
       
    43 // ---------------------------------------------------------------------------
       
    44 // CPSUIGSPluginContainer::ConstructL(const TRect& aRect)
       
    45 // Symbian OS phase 2 constructor
       
    46 // ---------------------------------------------------------------------------
       
    47 //
       
    48 void CPSUIGSPluginContainer::ConstructL( const TRect& aRect )
       
    49     {
       
    50     iListBox = new ( ELeave ) CAknSingleStyleListBox();// base needs the iListBox to be prepared 1st
       
    51     BaseConstructL( aRect, R_PSUI_MAINVIEW_TITLE, 0 );// last parameter 0, since dynamic listbox
       
    52     
       
    53     iEikMenuBar = new ( ELeave ) CEikMenuBar();
       
    54     iEikMenuBar->ConstructL( this, NULL, R_PSUI_MAINVIEW_MENUBAR );
       
    55     }
       
    56 
       
    57 // ---------------------------------------------------------------------------
       
    58 // CPSUIGSPluginContainer::~CPSUIGSPluginContainer()
       
    59 // Destructor
       
    60 // ---------------------------------------------------------------------------
       
    61 //
       
    62 CPSUIGSPluginContainer::~CPSUIGSPluginContainer()
       
    63     {
       
    64     delete iEikMenuBar;
       
    65     }
       
    66 
       
    67 // ---------------------------------------------------------------------------
       
    68 // CPSUIGSPluginContainer::ConstructListBoxL()
       
    69 // See header for details. 
       
    70 // ---------------------------------------------------------------------------
       
    71 //
       
    72 void CPSUIGSPluginContainer::ConstructListBoxL( TInt /*aResLbxId*/ )
       
    73     {
       
    74     // listbox creation and initialization
       
    75     iListBox->SetContainerWindowL( *this );
       
    76     iListBox->ConstructL( this, EAknListBoxLoopScrolling );
       
    77     iListBox->CreateScrollBarFrameL( ETrue );
       
    78     iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
       
    79         CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
       
    80 
       
    81     SetEmptyTextsToListboxL();
       
    82     
       
    83     CPSUIGSPluginModel* psuiModel = iView->PSModel();// not owned
       
    84     CTextListBoxModel* model = iListBox->Model();
       
    85     model->SetItemTextArray( psuiModel );
       
    86     model->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
    87     }
       
    88 
       
    89 // ---------------------------------------------------------------------------
       
    90 // CPSUIGSPluginContainer::SetEmptyTextsToListboxL()
       
    91 // See header for details. 
       
    92 // ---------------------------------------------------------------------------
       
    93 //
       
    94 void CPSUIGSPluginContainer::SetEmptyTextsToListboxL()
       
    95     {
       
    96     // empty texts
       
    97     _LIT ( KPSUIEmptyStringHeader, "%S\n%S" );
       
    98     HBufC* emptyText = iEikonEnv->AllocReadResourceLC( 
       
    99         R_QTN_PRESENCE_SETTINGS_EMPTY_PRIMARY );
       
   100     HBufC* emptyText2 = iEikonEnv->AllocReadResourceLC( 
       
   101         R_QTN_PRESENCE_SETTINGS_EMPTY_SECONDARY );   
       
   102     HBufC* emptyFinal = HBufC::NewLC( 
       
   103         emptyText->Length() + emptyText2->Length() + 2 );// 2 is length of "\n" 
       
   104     emptyFinal->Des().Format( KPSUIEmptyStringHeader, emptyText, emptyText2 );
       
   105     iListBox->View()->SetListEmptyTextL( *emptyFinal );
       
   106     CleanupStack::PopAndDestroy( 3, emptyText );// emptyText, emptyText2, emptyFinal
       
   107     }
       
   108     
       
   109 // ---------------------------------------------------------------------------
       
   110 // CPSUIGSPluginContainer::OfferKeyEventL()
       
   111 // See header for details. 
       
   112 // ---------------------------------------------------------------------------
       
   113 //
       
   114 TKeyResponse CPSUIGSPluginContainer::OfferKeyEventL( 
       
   115     const TKeyEvent& aKeyEvent, 
       
   116     TEventCode aType )
       
   117     {
       
   118     if ( iView && aType == EEventKey 
       
   119         && aKeyEvent.iCode == EKeyBackspace && 
       
   120         iEikMenuBar->ItemSpecificCommandsEnabled() )
       
   121         {
       
   122         iView->DeleteSettingsL();
       
   123         return EKeyWasConsumed;
       
   124         }
       
   125     else
       
   126         {
       
   127         return iListBox->OfferKeyEventL( aKeyEvent, aType );
       
   128         }
       
   129     }
       
   130 
       
   131 // -----------------------------------------------------------------------------
       
   132 // CPSUIGSPluginContainer::GetHelpContext()
       
   133 // See header for details.
       
   134 // -----------------------------------------------------------------------------
       
   135 //
       
   136 void CPSUIGSPluginContainer::GetHelpContext( TCoeHelpContext& aContext ) const
       
   137     {
       
   138     aContext.iMajor = TUid::Uid( PSUIGSPluginDllUid );
       
   139     aContext.iContext = KPRE_HLP_LIST_VIEW;
       
   140     }
       
   141     
       
   142 // End of File