idlefw/plugins/pslnactiveidleplugin/src/pslnactiveidleplugincontainer.cpp
branchRCL_3
changeset 9 d0529222e3f0
parent 4 1a2a00e78665
child 10 5ef93ea513cb
child 18 bd874ee5e5e2
equal deleted inserted replaced
4:1a2a00e78665 9:d0529222e3f0
     1 /*
       
     2 * Copyright (c) 2005-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:  Container for the Application Shell plugin
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 
       
    21 // From this plugin.
       
    22 #include "pslnactiveidleplugincontainer.h"
       
    23 #include "pslnactiveidlepluginengine.h"
       
    24 #include "pslnactiveidleplugin.h"
       
    25 
       
    26 // From Psln application.
       
    27 #include <csxhelp/skins.hlp.hrh>
       
    28 
       
    29 // From PSLN framework
       
    30 #include <pslnfwbaseview.h>
       
    31 #include <pslnfwiconhelper.h>
       
    32 
       
    33 // Resources
       
    34 #include <psln.rsg>
       
    35 #include <pslnactiveidlepluginrsc.rsg>
       
    36 
       
    37 // General services
       
    38 #include <Aknlists.h>
       
    39 
       
    40 // XUIKON
       
    41 #include <XnODT.h>
       
    42 
       
    43 // CONSTANTS
       
    44 // UID of Personlisation application
       
    45 const TUid KPslnAppUid = { 0x10005A32 };
       
    46 
       
    47 // ========================= MEMBER FUNCTIONS ================================
       
    48 
       
    49 CPslnActiveIdlePluginContainer::CPslnActiveIdlePluginContainer(
       
    50                     TBool aGSCalling,
       
    51                     CPslnActiveIdlePlugin* aPlugin )
       
    52     :
       
    53     iPlugin( aPlugin ),
       
    54     iGSCalling( aGSCalling )
       
    55     {
       
    56     }
       
    57 // ---------------------------------------------------------------------------
       
    58 // Symbian 2nd phase constructor can leave.
       
    59 // ---------------------------------------------------------------------------
       
    60 //
       
    61 void CPslnActiveIdlePluginContainer::ConstructL( const TRect& aRect )
       
    62     {
       
    63     iListBox = new( ELeave ) CAknSingleGraphicStyleListBox;
       
    64     TInt titleResId = 0;
       
    65 
       
    66     if (iGSCalling)
       
    67     {
       
    68         titleResId = R_PSLN_GS_LIST_VIEW_TITLE;
       
    69     }
       
    70     BaseConstructL(aRect, titleResId, R_PSLN_PLUGIN_DEFAULT_VIEW_LBX);
       
    71     // Do not show container immediately - to avoid seeing "No Data" first.
       
    72     iListBox->MakeVisible( EFalse );
       
    73     }
       
    74 
       
    75 // ---------------------------------------------------------------------------
       
    76 // Destructor 
       
    77 // ---------------------------------------------------------------------------
       
    78 //
       
    79 CPslnActiveIdlePluginContainer::~CPslnActiveIdlePluginContainer()
       
    80     {
       
    81     if( iItemArray )
       
    82         {
       
    83         TInt count = iItemArray->Count();
       
    84         iItemArray->Delete(0, count);
       
    85         }
       
    86 
       
    87     delete iItems;
       
    88     }
       
    89 
       
    90 // -----------------------------------------------------------------------------
       
    91 // CPslnActiveIdlePluginContainer::GetCurrentlySelectedIndex
       
    92 // -----------------------------------------------------------------------------
       
    93 //
       
    94 TInt CPslnActiveIdlePluginContainer::GetCurrentlySelectedIndex() const
       
    95     {
       
    96     return iCurrentlySelected;
       
    97     }
       
    98 
       
    99 // ---------------------------------------------------------------------------
       
   100 // Adds new item to the listbox.
       
   101 // ---------------------------------------------------------------------------
       
   102 //
       
   103 void CPslnActiveIdlePluginContainer::AddNewItemToListL( 
       
   104     const TInt aItemIndex, CXnODT* aSkinODT, TInt aUiController )
       
   105     {
       
   106     HBufC* item = HBufC::NewLC( KPslnItemMaxTextLength );
       
   107     TPtr itemPtr = item->Des();
       
   108     TBool newActiveItem = EFalse;
       
   109 
       
   110     // Get theme ODT and full name. 
       
   111     // Index aItemIndex has been verified in view.
       
   112     itemPtr = aSkinODT->ThemeFullName();
       
   113     if ( aSkinODT->Flags() & EXnThemeStatusActive &&
       
   114         iPlugin->Engine()->CurrentUIController() == aUiController )
       
   115         {
       
   116         itemPtr.Insert( 0, KPslnFWActiveListItemFormat );
       
   117 
       
   118         // Set selected active.
       
   119         iCurrentlySelected = aItemIndex;
       
   120         newActiveItem = ETrue;
       
   121         }
       
   122     else
       
   123         {
       
   124         itemPtr.Insert( 0, KPslnFWNonActiveListItemFormat );
       
   125         }
       
   126     iItemArray->AppendL( itemPtr );
       
   127     CleanupStack::PopAndDestroy( item );
       
   128 
       
   129     if ( newActiveItem )
       
   130         {
       
   131         // Set highlight.
       
   132         iListBox->SetCurrentItemIndex( iCurrentlySelected );
       
   133         // Since we now have content, show container.
       
   134         iListBox->MakeVisible( ETrue );
       
   135         if ( iPlugin )
       
   136             {
       
   137             iPlugin->CheckMiddleSoftkeyLabelL();
       
   138             }
       
   139         }
       
   140     }
       
   141 
       
   142 // ---------------------------------------------------------------------------
       
   143 // Removes themes from listbox.
       
   144 // ---------------------------------------------------------------------------
       
   145 //
       
   146 void CPslnActiveIdlePluginContainer::RemoveThemes( const TInt aDeleteFrom )
       
   147     {
       
   148     // Validate parameter first.
       
   149     if ( iItemArray &&
       
   150          ( aDeleteFrom >= 0 ) &&
       
   151          ( aDeleteFrom < iItemArray->Count() ) )
       
   152         {
       
   153         iItemArray->Delete( aDeleteFrom, iItemArray->Count() - aDeleteFrom );
       
   154         }
       
   155     }
       
   156 
       
   157 // ---------------------------------------------------------------------------
       
   158 // Construct the listbox from resource array.
       
   159 // ---------------------------------------------------------------------------
       
   160 //
       
   161 void CPslnActiveIdlePluginContainer::ConstructListBoxL( TInt aResLbxId )
       
   162     {
       
   163     iListBox->ConstructL( this, EAknListBoxSelectionList );
       
   164 
       
   165     iItemArray = static_cast<CDesCArray*>
       
   166         ( iListBox->Model()->ItemTextArray() );
       
   167 
       
   168     iItems = iCoeEnv->ReadDesC16ArrayResourceL( aResLbxId );
       
   169 
       
   170     // Create pre- and post-text icons.
       
   171     AddIconsToListL();
       
   172     }
       
   173 
       
   174 // ---------------------------------------------------------------------------
       
   175 // Gets Help context.
       
   176 // ---------------------------------------------------------------------------
       
   177 //
       
   178 void CPslnActiveIdlePluginContainer::GetHelpContext( 
       
   179     TCoeHelpContext& aContext ) const
       
   180     {
       
   181     aContext.iMajor = KPslnAppUid;
       
   182     aContext.iContext = KSKINS_HLP_APPSKINS_LIST;
       
   183     }
       
   184 
       
   185 // ---------------------------------------------------------------------------
       
   186 // Adds icons to setting list items.
       
   187 // ---------------------------------------------------------------------------
       
   188 //
       
   189 void CPslnActiveIdlePluginContainer::AddIconsToListL()
       
   190     {
       
   191     CPslnFWIconHelper* iconHelper = CPslnFWIconHelper::NewL();
       
   192     CleanupStack::PushL( iconHelper );
       
   193     iconHelper->AddIconsToSettingItemsL(
       
   194         ETrue,
       
   195         KErrNotFound, // none, selected
       
   196         iListBox );
       
   197     CleanupStack::PopAndDestroy( iconHelper );
       
   198     }
       
   199 
       
   200 void CPslnActiveIdlePluginContainer::RefreshList()
       
   201     {
       
   202     TRAP_IGNORE(iListBox->HandleItemAdditionL());
       
   203     iListBox->SetCurrentItemIndex(iCurrentlySelected);
       
   204     TRAP_IGNORE(iPlugin->CheckMiddleSoftkeyLabelL());
       
   205     DrawDeferred();
       
   206     // Since we now have content, show container.
       
   207     iListBox->MakeVisible( ETrue );
       
   208     }
       
   209 
       
   210 // End of File