presencesettingsui/src/psuigsplugincontainer.cpp
changeset 13 b7e70c0792e6
parent 12 e6a66db4e9d0
equal deleted inserted replaced
12:e6a66db4e9d0 13:b7e70c0792e6
    19 
    19 
    20 
    20 
    21 // INCLUDE FILES
    21 // INCLUDE FILES
    22 #include <psuigspluginrsc.rsg>
    22 #include <psuigspluginrsc.rsg>
    23 #include <aknlists.h>
    23 #include <aknlists.h>
    24 #include <gsbasecontainer.h>
       
    25 #include "psuigsplugincontainer.h"
    24 #include "psuigsplugincontainer.h"
    26 #include "psuigspluginmodel.h"
    25 #include "psuigspluginmodel.h"
    27 #include "psuigsplugin.h"
    26 #include "psuigsplugin.h"
    28 #include "psuigspluginids.hrh"
    27 #include "psuigspluginids.hrh"
    29 #include <csxhelp/pre.hlp.hrh>
    28 #include <csxhelp/pre.hlp.hrh>
    43 // ---------------------------------------------------------------------------
    42 // ---------------------------------------------------------------------------
    44 // CPSUIGSPluginContainer::ConstructL(const TRect& aRect)
    43 // CPSUIGSPluginContainer::ConstructL(const TRect& aRect)
    45 // Symbian OS phase 2 constructor
    44 // Symbian OS phase 2 constructor
    46 // ---------------------------------------------------------------------------
    45 // ---------------------------------------------------------------------------
    47 //
    46 //
    48 void CPSUIGSPluginContainer::ConstructL( const TRect& aRect )
    47 void CPSUIGSPluginContainer::ConstructL( const TRect& /*aRect*/ )
    49     {
    48     {
    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     }
    49     }
    53 
    50 
    54 // ---------------------------------------------------------------------------
    51 // ---------------------------------------------------------------------------
    55 // CPSUIGSPluginContainer::~CPSUIGSPluginContainer()
    52 // CPSUIGSPluginContainer::~CPSUIGSPluginContainer()
    56 // Destructor
    53 // Destructor
    59 CPSUIGSPluginContainer::~CPSUIGSPluginContainer()
    56 CPSUIGSPluginContainer::~CPSUIGSPluginContainer()
    60     {
    57     {
    61     }
    58     }
    62 
    59 
    63 // ---------------------------------------------------------------------------
    60 // ---------------------------------------------------------------------------
    64 // CPSUIGSPluginContainer::ConstructListBoxL()
       
    65 // See header for details. 
       
    66 // ---------------------------------------------------------------------------
       
    67 //
       
    68 void CPSUIGSPluginContainer::ConstructListBoxL( TInt /*aResLbxId*/ )
       
    69     {
       
    70     // listbox creation and initialization
       
    71     iListBox->SetContainerWindowL( *this );
       
    72     iListBox->ConstructL( this, EAknListBoxLoopScrolling );
       
    73     iListBox->CreateScrollBarFrameL( ETrue );
       
    74     iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
       
    75         CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
       
    76 
       
    77     SetEmptyTextsToListboxL();
       
    78     
       
    79     CPSUIGSPluginModel* psuiModel = iView->PSModel();// not owned
       
    80     CTextListBoxModel* model = iListBox->Model();
       
    81     model->SetItemTextArray( psuiModel );
       
    82     model->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
    83     }
       
    84 
       
    85 // ---------------------------------------------------------------------------
       
    86 // CPSUIGSPluginContainer::SetEmptyTextsToListboxL()
    61 // CPSUIGSPluginContainer::SetEmptyTextsToListboxL()
    87 // See header for details. 
    62 // See header for details. 
    88 // ---------------------------------------------------------------------------
    63 // ---------------------------------------------------------------------------
    89 //
    64 //
    90 void CPSUIGSPluginContainer::SetEmptyTextsToListboxL()
    65 void CPSUIGSPluginContainer::SetEmptyTextsToListboxL()
    91     {
    66     {
    92     // empty texts
       
    93     _LIT ( KPSUIEmptyStringHeader, "%S\n%S" );
       
    94     HBufC* emptyText = iEikonEnv->AllocReadResourceLC( 
       
    95         R_QTN_PRESENCE_SETTINGS_EMPTY_PRIMARY );
       
    96     HBufC* emptyText2 = iEikonEnv->AllocReadResourceLC( 
       
    97         R_QTN_PRESENCE_SETTINGS_EMPTY_SECONDARY );   
       
    98     HBufC* emptyFinal = HBufC::NewLC( 
       
    99         emptyText->Length() + emptyText2->Length() + 2 );// 2 is length of "\n" 
       
   100     emptyFinal->Des().Format( KPSUIEmptyStringHeader, emptyText, emptyText2 );
       
   101     iListBox->View()->SetListEmptyTextL( *emptyFinal );
       
   102     CleanupStack::PopAndDestroy( 3, emptyText );// emptyText, emptyText2, emptyFinal
       
   103     }
       
   104     
       
   105 // ---------------------------------------------------------------------------
       
   106 // CPSUIGSPluginContainer::OfferKeyEventL()
       
   107 // See header for details. 
       
   108 // ---------------------------------------------------------------------------
       
   109 //
       
   110 TKeyResponse CPSUIGSPluginContainer::OfferKeyEventL( 
       
   111     const TKeyEvent& aKeyEvent, 
       
   112     TEventCode aType )
       
   113     {
       
   114     if ( iView && aType == EEventKey 
       
   115         && aKeyEvent.iCode == EKeyBackspace )
       
   116         {
       
   117         iView->DeleteSettingsL();
       
   118         return EKeyWasConsumed;
       
   119         }
       
   120     else
       
   121         {
       
   122         return iListBox->OfferKeyEventL( aKeyEvent, aType );
       
   123         }
       
   124     }
    67     }
   125 
    68 
   126 // -----------------------------------------------------------------------------
    69 // -----------------------------------------------------------------------------
   127 // CPSUIGSPluginContainer::GetHelpContext()
    70 // CPSUIGSPluginContainer::GetHelpContext()
   128 // See header for details.
    71 // See header for details.