mpxplugins/viewplugins/views/podcastview/src/mpxpodcastcollectionviewcontainer.cpp
changeset 0 ff3acec5bc43
child 21 a1247965635c
equal deleted inserted replaced
-1:000000000000 0:ff3acec5bc43
       
     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 Podcast Collection view container
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <hlplch.h>
       
    21 #include <aknappui.h>
       
    22 #include <akncontext.h>
       
    23 #include <AknIconUtils.h>
       
    24 #include <data_caging_path_literals.hrh>
       
    25 #include <eikspane.h>
       
    26 #include <eiktxlbx.h>
       
    27 #include <mpxcollectionview.mbg>
       
    28 #include <mpxplaybackframeworkdefs.h>
       
    29 #include <mpxconstants.h>
       
    30 #include <mpxlog.h>
       
    31 #include <eikon.hrh>
       
    32 
       
    33 #include "mpxpodcastcollectionview.hrh"
       
    34 #include "mpxpodcastcollectionviewlistboxarray.h"
       
    35 #include "mpxpodcastcollectionview.hlp.hrh"
       
    36 #include "mpxpodcastcollectionviewcontainer.h"
       
    37 
       
    38 
       
    39 // ======== MEMBER FUNCTIONS ========
       
    40 
       
    41 // ---------------------------------------------------------------------------
       
    42 // Two-phased constructor.
       
    43 // ---------------------------------------------------------------------------
       
    44 //
       
    45 CMPXPodcastCollectionViewContainer* CMPXPodcastCollectionViewContainer::NewL(
       
    46     MEikCommandObserver* aView,
       
    47     MEikListBoxObserver* aObserver )
       
    48     {
       
    49     MPX_FUNC( "CMPXPodcastCollectionViewContainer::NewL" );
       
    50     CMPXPodcastCollectionViewContainer* self =
       
    51         new ( ELeave ) CMPXPodcastCollectionViewContainer(aView, aObserver);
       
    52     CleanupStack::PushL( self );
       
    53     self->ConstructL();
       
    54     CleanupStack::Pop( self );
       
    55     return self;
       
    56     }
       
    57 
       
    58 // ---------------------------------------------------------------------------
       
    59 // C++ default constructor can NOT contain any code, that
       
    60 // might leave.
       
    61 // ---------------------------------------------------------------------------
       
    62 //
       
    63 CMPXPodcastCollectionViewContainer::CMPXPodcastCollectionViewContainer(
       
    64     MEikCommandObserver* aView,
       
    65     MEikListBoxObserver* aObserver )
       
    66     : iView( aView )
       
    67     , iListBoxObserver( aObserver )
       
    68     {
       
    69     iCurrentView = EMPXMainPodcastMenuView;
       
    70     }
       
    71 
       
    72 // ---------------------------------------------------------------------------
       
    73 // Destructor
       
    74 // ---------------------------------------------------------------------------
       
    75 //
       
    76 CMPXPodcastCollectionViewContainer::~CMPXPodcastCollectionViewContainer()
       
    77     {
       
    78     MPX_FUNC( "CMPXPodcastCollectionViewContainer::~CMPXPodcastCollectionViewContainer" );
       
    79     delete iCommonContainer;
       
    80     }
       
    81 
       
    82 // ---------------------------------------------------------------------------
       
    83 // Symbian 2nd phase constructor can leave.
       
    84 // ---------------------------------------------------------------------------
       
    85 //
       
    86 void CMPXPodcastCollectionViewContainer::ConstructL()
       
    87     {
       
    88     MPX_FUNC( "CMPXPodcastCollectionViewContainer::ConstructL" );
       
    89     iCommonContainer = CMPXCommonContainerFactory::NewL();
       
    90     iCommonContainer->SetViewContainer( this );
       
    91     iCommonContainer->SetCommandObserver( iView );
       
    92     iCommonContainer->SetListBoxObserver( iListBoxObserver );
       
    93     iCommonContainer->ConstructContainerL(MMPXCommonContainer::EMPXCommonContainerPodcast);
       
    94     iLbxArray = static_cast<CMPXPodcastCollectionViewListBoxArray*>(
       
    95         CreateListBoxArrayL() );
       
    96     iCommonContainer->SetListBoxArrayL( iLbxArray );
       
    97     iCommonContainer->HandleListBoxArrayEventL(
       
    98         MMPXCommonListBoxArrayObserver::EMPXCommonListBoxArrayEventIconArrayChange );
       
    99     }
       
   100 
       
   101 // ---------------------------------------------------------------------------
       
   102 // Sets playback status
       
   103 // ---------------------------------------------------------------------------
       
   104 //
       
   105 void CMPXPodcastCollectionViewContainer::SetPlaybackStatusByIdL(
       
   106     TMPXItemId aId, TMPXPlaybackState aStatus )
       
   107     {
       
   108     MPX_FUNC( "CMPXPodcastCollectionViewContainer::SetPlaybackStatusByIdL" );
       
   109     if ( iLbxArray && iCommonContainer )
       
   110         {
       
   111         TInt index( iLbxArray->SetPlaybackStatusByIdL( aId, aStatus ) );
       
   112         if ( index != KErrNotFound )
       
   113             {
       
   114             // Update the previous item as not playing anymore
       
   115             iCommonContainer->DrawLbxItem( index );
       
   116             }
       
   117         index = iLbxArray->GetPlaybackIndex();
       
   118         if ( index != KErrNotFound )
       
   119             {
       
   120             // Update new item as playing
       
   121             iCommonContainer->DrawLbxItem( index );
       
   122             }
       
   123         }
       
   124     }
       
   125 
       
   126 // ---------------------------------------------------------------------------
       
   127 // Get playback index
       
   128 // ---------------------------------------------------------------------------
       
   129 //
       
   130 TInt CMPXPodcastCollectionViewContainer::PlaybackIndex()
       
   131     {
       
   132     MPX_FUNC( "CMPXPodcastCollectionViewContainer::PlaybackIndex" );
       
   133     return ( iLbxArray ? iLbxArray->GetPlaybackIndex() : KErrNotFound );
       
   134     }
       
   135 
       
   136 // ---------------------------------------------------------------------------
       
   137 // Sets the current view to be used to determine the correct help context
       
   138 // ---------------------------------------------------------------------------
       
   139 //
       
   140 void CMPXPodcastCollectionViewContainer::SetCurrentView(
       
   141     const TMPXPodcastView& currentView )
       
   142     {
       
   143     iCurrentView = currentView;
       
   144     }
       
   145 
       
   146 // -----------------------------------------------------------------------------
       
   147 // Creates listbox array
       
   148 // -----------------------------------------------------------------------------
       
   149 //
       
   150 CMPXCommonListBoxArrayBase* CMPXPodcastCollectionViewContainer::CreateListBoxArrayL()
       
   151     {
       
   152     MPX_FUNC( "CMPXPodcastCollectionViewContainer::CreateListBoxArrayL" );
       
   153     CMPXPodcastCollectionViewListBoxArray* array = CMPXPodcastCollectionViewListBoxArray::NewL();
       
   154     array->ConstructListBoxArrayL();
       
   155     array->SetObserver( this );
       
   156     return array;
       
   157     }
       
   158 
       
   159 // ---------------------------------------------------------------------------
       
   160 // From MMPXViewContainer
       
   161 // Handles the retrieval of the view container's help context.
       
   162 // ---------------------------------------------------------------------------
       
   163 //
       
   164 void CMPXPodcastCollectionViewContainer::HandleHelpContext(
       
   165     TCoeHelpContext& aContext ) const
       
   166     {
       
   167     MPX_FUNC( "CMPXPodcastCollectionViewContainer::HandleHelpContext" );
       
   168     aContext.iMajor = KAppUidMusicPlayerX;
       
   169 
       
   170     switch(iCurrentView)
       
   171         {
       
   172         case EMPXMainPodcastMenuView:
       
   173             {
       
   174             aContext.iContext = KMUS_HLP_PODCAST_MENU_VIEW;
       
   175             break;
       
   176             }
       
   177         case EMPXPublishDateView:
       
   178             {
       
   179             aContext.iContext = KMUS_HLP_PODCAST_PUBLISH_DATE_CAT_VIEW;
       
   180             break;
       
   181             }
       
   182         case EMPXTitlesView:
       
   183             {
       
   184             aContext.iContext = KMUS_HLP_PODCAST_MENU_VIEW;
       
   185             break;
       
   186             }
       
   187         case EMPXEpisodesView:
       
   188             {
       
   189             aContext.iContext = KMUS_HLP_PODCAST_EPISODES_VIEW;
       
   190             break;
       
   191             }
       
   192         }
       
   193     }
       
   194 
       
   195 // ---------------------------------------------------------------------------
       
   196 // From MMPXViewContainer
       
   197 // Handles key events.
       
   198 // ---------------------------------------------------------------------------
       
   199 //
       
   200 TKeyResponse CMPXPodcastCollectionViewContainer::HandleKeyEventL(
       
   201     const TKeyEvent& aKeyEvent, TEventCode aType )
       
   202     {
       
   203     ASSERT( iCommonContainer );
       
   204     MPX_DEBUG4( "CMPXPodcastCollectionViewContainer::HandleKeyEventL(iCode=%d, iScanCode=%d, aType=%d)",
       
   205         aKeyEvent.iCode, aKeyEvent.iScanCode, aType );
       
   206 
       
   207     if ( aKeyEvent.iCode == EKeyUpArrow  ||
       
   208         aKeyEvent.iCode == EKeyPrevious )
       
   209         {
       
   210         iView->ProcessCommandL( EMPXCmdUpArrow );
       
   211         }
       
   212     else if ( aKeyEvent.iCode == EKeyDownArrow ||
       
   213         aKeyEvent.iCode == EKeyNext)
       
   214         {
       
   215         iView->ProcessCommandL( EMPXCmdDownArrow );
       
   216         }
       
   217 
       
   218     TKeyResponse response = EKeyWasNotConsumed;
       
   219     // Hashkey mark/unmark only works in episodes view
       
   220     if( iCurrentView == EMPXEpisodesView ||
       
   221         aKeyEvent.iScanCode != EStdKeyHash )
       
   222         {
       
   223         response = iCommonContainer->HandleKeyEventL( aKeyEvent, aType );
       
   224         }
       
   225 
       
   226     return response;
       
   227     }
       
   228 
       
   229 // ---------------------------------------------------------------------------
       
   230 // From MMPXViewContainer
       
   231 // Returns the indicators for the specified item within the view container
       
   232 // Only used when using Hitchcock container.
       
   233 // ---------------------------------------------------------------------------
       
   234 //
       
   235 RArray<TInt> CMPXPodcastCollectionViewContainer::IndicatorsL( TInt aIndex )
       
   236     {
       
   237         return iLbxArray->IndicatorIconIndicesL( aIndex );
       
   238     }
       
   239 
       
   240 // -----------------------------------------------------------------------------
       
   241 // Returns common container
       
   242 // -----------------------------------------------------------------------------
       
   243 //
       
   244 MMPXCommonContainer* CMPXPodcastCollectionViewContainer::Common()
       
   245     {
       
   246     return iCommonContainer;
       
   247     }
       
   248 
       
   249 // ---------------------------------------------------------------------------
       
   250 // From MMPXCommonListBoxArrayObserver
       
   251 // Handle listbox array events.
       
   252 // ---------------------------------------------------------------------------
       
   253 //
       
   254 void CMPXPodcastCollectionViewContainer::HandleListBoxArrayEventL(
       
   255     TMPXCommonListBoxArrayEvents aEvent )
       
   256     {
       
   257     MPX_FUNC( "CMPXPodcastCollectionViewContainer::HandleListBoxArrayEventL" );
       
   258     ASSERT( iCommonContainer );
       
   259     iCommonContainer->HandleListBoxArrayEventL( aEvent );
       
   260     }
       
   261 
       
   262 //  End of File