mpxplugins/viewplugins/views/collectionviewhg/src/mpxcollectionviewhgcontainer.cpp
branchRCL_3
changeset 14 943ff5625028
parent 5 2a40e88564c8
child 15 171e07ac910f
equal deleted inserted replaced
11:13afc0e517bd 14:943ff5625028
    53 #include <mpxcollectionpath.h>
    53 #include <mpxcollectionpath.h>
    54 #include <mpxplaybackutility.h>
    54 #include <mpxplaybackutility.h>
    55 #include <mpxcollectionviewhg.rsg>
    55 #include <mpxcollectionviewhg.rsg>
    56 #include <mpxcollectionviewhg.mbg>
    56 #include <mpxcollectionviewhg.mbg>
    57 #include <mpxappui.hrh>
    57 #include <mpxappui.hrh>
       
    58 #include <mpxmusicplayerviewplugin.hrh>
    58 
    59 
    59 #include <ganes/HgDoubleGraphicListFlat.h>
    60 #include <ganes/HgDoubleGraphicListFlat.h>
    60 #include <ganes/HgSingleGraphicList.h>
    61 #include <ganes/HgSingleGraphicList.h>
    61 #include <ganes/HgSingleTextListWithIcon.h>
    62 #include <ganes/HgSingleTextListWithIcon.h>
    62 #include <ganes/HgVgItem.h>
    63 #include <ganes/HgVgItem.h>
    63 #include <ganes/HgItem.h>
    64 #include <ganes/HgItem.h>
    64 #include <ganes/HgScrollerWithTitle.h>
    65 #include <ganes/HgScrollerWithTitle.h>
    65 #include <ganes/HgVgMediaWall.h>
    66 #include <ganes/HgVgMediaWall.h>
    66 
    67 
    67 #include <layoutmetadata.cdl.h>
    68 #include <layoutmetadata.cdl.h>
       
    69 #include <akntranseffect.h>                 // For transition effects
       
    70 #include <gfxtranseffect\gfxtranseffect.h>  // For transition effects
    68 
    71 
    69 #include "mpxcommoncontainer.hrh"
    72 #include "mpxcommoncontainer.hrh"
    70 #include "mpxcollectionviewhg.hrh"
    73 #include "mpxcollectionviewhg.hrh"
    71 #include "mpxcollectionviewhglistboxarray.h"
    74 #include "mpxcollectionviewhglistboxarray.h"
    72 #include "mpxcollectionviewhg.hlp.hrh"
    75 #include "mpxcollectionviewhg.hlp.hrh"
    73 #include "mpxcollectionviewhgcontainer.h"
    76 #include "mpxcollectionviewhgcontainer.h"
    74 #include "mpxcollectionviewhgplaylisthelper.h"
    77 #include "mpxcollectionviewhgplaylisthelper.h"
    75 #include "mpxcollectionviewhgtnloader.h"
    78 #include "mpxcollectionviewhgtnloader.h"
    76 #include "mpxcbahandler.h"
    79 #include "mpxcbahandler.h"
       
    80 #include "mpxselectedalbumhandler.h"
       
    81 #include "mpxpopuplist.h"
    77 
    82 
    78 // CONSTANTS
    83 // CONSTANTS
    79 _LIT( KMPXCollectionViewRscPath, "mpxcollectionviewhg.rsc" );
    84 _LIT( KMPXCollectionViewRscPath, "mpxcollectionviewhg.rsc" );
    80 _LIT( KMPXCollectionViewIconFile, "mpxcollectionviewhg.mbm" );
    85 _LIT( KMPXCollectionViewIconFile, "mpxcollectionviewhg.mbm" );
    81 const TInt KMPXListSelectionCount = 5;
    86 const TInt KMPXListSelectionCount = 5;
    94 const TInt KMPXListBufferSizeWithMediaWall = 80;
    99 const TInt KMPXListBufferSizeWithMediaWall = 80;
    95 #endif
   100 #endif
    96 const TInt KMPXMaxFileLength = 256;
   101 const TInt KMPXMaxFileLength = 256;
    97 const TReal KIconFactor = 0.7;
   102 const TReal KIconFactor = 0.7;
    98 
   103 
       
   104 const TInt KThumbLoadingPauseForTransition(500000);
       
   105 
    99 _LIT( KMPXDash, " - " );
   106 _LIT( KMPXDash, " - " );
   100 #ifdef HG_MP_LOC_AVAILABLE
   107 #ifdef HG_MP_LOC_AVAILABLE
   101 _LIT( KMPXSpace, " ");
   108 _LIT( KMPXSpace, " ");
   102 #endif //HG_MP_LOC_AVAILABLE
   109 #endif //HG_MP_LOC_AVAILABLE
   103 _LIT( KMPXZeroDurationMark, "--");
   110 _LIT( KMPXZeroDurationMark, "--");
   109 _LIT( KAlbum, " album" );
   116 _LIT( KAlbum, " album" );
   110 _LIT( KAlbums, " albums" );
   117 _LIT( KAlbums, " albums" );
   111 _LIT( KSongDash, " song - " );
   118 _LIT( KSongDash, " song - " );
   112 _LIT( KSongsDash, " songs - " );
   119 _LIT( KSongsDash, " songs - " );
   113 
   120 
   114 _LIT( KMPXDriveC, "c:" );
       
   115 _LIT( KMPXSelectedAlbumItemFileName, "mpxalbumitem.dat");
       
   116 
       
   117 // ======== MEMBER FUNCTIONS ========
   121 // ======== MEMBER FUNCTIONS ========
   118 
   122 
   119 // ---------------------------------------------------------------------------
   123 // ---------------------------------------------------------------------------
   120 // Two-phased constructor.
   124 // Two-phased constructor.
   121 // ---------------------------------------------------------------------------
   125 // ---------------------------------------------------------------------------
   122 //
   126 //
   123 CMPXCollectionViewHgContainer* CMPXCollectionViewHgContainer::NewL(
   127 CMPXCollectionViewHgContainer* CMPXCollectionViewHgContainer::NewL(
   124     MEikCommandObserver* aView,
   128     MEikCommandObserver* aView,
   125     MEikListBoxObserver* aObserver,
   129     MEikListBoxObserver* aObserver,
       
   130     MMPXSelectedAlbumHandler* aSelectedAlbumHandler,
   126     TBool aIsEmbedded)
   131     TBool aIsEmbedded)
   127     {
   132     {
   128     MPX_FUNC( "CMPXCollectionViewHgContainer::NewL" );
   133     MPX_FUNC( "CMPXCollectionViewHgContainer::NewL" );
   129     CMPXCollectionViewHgContainer* self =
   134     CMPXCollectionViewHgContainer* self =
   130         new ( ELeave ) CMPXCollectionViewHgContainer(aView, aObserver, aIsEmbedded);
   135         new ( ELeave ) CMPXCollectionViewHgContainer(
       
   136                 aView, aObserver, aSelectedAlbumHandler, aIsEmbedded);
   131     CleanupStack::PushL( self );
   137     CleanupStack::PushL( self );
   132     self->ConstructL();
   138     self->ConstructL();
   133     CleanupStack::Pop( self );
   139     CleanupStack::Pop( self );
   134     return self;
   140     return self;
   135     }
   141     }
   139 // ---------------------------------------------------------------------------
   145 // ---------------------------------------------------------------------------
   140 //
   146 //
   141 CMPXCollectionViewHgContainer::CMPXCollectionViewHgContainer(
   147 CMPXCollectionViewHgContainer::CMPXCollectionViewHgContainer(
   142     MEikCommandObserver* aView,
   148     MEikCommandObserver* aView,
   143     MEikListBoxObserver* aObserver,
   149     MEikListBoxObserver* aObserver,
       
   150     MMPXSelectedAlbumHandler* aSelectedAlbumHandler,
   144     TBool aIsEmbedded) :
   151     TBool aIsEmbedded) :
   145 	iView( aView ),
   152 	iView( aView ),
   146 	iListBoxObserver( aObserver ),
   153 	iListBoxObserver( aObserver ),
   147 	iReady( EFalse ),
   154 	iReady( EFalse ),
   148 	iIsEmbedded(aIsEmbedded),
   155 	iIsEmbedded(aIsEmbedded),
   150 	iContext( EContextUnknown ),
   157 	iContext( EContextUnknown ),
   151 	iTopIndex( 0 ),
   158 	iTopIndex( 0 ),
   152 	iBottomIndex( KErrNotFound ),
   159 	iBottomIndex( KErrNotFound ),
   153 	iAlbumIndex(KErrNotFound),
   160 	iAlbumIndex(KErrNotFound),
   154 	iSelectedAlbumIndex(KErrNotFound),
   161 	iSelectedAlbumIndex(KErrNotFound),
   155 	iRestoredAlbumIndex(KErrNotFound)
   162 	iRestoredAlbumIndex(KErrNotFound),
       
   163 	iSelectedAlbumHandler (aSelectedAlbumHandler),
       
   164 	iOpenAlbumTracks(EFalse),
       
   165 	iShuffleItem(0),
       
   166 	iSetEmptyTextNeeded(EFalse),
       
   167 	iPopupListRect(TRect(0,0,0,0)),
       
   168 	iPreviousViewId(TUid::Uid(0))
   156     {
   169     {
   157     }
   170     }
   158 
   171 
   159 // ---------------------------------------------------------------------------
   172 // ---------------------------------------------------------------------------
   160 // Destructor
   173 // Destructor
   248     iListSelections = new (ELeave) CArrayFixFlat<TInt>( KMPXListSelectionCount );
   261     iListSelections = new (ELeave) CArrayFixFlat<TInt>( KMPXListSelectionCount );
   249 
   262 
   250     iThumbnailManager = CMpxTNLoader::NewL( *this, EAudioListThumbnailSize );
   263     iThumbnailManager = CMpxTNLoader::NewL( *this, EAudioListThumbnailSize );
   251 
   264 
   252     iImageSize = CHgDoubleGraphicListFlat::PreferredImageSize();
   265     iImageSize = CHgDoubleGraphicListFlat::PreferredImageSize();
   253 
       
   254     TFileName pathWithoutDrive;
       
   255     iEikonEnv->FsSession().PrivatePath( pathWithoutDrive );
       
   256     iSelectedAlbumItemFileName.Copy( KMPXDriveC );
       
   257     iSelectedAlbumItemFileName.Append( pathWithoutDrive );
       
   258     iSelectedAlbumItemFileName.Append( KMPXSelectedAlbumItemFileName );
       
   259 
       
   260     iListBoxArray = static_cast<CMPXCollectionViewListBoxArray*>(
   266     iListBoxArray = static_cast<CMPXCollectionViewListBoxArray*>(
   261         CreateListBoxArrayL() );
   267         CreateListBoxArrayL() );
   262 
   268 
   263     CreateIconArrayL();
   269     CreateIconArrayL();
   264 
   270 
   266     iCoeEnv->AddForegroundObserverL( *this );
   272     iCoeEnv->AddForegroundObserverL( *this );
   267 
   273 
   268     TCallBack callback(CMPXCollectionViewHgContainer::AsyncCallback, this);
   274     TCallBack callback(CMPXCollectionViewHgContainer::AsyncCallback, this);
   269     iAsyncCallBack = new (ELeave) CAsyncCallBack( CActive::EPriorityStandard );
   275     iAsyncCallBack = new (ELeave) CAsyncCallBack( CActive::EPriorityStandard );
   270     iAsyncCallBack->Set(callback);
   276     iAsyncCallBack->Set(callback);
       
   277 
       
   278     GfxTransEffect::Enable();
   271 
   279 
   272     CreateWindowL();
   280     CreateWindowL();
   273     ActivateL();
   281     ActivateL();
   274     }
   282     }
   275 
   283 
   712             {
   720             {
   713             delete iIconArray;
   721             delete iIconArray;
   714             iIconArray = NULL;
   722             iIconArray = NULL;
   715             CreateIconArrayL();
   723             CreateIconArrayL();
   716 
   724 
   717             if( iCurrentViewType == EMPXViewCoverFlow || iCurrentViewType == EMPXViewTBone )
   725             if( iCurrentViewType == EMPXViewMediawall || iCurrentViewType == EMPXViewTBone )
   718                 {
   726                 {
   719             	iMediaWall->SetDefaultIconL(NULL);
   727             	iMediaWall->SetDefaultIconL(NULL);
   720                 iMediaWall->EnableScrollBufferL(*this, KMPXListBufferSize, KMPXListBufferSize/4);
   728                 iMediaWall->EnableScrollBufferL(*this, KMPXListBufferSize, KMPXListBufferSize/4);
   721                 }
   729                 }
   722             else
   730             else
   730                 }
   738                 }
   731 			SetDetailIconShuffleL();
   739 			SetDetailIconShuffleL();
   732             }
   740             }
   733         else if ( aType == KEikDynamicLayoutVariantSwitch )
   741         else if ( aType == KEikDynamicLayoutVariantSwitch )
   734             {
   742             {
   735             if ( iCurrentViewType == EMPXViewCoverFlow )
   743             if ( iCurrentViewType == EMPXViewMediawall )
   736                 {
   744                 {
   737                 if ( iDialog ) 
   745                 if ( iDialog ) 
   738                     {
   746                     {
   739                     iDialog->CancelPopup();
   747                     iDialog->CancelPopup();
   740                     iDialog = NULL;
       
   741                     }                
   748                     }                
   742                 }
   749                 }
   743             if( iCurrentViewType == EMPXViewTBone )
   750             iSetEmptyTextNeeded = ETrue;
       
   751 
       
   752             // Coe env is in middle if notifying observers (controls).
       
   753             // Just to be safe, lets just create a small async callback and then
       
   754             // call HandleLbxItemAdditionL
       
   755             if( !iAsyncCallBack->IsActive() )
   744                 {
   756                 {
   745 				iCollectionUtility->Collection().BackL();
   757                 iAsyncCallBack->CallBack();
   746                 }
   758                 }
   747             else
   759 
   748                 {
   760             iLayoutSwitch = ETrue;
   749                 // Coe env is in middle if notifying observers (controls).
       
   750                 // Just to be save, lets just create a small async callback and then
       
   751                 // call HandleLbxItemAdditionL
       
   752                 if( !iAsyncCallBack->IsActive() )
       
   753                     {
       
   754                     iAsyncCallBack->CallBack();
       
   755                     }
       
   756                 }
       
   757 
   761 
   758             if( iCbaHandler )
   762             if( iCbaHandler )
   759                 iCbaHandler->UpdateCba();
   763                 iCbaHandler->UpdateCba();
   760 
   764 
   761             TRect clientRect = ((CAknView*)iView)->ClientRect();
   765             TRect clientRect = ((CAknView*)iView)->ClientRect();
   762             SetRect( clientRect );
   766             SetRect( clientRect );
   763             iBgContext->SetRect(((CAknAppUi*)iCoeEnv->AppUi())->ApplicationRect());
   767             iBgContext->SetRect(((CAknAppUi*)iCoeEnv->AppUi())->ApplicationRect());
   764             }
   768             }
   765         );
   769         );
       
   770     if(iMediaWall)
       
   771         iMediaWall->HandleResourceChange( aType );
       
   772     if(iListWidget)
       
   773         iListWidget->HandleResourceChange( aType );
       
   774     if(iMwListWidget)
       
   775         iMwListWidget->HandleResourceChange( aType );
   766     }
   776     }
   767 
   777 
   768 
   778 
   769 // ---------------------------------------------------------------------------
   779 // ---------------------------------------------------------------------------
   770 // From CCoeControl
   780 // From CCoeControl
   789 //
   799 //
   790 TCoeInputCapabilities CMPXCollectionViewHgContainer::InputCapabilities() const
   800 TCoeInputCapabilities CMPXCollectionViewHgContainer::InputCapabilities() const
   791 	{
   801 	{
   792 	switch( iCurrentViewType )
   802 	switch( iCurrentViewType )
   793         {
   803         {
   794         case EMPXViewCoverFlow:
   804         case EMPXViewMediawall:
   795         case EMPXViewTBone:
   805         case EMPXViewTBone:
   796             {
   806             {
   797             return iMediaWall->InputCapabilities();
   807             return iMediaWall->InputCapabilities();
   798             }
   808             }
   799         case EMPXViewList:
   809         case EMPXViewList:
   909     MPX_FUNC( "CMPXCollectionViewHgContainer::CurrentListItemCount" );
   919     MPX_FUNC( "CMPXCollectionViewHgContainer::CurrentListItemCount" );
   910     TInt count = 0;
   920     TInt count = 0;
   911 
   921 
   912     switch( iCurrentViewType )
   922     switch( iCurrentViewType )
   913         {
   923         {
   914         case EMPXViewCoverFlow:
   924         case EMPXViewMediawall:
   915         case EMPXViewTBone:
   925         case EMPXViewTBone:
   916             {
   926             {
   917             count = iMediaWall->ItemCount();
   927             count = iMediaWall->ItemCount();
   918             break;
   928             break;
   919             }
   929             }
   982     if ( count <= 0 )
   992     if ( count <= 0 )
   983         return index;
   993         return index;
   984 
   994 
   985     switch( iCurrentViewType )
   995     switch( iCurrentViewType )
   986         {
   996         {
   987         case EMPXViewCoverFlow:
   997         case EMPXViewMediawall:
   988         case EMPXViewTBone:
   998         case EMPXViewTBone:
   989             {
   999             {
   990             index = iMediaWall->SelectedIndex();
  1000             index = MediaIndex(iMediaWall->SelectedIndex());
   991             break;
  1001             break;
   992             }
  1002             }
   993         case EMPXViewList:
  1003         case EMPXViewList:
   994             {
  1004             {
   995             index = iListWidget->SelectedIndex();
  1005             index = MediaIndex(iListWidget->SelectedIndex());
   996             break;
  1006             break;
   997             }
  1007             }
   998         default:
  1008         default:
   999             break;
  1009             break;
  1000         }
  1010         }
  1127     {
  1137     {
  1128     MPX_DEBUG2( "CMPXCollectionViewHgContainer::DrawLbxItem (aIndex=%d)", aIndex );
  1138     MPX_DEBUG2( "CMPXCollectionViewHgContainer::DrawLbxItem (aIndex=%d)", aIndex );
  1129 
  1139 
  1130     CHgScroller* list = CurrentListWidget();
  1140     CHgScroller* list = CurrentListWidget();
  1131 
  1141 
  1132     if( list && aIndex < list->ItemCount() )
  1142 	TInt listIndex = aIndex + iShuffleItem;
  1133         {
  1143     if( list && listIndex < list->ItemCount() )
  1134         CHgItem* item = &list->ItemL(aIndex);
  1144         {
       
  1145         CHgItem* item = &list->ItemL(listIndex);
  1135         SetDetailIndicatorL(item, aIndex);
  1146         SetDetailIndicatorL(item, aIndex);
  1136         list->RefreshScreen(aIndex);
  1147         list->RefreshScreen(listIndex);
  1137         }
  1148         }
  1138     }
  1149     }
  1139 
  1150 
  1140 
  1151 
  1141 // -----------------------------------------------------------------------------
  1152 // -----------------------------------------------------------------------------
  1154 //
  1165 //
  1155 void CMPXCollectionViewHgContainer::HandleLbxItemAdditionL()
  1166 void CMPXCollectionViewHgContainer::HandleLbxItemAdditionL()
  1156     {
  1167     {
  1157     MPX_FUNC( "CMPXCollectionViewHgContainer::HandleLbxItemAdditionL" );
  1168     MPX_FUNC( "CMPXCollectionViewHgContainer::HandleLbxItemAdditionL" );
  1158     SetCollectionContextL();
  1169     SetCollectionContextL();
       
  1170 
       
  1171 	// When the collection is reopened after coming from playback view,
       
  1172 	// it is reopened in Album-Tracks level (EContextItemAlbum).
       
  1173 	// We don't display its content in that context but inturn reopen the
       
  1174 	// collection at one level up (Albums) and display it in T-bone view.
       
  1175 	// T-Bone view is just a list of albums presented differently.
       
  1176     if ( iContext == EContextItemAlbum )
       
  1177 		{
       
  1178 		iCollectionUtility->Collection().BackL();
       
  1179 		iOpenAlbumTracks = ETrue;
       
  1180 		return;
       
  1181 		}
       
  1182 
  1159     iLastValidMediaItemIndex = 0;
  1183     iLastValidMediaItemIndex = 0;
  1160 
  1184 
  1161     const CMPXMediaArray& mediaArray = iListBoxArray->MediaArray();
  1185     const CMPXMediaArray& mediaArray = iListBoxArray->MediaArray();
  1162     const TInt count( mediaArray.Count() );
  1186     TInt count( mediaArray.Count() );
  1163     MPX_DEBUG2( "CMPXCollectionViewHgContainer::HandleLbxItemAdditionL count=%d", count);
  1187     MPX_DEBUG2( "CMPXCollectionViewHgContainer::HandleLbxItemAdditionL count=%d", count);
       
  1188 
  1164     HandleLbxItemRemovalL();
  1189     HandleLbxItemRemovalL();
  1165 
       
  1166     iThumbnailReqMap.Reset();
       
  1167     iThumbnailReqMap.ReserveL(count);
       
  1168     for ( TInt i = 0; i < count; i++ )
       
  1169         {
       
  1170         iThumbnailReqMap.Append( EFalse );
       
  1171         }
       
  1172 
       
  1173     iThumbnailManager->CancelAll();
       
  1174 
       
  1175     TViewType prevViewType = iCurrentViewType;
  1190     TViewType prevViewType = iCurrentViewType;
  1176     ResolveCurrentViewType();
  1191     ResolveCurrentViewType();
  1177 
  1192 
       
  1193     iThumbnailReqMap.Reset();
       
  1194     if (ShuffleItemPresent())
       
  1195         iShuffleItem = 1;
       
  1196     else
       
  1197     	iShuffleItem = 0;
       
  1198 
       
  1199     count = count + iShuffleItem;
       
  1200     iThumbnailReqMap.ReserveL(count );
       
  1201     for ( TInt i = 0; i < count ; i++ )
       
  1202         {
       
  1203         iThumbnailReqMap.Append( EFalse );
       
  1204         }
       
  1205 
       
  1206     iThumbnailManager->CancelAll();
       
  1207 
  1178     if( prevViewType == iCurrentViewType && iContext == iPrevContext )
  1208     if( prevViewType == iCurrentViewType && iContext == iPrevContext )
  1179         {
  1209         {
  1180         ResizeListL( mediaArray, count );
  1210         ResizeListL( mediaArray, count );
  1181         }
  1211         }
  1182     else
  1212     else
  1183         {
  1213         {
  1184         // MediaWall sets the default icon in the construction phase.
  1214         // MediaWall sets the default icon in the construction phase.
  1185         iDefaultIconSet = EFalse;
  1215         iDefaultIconSet = EFalse;
       
  1216 
       
  1217         if( !iLayoutSwitch  )
       
  1218             {
       
  1219 			// We only need to use this for one transition coming
       
  1220 			// from playback view.
       
  1221 			TBool pbv = (iPreviousViewId == TUid::Uid(KMPXPluginTypePlaybackUid)) ? ETrue : EFalse;
       
  1222 			if ( pbv )
       
  1223 				{
       
  1224             	iPreviousViewId = TUid::Uid(0);
       
  1225 				}
       
  1226             BeginFullScreenAnimation( pbv );
       
  1227             }
       
  1228 
  1186         switch (iCurrentViewType)
  1229         switch (iCurrentViewType)
  1187             {
  1230             {
  1188             case EMPXViewCoverFlow:
  1231             case EMPXViewMediawall:
  1189                 {
  1232                 {
  1190                 TMPXPlaybackState pbState( iPlaybackUtility->StateL() );
  1233                 TMPXPlaybackState pbState( iPlaybackUtility->StateL() );
  1191                 if ( pbState == EPbStatePlaying || pbState == EPbStatePaused )
  1234                 if ( pbState == EPbStatePlaying || pbState == EPbStatePaused )
  1192                     RestoreSelectedAlbumItemL(mediaArray);
  1235                     RestoreSelectedAlbumItemL(mediaArray);
  1193                 PrepareMediaWallL(mediaArray, count);
  1236                 PrepareMediaWallL(mediaArray, count);
       
  1237                 iOpenAlbumTracks = EFalse;
  1194                 break;
  1238                 break;
  1195                 }
  1239                 }
  1196             case EMPXViewTBone:
  1240             case EMPXViewTBone:
  1197                 {
  1241                 {
  1198                 RestoreSelectedAlbumItemL(mediaArray);
  1242                 RestoreSelectedAlbumItemL(mediaArray);
  1199                 PrepareMediaWallWithListL( mediaArray, count );
  1243                 PrepareMediaWallWithListL( mediaArray, count );
       
  1244 				// We need to adjust the CBA for this view.
       
  1245 				if( iCbaHandler )
       
  1246 					iCbaHandler->UpdateCba();
  1200                 break;
  1247                 break;
  1201                 }
  1248                 }
  1202             case EMPXViewList:
  1249             case EMPXViewList:
  1203                 {
  1250                 {
  1204                 PrepareListL(mediaArray, count);
  1251                 PrepareListL(mediaArray, count);
       
  1252                 iOpenAlbumTracks = EFalse;
  1205                 break;
  1253                 break;
  1206                 }
  1254                 }
  1207             default:
  1255             default:
  1208                 User::Leave( KErrGeneral );
  1256                 User::Leave( KErrGeneral );
  1209                 break;
  1257                 break;
  1210             }
  1258             }
  1211 
       
  1212         }
  1259         }
  1213 
  1260 
  1214     DrawableWindow()->SetOrdinalPosition( -1 );
  1261     DrawableWindow()->SetOrdinalPosition( -1 );
  1215 
  1262 
  1216     CleanPrevView();
  1263     CleanPrevView();
  1217 
       
  1218     iPrevViewType = iCurrentViewType;
  1264     iPrevViewType = iCurrentViewType;
  1219     iPrevContext = iContext;
  1265     iPrevContext = iContext;
       
  1266     if ( iSetEmptyTextNeeded )
       
  1267         {
       
  1268         LoadAndSetEmptyTextL();
       
  1269         iSetEmptyTextNeeded = EFalse;
       
  1270         }    
  1220     if( !iDefaultIconSet )
  1271     if( !iDefaultIconSet )
  1221         {
  1272         {
  1222         SetDefaultIconL();
  1273         SetDefaultIconL();
  1223         }
  1274         }
  1224 
  1275 
       
  1276     iLayoutSwitch = EFalse;
  1225     }
  1277     }
  1226 
  1278 
  1227 // -----------------------------------------------------------------------------
  1279 // -----------------------------------------------------------------------------
  1228 // Handle listbox item addition, preserving the current display index
  1280 // Handle listbox item addition, preserving the current display index
  1229 // -----------------------------------------------------------------------------
  1281 // -----------------------------------------------------------------------------
  1432             {
  1484             {
  1433             iMediaWall->ResizeL( aCount );
  1485             iMediaWall->ResizeL( aCount );
  1434             ProvideDataWithoutThumbnailsMwL(aMediaArray);
  1486             ProvideDataWithoutThumbnailsMwL(aMediaArray);
  1435             index = index >= 0 ? index : 0;
  1487             index = index >= 0 ? index : 0;
  1436             iMediaWall->SetSelectedIndex( index );
  1488             iMediaWall->SetSelectedIndex( index );
  1437             OpenAlbumL( index );
  1489             if ( iCurrentViewType == EMPXViewTBone )
       
  1490                 {
       
  1491                 OpenAlbumL( index );
       
  1492                 }
  1438             }
  1493             }
  1439         else
  1494         else
  1440             {
  1495             {
  1441             iMediaWall->RefreshScreen(0);
  1496             iMediaWall->RefreshScreen(0);
  1442             }
  1497             }
  1485 
  1540 
  1486     // TODO. Define here in which views we need to have buffering enabled in the list
  1541     // TODO. Define here in which views we need to have buffering enabled in the list
  1487     if( iContext == EContextGroupAlbum ||
  1542     if( iContext == EContextGroupAlbum ||
  1488         iContext == EContextGroupArtist ||
  1543         iContext == EContextGroupArtist ||
  1489         iContext == EContextGroupSong ||
  1544         iContext == EContextGroupSong ||
  1490         iContext == EContextItemPlaylist ||
  1545         iContext == EContextItemPlaylist )
  1491         iContext == EContextGroupGenre )
       
  1492         {
  1546         {
  1493         iListWidget->EnableScrollBufferL(*this, KMPXListBufferSize, KMPXListBufferSize/4);
  1547         iListWidget->EnableScrollBufferL(*this, KMPXListBufferSize, KMPXListBufferSize/4);
  1494         }
  1548         }
  1495     else
  1549     else
  1496         {
  1550         {
       
  1551         EndFullScreenAnimation();
  1497         iListWidget->RefreshScreen(0);
  1552         iListWidget->RefreshScreen(0);
  1498         }
  1553         }
  1499     iDefaultIconSet = EFalse;
  1554     iDefaultIconSet = EFalse;
  1500     }
  1555     }
  1501 
  1556 
  1531 				mediaWallRect,
  1586 				mediaWallRect,
  1532 				aCount,
  1587 				aCount,
  1533 				CHgVgMediaWall::EHgVgMediaWallStyleCoverflowTBonePortrait,
  1588 				CHgVgMediaWall::EHgVgMediaWallStyleCoverflowTBonePortrait,
  1534 				EFalse,
  1589 				EFalse,
  1535 				this,
  1590 				this,
  1536 				DefaultIconL() );
  1591 				NULL );
  1537 
  1592 
  1538 		if( !iIsForeground )
  1593 		if( !iIsForeground )
  1539 		    iMediaWall->HandleLosingForeground();
  1594 		    iMediaWall->HandleLosingForeground();
  1540 
  1595 
  1541 		iMediaWall->SetMopParent(this);
  1596 		iMediaWall->SetMopParent(this);
  1573             iMwListWidget->SetRect( mwListRect );
  1628             iMwListWidget->SetRect( mwListRect );
  1574             iMwListWidget->DrawNow();
  1629             iMwListWidget->DrawNow();
  1575             }
  1630             }
  1576 	    }
  1631 	    }
  1577 
  1632 
       
  1633     if( iTranstionType != EMPXTranstionNotDefined )
       
  1634         {
       
  1635         iMediaWall->SetFlags( CHgVgMediaWall::EHgVgMediaWallDrawToWindowGC );
       
  1636         }
       
  1637 
       
  1638     iMediaWall->SetOpeningAnimationType( CHgVgMediaWall::EHgVgOpeningAnimationNone );
       
  1639 
  1578     if ( iAlbumIndex == KErrNotFound )
  1640     if ( iAlbumIndex == KErrNotFound )
  1579         {
  1641         {
  1580         iMediaWall->SetSelectedIndex( iRestoredAlbumIndex );
  1642         iMediaWall->SetSelectedIndex( iRestoredAlbumIndex );
  1581         iMediaWall->RefreshScreen(iRestoredAlbumIndex);
  1643         // If we are about to start a transition animation we should draw only
       
  1644         // when we have received first screen of thumbs in Refresh function.
       
  1645         if( iTranstionType == EMPXTranstionNotDefined )
       
  1646             iMediaWall->RefreshScreen(iRestoredAlbumIndex);
  1582         OpenAlbumL(iRestoredAlbumIndex);
  1647         OpenAlbumL(iRestoredAlbumIndex);
  1583       }
  1648       }
  1584     else
  1649     else
  1585         {
  1650         {
  1586         iMediaWall->SetSelectedIndex( iAlbumIndex );
  1651         iMediaWall->SetSelectedIndex( iAlbumIndex );
  1587         iMediaWall->RefreshScreen(iAlbumIndex);
  1652         // If we are about to start a transition animation we should draw only
       
  1653         // when we have received first screen of thumbs in Refresh function.
       
  1654         if( iTranstionType == EMPXTranstionNotDefined )
       
  1655             iMediaWall->RefreshScreen(iAlbumIndex);
  1588         OpenAlbumL(iAlbumIndex);
  1656         OpenAlbumL(iAlbumIndex);
  1589        }
  1657        }
  1590     iMwListWidget->RefreshScreen(0);
  1658     iMwListWidget->RefreshScreen(0);
  1591     iDefaultIconSet = ETrue;
  1659 
  1592     }
  1660     }
  1593 
  1661 
  1594 // ----------------------------------------------------------------------------
  1662 // ----------------------------------------------------------------------------
  1595 // Prepare view for displaying data in Media wall format.
  1663 // Prepare view for displaying data in Media wall format.
  1596 // ----------------------------------------------------------------------------
  1664 // ----------------------------------------------------------------------------
  1623             iMediaWall->HandleLosingForeground();
  1691             iMediaWall->HandleLosingForeground();
  1624 
  1692 
  1625         iMediaWall->SetMopParent(this);
  1693         iMediaWall->SetMopParent(this);
  1626         iMediaWall->SetSelectionObserver(*this);
  1694         iMediaWall->SetSelectionObserver(*this);
  1627         iMediaWall->SetObserver( this ); // softkey visibility event observer
  1695         iMediaWall->SetObserver( this ); // softkey visibility event observer
  1628         iMediaWall->SetOpeningAnimationType( CHgVgMediaWall::EHgVgOpeningAnimationFlipToFront );
       
  1629         iMediaWall->EnableScrollBufferL(
  1696         iMediaWall->EnableScrollBufferL(
  1630                 *this,
  1697                 *this,
  1631                 KMPXListBufferSizeWithMediaWall,
  1698                 KMPXListBufferSizeWithMediaWall,
  1632                 KMPXListBufferSizeWithMediaWall / 4);
  1699                 KMPXListBufferSizeWithMediaWall / 4);
  1633         // We want softkeys to be drawn on top of mediawall, thats we need to manipulate window pos
  1700         // We want softkeys to be drawn on top of mediawall, thats we need to manipulate window pos
  1634         iMediaWall->DrawableWindow()->SetOrdinalPosition( -1 );
  1701         iMediaWall->DrawableWindow()->SetOrdinalPosition( -1 );
  1635         ProvideDataWithoutThumbnailsMwL(aMediaArray);
  1702         ProvideDataWithoutThumbnailsMwL(aMediaArray);
  1636         if( iAlbumIndex == KErrNotFound )
  1703         if( iAlbumIndex == KErrNotFound )
  1637             iMediaWall->SetSelectedIndex( iRestoredAlbumIndex );
  1704             iMediaWall->SetSelectedIndex( iRestoredAlbumIndex + iShuffleItem );
  1638         else
  1705         else
  1639             iMediaWall->SetSelectedIndex( iAlbumIndex );
  1706             iMediaWall->SetSelectedIndex( iAlbumIndex + iShuffleItem );
  1640 	    }
  1707 	    }
  1641 	else
  1708 	else
  1642 	    {
  1709 	    {
  1643 	    // TODO, do we need to refill the data or are the items same in fullscreen coverflow and tbone coverflow????
       
  1644 	    // David: Yes because there will be an extra shuffle item in the coverflow list but not in tbone coverflow.
       
  1645 	    //        Index will be off.
       
  1646 	    if( iMediaWall->Style() != CHgVgMediaWall::EHgVgMediaWallStyleCoverflowFullScreen )
  1710 	    if( iMediaWall->Style() != CHgVgMediaWall::EHgVgMediaWallStyleCoverflowFullScreen )
  1647 	        iMediaWall->ChangeStyleL( CHgVgMediaWall::EHgVgMediaWallStyleCoverflowFullScreen, appRect, ETrue );
  1711 	        iMediaWall->ChangeStyleL( CHgVgMediaWall::EHgVgMediaWallStyleCoverflowFullScreen, appRect, ETrue );
  1648 
  1712 
  1649 	    iMediaWall->MakeVisible( ETrue );
  1713 	    iMediaWall->MakeVisible( ETrue );
  1650         iMediaWall->SetFocus( ETrue );
  1714         iMediaWall->SetFocus( ETrue );
  1651         iMediaWall->EnableScrollBufferL(
  1715         iMediaWall->EnableScrollBufferL(
  1652                 *this,
  1716                 *this,
  1653                 KMPXListBufferSizeWithMediaWall,
  1717                 KMPXListBufferSizeWithMediaWall,
  1654                 KMPXListBufferSizeWithMediaWall / 4);
  1718                 KMPXListBufferSizeWithMediaWall / 4);
  1655         if( iAlbumIndex == KErrNotFound )
  1719         if( iAlbumIndex == KErrNotFound )
  1656             iMediaWall->SetSelectedIndex( iRestoredAlbumIndex );
  1720             iMediaWall->SetSelectedIndex( iRestoredAlbumIndex + iShuffleItem );
  1657         else
  1721         else
  1658             iMediaWall->SetSelectedIndex( iAlbumIndex );
  1722             iMediaWall->SetSelectedIndex( iAlbumIndex + iShuffleItem );
  1659 
       
  1660         iMediaWall->DrawDeferred();
       
  1661 	    }
  1723 	    }
       
  1724 
       
  1725     if( iTranstionType != EMPXTranstionNotDefined )
       
  1726         {
       
  1727         iMediaWall->SetFlags( CHgVgMediaWall::EHgVgMediaWallDrawToWindowGC );
       
  1728         }
       
  1729 
       
  1730 	if( iPopupListRect == TRect(0,0,0,0) )
       
  1731 		{
       
  1732 	    ResolvePopupListSizeL();
       
  1733 		}
       
  1734 
       
  1735     iMediaWall->SetOpenedItemRect( iPopupListRect );
       
  1736     iMediaWall->SetOpeningAnimationType( CHgVgMediaWall::EHgVgOpeningAnimationZoomToFront );
  1662 
  1737 
  1663 	iDefaultIconSet = ETrue;
  1738 	iDefaultIconSet = ETrue;
  1664     }
  1739     }
  1665 
  1740 
  1666 // ----------------------------------------------------------------------------
  1741 // ----------------------------------------------------------------------------
  1735     switch (iContext)
  1810     switch (iContext)
  1736         {
  1811         {
  1737         case EContextGroupAlbum:
  1812         case EContextGroupAlbum:
  1738             {
  1813             {
  1739             if( landscapeOrientation )
  1814             if( landscapeOrientation )
  1740                 iCurrentViewType = EMPXViewCoverFlow;
  1815                 iCurrentViewType = EMPXViewMediawall;
  1741             else
  1816             else
  1742                 iCurrentViewType = EMPXViewList;
  1817             	{
       
  1818 				// In case we want to display the albums in T-Bone view
       
  1819 				// we change the view type and context appropriately.
       
  1820 				if ( iOpenAlbumTracks )
       
  1821 					{
       
  1822                 	iCurrentViewType = EMPXViewTBone;
       
  1823                 	iContext = EContextItemAlbum;
       
  1824                 	iOpenAlbumTracks = EFalse;
       
  1825 					}
       
  1826 				else
       
  1827 					{
       
  1828 					iCurrentViewType = EMPXViewList;
       
  1829 					}
       
  1830 				}
  1743             break;
  1831             break;
  1744             }
  1832             }
  1745         case EContextItemAlbum:
  1833         case EContextItemAlbum:
  1746         case EContextItemArtist:
  1834         case EContextItemArtist:
  1747             {
  1835             {
  1748             // TODO, Change by Harri. Is this correct?
       
  1749             if( landscapeOrientation )
  1836             if( landscapeOrientation )
  1750                 iCurrentViewType = EMPXViewCoverFlow;
  1837                 iCurrentViewType = EMPXViewMediawall;
  1751             else
  1838             else
  1752                 iCurrentViewType = EMPXViewTBone;
  1839                 iCurrentViewType = EMPXViewTBone;
  1753             break;
  1840             break;
  1754             }
  1841             }
  1755         default:
  1842         default:
  1766     if( iCurrentViewType == iPrevViewType )
  1853     if( iCurrentViewType == iPrevViewType )
  1767         return;
  1854         return;
  1768 
  1855 
  1769     switch (iPrevViewType)
  1856     switch (iPrevViewType)
  1770         {
  1857         {
  1771         case EMPXViewCoverFlow:
  1858         case EMPXViewMediawall:
  1772             {
  1859             {
  1773             if( iCurrentViewType != EMPXViewTBone )
  1860             if( iCurrentViewType != EMPXViewTBone )
  1774                 {
  1861                 {
  1775                 delete iMediaWall;
  1862                 delete iMediaWall;
  1776                 iMediaWall = 0;
  1863                 iMediaWall = 0;
  1777                 }
  1864                 }
  1778             break;
  1865             break;
  1779             }
  1866             }
  1780         case EMPXViewTBone:
  1867         case EMPXViewTBone:
  1781             {
  1868             {
  1782             if( iCurrentViewType != EMPXViewCoverFlow )
  1869             if( iCurrentViewType != EMPXViewMediawall )
  1783                 {
  1870                 {
  1784                 delete iMediaWall;
  1871                 delete iMediaWall;
  1785                 iMediaWall = 0;
  1872                 iMediaWall = 0;
  1786                 }
  1873                 }
  1787             delete iMwListWidget;
  1874             delete iMwListWidget;
  1806 TBool CMPXCollectionViewHgContainer::IsSelectedItemASong()
  1893 TBool CMPXCollectionViewHgContainer::IsSelectedItemASong()
  1807     {
  1894     {
  1808     MPX_FUNC( "CMPXCollectionViewHgContainer::IsSelectedItemASong" );
  1895     MPX_FUNC( "CMPXCollectionViewHgContainer::IsSelectedItemASong" );
  1809 
  1896 
  1810 	TBool res(EFalse);
  1897 	TBool res(EFalse);
  1811     if ( iContext == EContextItemAlbum || iContext == EContextGroupSong )
  1898     if ( iContext == EContextItemAlbum || 
       
  1899          iContext == EContextGroupSong ||
       
  1900          iContext == EContextItemGenre )
  1812         {
  1901         {
  1813     	CHgScroller* listWidget = CurrentListWidget();
  1902     	CHgScroller* listWidget = CurrentListWidget();
       
  1903     	if ( !listWidget )
       
  1904 			{
       
  1905 			return EFalse;
       
  1906 			}
  1814 		if ( listWidget->SelectedIndex() == 0 &&
  1907 		if ( listWidget->SelectedIndex() == 0 &&
  1815 			 listWidget->ItemCount() > 1 )
  1908 			 listWidget->ItemCount() > 1 )
  1816 			{
  1909 			{
  1817 			res = EFalse;
  1910 			res = EFalse;
  1818 			}
  1911 			}
  1837     CMPXMedia* album( albums.AtL( iSelectedAlbumIndex ) );    
  1930     CMPXMedia* album( albums.AtL( iSelectedAlbumIndex ) );    
  1838     const CMPXMediaArray* songs = album->Value<CMPXMediaArray>(KMPXMediaArrayContents);
  1931     const CMPXMediaArray* songs = album->Value<CMPXMediaArray>(KMPXMediaArrayContents);
  1839     CHgScroller* listWidget = CurrentListWidget();
  1932     CHgScroller* listWidget = CurrentListWidget();
  1840     if (listWidget && songs)
  1933     if (listWidget && songs)
  1841         {
  1934         {
       
  1935 		// Tracks list may have a shuffle item inserted so account for that.
  1842         if (listWidget->ItemCount() > 1)
  1936         if (listWidget->ItemCount() > 1)
  1843             {
  1937             {
  1844             song = songs->AtL(listWidget->SelectedIndex()-1);
  1938             song = songs->AtL(listWidget->SelectedIndex()-1);
  1845             }
  1939             }
  1846         else
  1940         else
  1860     {
  1954     {
  1861     MPX_FUNC( "CMPXCollectionViewHgContainer::HandleItemCommanddL" );
  1955     MPX_FUNC( "CMPXCollectionViewHgContainer::HandleItemCommanddL" );
  1862 
  1956 
  1863     if( aCommand == EMPXCmdPlay )
  1957     if( aCommand == EMPXCmdPlay )
  1864         {
  1958         {
  1865         switch( iCurrentViewType )
  1959         if ( iContext == EContextGroupAlbum  )
  1866             {
  1960             {
  1867             case EMPXViewCoverFlow:
  1961             iSelectedAlbumIndex = MediaIndex(iListWidget->SelectedIndex());
  1868             case EMPXViewTBone:
  1962             SaveSelectedAlbumItemL(iSelectedAlbumIndex);
  1869                 {
  1963             // Open first song of album & playlist for entire album is created.
  1870                 iSelectedAlbumIndex = iMediaWall->SelectedIndex();
  1964             PlayAlbumL(iSelectedAlbumIndex);
  1871                 SaveSelectedAlbumItemL(iSelectedAlbumIndex);
  1965             }
  1872                 // Open first song of album & playlist for entire album is created.
  1966         else if ( iContext == EContextGroupPlaylist  )
  1873                 UpdatePathAndOpenL(0, ETrue);
  1967             {
  1874                 break;
  1968             TInt index = MediaIndex(iListWidget->SelectedIndex());
  1875                 }
  1969             PlayPlaylistL(index);
  1876             case EMPXViewList:
  1970             }
  1877                 {
  1971         else if ( iContext == EContextGroupGenre  )
  1878                 if ( iContext == EContextGroupAlbum  )
  1972             {
  1879                     {
  1973             TInt index = MediaIndex(iListWidget->SelectedIndex());
  1880                     iSelectedAlbumIndex = iListWidget->SelectedIndex();
  1974             PlayGenreL(index);
  1881                     SaveSelectedAlbumItemL(iSelectedAlbumIndex);
       
  1882                     // Open first song of album & playlist for entire album is created.
       
  1883                     PlayAlbumL(iSelectedAlbumIndex);
       
  1884                     }
       
  1885                 else if ( iContext == EContextGroupPlaylist  )
       
  1886                     {
       
  1887                     TInt index = iListWidget->SelectedIndex();
       
  1888                     PlayPlaylistL(index);
       
  1889                     }
       
  1890                 else if ( iContext == EContextGroupGenre  )
       
  1891                     {
       
  1892                     TInt index = iListWidget->SelectedIndex();
       
  1893                     PlayGenreL(index);
       
  1894                     }
       
  1895                 break;
       
  1896                 }
       
  1897             default:
       
  1898                 break;
       
  1899             }
  1975             }
  1900         }
  1976         }
  1901     }
  1977     }
  1902 
  1978 
  1903 // ---------------------------------------------------------------------------
  1979 // ---------------------------------------------------------------------------
  1917 // ---------------------------------------------------------------------------
  1993 // ---------------------------------------------------------------------------
  1918 //
  1994 //
  1919 void CMPXCollectionViewHgContainer::HandleSelectL( TInt aIndex, CCoeControl* aControl )
  1995 void CMPXCollectionViewHgContainer::HandleSelectL( TInt aIndex, CCoeControl* aControl )
  1920     {
  1996     {
  1921     MPX_FUNC( "CMPXCollectionViewHgContainer::HandleSelect" );
  1997     MPX_FUNC( "CMPXCollectionViewHgContainer::HandleSelect" );
  1922     if( iCurrentViewType == EMPXViewTBone && iSelectedAlbumIndex != aIndex )
  1998 
       
  1999     TInt index(MediaIndex(aIndex));
       
  2000 
       
  2001     if( iCurrentViewType == EMPXViewTBone && iSelectedAlbumIndex != index )
  1923         {
  2002         {
  1924         if ( aControl == iMediaWall )
  2003         if ( aControl == iMediaWall )
  1925             {
  2004             {
  1926             iSelectedAlbumIndex = aIndex;
  2005             iSelectedAlbumIndex = index;
  1927             OpenAlbumL(aIndex);
  2006             OpenAlbumL(index);
  1928             }
  2007             }
  1929         }
  2008         }
  1930     else if( iCurrentViewType == EMPXViewCoverFlow )
  2009     else if( iCurrentViewType == EMPXViewMediawall )
  1931         {
  2010         {
  1932         iSelectedAlbumIndex = aIndex;
  2011         iSelectedAlbumIndex = index;
  1933         }
  2012         }
  1934     }
  2013     }
  1935 
  2014 
  1936 
  2015 
  1937 // ---------------------------------------------------------------------------
  2016 // ---------------------------------------------------------------------------
  1941 //
  2020 //
  1942 void CMPXCollectionViewHgContainer::HandleOpenL( TInt aIndex )
  2021 void CMPXCollectionViewHgContainer::HandleOpenL( TInt aIndex )
  1943     {
  2022     {
  1944     MPX_FUNC( "CMPXCollectionViewHgContainer::HandleOpenL" );
  2023     MPX_FUNC( "CMPXCollectionViewHgContainer::HandleOpenL" );
  1945 
  2024 
  1946     // Mod by harri, had to enable this block since ganes list components still
  2025     TInt index(MediaIndex(aIndex));
  1947     // uses this version of the HandleOpen
  2026 
       
  2027     // ganes list components still uses this version of the HandleOpen
  1948     if ( iContext == EContextItemAlbum  )
  2028     if ( iContext == EContextItemAlbum  )
  1949 		{
  2029 		{
  1950         SaveSelectedAlbumItemL(iSelectedAlbumIndex);
  2030         SaveSelectedAlbumItemL(iSelectedAlbumIndex);
  1951 		UpdatePathAndOpenL(aIndex);
  2031 		UpdatePathAndOpenL(index);
  1952 		}
  2032 		}
  1953     else if ( iContext == EContextGroupAlbum )
  2033     else if ( iContext == EContextGroupAlbum )
  1954         {
  2034         {
  1955         SaveSelectedAlbumItemL(aIndex);
  2035         SaveSelectedAlbumItemL(index);
       
  2036         iAlbumIndex = index;
  1956         // Check if shuffle play all was selected.
  2037         // Check if shuffle play all was selected.
  1957         if (!ShufflePlayAllL(aIndex))
  2038         if (!ShufflePlayAllL(index))
  1958             {
  2039             {
  1959 			// To open the selected album.
  2040 			// To open the selected album.
  1960             iView->ProcessCommandL( EMPXCmdCommonEnterKey );
  2041             PrepareTboneViewL();
  1961             }
  2042             }
  1962         }
  2043         }
  1963     else if ( iContext == EContextGroupSong || iContext == EContextItemPlaylist )
  2044     else if ( iContext == EContextGroupSong || iContext == EContextItemPlaylist || iContext == EContextItemGenre )
  1964         {
  2045         {
  1965         // Check if shuffle play all was selected.
  2046         // Check if shuffle play all was selected.
  1966         if (!ShufflePlayAllL(aIndex))
  2047         if (!ShufflePlayAllL(index))
  1967             {
  2048             {
  1968             // To open the selected album.
  2049             // To open the selected album.
  1969             iView->ProcessCommandL( EMPXCmdCommonEnterKey );
  2050             iView->ProcessCommandL( EMPXCmdCommonEnterKey );
  1970             }
  2051             }
  1971         }
  2052         }
  1982 //
  2063 //
  1983 void CMPXCollectionViewHgContainer::HandleOpenL( TInt aIndex, CCoeControl* aControl )
  2064 void CMPXCollectionViewHgContainer::HandleOpenL( TInt aIndex, CCoeControl* aControl )
  1984     {
  2065     {
  1985     MPX_FUNC( "CMPXCollectionViewHgContainer::HandleOpenL" );
  2066     MPX_FUNC( "CMPXCollectionViewHgContainer::HandleOpenL" );
  1986 
  2067 
  1987     if( iContext == EContextGroupAlbum )
  2068     TInt index(MediaIndex(aIndex));
  1988         {
  2069 
  1989         iAlbumIndex = aIndex;
  2070     if( iContext == EContextGroupAlbum && index >= 0 )
  1990         iSelectedAlbumIndex = aIndex;
  2071         {
  1991         SaveSelectedAlbumItemL(aIndex);
  2072         iAlbumIndex = index;
       
  2073         iSelectedAlbumIndex = index;
       
  2074         SaveSelectedAlbumItemL(index);
  1992         }
  2075         }
  1993 
  2076 
  1994     if ( iContext == EContextItemAlbum  )
  2077     if ( iContext == EContextItemAlbum  )
  1995         {
  2078         {
       
  2079         if( iCurrentViewType == EMPXViewTBone )
       
  2080             {
       
  2081             iMediaWall->SetFlags( CHgVgMediaWall::EHgVgMediaWallDrawToWindowGC );
       
  2082             iMediaWall->DrawNow();
       
  2083             }
  1996         if ( aControl == iMediaWall )
  2084         if ( aControl == iMediaWall )
  1997             {
  2085             {
  1998 			// If album was opened, we will play all tracks in the album.
  2086 			// If album was opened, we will play all tracks in the album.
  1999             SaveSelectedAlbumItemL(aIndex);
  2087             SaveSelectedAlbumItemL(index);
  2000             // Open first song of album & playlist for entire album is created.
  2088             // Open first song of album & playlist for entire album is created.
  2001             UpdatePathAndOpenL(0, ETrue);
  2089             UpdatePathAndOpenL(0, ETrue);
  2002             }
  2090             }
  2003         else if ( aControl == iMwListWidget )
  2091         else if ( aControl == iMwListWidget )
  2004             {
  2092             {
  2005 			// If item in list was opened, we only play the selected one.
  2093 			// If item in list was opened, we only play the selected one.
  2006             SaveSelectedAlbumItemL(iSelectedAlbumIndex);
  2094             SaveSelectedAlbumItemL(iSelectedAlbumIndex);
  2007            // Open the selected song of album
  2095            // Open the selected song of album
  2008             UpdatePathAndOpenL(aIndex);
  2096             UpdatePathAndOpenL(index);
  2009             }
  2097             }
  2010         }
  2098         }
  2011     else if ( iContext == EContextGroupAlbum  )
  2099     else if ( iContext == EContextGroupAlbum  )
  2012         {
  2100         {
  2013         if ( aControl == iMediaWall )
  2101         if ( aControl == iMediaWall )
  2014             {
  2102             {
  2015 			// Check if shuffle play all was selected.
  2103 			// Check if shuffle play all was selected.
  2016 			if (!ShufflePlayAllL(aIndex))
  2104 			if (!ShufflePlayAllL(index))
  2017 				{
  2105 				{
  2018 	            OpenAlbumL(aIndex);
  2106 	            OpenAlbumL(index);
  2019 				}
  2107 				}
  2020             }
  2108             }
  2021         }
  2109         }
  2022     else
  2110     else
  2023         {
  2111         {
  2066 
  2154 
  2067 	// This should not happen but if not handled, bad things will happen.
  2155 	// This should not happen but if not handled, bad things will happen.
  2068 	if ( aBufferStart < 0 || aBufferEnd < 0 )
  2156 	if ( aBufferStart < 0 || aBufferEnd < 0 )
  2069    	    return;
  2157    	    return;
  2070 
  2158 
  2071 	// TODO, add support for last valid media item index later
  2159     if ( aBufferStart - iShuffleItem > iLastValidMediaItemIndex ||
  2072     if ( aBufferStart > iLastValidMediaItemIndex || aBufferEnd > iLastValidMediaItemIndex )
  2160          aBufferEnd - iShuffleItem > iLastValidMediaItemIndex )
  2073 		{
  2161 		{
  2074 		// We cannot provide data for the requested range at this time.
  2162 		// We cannot provide data for the requested range at this time.
  2075 		// Remember the request so we can handle it when there's enough data.
  2163 		// Remember the request so we can handle it when there's enough data.
  2076 		iRequestStart = aBufferStart;
  2164 		iRequestStart = aBufferStart;
  2077     	iRequestEnd = aBufferEnd;
  2165     	iRequestEnd = aBufferEnd;
  2133     else
  2221     else
  2134         {
  2222         {
  2135         firstOnScreen = iListWidget->FirstIndexOnScreen();
  2223         firstOnScreen = iListWidget->FirstIndexOnScreen();
  2136         lastOnScreen = firstOnScreen + iListWidget->ItemsOnScreen();
  2224         lastOnScreen = firstOnScreen + iListWidget->ItemsOnScreen();
  2137         }
  2225         }
  2138     const CMPXMediaArray& mediaArray = iListBoxArray->MediaArray();
       
  2139 
  2226 
  2140     TInt startIndex = Max( firstOnScreen, aBufferStart );
  2227     TInt startIndex = Max( firstOnScreen, aBufferStart );
  2141     TInt endIndex = Min( lastOnScreen, aBufferEnd );
  2228     TInt endIndex = Min( lastOnScreen, aBufferEnd );
  2142 
  2229 
  2143     ProvideDataForRangeL( startIndex, endIndex );
  2230     ProvideDataForRangeL( startIndex, endIndex );
  2180 // -----------------------------------------------------------------------------
  2267 // -----------------------------------------------------------------------------
  2181 //
  2268 //
  2182 void CMPXCollectionViewHgContainer::ProvideDataForRangeL( TInt aBufferStart, TInt aBufferEnd )
  2269 void CMPXCollectionViewHgContainer::ProvideDataForRangeL( TInt aBufferStart, TInt aBufferEnd )
  2183     {
  2270     {
  2184     const CMPXMediaArray& mediaArray = iListBoxArray->MediaArray();
  2271     const CMPXMediaArray& mediaArray = iListBoxArray->MediaArray();
       
  2272     TInt index(0);
  2185     for( TInt i = aBufferStart; i <= aBufferEnd; i++ )
  2273     for( TInt i = aBufferStart; i <= aBufferEnd; i++ )
  2186         {
  2274         {
  2187         // Just get the exiting item and update the fields + icon.
  2275         // Just get the exiting item and update the fields + icon.
  2188         CHgItem* item = NULL;
  2276         CHgItem* item = NULL;
  2189         if( iMediaWall )
  2277         if( iMediaWall )
  2190             item = &iMediaWall->ItemL(i);
  2278             item = &iMediaWall->ItemL(i);
  2191         else
  2279         else
  2192             item = &iListWidget->ItemL(i);
  2280             item = &iListWidget->ItemL(i);
  2193 
  2281 
  2194         CMPXMedia* currentMedia( mediaArray.AtL( i ) );
  2282         index = MediaIndex(i);
  2195         AddThumbnailToDisplayedItemL( item, currentMedia, i );
  2283         if ( index >= 0 )
       
  2284             {
       
  2285             CMPXMedia* currentMedia( mediaArray.AtL( index ) );
       
  2286             AddThumbnailToDisplayedItemL( item, currentMedia, index );
       
  2287             }
       
  2288         else
       
  2289         	{
       
  2290 			if ( iCurrentViewType == EMPXViewMediawall ||
       
  2291 				 iCurrentViewType == EMPXViewList && (i-iShuffleItem) == -1 )
       
  2292 				SetDetailIconShuffleL(); 
       
  2293 			iThumbnailReqMap[i] = ETrue;
       
  2294 			RefreshNoThumbnailL(i);
       
  2295 			}
  2196         }
  2296         }
  2197     }
  2297     }
  2198 
  2298 
  2199 // -----------------------------------------------------------------------------
  2299 // -----------------------------------------------------------------------------
  2200 // CMPXCollectionViewHgContainer::ProvideDataWithouThumbnailsL
  2300 // CMPXCollectionViewHgContainer::ProvideDataWithouThumbnailsL
  2204 	const CMPXMediaArray& aMediaArray,
  2304 	const CMPXMediaArray& aMediaArray,
  2205 	TInt aStartIndex )
  2305 	TInt aStartIndex )
  2206     {
  2306     {
  2207     MPX_FUNC( "CMPXCollectionViewHgContainer::ProvideDataWithoutThumbnailsL" );
  2307     MPX_FUNC( "CMPXCollectionViewHgContainer::ProvideDataWithoutThumbnailsL" );
  2208 
  2308 
       
  2309 	if ( ShuffleItemPresent() )
       
  2310 		{
       
  2311 		CHgItem* item = &iListWidget->ItemL(0);
       
  2312 		SetShuffleItemTextL(item, NULL);
       
  2313 		}
       
  2314 
  2209 	TInt mediaCount = aMediaArray.Count();
  2315 	TInt mediaCount = aMediaArray.Count();
  2210 
  2316 
  2211     for ( TInt i = aStartIndex; i < mediaCount ; i++ )
  2317     for ( TInt i = aStartIndex; i < mediaCount ; i++ )
  2212         {
  2318         {
  2213         CMPXMedia* currentMedia( aMediaArray.AtL( i ) );
  2319         CMPXMedia* currentMedia( aMediaArray.AtL( i ) );
  2215 		if ( currentMedia->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) ==
  2321 		if ( currentMedia->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) ==
  2216 			KMPXInvalidItemId )
  2322 			KMPXInvalidItemId )
  2217 			{
  2323 			{
  2218 			break;
  2324 			break;
  2219 			}
  2325 			}
  2220 
       
  2221         // Just get the exiting item and update the fields + icon.
  2326         // Just get the exiting item and update the fields + icon.
  2222         CHgItem* item = &iListWidget->ItemL(i);
  2327         CHgItem* item = &iListWidget->ItemL(i+iShuffleItem);
  2223 
  2328 		SetTitleL( item, currentMedia );
  2224 		TBool shuffleItem(EFalse);
  2329 		AddDetailToDisplayedItemL( item, currentMedia, i );
  2225         if ( i == 0 )
       
  2226         	{
       
  2227             shuffleItem = SetShuffleItemTextL(item, currentMedia);
       
  2228 			}
       
  2229 
       
  2230         if (!shuffleItem)
       
  2231         	{
       
  2232             SetTitleL( item, currentMedia );
       
  2233         	AddDetailToDisplayedItemL( item, currentMedia, i );
       
  2234 			}
       
  2235 		iLastValidMediaItemIndex = i;
  2330 		iLastValidMediaItemIndex = i;
  2236         }
  2331         }
  2237     }
  2332     }
  2238 
  2333 
  2239 // -----------------------------------------------------------------------------
  2334 // -----------------------------------------------------------------------------
  2244 	const CMPXMediaArray& aMediaArray,
  2339 	const CMPXMediaArray& aMediaArray,
  2245 	TInt aStartIndex )
  2340 	TInt aStartIndex )
  2246     {
  2341     {
  2247     MPX_FUNC( "CMPXCollectionViewHgContainer::ProvideDataWithoutThumbnailsMwL" );
  2342     MPX_FUNC( "CMPXCollectionViewHgContainer::ProvideDataWithoutThumbnailsMwL" );
  2248 
  2343 
       
  2344 	if ( ShuffleItemPresent() )
       
  2345 		{
       
  2346 		CHgVgItem* item = &iMediaWall->ItemL(0);
       
  2347 		SetShuffleItemTextL(item, NULL);
       
  2348 		}
       
  2349 
  2249 	TInt mediaCount = aMediaArray.Count();
  2350 	TInt mediaCount = aMediaArray.Count();
  2250 
  2351 
  2251     for ( TInt i = aStartIndex; i < mediaCount ; i++ )
  2352     for ( TInt i = aStartIndex; i < mediaCount ; i++ )
  2252         {
  2353         {
  2253         // Just get the exiting item and update the fields + icon.
       
  2254         CMPXMedia* currentMedia( aMediaArray.AtL( i ) );
  2354         CMPXMedia* currentMedia( aMediaArray.AtL( i ) );
  2255 
  2355 
  2256 		if ( currentMedia->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) ==
  2356 		if ( currentMedia->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) ==
  2257 			KMPXInvalidItemId )
  2357 			KMPXInvalidItemId )
  2258 			{
  2358 			{
  2259 			break;
  2359 			break;
  2260 			}
  2360 			}
  2261 
       
  2262         // Just get the exiting item and update the fields + icon.
  2361         // Just get the exiting item and update the fields + icon.
  2263 
  2362         CHgVgItem* item = &iMediaWall->ItemL(i+iShuffleItem);
  2264         CHgVgItem* item = &iMediaWall->ItemL(i);
  2363 
  2265 		TBool shuffleItem(EFalse);
  2364 		SetTitleL( item, currentMedia );
  2266         if ( i == 0 )
  2365 		AddDetailToDisplayedItemL( item, currentMedia, i );
  2267         	{
       
  2268             shuffleItem = SetShuffleItemTextL(item, currentMedia);
       
  2269 			}
       
  2270 
       
  2271         if (!shuffleItem)
       
  2272         	{
       
  2273             SetTitleL( item, currentMedia );
       
  2274         	AddDetailToDisplayedItemL( item, currentMedia, i );
       
  2275 			}
       
  2276 		iLastValidMediaItemIndex = i;
  2366 		iLastValidMediaItemIndex = i;
  2277         }
  2367         }
  2278     }
  2368     }
  2279 // -----------------------------------------------------------------------------
  2369 // -----------------------------------------------------------------------------
  2280 // CMPXCollectionViewHgContainer::ProvideDataL
  2370 // CMPXCollectionViewHgContainer::ProvideDataL
  2286    	MPX_DEBUG3( "CMPXCollectionViewHgContainer::ProvideDataL aStart = %d, aEnd = %d",
  2376    	MPX_DEBUG3( "CMPXCollectionViewHgContainer::ProvideDataL aStart = %d, aEnd = %d",
  2287             aStart, aEnd );
  2377             aStart, aEnd );
  2288    	if ( aStart < 0 ) aStart = 0;
  2378    	if ( aStart < 0 ) aStart = 0;
  2289    	if ( aEnd < 0 ) aEnd = 0;
  2379    	if ( aEnd < 0 ) aEnd = 0;
  2290 
  2380 
       
  2381 	TInt index(0);
  2291 	const CMPXMediaArray& mediaArray = iListBoxArray->MediaArray();
  2382 	const CMPXMediaArray& mediaArray = iListBoxArray->MediaArray();
  2292     for ( TInt i = aStart; i <= aEnd ; i++ )
  2383     for ( TInt i = aStart; i <= aEnd ; i++ )
  2293         {
  2384         {
  2294         // Just get the exiting item and update the fields + icon.
  2385         // Just get the exiting item and update the fields + icon.
  2295         CHgItem* item = NULL;
  2386         CHgItem* item = NULL;
  2296         if( iCurrentViewType == EMPXViewCoverFlow || iCurrentViewType == EMPXViewTBone )
  2387         if( iCurrentViewType == EMPXViewMediawall || iCurrentViewType == EMPXViewTBone )
  2297             item = &iMediaWall->ItemL(i);
  2388             item = &iMediaWall->ItemL(i);
  2298         else
  2389         else
  2299             item = &iListWidget->ItemL(i);
  2390             item = &iListWidget->ItemL(i);
  2300 
  2391 
  2301         CMPXMedia* currentMedia( mediaArray.AtL( i ) );
  2392         index = MediaIndex(i);
  2302 
  2393         if ( index >= 0 )
  2303         AddThumbnailToDisplayedItemL( item, currentMedia, i );
  2394             {
  2304         }
  2395             CMPXMedia* currentMedia( mediaArray.AtL( index ) );
  2305     }
  2396             AddThumbnailToDisplayedItemL( item, currentMedia, index );
       
  2397             }
       
  2398         }
       
  2399     }
       
  2400 
  2306 
  2401 
  2307 // -----------------------------------------------------------------------------
  2402 // -----------------------------------------------------------------------------
  2308 // CMPXCollectionViewHgContainer::Release
  2403 // CMPXCollectionViewHgContainer::Release
  2309 // -----------------------------------------------------------------------------
  2404 // -----------------------------------------------------------------------------
  2310 //
  2405 //
  2311 void CMPXCollectionViewHgContainer::Release(TInt aReleaseStart, TInt aReleaseEnd)
  2406 void CMPXCollectionViewHgContainer::Release(TInt aReleaseStart, TInt aReleaseEnd)
  2312     {
  2407     {
  2313     MPX_FUNC( "CMPXCollectionViewHgContainer::Release" );
  2408     MPX_FUNC( "CMPXCollectionViewHgContainer::Release" );
  2314 
  2409 
  2315     for(; aReleaseStart <= aReleaseEnd; ++aReleaseStart)
  2410 	TInt temp = aReleaseStart - iShuffleItem;
  2316         {
  2411 	TInt start =  temp >=0 ? temp : 0 ;
  2317         MPX_DEBUG2( "-->CMPXCollectionViewHgContainer::Release aReleaseStart = %d", aReleaseStart );
  2412 	TInt end = aReleaseEnd - iShuffleItem;
  2318         iThumbnailManager->CancelThumb( aReleaseStart );
  2413 
  2319         }
  2414     for(; start <= end; ++start)
  2320 
  2415         {
       
  2416         MPX_DEBUG2( "-->CMPXCollectionViewHgContainer::Release aReleaseStart = %d", start );
       
  2417         iThumbnailManager->CancelThumb( start );
       
  2418         }
  2321     }
  2419     }
  2322 
  2420 
  2323 // ---------------------------------------------------------------------------
  2421 // ---------------------------------------------------------------------------
  2324 // Refresh for item without thumbnail
  2422 // Refresh for item without thumbnail
  2325 // ---------------------------------------------------------------------------
  2423 // ---------------------------------------------------------------------------
  2326 //
  2424 //
  2327 void CMPXCollectionViewHgContainer::RefreshNoThumbnailL(TInt aIndex)
  2425 void CMPXCollectionViewHgContainer::RefreshNoThumbnailL(TInt aDisplayIndex)
  2328     {
  2426     {
  2329     MPX_FUNC( "CMPXCollectionViewHgContainer::RefreshNoThumbnail" );
  2427     MPX_FUNC( "CMPXCollectionViewHgContainer::RefreshNoThumbnail" );
  2330 
  2428 
  2331     RefreshL(aIndex);
  2429     RefreshL(aDisplayIndex);
  2332     }
  2430     }
  2333 // ---------------------------------------------------------------------------
  2431 // ---------------------------------------------------------------------------
  2334 // Refresh list as needed.
  2432 // Refresh list as needed.
  2335 // This function tries to determine the best time to refresh the screen as to
  2433 // This function tries to determine the best time to refresh the screen as to
  2336 // avoid too many redraws. In some cases, multiple refresh is unavoidable.
  2434 // avoid too many redraws. In some cases, multiple refresh is unavoidable.
  2337 // ---------------------------------------------------------------------------
  2435 // ---------------------------------------------------------------------------
  2338 //
  2436 //
  2339 void CMPXCollectionViewHgContainer::RefreshL(TInt aIndex)
  2437 void CMPXCollectionViewHgContainer::RefreshL(TInt aDisplayIndex)
  2340     {
  2438     {
  2341     if( !iIsForeground )
  2439     if( !iIsForeground )
  2342         {
  2440         {
  2343         return;
  2441         return;
  2344         }
  2442         }
  2345 
  2443 
  2346     MPX_FUNC( "CMPXCollectionViewHgContainer::Refresh" );
  2444     MPX_FUNC( "CMPXCollectionViewHgContainer::Refresh" );
  2347 
  2445 
  2348 	TInt mediaCount = iListBoxArray->MediaArray().Count();
  2446 	TInt mediaCount = iListBoxArray->MediaArray().Count();
       
  2447 	TInt displayCount = mediaCount + iShuffleItem;
  2349 
  2448 
  2350 	TInt firstOnScreen = 0;
  2449 	TInt firstOnScreen = 0;
  2351 	TInt lastOnScreen =  0;
  2450 	TInt lastOnScreen =  0;
  2352 
  2451 
  2353     TBool landscapeOrientation = Layout_Meta_Data::IsLandscapeOrientation();
  2452     TBool landscapeOrientation = Layout_Meta_Data::IsLandscapeOrientation();
  2354     CHgScroller* listWidget = CurrentListWidget();
  2453     CHgScroller* listWidget = CurrentListWidget();
  2355 
  2454 
  2356     if( iCurrentViewType == EMPXViewTBone || iCurrentViewType == EMPXViewCoverFlow )
  2455     if( iCurrentViewType == EMPXViewTBone || iCurrentViewType == EMPXViewMediawall )
  2357         {
  2456         {
  2358         firstOnScreen = iMediaWall->FirstIndexOnScreen();
  2457         firstOnScreen = iMediaWall->FirstIndexOnScreen();
  2359         lastOnScreen = firstOnScreen + iMediaWall->ItemsOnScreen();
  2458         lastOnScreen = firstOnScreen + iMediaWall->ItemsOnScreen();
  2360         }
  2459         }
  2361     else
  2460     else
  2362         {
  2461         {
  2363         firstOnScreen = listWidget->FirstIndexOnScreen();
  2462         firstOnScreen = listWidget->FirstIndexOnScreen();
  2364         lastOnScreen = firstOnScreen + listWidget->ItemsOnScreen();
  2463         lastOnScreen = firstOnScreen + listWidget->ItemsOnScreen();
  2365         }
  2464         }
  2366 
  2465 
  2367 	// Added by Harri
       
  2368 	if( firstOnScreen < 0 )
  2466 	if( firstOnScreen < 0 )
  2369 	    firstOnScreen = 0;
  2467 	    firstOnScreen = 0;
  2370 	if (lastOnScreen > (mediaCount - 1))
  2468 	if (lastOnScreen > (displayCount - 1))
  2371 		lastOnScreen = mediaCount - 1;
  2469 		lastOnScreen = displayCount - 1;
  2372 
  2470 
  2373 	// Refresh screen if the item is within view and no more thumbnails expected.
  2471 	// Refresh screen if the item is within view and no more thumbnails expected.
  2374 	if ( aIndex >= firstOnScreen && aIndex <= lastOnScreen )
  2472 	if ( aDisplayIndex >= firstOnScreen && aDisplayIndex <= lastOnScreen )
  2375 		{
  2473 		{
  2376 		TBool canRefresh(ETrue);
  2474 		TBool canRefresh(ETrue);
  2377 		for (TInt i= firstOnScreen; i <= lastOnScreen; i++)
  2475 		for (TInt i= firstOnScreen; i <= lastOnScreen; i++)
  2378 			{
  2476 			{
  2379 			if ( !iThumbnailReqMap[i] )
  2477 			if ( !iThumbnailReqMap[i] )
  2382 				break;
  2480 				break;
  2383 				}
  2481 				}
  2384 			}
  2482 			}
  2385         if ( canRefresh )
  2483         if ( canRefresh )
  2386             {
  2484             {
  2387             if( iCurrentViewType == EMPXViewTBone || iCurrentViewType == EMPXViewCoverFlow )
  2485             if( iCurrentViewType == EMPXViewTBone || iCurrentViewType == EMPXViewMediawall )
  2388                 iMediaWall->RefreshScreen( firstOnScreen );
  2486                 {
       
  2487                 if( iTranstionType != EMPXTranstionNotDefined )
       
  2488                     {
       
  2489                     // This will tricker the transtition animation
       
  2490                     EndFullScreenAnimation();
       
  2491                     iMediaWall->DrawNow();
       
  2492                     }
       
  2493                 else
       
  2494                     {
       
  2495                     iMediaWall->RefreshScreen( firstOnScreen );
       
  2496                     }
       
  2497                 }
  2389             else
  2498             else
  2390                 listWidget->RefreshScreen( firstOnScreen );
  2499                 {
       
  2500                 if( iTranstionType != EMPXTranstionNotDefined )
       
  2501                     {
       
  2502                     // This will tricker the transtition animation
       
  2503                     // Use DrawNow since RefreshScreen uses DrawDeferred and we want to start
       
  2504                     // the animation immediately.
       
  2505                     EndFullScreenAnimation();
       
  2506                     listWidget->DrawNow();
       
  2507                     }
       
  2508                 else
       
  2509                     {
       
  2510                     listWidget->RefreshScreen( firstOnScreen );
       
  2511                     }
       
  2512                 }
  2391             }
  2513             }
  2392 		}
  2514 		}
  2393     }
  2515     }
  2394 
  2516 
  2395 // ----------------------------------------------------------------------------
  2517 // ----------------------------------------------------------------------------
  2409             break;
  2531             break;
  2410             }
  2532             }
  2411         case EContextGroupAlbum:
  2533         case EContextGroupAlbum:
  2412         case EContextItemAlbum:
  2534         case EContextItemAlbum:
  2413             {
  2535             {
  2414             // Mod by Harri. Lampainen wanted to try default icon in album view.
       
  2415             iconIndex = EMPXClvIconAlbum;
  2536             iconIndex = EMPXClvIconAlbum;
  2416             break;
  2537             break;
  2417             }
  2538             }
  2418         case EContextGroupPodcast:
  2539         case EContextGroupPodcast:
  2419         case EContextItemPodcast:
  2540         case EContextItemPodcast:
  2483 			break;
  2604 			break;
  2484 			}
  2605 			}
  2485 		case EContextGroupAlbum:
  2606 		case EContextGroupAlbum:
  2486 		case EContextItemAlbum:
  2607 		case EContextItemAlbum:
  2487             {
  2608             {
  2488 			// Mod by Harri. Lampainen wanted to try default icon in album view.
       
  2489             defaultIcon = EMPXDefaultIconAlbum;
  2609             defaultIcon = EMPXDefaultIconAlbum;
  2490             iconIndex = EMPXClvIconAlbum;
  2610             iconIndex = EMPXClvIconAlbum;
  2491 			break;
  2611 			break;
  2492 			}
  2612 			}
  2493 		case EContextGroupPodcast:
  2613 		case EContextGroupPodcast:
  3285 			}
  3405 			}
  3286 		else
  3406 		else
  3287 			{
  3407 			{
  3288 			//no albumart
  3408 			//no albumart
  3289 			// Default album art has already been set earlier.
  3409 			// Default album art has already been set earlier.
  3290     		iThumbnailReqMap[aIndex] = ETrue;
  3410     		iThumbnailReqMap[aIndex+iShuffleItem] = ETrue;
  3291     		RefreshNoThumbnailL(aIndex);
  3411     		RefreshNoThumbnailL(aIndex);
  3292 			}
  3412 			}
  3293 		}
  3413 		}
  3294 	else
  3414 	else
  3295 	    {
  3415 	    {
  3296 		// no album art supported
  3416 		// no album art supported
  3297 		// Default album art has already been set earlier.
  3417 		// Default album art has already been set earlier.
  3298 	    if ( iCurrentViewType == EMPXViewCoverFlow ||
  3418 	    if ( iCurrentViewType == EMPXViewMediawall ||
  3299 	         iCurrentViewType == EMPXViewList && aIndex == 0 )
  3419 	         iCurrentViewType == EMPXViewList && (aIndex-iShuffleItem) == -1 )
  3300 	        SetDetailIconShuffleL(); // BUG: temporarily called here because default icon is shown if SetDefaultIconL is called after.
  3420 	        SetDetailIconShuffleL(); // BUG: temporarily called here because default icon is shown if SetDefaultIconL is called after.
  3301     	iThumbnailReqMap[aIndex] = ETrue;
  3421     	iThumbnailReqMap[aIndex+iShuffleItem] = ETrue;
  3302         RefreshNoThumbnailL(aIndex);
  3422         RefreshNoThumbnailL(aIndex);
  3303 	    }
  3423 	    }
  3304     }
  3424     }
  3305 
  3425 
  3306 // ----------------------------------------------------------------------------
  3426 // ----------------------------------------------------------------------------
  3308 // ----------------------------------------------------------------------------
  3428 // ----------------------------------------------------------------------------
  3309 
  3429 
  3310 void CMPXCollectionViewHgContainer::SetDetailIconShuffleL()
  3430 void CMPXCollectionViewHgContainer::SetDetailIconShuffleL()
  3311     {
  3431     {
  3312 
  3432 
  3313 	const CMPXMediaArray& mediaArray = iListBoxArray->MediaArray();
  3433 	if (iShuffleItem)
  3314 	if (mediaArray.Count())
       
  3315 		{
  3434 		{
  3316 		CMPXMedia* currentMedia( mediaArray.AtL( 0 ) );
  3435 		CGulIcon* icon = (*iIconArray)[EMPXClvIconShuffle];
  3317 
  3436 		CFbsBitmap* bitmap = icon->Bitmap();
  3318 		TMPXGeneralType type( EMPXNoType );
  3437 		CFbsBitmap* mask = icon->Mask();
  3319 		if ( currentMedia->IsSupported( KMPXMediaGeneralType ) )
  3438 
  3320 			{
  3439 		TSize size(240,240);
  3321 			type = currentMedia->ValueTObjectL<TMPXGeneralType>( KMPXMediaGeneralType );
  3440 		CHgItem* item = NULL;
  3322 			}
  3441 		if( iCurrentViewType == EMPXViewMediawall || iCurrentViewType == EMPXViewTBone )
  3323 
  3442 			{
  3324 		TMPXGeneralCategory category( EMPXNoCategory );
  3443 			item = &iMediaWall->ItemL(0);
  3325 		if ( currentMedia->IsSupported( KMPXMediaGeneralCategory ) )
  3444 			}
  3326 			{
  3445 		else if( iCurrentViewType == EMPXViewList )
  3327 			category = currentMedia->ValueTObjectL<TMPXGeneralCategory>( KMPXMediaGeneralCategory );
  3446 			{
  3328 			}
  3447 			item = &iListWidget->ItemL(0);
  3329 
  3448 			size = CHgDoubleGraphicListFlat::PreferredImageSize();
  3330 		if ( type == EMPXItem && category == EMPXCommand )
  3449 			}
  3331 			{
  3450 		else
  3332 
  3451 			{
  3333 			CGulIcon* icon = (*iIconArray)[EMPXClvIconShuffle];
  3452 			User::Leave( KErrNotSupported );
  3334 			CFbsBitmap* bitmap = icon->Bitmap();
  3453 			}
  3335 			CFbsBitmap* mask = icon->Mask();
  3454 
  3336 
  3455 		if ( item )
  3337 			TSize size(240,240);
  3456 			{
  3338 			CHgItem* item = NULL;
  3457 			AknIconUtils::SetSize( bitmap, size );
  3339 			if( iCurrentViewType == EMPXViewCoverFlow || iCurrentViewType == EMPXViewTBone )
  3458 			AknIconUtils::SetSize( mask, size );
  3340 				{
  3459 
  3341 				item = &iMediaWall->ItemL(0);
  3460 			CGulIcon* iconCopy = CGulIcon::NewL(bitmap, mask);
  3342 				}
  3461 			iconCopy->SetBitmapsOwnedExternally(ETrue);
  3343 			else if( iCurrentViewType == EMPXViewList )
  3462 			item->SetIcon( iconCopy );
  3344 				{
       
  3345 				item = &iListWidget->ItemL(0);
       
  3346 				size = CHgDoubleGraphicListFlat::PreferredImageSize();
       
  3347 				}
       
  3348 			else
       
  3349 				{
       
  3350 				User::Leave( KErrNotSupported );
       
  3351 				}
       
  3352 
       
  3353 			if ( item )
       
  3354 				{
       
  3355 				AknIconUtils::SetSize( bitmap, size );
       
  3356 				AknIconUtils::SetSize( mask, size );
       
  3357 
       
  3358 				CGulIcon* iconCopy = CGulIcon::NewL(bitmap, mask);
       
  3359 				iconCopy->SetBitmapsOwnedExternally(ETrue);
       
  3360 				item->SetIcon( iconCopy );
       
  3361 				}
       
  3362 			}
  3463 			}
  3363 		}
  3464 		}
       
  3465 
       
  3466 
       
  3467 
  3364     }
  3468     }
  3365 
  3469 
  3366 // ----------------------------------------------------------------------------
  3470 // ----------------------------------------------------------------------------
  3367 // Set the shuffle item text
  3471 // Set the shuffle item text
  3368 // ----------------------------------------------------------------------------
  3472 // ----------------------------------------------------------------------------
  3369 
  3473 
  3370 TBool CMPXCollectionViewHgContainer::SetShuffleItemTextL(CHgItem* aItem, CMPXMedia* aMedia)
  3474 TBool CMPXCollectionViewHgContainer::SetShuffleItemTextL(CHgItem* aItem, CMPXMedia* aMedia)
  3371     {
  3475     {
  3372 
  3476 
  3373 	TBool res(EFalse);
  3477 	TBool res(EFalse);
  3374     TMPXGeneralType type( EMPXNoType );
  3478 
  3375     if ( aMedia->IsSupported( KMPXMediaGeneralType ) )
  3479     const CMPXMediaArray& mediaArray = iListBoxArray->MediaArray();
  3376         {
  3480     const TInt count( mediaArray.Count() );
  3377         type = aMedia->ValueTObjectL<TMPXGeneralType>( KMPXMediaGeneralType );
  3481 
  3378         }
  3482 	if ( count > 1 && iContext == EContextGroupAlbum ||
  3379 
  3483 		 iContext == EContextGroupSong ||
  3380     TMPXGeneralCategory category( EMPXNoCategory );
  3484 		 iContext == EContextGroupGenre ||
  3381     if ( aMedia->IsSupported( KMPXMediaGeneralCategory ) )
  3485 		 iContext == EContextItemPlaylist ||
  3382         {
  3486 		 iContext == EContextItemGenre ||
  3383         category = aMedia->ValueTObjectL<TMPXGeneralCategory>( KMPXMediaGeneralCategory );
  3487 		 iContext == EContextItemSong )
  3384         }
  3488 		{
  3385 
  3489 		aItem->SetTitleL( _L("Shuffle All") );
  3386     if ( type == EMPXItem && category == EMPXCommand )
       
  3387         {
       
  3388 
       
  3389         if ( aMedia->IsSupported( KMPXMediaGeneralTitle ) )
       
  3390             {
       
  3391 
       
  3392             const TDesC& title = aMedia->ValueText( KMPXMediaGeneralTitle );
       
  3393             if ( title.Compare( KNullDesC ) != 0 )
       
  3394                 {
       
  3395                 aItem->SetTitleL( title );
       
  3396                 }
       
  3397             else
       
  3398                 {
       
  3399                 HBufC* unknownText =
       
  3400                         StringLoader::LoadLC( R_MPX_COLLECTION_UNKNOWN );
       
  3401                 aItem->SetTitleL( *unknownText );
       
  3402                 CleanupStack::PopAndDestroy( unknownText );
       
  3403                 }
       
  3404             }
       
  3405 
       
  3406         if ( aMedia->IsSupported( KMPXMediaColDetailNumberOfItems ) )
       
  3407             {
       
  3408             TInt songsCount = aMedia->ValueTObjectL<TInt>( KMPXMediaColDetailNumberOfItems );
       
  3409 
       
  3410 			HBufC* songsTitle = StringLoader::LoadLC( R_MPX_COLLECTION_DETAILS_NUMBER_OF_SONGS, songsCount );
       
  3411 			TPtr ptr = songsTitle->Des();
       
  3412 			AknTextUtils::LanguageSpecificNumberConversion( ptr );
       
  3413 			aItem->SetTextL( ptr );
       
  3414 			CleanupStack::PopAndDestroy( songsTitle );
       
  3415             }
       
  3416 
  3490 
  3417 		// We can try to set icon too.
  3491 		// We can try to set icon too.
  3418 		SetDetailIconShuffleL();
  3492 		SetDetailIconShuffleL();
  3419 		res = ETrue;
  3493 		res = ETrue;
  3420 		}
  3494 		}
  3561 
  3635 
  3562 
  3636 
  3563 
  3637 
  3564 void CMPXCollectionViewHgContainer::TNReadyL(TInt aError, CFbsBitmap* aBitmap, CFbsBitmap* /*aMask*/, TInt aIndex)
  3638 void CMPXCollectionViewHgContainer::TNReadyL(TInt aError, CFbsBitmap* aBitmap, CFbsBitmap* /*aMask*/, TInt aIndex)
  3565     {
  3639     {
  3566     if ( aError == KErrNone )
  3640    TInt displayIndex = aIndex+iShuffleItem;
       
  3641    if ( aError == KErrNone )
  3567         {
  3642         {
  3568         const CMPXMediaArray& mediaArray = iListBoxArray->MediaArray();
  3643         const CMPXMediaArray& mediaArray = iListBoxArray->MediaArray();
  3569         CMPXMedia* currentMedia( mediaArray.AtL( aIndex ) );
  3644         CMPXMedia* currentMedia( mediaArray.AtL( aIndex ) );
  3570         if ( currentMedia->IsSupported( KMPXMediaGeneralId ) )
  3645         if ( currentMedia->IsSupported( KMPXMediaGeneralId ) )
  3571             {
  3646             {
  3573                 {
  3648                 {
  3574                 CGulIcon* icon = CGulIcon::NewL(aBitmap, NULL);
  3649                 CGulIcon* icon = CGulIcon::NewL(aBitmap, NULL);
  3575 
  3650 
  3576                 switch (iCurrentViewType)
  3651                 switch (iCurrentViewType)
  3577                     {
  3652                     {
  3578                     case EMPXViewCoverFlow:
  3653                     case EMPXViewMediawall:
  3579                     case EMPXViewTBone:
  3654                     case EMPXViewTBone:
  3580                         {
  3655                         {
  3581                         iMediaWall->ItemL(aIndex).SetIcon(icon);
  3656                         iMediaWall->ItemL(displayIndex).SetIcon(icon);
  3582     					iThumbnailReqMap[aIndex] = ETrue;
       
  3583                         break;
  3657                         break;
  3584                         }
  3658                         }
  3585                     case EMPXViewList:
  3659                     case EMPXViewList:
  3586                         {
  3660                         {
  3587                         iListWidget->ItemL(aIndex).SetIcon(icon);
  3661                         iListWidget->ItemL(displayIndex).SetIcon(icon);
  3588     					iThumbnailReqMap[aIndex] = ETrue;
       
  3589                         break;
  3662                         break;
  3590                         }
  3663                         }
  3591                     default:
  3664                     default:
  3592                         break;
  3665                         break;
  3593                     }
  3666                     }
  3594 
  3667 
  3595                 RefreshL(aIndex);
  3668 
  3596                 }
  3669                 }
  3597             }
  3670             }
  3598         }
  3671         }
  3599     else
  3672     else
  3600         {
  3673         {
  3601         //no albumart supported
  3674         //no albumart supported
  3602         iThumbnailReqMap[aIndex] = ETrue;
  3675         //iThumbnailReqMap[displayIndex] = ETrue;
  3603         RefreshL(aIndex);
  3676         //RefreshL(displayIndex);
  3604         }
  3677         }
       
  3678 
       
  3679 	iThumbnailReqMap[displayIndex] = ETrue;
       
  3680 	RefreshL(displayIndex);
       
  3681 
       
  3682 
  3605     }
  3683     }
  3606 
  3684 
  3607 // ----------------------------------------------------------------------------
  3685 // ----------------------------------------------------------------------------
  3608 // Clears the TN request if any
  3686 // Clears the TN request if any
  3609 // ----------------------------------------------------------------------------
  3687 // ----------------------------------------------------------------------------
  3712 				{
  3790 				{
  3713 				if ( pbState == EPbStatePaused )
  3791 				if ( pbState == EPbStatePaused )
  3714 					{
  3792 					{
  3715 					iPlaybackUtility->CommandL( EPbCmdPlay );
  3793 					iPlaybackUtility->CommandL( EPbCmdPlay );
  3716 					}
  3794 					}
  3717                 iPlaybackUtility->SetL( EPbPropertyRandomMode, shuffle );
  3795                 iPlaybackUtility->SetL( EPbPropertyRandomMode, EFalse );
  3718 				iView->ProcessCommandL( EMPXCmdGoToNowPlaying );
  3796 				iView->ProcessCommandL( EMPXCmdGoToNowPlaying );
  3719 				}
  3797 				}
  3720 			else
  3798 			else
  3721 			    {
  3799 			    {
  3722                 iPlaylistHelper->InitPlaylistL(*cpath, shuffle);
  3800             	iPlaybackUtility->SetL( EPbPropertyRandomMode, shuffle );
       
  3801                 iCollectionUtility->Collection().OpenL(*cpath);
  3723 			    }
  3802 			    }
  3724 			}
  3803 			}
  3725 		else
  3804 		else
  3726 		    {
  3805 		    {
  3727             iPlaylistHelper->InitPlaylistL(*cpath, shuffle);
  3806             iPlaybackUtility->SetL( EPbPropertyRandomMode, shuffle );
       
  3807             iCollectionUtility->Collection().OpenL(*cpath);
  3728 		    }
  3808 		    }
  3729 
  3809 
  3730 		CleanupStack::PopAndDestroy( cpath );
  3810 		CleanupStack::PopAndDestroy( cpath );
  3731 
  3811 
  3732 		// We need to restore the status pane before switching to playback view.
       
  3733 		if (!((CAknAppUi*)iCoeEnv->AppUi())->StatusPane()->IsVisible())
       
  3734 			((CAknAppUi*)iCoeEnv->AppUi())->StatusPane()->MakeVisible(ETrue);
       
  3735 
  3812 
  3736 		}
  3813 		}
  3737 	CleanupStack::PopAndDestroy(&ids);
  3814 	CleanupStack::PopAndDestroy(&ids);
  3738 	}
  3815 	}
  3739 
  3816 
  3750 	TInt selectedIndex(0);
  3827 	TInt selectedIndex(0);
  3751     CHgScroller* listWidget = CurrentListWidget();
  3828     CHgScroller* listWidget = CurrentListWidget();
  3752 	if ( iContext == EContextGroupPlaylist ||
  3829 	if ( iContext == EContextGroupPlaylist ||
  3753 	     iContext == EContextGroupGenre && listWidget )
  3830 	     iContext == EContextGroupGenre && listWidget )
  3754 		{
  3831 		{
  3755 		selectedIndex = listWidget->SelectedIndex();
  3832 		selectedIndex = MediaIndex(listWidget->SelectedIndex());
  3756 		}
  3833 		}
  3757 	else
  3834 	else
  3758 		{
  3835 		{
  3759 		return;
  3836 		return;
  3760 		}
  3837 		}
  3846     CMPXMedia* album( mediaArray.AtL( aIndex ) );
  3923     CMPXMedia* album( mediaArray.AtL( aIndex ) );
  3847     if( album->IsSupported(KMPXMediaArrayContents) )
  3924     if( album->IsSupported(KMPXMediaArrayContents) )
  3848         {
  3925         {
  3849         // We've previously fetched the songs for this album so
  3926         // We've previously fetched the songs for this album so
  3850         // all we do now is populate the list with the song titles.
  3927         // all we do now is populate the list with the song titles.
  3851         if( iCurrentViewType == EMPXViewCoverFlow )
  3928         if( iCurrentViewType == EMPXViewMediawall )
  3852             {
  3929             {
  3853             ShowAlbumSongsDialogL(*album);
  3930             ShowAlbumSongsDialogL(*album);
  3854             }
  3931             }
  3855         else
  3932         else
  3856             {
  3933             {
  3919 TBool CMPXCollectionViewHgContainer::ShufflePlayAllL(TInt aIndex)
  3996 TBool CMPXCollectionViewHgContainer::ShufflePlayAllL(TInt aIndex)
  3920     {
  3997     {
  3921     MPX_FUNC("CMPXCollectionViewHgContainer::ShufflePlayAllL");
  3998     MPX_FUNC("CMPXCollectionViewHgContainer::ShufflePlayAllL");
  3922 
  3999 
  3923     TBool shuffle(EFalse);
  4000     TBool shuffle(EFalse);
  3924     const CMPXMediaArray& mediaArray = iListBoxArray->MediaArray();
  4001 
  3925 
  4002     if ( aIndex == -1 )
  3926 	CMPXMedia* currentMedia( mediaArray.AtL( aIndex ) );
  4003         {
  3927 
  4004         shuffle = ETrue;
  3928     TMPXGeneralType type( EMPXNoType );
  4005         if ( iContext == EContextItemPlaylist || iContext == EContextItemGenre )
  3929     if ( currentMedia->IsSupported( KMPXMediaGeneralType ) )
  4006             {
  3930         {
  4007             CMPXCollectionPath* cpath = iCollectionUtility->Collection().PathL();
  3931         type = currentMedia->ValueTObjectL<TMPXGeneralType>( KMPXMediaGeneralType );
  4008             CleanupStack::PushL( cpath );
  3932         }
  4009             iPlaylistHelper->InitPlaylistL(*cpath, shuffle);
  3933 
  4010             CleanupStack::PopAndDestroy( cpath );
  3934     TMPXGeneralCategory category( EMPXNoCategory );
  4011             }
  3935     if ( currentMedia->IsSupported( KMPXMediaGeneralCategory ) )
  4012         else
  3936         {
  4013             {
  3937         category = currentMedia->ValueTObjectL<TMPXGeneralCategory>( KMPXMediaGeneralCategory );
  4014             iPlaylistHelper->InitPlaylistL(shuffle);
  3938         }
  4015             }
  3939 
       
  3940     if ( type == EMPXItem && category == EMPXCommand )
       
  3941         {
       
  3942 		shuffle = ETrue;
       
  3943 		if ( iContext == EContextItemPlaylist )
       
  3944 			{
       
  3945 			CMPXCollectionPath* cpath = iCollectionUtility->Collection().PathL();
       
  3946 			CleanupStack::PushL( cpath );
       
  3947 			cpath->Remove(0); // we want to remove index 0 which is shuffle item
       
  3948 			iPlaylistHelper->InitPlaylistL(*cpath, shuffle);
       
  3949 			CleanupStack::PopAndDestroy( cpath );
       
  3950 			}
       
  3951 		else
       
  3952 			{
       
  3953 			iPlaylistHelper->InitPlaylistL(shuffle);
       
  3954 			}
       
  3955         }
  4016         }
  3956 
  4017 
  3957     return shuffle;
  4018     return shuffle;
  3958     }
  4019     }
  3959 
  4020 
  4094 				albumMedia->SetTObjectValueL<TInt>(KMPXMediaArrayCount, songArray->Count());
  4155 				albumMedia->SetTObjectValueL<TInt>(KMPXMediaArrayCount, songArray->Count());
  4095 				}
  4156 				}
  4096 
  4157 
  4097 			if ( iFindOp == EMPXOpenAlbum )
  4158 			if ( iFindOp == EMPXOpenAlbum )
  4098 			    {
  4159 			    {
  4099                 if( iCurrentViewType == EMPXViewCoverFlow )
  4160                 if( iCurrentViewType == EMPXViewMediawall )
  4100                     {
  4161                     {
  4101                     ShowAlbumSongsDialogL( aResults );
  4162                     ShowAlbumSongsDialogL( aResults );
  4102                     }
  4163                     }
  4103                 else
  4164                 else
  4104                     {
  4165                     {
  4179 void CMPXCollectionViewHgContainer::ShowAlbumSongsDialogL( const CMPXMedia& aResults )
  4240 void CMPXCollectionViewHgContainer::ShowAlbumSongsDialogL( const CMPXMedia& aResults )
  4180     {
  4241     {
  4181     CAknSinglePopupMenuStyleListBox* listBox = new ( ELeave ) CAknSinglePopupMenuStyleListBox;
  4242     CAknSinglePopupMenuStyleListBox* listBox = new ( ELeave ) CAknSinglePopupMenuStyleListBox;
  4182     CleanupStack::PushL( listBox );
  4243     CleanupStack::PushL( listBox );
  4183 
  4244 
  4184     iDialog = CAknPopupList::NewL(listBox, R_MPX_COLLECTION_ALBUMSONGS_LIST_CBA,
  4245     CAknPopupList* dialog = CAknPopupList::NewL(listBox, R_MPX_COLLECTION_ALBUMSONGS_LIST_CBA,
  4185             AknPopupLayouts::EDynMenuWindow );
  4246             AknPopupLayouts::EDynMenuWindow );
  4186 
  4247 
  4187 	CleanupStack::PushL( iDialog );
  4248 	CleanupStack::PushL( dialog );
  4188 
  4249 
  4189     listBox->ConstructL( iDialog,
  4250     listBox->ConstructL( dialog,
  4190             EAknListBoxSelectionList | EAknListBoxScrollBarSizeExcluded  );
  4251             EAknListBoxSelectionList | EAknListBoxScrollBarSizeExcluded  );
  4191 	
  4252 	
  4192 
  4253 
  4193     listBox->CreateScrollBarFrameL( ETrue );
  4254     listBox->CreateScrollBarFrameL( ETrue );
  4194     listBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff,
  4255     listBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff,
  4198     if ( iSelectedMediaInAlbumView && iSelectedMediaInAlbumView->IsSupported( KMPXMediaMusicAlbum ) )
  4259     if ( iSelectedMediaInAlbumView && iSelectedMediaInAlbumView->IsSupported( KMPXMediaMusicAlbum ) )
  4199         {
  4260         {
  4200         const TDesC& album = iSelectedMediaInAlbumView->ValueText( KMPXMediaMusicAlbum );
  4261         const TDesC& album = iSelectedMediaInAlbumView->ValueText( KMPXMediaMusicAlbum );
  4201             if ( album.Compare( KNullDesC ) != 0 )
  4262             if ( album.Compare( KNullDesC ) != 0 )
  4202             {
  4263             {
  4203             iDialog->SetTitleL( album );
  4264             dialog->SetTitleL( album );
  4204             }
  4265             }
  4205         }
  4266         }
  4206 
  4267 
  4207     CMPXMediaArray* songArray(const_cast<CMPXMediaArray*>( aResults.Value<CMPXMediaArray>(
  4268     CMPXMediaArray* songArray(const_cast<CMPXMediaArray*>( aResults.Value<CMPXMediaArray>(
  4208             KMPXMediaArrayContents ) ) );
  4269             KMPXMediaArrayContents ) ) );
  4235         }
  4296         }
  4236 
  4297 
  4237     CTextListBoxModel* model = listBox->Model();
  4298     CTextListBoxModel* model = listBox->Model();
  4238     model->SetItemTextArray( songList );
  4299     model->SetItemTextArray( songList );
  4239     model->SetOwnershipType( ELbmOwnsItemArray );
  4300     model->SetOwnershipType( ELbmOwnsItemArray );
  4240     TBool play = iDialog->ExecuteLD();
  4301     CleanupStack::Pop( dialog );
  4241     CleanupStack::Pop( iDialog );
  4302     iDialog = dialog;
       
  4303     TBool play( EFalse );
       
  4304     GfxTransEffect::Deregister( iDialog );
       
  4305     GfxTransEffect::Register( iDialog, KAppUidMusicPlayerX, EFalse );
       
  4306     // Trap ExecuteLD to make sure iDialog always get reset.
       
  4307     TRAP_IGNORE( play = iDialog->ExecuteLD() );
       
  4308     iDialog = NULL;
  4242     if( play )
  4309     if( play )
  4243         {
  4310         {
       
  4311         iMediaWall->SetFlags( CHgVgMediaWall::EHgVgMediaWallDrawToWindowGC );
       
  4312         iMediaWall->DrawNow();
  4244         TInt index = listBox->CurrentItemIndex();
  4313         TInt index = listBox->CurrentItemIndex();
  4245         // If item in list was opened, we only play the selected one.
  4314         // If item in list was opened, we only play the selected one.
  4246         SaveSelectedAlbumItemL(iSelectedAlbumIndex);
  4315         SaveSelectedAlbumItemL(iSelectedAlbumIndex);
  4247         // Open the selected song of album
  4316         // Open the selected song of album
  4248         UpdatePathAndOpenL(index);
  4317         UpdatePathAndOpenL(index);
  4249         }
  4318         }
  4250     else
  4319     else
  4251         {
  4320         {
  4252         // Do nothing if cancel was pressed.
  4321         // Close mediawall "flip animation"
       
  4322         iMediaWall->StartOpeningAnimationL( EFalse );
  4253         }
  4323         }
  4254 
  4324 
  4255     CleanupStack::PopAndDestroy( listBox );
  4325     CleanupStack::PopAndDestroy( listBox );
  4256 
       
  4257     // Close mediawall "flip animation"
       
  4258     iMediaWall->StartOpeningAnimationL( EFalse );
       
  4259     }
  4326     }
  4260 
  4327 
  4261 
  4328 
  4262 // -----------------------------------------------------------------------------
  4329 // -----------------------------------------------------------------------------
  4263 // Shows the album songs in the tbone list.
  4330 // Shows the album songs in the tbone list.
  4333             {
  4400             {
  4334             delete iSelectedMediaInAlbumView;
  4401             delete iSelectedMediaInAlbumView;
  4335             iSelectedMediaInAlbumView = NULL;
  4402             iSelectedMediaInAlbumView = NULL;
  4336             }
  4403             }
  4337 
  4404 
       
  4405 		if ( aIndex < 0 ) // We try to save a valid album otherwise restore will not work.
       
  4406 			{
       
  4407 			aIndex = 0;
       
  4408 			}
       
  4409 
  4338         iSelectedMediaInAlbumView = CMPXMedia::NewL( *mediaArray.AtL( aIndex ) );
  4410         iSelectedMediaInAlbumView = CMPXMedia::NewL( *mediaArray.AtL( aIndex ) );
  4339 
  4411 
  4340         if ( iSelectedMediaInAlbumView->IsSupported( KMPXMediaGeneralTitle ) )
  4412         if ( iSelectedMediaInAlbumView->IsSupported( KMPXMediaGeneralTitle ) )
  4341             {
  4413             {
  4342             const TDesC& title = iSelectedMediaInAlbumView->ValueText( KMPXMediaGeneralTitle );
  4414             const TDesC& title = iSelectedMediaInAlbumView->ValueText( KMPXMediaGeneralTitle );
  4370                 }
  4442                 }
  4371 
  4443 
  4372             CleanupStack::PopAndDestroy( unknownArtistText );
  4444             CleanupStack::PopAndDestroy( unknownArtistText );
  4373             }
  4445             }
  4374 
  4446 
  4375         WriteToStreamFileL( iSelectedMediaInAlbumView );
  4447         iSelectedAlbumHandler->SaveSelectedAlbum(*iSelectedMediaInAlbumView);
  4376         }
  4448         }
  4377     }
  4449     }
  4378 
  4450 
  4379 // -----------------------------------------------------------------------------
  4451 // -----------------------------------------------------------------------------
  4380 // CMPXCollectionViewHgContainer::RestoreSelectedAlbumItemL
  4452 // CMPXCollectionViewHgContainer::RestoreSelectedAlbumItemL
  4385 void CMPXCollectionViewHgContainer::RestoreSelectedAlbumItemL(
  4457 void CMPXCollectionViewHgContainer::RestoreSelectedAlbumItemL(
  4386     const CMPXMediaArray& aMediaArray )
  4458     const CMPXMediaArray& aMediaArray )
  4387     {
  4459     {
  4388     MPX_FUNC( "CMPXCollectionViewHgContainer::RestoreSelectedAlbumItemL" );
  4460     MPX_FUNC( "CMPXCollectionViewHgContainer::RestoreSelectedAlbumItemL" );
  4389 
  4461 
  4390     CMPXMedia* restoredAlbum = CMPXMedia::NewL();
  4462 	const CMPXMedia* restoredAlbum = iSelectedAlbumHandler->RestoreSelectedAlbum();
  4391     CleanupStack::PushL( restoredAlbum );
  4463 	iRestoredAlbumIndex = 0;
  4392     ReadFromStreamFileL(restoredAlbum);
  4464 	iSelectedAlbumIndex = 0;
  4393     TMPXItemId id=restoredAlbum->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId);
  4465 	if ( restoredAlbum )
  4394     iRestoredAlbumIndex = 0; 
  4466 		{
  4395     iSelectedAlbumIndex = 0;
  4467 	    TMPXItemId id=restoredAlbum->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId);
  4396 	
  4468 
  4397     for ( TInt i = 0; i < aMediaArray.Count() ; i++ )
  4469 	    for ( TInt i = 0; i < aMediaArray.Count() ; i++ )
  4398         {
  4470 	        {
  4399         CMPXMedia* currentMedia( aMediaArray.AtL( i ) );
  4471 	        CMPXMedia* currentMedia( aMediaArray.AtL( i ) );
  4400 
  4472 
  4401         if ( (currentMedia->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) == id) || 
  4473 	        if ( (currentMedia->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) == id) ||
  4402              (id.iId1 == 0 && currentMedia->ValueText(KMPXMediaGeneralTitle).Compare( restoredAlbum->ValueText(KMPXMediaGeneralTitle) ) == 0 )  )
  4474 	             (id.iId1 == 0 && currentMedia->ValueText(KMPXMediaGeneralTitle).Compare( restoredAlbum->ValueText(KMPXMediaGeneralTitle) ) == 0 )  )
  4403             {
  4475 	            {
  4404             iRestoredAlbumIndex = i;
  4476 	            iRestoredAlbumIndex = i;
  4405             iSelectedAlbumIndex = i;
  4477 	            iSelectedAlbumIndex = i;
  4406             break;
  4478 	            break;
  4407             }
  4479 	            }
  4408         }
  4480 	        }
  4409 		
  4481 		}
  4410     CleanupStack::PopAndDestroy( restoredAlbum );
       
  4411     }
  4482     }
  4412 
  4483 
  4413 // ----------------------------------------------------------------------------
  4484 // ----------------------------------------------------------------------------
  4414 // Write the album name, artist name and album art in media data to file
  4485 // Write the album name, artist name and album art in media data to file
  4415 // ----------------------------------------------------------------------------
  4486 // ----------------------------------------------------------------------------
  4499         self->HandleLbxItemAdditionL();
  4570         self->HandleLbxItemAdditionL();
  4500         }
  4571         }
  4501     return KErrNone;
  4572     return KErrNone;
  4502     }
  4573     }
  4503 
  4574 
       
  4575 // -----------------------------------------------------------------------------
       
  4576 // Prepare T-bone view
       
  4577 // -----------------------------------------------------------------------------
       
  4578 //
       
  4579 void CMPXCollectionViewHgContainer::PrepareTboneViewL()
       
  4580     {
       
  4581     MPX_FUNC( "CMPXCollectionViewHgContainer::PrepareTboneViewL" );
       
  4582 
       
  4583     const CMPXMediaArray& mediaArray = iListBoxArray->MediaArray();
       
  4584     TInt mediaCount( mediaArray.Count() );
       
  4585     HandleLbxItemRemovalL();
       
  4586 
       
  4587     iPrevContext = EContextGroupAlbum;
       
  4588     iOpenAlbumTracks = ETrue;
       
  4589 	iContext = EContextItemAlbum;
       
  4590 	iCurrentViewType = EMPXViewTBone;
       
  4591 
       
  4592     if (ShuffleItemPresent())
       
  4593         iShuffleItem = 1;
       
  4594     else
       
  4595     	iShuffleItem = 0;
       
  4596 
       
  4597 	TInt listCount = mediaCount + iShuffleItem;
       
  4598     iThumbnailReqMap.Reset();
       
  4599     iThumbnailReqMap.ReserveL(listCount);
       
  4600     for ( TInt i = 0; i < listCount; i++ )
       
  4601         {
       
  4602         iThumbnailReqMap.Append( EFalse );
       
  4603         }
       
  4604 
       
  4605     iThumbnailManager->CancelAll();
       
  4606 
       
  4607 	// MediaWall sets the default icon in the construction phase.
       
  4608 	iDefaultIconSet = EFalse;
       
  4609 
       
  4610     if( !iLayoutSwitch  )
       
  4611         {
       
  4612         BeginFullScreenAnimation();
       
  4613         }
       
  4614 
       
  4615 	RestoreSelectedAlbumItemL(mediaArray);
       
  4616 	PrepareMediaWallWithListL( mediaArray, mediaCount );
       
  4617 
       
  4618     DrawableWindow()->SetOrdinalPosition( -1 );
       
  4619 
       
  4620     CleanPrevView();
       
  4621 
       
  4622     iPrevViewType = iCurrentViewType;
       
  4623 
       
  4624     if( !iDefaultIconSet )
       
  4625         {
       
  4626         SetDefaultIconL();
       
  4627         }
       
  4628     // We need to adjust the CBA for this view.
       
  4629 	if( iCbaHandler )
       
  4630 		iCbaHandler->UpdateCba();
       
  4631 
       
  4632 	iLayoutSwitch = EFalse;
       
  4633 	}
       
  4634 
       
  4635 // -----------------------------------------------------------------------------
       
  4636 // Determine if adding shuffle command is needed
       
  4637 // -----------------------------------------------------------------------------
       
  4638 //
       
  4639 TBool CMPXCollectionViewHgContainer::ShuffleItemPresent()
       
  4640     {
       
  4641     MPX_FUNC( "CMPXCollectionViewHgContainer::ShuffleItemNeeded" );
       
  4642 
       
  4643     const CMPXMediaArray& mediaArray = iListBoxArray->MediaArray();
       
  4644 
       
  4645 	TBool res = EFalse;
       
  4646 	if ( mediaArray.Count() > 1 &&
       
  4647 	     (iContext == EContextGroupAlbum ||
       
  4648 		 iContext == EContextGroupSong ||
       
  4649 		 iContext == EContextItemPlaylist ||
       
  4650 		 iContext == EContextItemGenre ||
       
  4651 		 iContext == EContextItemSong ))
       
  4652 		{
       
  4653 		res = ETrue;
       
  4654 		}
       
  4655 
       
  4656 	return res;
       
  4657     }
       
  4658 
       
  4659 // -----------------------------------------------------------------------------
       
  4660 // Handles translation from list index to media array index
       
  4661 // -----------------------------------------------------------------------------
       
  4662 //
       
  4663 TInt CMPXCollectionViewHgContainer::MediaIndex(TInt aIndex) const
       
  4664     {
       
  4665     MPX_FUNC( "CMPXCollectionViewHgContainer::MediaIndex" );
       
  4666 
       
  4667 	TInt index(aIndex);
       
  4668 
       
  4669 	if ( iShuffleItem )
       
  4670 		{
       
  4671 		index = aIndex - 1;
       
  4672 		}
       
  4673 
       
  4674 	return index;
       
  4675     }
       
  4676 
       
  4677 
       
  4678 // ---------------------------------------------------------------------------
       
  4679 // Offer command by view, if handled, return ETrue.
       
  4680 // ---------------------------------------------------------------------------
       
  4681 //
       
  4682 TBool CMPXCollectionViewHgContainer::OfferCommandL( TInt aCommand )
       
  4683     {
       
  4684     MPX_FUNC( "CMPXCollectionViewHgContainer::OfferCommandL" );
       
  4685 
       
  4686     if( aCommand == EAknSoftkeyBack && iContext == EContextItemAlbum )
       
  4687         {
       
  4688 		iOpenAlbumTracks = EFalse;
       
  4689 		HandleLbxItemAdditionL();
       
  4690 		return ETrue;
       
  4691 		}
       
  4692 	else
       
  4693 		{
       
  4694 		return EFalse;
       
  4695 		}
       
  4696     }
       
  4697 
       
  4698 // ---------------------------------------------------------------------------
       
  4699 // Load and set empty text
       
  4700 // ---------------------------------------------------------------------------
       
  4701 //
       
  4702 void CMPXCollectionViewHgContainer::LoadAndSetEmptyTextL()
       
  4703     {
       
  4704     MPX_FUNC( "CMPXCollectionViewHgContainer::LoadAndSetEmptyTextL" );
       
  4705 
       
  4706     if ( iContext == EContextGroupAlbum )
       
  4707         {
       
  4708         TInt resId = R_MPX_COLLECTION_ALBUM_LBX_EMPTYTEXT;
       
  4709         HBufC* emptyText = StringLoader::LoadLC( resId );
       
  4710         SetLbxEmptyTextL( *emptyText );
       
  4711         CleanupStack::PopAndDestroy( emptyText );        
       
  4712         }
       
  4713     }
       
  4714 
       
  4715 // ---------------------------------------------------------------------------
       
  4716 // Set previous view Uid
       
  4717 // ---------------------------------------------------------------------------
       
  4718 //
       
  4719 void CMPXCollectionViewHgContainer::SetPreviousViewId(TUid aViewUid)
       
  4720     {
       
  4721     MPX_FUNC( "CMPXCollectionViewHgContainer::SetPreviousViewId" );
       
  4722 
       
  4723 	iPreviousViewId = aViewUid;
       
  4724     }
       
  4725 
       
  4726 // ---------------------------------------------------------------------------
       
  4727 // Prepare and begin fullscreen animation effects
       
  4728 // ---------------------------------------------------------------------------
       
  4729 //
       
  4730 void CMPXCollectionViewHgContainer::BeginFullScreenAnimation(TBool aPrevViewWasPlayback)
       
  4731     {
       
  4732     if( iTranstionType != EMPXTranstionNotDefined )
       
  4733         return;
       
  4734 
       
  4735     iTranstionType = EMPXTranstionToLeft;
       
  4736 
       
  4737     if ( (iPrevContext == EContextUnknown ||
       
  4738           iPrevContext == EContextItemAlbum ) && aPrevViewWasPlayback )
       
  4739         {
       
  4740         iTranstionType = EMPXTranstionToLeft;
       
  4741         }
       
  4742     else if( iPrevContext == EContextUnknown )
       
  4743         {
       
  4744         // We aren't coming from playback view and prev context is unknown.
       
  4745         // Musicplayer is propably started so we shouldn't use any animation.
       
  4746         iTranstionType = EMPXTranstionNotDefined;
       
  4747         return;
       
  4748         }
       
  4749     else if( iCurrentViewType == EMPXViewTBone )
       
  4750         {
       
  4751         iTranstionType = EMPXTranstionToRight;
       
  4752         }
       
  4753 
       
  4754     if( iPrevViewType == EMPXViewMediawall || iPrevViewType == EMPXViewTBone )
       
  4755         {
       
  4756         iMediaWall->SetFlags( CHgVgMediaWall::EHgVgMediaWallDrawToWindowGC );
       
  4757         iMediaWall->DrawNow();
       
  4758         }
       
  4759 
       
  4760     const TInt flags = AknTransEffect::TParameter::EActivateExplicitCancel;
       
  4761     TRect appRect = ((CAknAppUi*)iCoeEnv->AppUi())->ApplicationRect();
       
  4762     GfxTransEffect::BeginFullScreen( iTranstionType, appRect,
       
  4763             AknTransEffect::EParameterType,
       
  4764             AknTransEffect::GfxTransParam(KAppUidMusicPlayerX, flags));
       
  4765     }
       
  4766 
       
  4767 // ---------------------------------------------------------------------------
       
  4768 // End fullscreen animation effects
       
  4769 // ---------------------------------------------------------------------------
       
  4770 //
       
  4771 void CMPXCollectionViewHgContainer::EndFullScreenAnimation()
       
  4772     {
       
  4773     if( iTranstionType != EMPXTranstionNotDefined )
       
  4774         {
       
  4775         GfxTransEffect::EndFullScreen();
       
  4776         iTranstionType = EMPXTranstionNotDefined;
       
  4777         // TODO: uncomment if really needed.
       
  4778         //iThumbnailManager->Pause(TTimeIntervalMicroSeconds32(KThumbLoadingPauseForTransition));
       
  4779         }
       
  4780     }
       
  4781 
       
  4782 // ---------------------------------------------------------------------------
       
  4783 // Resolving the size of the popup list rectangle.
       
  4784 // ---------------------------------------------------------------------------
       
  4785 //
       
  4786 void CMPXCollectionViewHgContainer::ResolvePopupListSizeL()
       
  4787     {
       
  4788     // Resolve popuplistbox rect that is used to show the album songs
       
  4789     CAknSinglePopupMenuStyleListBox* listBox = new ( ELeave ) CAknSinglePopupMenuStyleListBox;
       
  4790     CleanupStack::PushL( listBox );
       
  4791 
       
  4792     CMpxPopupList* dialog = CMpxPopupList::NewL(listBox, R_MPX_COLLECTION_ALBUMSONGS_LIST_CBA,
       
  4793             AknPopupLayouts::EDynMenuWindow );
       
  4794 
       
  4795     CleanupStack::PushL( dialog );
       
  4796 
       
  4797     listBox->ConstructL( dialog,
       
  4798             EAknListBoxSelectionList | EAknListBoxScrollBarSizeExcluded  );
       
  4799 
       
  4800     // title can be hardcoded because it is not shown to user. Just for the calculations.
       
  4801     dialog->SetTitleL(_L("Foo"));
       
  4802     iPopupListRect = dialog->LayoutRect();
       
  4803 
       
  4804     CleanupStack::PopAndDestroy( dialog );
       
  4805     CleanupStack::PopAndDestroy( listBox );
       
  4806     }
  4504 //  End of File
  4807 //  End of File