mpxplugins/viewplugins/views/collectionviewhg/src/mpxcollectionviewhgcontainer.cpp
changeset 1 8118492f1bdf
parent 0 ff3acec5bc43
child 2 b70d77332e66
equal deleted inserted replaced
0:ff3acec5bc43 1:8118492f1bdf
   197         iPlaybackUtility->Close();
   197         iPlaybackUtility->Close();
   198         }
   198         }
   199 
   199 
   200     delete iPlaylist;
   200     delete iPlaylist;
   201     delete iPlaylistHelper;
   201     delete iPlaylistHelper;
       
   202 
       
   203     if( iAsyncCallBack )
       
   204         {
       
   205         iAsyncCallBack->Cancel();
       
   206         }
       
   207     delete iAsyncCallBack;
       
   208 
       
   209     iCoeEnv->RemoveForegroundObserver( *this );
   202     }
   210     }
   203 
   211 
   204 // ---------------------------------------------------------------------------
   212 // ---------------------------------------------------------------------------
   205 // Symbian 2nd phase constructor can leave.
   213 // Symbian 2nd phase constructor can leave.
   206 // ---------------------------------------------------------------------------
   214 // ---------------------------------------------------------------------------
   251     iListBoxArray = static_cast<CMPXCollectionViewListBoxArray*>(
   259     iListBoxArray = static_cast<CMPXCollectionViewListBoxArray*>(
   252         CreateListBoxArrayL() );
   260         CreateListBoxArrayL() );
   253 
   261 
   254     CreateIconArrayL();
   262     CreateIconArrayL();
   255 
   263 
       
   264     iIsForeground = ETrue;
       
   265     iCoeEnv->AddForegroundObserverL( *this );
       
   266 
       
   267     TCallBack callback(CMPXCollectionViewHgContainer::AsyncCallback, this);
       
   268     iAsyncCallBack = new (ELeave) CAsyncCallBack( CActive::EPriorityStandard );
       
   269     iAsyncCallBack->Set(callback);
       
   270 
   256     CreateWindowL();
   271     CreateWindowL();
   257     ActivateL();
   272     ActivateL();
   258     DrawableWindow()->SetPointerCapture( RWindowBase::TCaptureDisabled );
       
   259     SetPointerCapture( EFalse );
       
   260     CapturesPointer();
       
   261     }
   273     }
   262 
   274 
   263 // -----------------------------------------------------------------------------
   275 // -----------------------------------------------------------------------------
   264 // CMPXCollectionViewHgContainer::MopSupplyObject
   276 // CMPXCollectionViewHgContainer::MopSupplyObject
   265 // -----------------------------------------------------------------------------
   277 // -----------------------------------------------------------------------------
   712                 }
   724                 }
   713 			SetDetailIconShuffleL();
   725 			SetDetailIconShuffleL();
   714             }
   726             }
   715         else if ( aType == KEikDynamicLayoutVariantSwitch )
   727         else if ( aType == KEikDynamicLayoutVariantSwitch )
   716             {
   728             {
       
   729             if( iCurrentViewType == EMPXViewTBone )
       
   730                 {
       
   731 				iCollectionUtility->Collection().BackL();
       
   732                 }
       
   733             else
       
   734                 {
       
   735                 // Coe env is in middle if notifying observers (controls).
       
   736                 // Just to be save, lets just create a small async callback and then
       
   737                 // call HandleLbxItemAdditionL
       
   738                 if( !iAsyncCallBack->IsActive() )
       
   739                     {
       
   740                     iAsyncCallBack->CallBack();
       
   741                     }
       
   742                 }
       
   743 
       
   744             if( iCbaHandler )
       
   745                 iCbaHandler->UpdateCba();
       
   746 
   717             TRect clientRect = ((CAknView*)iView)->ClientRect();
   747             TRect clientRect = ((CAknView*)iView)->ClientRect();
   718 
   748             SetRect( clientRect );
   719             iBgContext->SetRect(((CAknAppUi*)iCoeEnv->AppUi())->ApplicationRect());
   749             iBgContext->SetRect(((CAknAppUi*)iCoeEnv->AppUi())->ApplicationRect());
   720 
       
   721             // In current design we switch to different type of control in
       
   722             // all orientation switches.
       
   723             HandleLbxItemAdditionL();
       
   724             }
   750             }
   725         );
   751         );
   726     }
   752     }
   727 
   753 
   728 
   754 
  1083     {
  1109     {
  1084     MPX_DEBUG2( "CMPXCollectionViewHgContainer::DrawLbxItem (aIndex=%d)", aIndex );
  1110     MPX_DEBUG2( "CMPXCollectionViewHgContainer::DrawLbxItem (aIndex=%d)", aIndex );
  1085 
  1111 
  1086     CHgScroller* list = CurrentListWidget();
  1112     CHgScroller* list = CurrentListWidget();
  1087 
  1113 
  1088     if( list )
  1114     if( list && aIndex < list->ItemCount() )
  1089         {
  1115         {
  1090         CHgItem* item = &list->ItemL(aIndex);
  1116         CHgItem* item = &list->ItemL(aIndex);
  1091         SetDetailIndicatorL(item, aIndex);
  1117         SetDetailIndicatorL(item, aIndex);
  1092         list->RefreshScreen(aIndex);
  1118         list->RefreshScreen(aIndex);
  1093         }
  1119         }
  1359 // Resize the list when contents of media array changed.
  1385 // Resize the list when contents of media array changed.
  1360 // ---------------------------------------------------------------------------
  1386 // ---------------------------------------------------------------------------
  1361 //
  1387 //
  1362 void CMPXCollectionViewHgContainer::ResizeListL(const CMPXMediaArray& aMediaArray, TInt aCount)
  1388 void CMPXCollectionViewHgContainer::ResizeListL(const CMPXMediaArray& aMediaArray, TInt aCount)
  1363     {
  1389     {
  1364     TRect clientRect = ((CAknView*)iView)->ClientRect();
       
  1365     if( iListWidget )
  1390     if( iListWidget )
  1366         {
  1391         {
       
  1392         TRect clientRect = ((CAknView*)iView)->ClientRect();
  1367         TInt index = iListWidget->SelectedIndex();
  1393         TInt index = iListWidget->SelectedIndex();
  1368         iListWidget->InitScreenL( clientRect );
  1394         iListWidget->InitScreenL( clientRect );
  1369         iListWidget->Reset();
  1395         iListWidget->Reset();
  1370         if ( aCount )
  1396         if ( aCount )
  1371             {
  1397             {
  1378             iListWidget->RefreshScreen(0);
  1404             iListWidget->RefreshScreen(0);
  1379             }
  1405             }
  1380         }
  1406         }
  1381     else if( iMediaWall )
  1407     else if( iMediaWall )
  1382         {
  1408         {
  1383         TInt index = iMediaWall->SelectedIndex();
  1409         // In case of mediawall components we switch to different view type if orientation changes
  1384         iMediaWall->InitScreenL( clientRect );
  1410         // so there is no need to set new client rect for mediawall.
       
  1411 
  1385         iMediaWall->Reset();
  1412         iMediaWall->Reset();
  1386         if ( aCount )
  1413         if ( aCount )
  1387             {
  1414             {
  1388             iMediaWall->ResizeL( aCount );
  1415             iMediaWall->ResizeL( aCount );
  1389             ProvideDataWithoutThumbnailsMwL(aMediaArray);
  1416             ProvideDataWithoutThumbnailsMwL(aMediaArray);
  1390             iMediaWall->SetSelectedIndex( CurrentLbxItemIndex() );
  1417             TInt index = CurrentLbxItemIndex();
       
  1418             index = index >= 0 ? index : 0;
       
  1419             iMediaWall->SetSelectedIndex( index );
       
  1420             OpenAlbumL( index );
  1391             }
  1421             }
  1392         else
  1422         else
  1393             {
  1423             {
  1394             iMediaWall->RefreshScreen(0);
  1424             iMediaWall->RefreshScreen(0);
  1395             }
  1425             }
  1466 
  1496 
  1467     // Temporary until we have real layout data
  1497     // Temporary until we have real layout data
  1468     TRect mediaWallRect = TRect(clientRect.iTl, TPoint(clientRect.iBr.iX, 250));
  1498     TRect mediaWallRect = TRect(clientRect.iTl, TPoint(clientRect.iBr.iX, 250));
  1469     TRect mwListRect = TRect(TPoint(clientRect.iTl.iX, 250), clientRect.iBr);
  1499     TRect mwListRect = TRect(TPoint(clientRect.iTl.iX, 250), clientRect.iBr);
  1470 
  1500 
       
  1501     if( iMediaWall )
       
  1502         {
       
  1503         delete iMediaWall;
       
  1504         iMediaWall = 0;
       
  1505         delete iMwListWidget;
       
  1506         iMwListWidget = 0;
       
  1507         }
       
  1508 
  1471     if ( !iMediaWall )
  1509     if ( !iMediaWall )
  1472 		{
  1510 		{
  1473 		iMediaWall = CHgVgMediaWall::NewL (
  1511 		iMediaWall = CHgVgMediaWall::NewL (
  1474 				mediaWallRect,
  1512 				mediaWallRect,
  1475 				aCount,
  1513 				aCount,
  1476 				CHgVgMediaWall::EHgVgMediaWallStyleCoverflowTBonePortrait,
  1514 				CHgVgMediaWall::EHgVgMediaWallStyleCoverflowTBonePortrait,
  1477 				EFalse,
  1515 				EFalse,
  1478 				this,
  1516 				this,
  1479 				DefaultIconL() );
  1517 				DefaultIconL() );
  1480 
  1518 
       
  1519 		if( !iIsForeground )
       
  1520 		    iMediaWall->HandleLosingForeground();
       
  1521 
  1481 		iMediaWall->SetMopParent(this);
  1522 		iMediaWall->SetMopParent(this);
  1482 		iMediaWall->EnableScrollBufferL(*this, KMPXListBufferSizeWithMediaWall, KMPXListBufferSizeWithMediaWall/4);
  1523 		iMediaWall->EnableScrollBufferL(*this, KMPXListBufferSizeWithMediaWall, KMPXListBufferSizeWithMediaWall/4);
  1483         iMediaWall->SetSelectionObserver(*this);
  1524         iMediaWall->SetSelectionObserver(*this);
  1484 		ProvideDataWithoutThumbnailsMwL(aMediaArray);
  1525 		ProvideDataWithoutThumbnailsMwL(aMediaArray);
  1485 
  1526 
  1538     {
  1579     {
  1539     MPX_FUNC("CMPXCollectionViewHgContainer::PrepareMediaWallL");
  1580     MPX_FUNC("CMPXCollectionViewHgContainer::PrepareMediaWallL");
  1540    	TRect appRect = ((CAknAppUi*)iCoeEnv->AppUi())->ApplicationRect();
  1581    	TRect appRect = ((CAknAppUi*)iCoeEnv->AppUi())->ApplicationRect();
  1541 	((CAknAppUi*)iCoeEnv->AppUi())->StatusPane()->MakeVisible(EFalse);
  1582 	((CAknAppUi*)iCoeEnv->AppUi())->StatusPane()->MakeVisible(EFalse);
  1542 	iThumbnailManager->SetSizeL( EAudioFullScreenThumbnailSize );
  1583 	iThumbnailManager->SetSizeL( EAudioFullScreenThumbnailSize );
       
  1584 
       
  1585     if( iMediaWall )
       
  1586         {
       
  1587         delete iMediaWall;
       
  1588         iMediaWall = 0;
       
  1589         delete iMwListWidget;
       
  1590         iMwListWidget = 0;
       
  1591         }
  1543 
  1592 
  1544 	if (!iMediaWall)
  1593 	if (!iMediaWall)
  1545 	    {
  1594 	    {
  1546         iMediaWall = CHgVgMediaWall::NewL(
  1595         iMediaWall = CHgVgMediaWall::NewL(
  1547                 appRect,
  1596                 appRect,
  1548                 aCount,
  1597                 aCount,
  1549                 CHgVgMediaWall::EHgVgMediaWallStyleCoverflowFullScreen,
  1598                 CHgVgMediaWall::EHgVgMediaWallStyleCoverflowFullScreen,
  1550                 ETrue,
  1599                 ETrue,
  1551                 this,
  1600                 this,
  1552                 DefaultIconL() );
  1601                 DefaultIconL() );
       
  1602 
       
  1603         if( !iIsForeground )
       
  1604             iMediaWall->HandleLosingForeground();
       
  1605 
  1553         iMediaWall->SetMopParent(this);
  1606         iMediaWall->SetMopParent(this);
  1554         iMediaWall->SetSelectionObserver(*this);
  1607         iMediaWall->SetSelectionObserver(*this);
  1555         iMediaWall->SetObserver( this ); // softkey visibility event observer
  1608         iMediaWall->SetObserver( this ); // softkey visibility event observer
  1556         iMediaWall->SetOpeningAnimationType( CHgVgMediaWall::EHgVgOpeningAnimationFlipToFront );
  1609         iMediaWall->SetOpeningAnimationType( CHgVgMediaWall::EHgVgOpeningAnimationFlipToFront );
  1557         iMediaWall->EnableScrollBufferL(
  1610         iMediaWall->EnableScrollBufferL(
  1584             iMediaWall->SetSelectedIndex( iRestoredAlbumIndex );
  1637             iMediaWall->SetSelectedIndex( iRestoredAlbumIndex );
  1585         else
  1638         else
  1586             iMediaWall->SetSelectedIndex( iAlbumIndex );
  1639             iMediaWall->SetSelectedIndex( iAlbumIndex );
  1587 
  1640 
  1588         iMediaWall->DrawDeferred();
  1641         iMediaWall->DrawDeferred();
  1589 	    iMediaWall->RefreshScreen(0);
       
  1590 	    }
  1642 	    }
  1591 
  1643 
  1592 	iDefaultIconSet = ETrue;
  1644 	iDefaultIconSet = ETrue;
  1593     }
  1645     }
  1594 
  1646 
  1639         }
  1691         }
  1640 
  1692 
  1641     return current;
  1693     return current;
  1642     }
  1694     }
  1643 
  1695 
       
  1696 // ----------------------------------------------------------------------------
       
  1697 // Check if the current view is TBoneView.
       
  1698 // ----------------------------------------------------------------------------
       
  1699 TBool CMPXCollectionViewHgContainer::IsTBoneView()
       
  1700     {
       
  1701     TBool tBoneView = EFalse;
       
  1702     
       
  1703     if( EMPXViewTBone == iCurrentViewType )
       
  1704         tBoneView = ETrue;
       
  1705     
       
  1706     return tBoneView;
       
  1707     }
       
  1708 	
  1644 // ----------------------------------------------------------------------------
  1709 // ----------------------------------------------------------------------------
  1645 // Resolve the current view type based on the browsing context
  1710 // Resolve the current view type based on the browsing context
  1646 // ----------------------------------------------------------------------------
  1711 // ----------------------------------------------------------------------------
  1647 void CMPXCollectionViewHgContainer::ResolveCurrentViewType()
  1712 void CMPXCollectionViewHgContainer::ResolveCurrentViewType()
  1648     {
  1713     {
  1684 
  1749 
  1685     switch (iPrevViewType)
  1750     switch (iPrevViewType)
  1686         {
  1751         {
  1687         case EMPXViewCoverFlow:
  1752         case EMPXViewCoverFlow:
  1688             {
  1753             {
  1689             iMediaWall->MakeVisible( EFalse );
  1754             if( iCurrentViewType != EMPXViewTBone )
  1690             iMediaWall->SetFocus( EFalse );
  1755                 {
  1691             iMediaWall->DisableScrollBuffer();
  1756                 delete iMediaWall;
       
  1757                 iMediaWall = 0;
       
  1758                 }
  1692             break;
  1759             break;
  1693             }
  1760             }
  1694         case EMPXViewTBone:
  1761         case EMPXViewTBone:
  1695             {
  1762             {
  1696             iMediaWall->MakeVisible( EFalse );
  1763             if( iCurrentViewType != EMPXViewCoverFlow )
  1697             iMediaWall->DisableScrollBuffer();
  1764                 {
  1698             iMwListWidget->MakeVisible( EFalse );
  1765                 delete iMediaWall;
  1699             iMwListWidget->Reset();
  1766                 iMediaWall = 0;
       
  1767                 }
       
  1768             delete iMwListWidget;
       
  1769             iMwListWidget = 0;
  1700             break;
  1770             break;
  1701             }
  1771             }
  1702         case EMPXViewList:
  1772         case EMPXViewList:
  1703             {
  1773             {
  1704             iListWidget->MakeVisible( EFalse );
  1774             delete iListWidget;
  1705             iListWidget->SetFocus( EFalse );
  1775             iListWidget = 0;
  1706             iListWidget->DisableScrollBuffer();
       
  1707             iListWidget->Reset();
       
  1708             break;
  1776             break;
  1709             }
  1777             }
  1710         default:
  1778         default:
  1711             break;
  1779             break;
  1712         }
  1780         }
  1719 TBool CMPXCollectionViewHgContainer::IsSelectedItemASong()
  1787 TBool CMPXCollectionViewHgContainer::IsSelectedItemASong()
  1720     {
  1788     {
  1721     MPX_FUNC( "CMPXCollectionViewHgContainer::IsSelectedItemASong" );
  1789     MPX_FUNC( "CMPXCollectionViewHgContainer::IsSelectedItemASong" );
  1722 
  1790 
  1723 	TBool res(EFalse);
  1791 	TBool res(EFalse);
  1724     if ( iContext == EContextItemAlbum  )
  1792     if ( iContext == EContextItemAlbum || iContext == EContextGroupSong )
  1725         {
  1793         {
  1726     	CHgScroller* listWidget = CurrentListWidget();
  1794     	CHgScroller* listWidget = CurrentListWidget();
  1727 		if ( listWidget->SelectedIndex() == 0 &&
  1795 		if ( listWidget->SelectedIndex() == 0 &&
  1728 			 listWidget->ItemCount() > 1 )
  1796 			 listWidget->ItemCount() > 1 )
  1729 			{
  1797 			{
  1750     CMPXMedia* album( albums.AtL( iSelectedAlbumIndex ) );    
  1818     CMPXMedia* album( albums.AtL( iSelectedAlbumIndex ) );    
  1751     const CMPXMediaArray* songs = album->Value<CMPXMediaArray>(KMPXMediaArrayContents);
  1819     const CMPXMediaArray* songs = album->Value<CMPXMediaArray>(KMPXMediaArrayContents);
  1752     CHgScroller* listWidget = CurrentListWidget();
  1820     CHgScroller* listWidget = CurrentListWidget();
  1753     if (listWidget && songs)
  1821     if (listWidget && songs)
  1754         {
  1822         {
  1755         song = songs->AtL(listWidget->SelectedIndex());
  1823         if (listWidget->ItemCount() > 1)
       
  1824             {
       
  1825             song = songs->AtL(listWidget->SelectedIndex()-1);
       
  1826             }
       
  1827         else
       
  1828             {
       
  1829             song = songs->AtL(listWidget->SelectedIndex());
       
  1830             }
  1756         }
  1831         }
  1757     return song;
  1832     return song;
  1758     }
  1833     }
  1759 
  1834 
  1760 
  1835 
  1764 //
  1839 //
  1765 void CMPXCollectionViewHgContainer::HandleItemCommandL( TInt aCommand )
  1840 void CMPXCollectionViewHgContainer::HandleItemCommandL( TInt aCommand )
  1766     {
  1841     {
  1767     MPX_FUNC( "CMPXCollectionViewHgContainer::HandleItemCommanddL" );
  1842     MPX_FUNC( "CMPXCollectionViewHgContainer::HandleItemCommanddL" );
  1768 
  1843 
  1769     if ( iContext == EContextGroupAlbum && aCommand == EMPXCmdPlay )
  1844     if( aCommand == EMPXCmdPlay )
  1770         {
  1845         {
  1771     	CHgScroller* listWidget = CurrentListWidget();
  1846         switch( iCurrentViewType )
  1772 		iSelectedAlbumIndex = listWidget->SelectedIndex();
  1847             {
  1773         SaveSelectedAlbumItemL(iSelectedAlbumIndex);
  1848             case EMPXViewCoverFlow:
  1774 		// Open first song of album & playlist for entire album is created.
  1849             case EMPXViewTBone:
  1775 		PlayAlbumL(iSelectedAlbumIndex);
  1850                 {
  1776         }
  1851                 iSelectedAlbumIndex = iMediaWall->SelectedIndex();
  1777     else if ( iContext == EContextGroupPlaylist && aCommand == EMPXCmdPlay )
  1852                 SaveSelectedAlbumItemL(iSelectedAlbumIndex);
  1778         {
  1853                 // Open first song of album & playlist for entire album is created.
  1779     	CHgScroller* listWidget = CurrentListWidget();
  1854                 UpdatePathAndOpenL(0, ETrue);
  1780 		TInt index = listWidget->SelectedIndex();
  1855                 break;
  1781 		PlayPlaylistL(index);
  1856                 }
  1782         }
  1857             case EMPXViewList:
  1783     else if ( iContext == EContextGroupGenre && aCommand == EMPXCmdPlay )
  1858                 {
  1784         {
  1859                 if ( iContext == EContextGroupAlbum  )
  1785         CHgScroller* listWidget = CurrentListWidget();
  1860                     {
  1786         TInt index = listWidget->SelectedIndex();
  1861                     iSelectedAlbumIndex = iListWidget->SelectedIndex();
  1787         PlayGenreL(index);
  1862                     SaveSelectedAlbumItemL(iSelectedAlbumIndex);
       
  1863                     // Open first song of album & playlist for entire album is created.
       
  1864                     PlayAlbumL(iSelectedAlbumIndex);
       
  1865                     }
       
  1866                 else if ( iContext == EContextGroupPlaylist  )
       
  1867                     {
       
  1868                     TInt index = iListWidget->SelectedIndex();
       
  1869                     PlayPlaylistL(index);
       
  1870                     }
       
  1871                 else if ( iContext == EContextGroupGenre  )
       
  1872                     {
       
  1873                     TInt index = iListWidget->SelectedIndex();
       
  1874                     PlayGenreL(index);
       
  1875                     }
       
  1876                 break;
       
  1877                 }
       
  1878             default:
       
  1879                 break;
       
  1880             }
  1788         }
  1881         }
  1789     }
  1882     }
  1790 
  1883 
  1791 // ---------------------------------------------------------------------------
  1884 // ---------------------------------------------------------------------------
  1792 // From MHgSelectionObserver
  1885 // From MHgSelectionObserver
  2223 // avoid too many redraws. In some cases, multiple refresh is unavoidable.
  2316 // avoid too many redraws. In some cases, multiple refresh is unavoidable.
  2224 // ---------------------------------------------------------------------------
  2317 // ---------------------------------------------------------------------------
  2225 //
  2318 //
  2226 void CMPXCollectionViewHgContainer::RefreshL(TInt aIndex)
  2319 void CMPXCollectionViewHgContainer::RefreshL(TInt aIndex)
  2227     {
  2320     {
       
  2321     if( !iIsForeground )
       
  2322         {
       
  2323         return;
       
  2324         }
       
  2325 
  2228     MPX_FUNC( "CMPXCollectionViewHgContainer::Refresh" );
  2326     MPX_FUNC( "CMPXCollectionViewHgContainer::Refresh" );
  2229 
  2327 
  2230 	TInt mediaCount = iListBoxArray->MediaArray().Count();
  2328 	TInt mediaCount = iListBoxArray->MediaArray().Count();
  2231 
  2329 
  2232 	TInt firstOnScreen = 0;
  2330 	TInt firstOnScreen = 0;
  2433 		}
  2531 		}
  2434 	else if ( iListWidget )
  2532 	else if ( iListWidget )
  2435 		{
  2533 		{
  2436 		iListWidget->SetDefaultIconL(iconCopy);
  2534 		iListWidget->SetDefaultIconL(iconCopy);
  2437 		}
  2535 		}
       
  2536 	else
       
  2537 		{
       
  2538 		delete iconCopy;
       
  2539 		}
  2438 	iCurrentDefaultIcon = defaultIcon;
  2540 	iCurrentDefaultIcon = defaultIcon;
  2439 	}
  2541 	}
  2440 
  2542 
  2441 // -----------------------------------------------------------------------------
  2543 // -----------------------------------------------------------------------------
  2442 // Sets default icon to list item
  2544 // Sets default icon to list item
  2499         iMediaWall->ItemL(aIndex).SetIcon(iconCopy);
  2601         iMediaWall->ItemL(aIndex).SetIcon(iconCopy);
  2500 		}
  2602 		}
  2501 	else if ( iListWidget && defaultIcon != EMPXDefaultIconNotSet )
  2603 	else if ( iListWidget && defaultIcon != EMPXDefaultIconNotSet )
  2502 		{
  2604 		{
  2503         iListWidget->ItemL(aIndex).SetIcon(iconCopy);
  2605         iListWidget->ItemL(aIndex).SetIcon(iconCopy);
       
  2606 		}
       
  2607 	else
       
  2608 		{
       
  2609 		delete iconCopy;
  2504 		}
  2610 		}
  2505 	}
  2611 	}
  2506 
  2612 
  2507 
  2613 
  2508 // -----------------------------------------------------------------------------
  2614 // -----------------------------------------------------------------------------
  4043     CleanupStack::PushL( listBox );
  4149     CleanupStack::PushL( listBox );
  4044 
  4150 
  4045     CAknPopupList* dialog = CAknPopupList::NewL(listBox, R_MPX_COLLECTION_ALBUMSONGS_LIST_CBA,
  4151     CAknPopupList* dialog = CAknPopupList::NewL(listBox, R_MPX_COLLECTION_ALBUMSONGS_LIST_CBA,
  4046             AknPopupLayouts::EDynMenuWindow );
  4152             AknPopupLayouts::EDynMenuWindow );
  4047 
  4153 
       
  4154 	CleanupStack::PushL( dialog );
       
  4155 
  4048     listBox->ConstructL( dialog,
  4156     listBox->ConstructL( dialog,
  4049             EAknListBoxSelectionList | EAknListBoxScrollBarSizeExcluded  );
  4157             EAknListBoxSelectionList | EAknListBoxScrollBarSizeExcluded  );
       
  4158 	CleanupStack::Pop( dialog );
  4050 
  4159 
  4051     listBox->CreateScrollBarFrameL( ETrue );
  4160     listBox->CreateScrollBarFrameL( ETrue );
  4052     listBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff,
  4161     listBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff,
  4053             CEikScrollBarFrame::EAuto );
  4162             CEikScrollBarFrame::EAuto );
  4054 
  4163 
  4069 
  4178 
  4070     CDesC16ArrayFlat* songList = new (ELeave) CDesC16ArrayFlat(songCount);
  4179     CDesC16ArrayFlat* songList = new (ELeave) CDesC16ArrayFlat(songCount);
  4071 
  4180 
  4072     if ( songCount > 1 )
  4181     if ( songCount > 1 )
  4073         {
  4182         {
       
  4183 		// Todo: Use localized string.
  4074         songList->AppendL( _L("Shuffle All") );
  4184         songList->AppendL( _L("Shuffle All") );
  4075         }
  4185         }
  4076 
  4186 
  4077     for ( TInt i = 0; i < songCount; i++ )
  4187     for ( TInt i = 0; i < songCount; i++ )
  4078         {
  4188         {
  4249 
  4359 
  4250     for ( TInt i = 0; i < aMediaArray.Count() ; i++ )
  4360     for ( TInt i = 0; i < aMediaArray.Count() ; i++ )
  4251         {
  4361         {
  4252         CMPXMedia* currentMedia( aMediaArray.AtL( i ) );
  4362         CMPXMedia* currentMedia( aMediaArray.AtL( i ) );
  4253 
  4363 
  4254         if ( currentMedia->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) == id )
  4364         if ( (currentMedia->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) == id) || 
       
  4365              (id == KMPXInvalidItemId && currentMedia->ValueText(KMPXMediaGeneralTitle).Compare( restoredAlbum->ValueText(KMPXMediaGeneralTitle) ) == 0 )  )
  4255             {
  4366             {
  4256             iRestoredAlbumIndex = i;
  4367             iRestoredAlbumIndex = i;
  4257             iSelectedAlbumIndex = i;
  4368             iSelectedAlbumIndex = i;
  4258             break;
  4369             break;
  4259             }
  4370             }
  4327 
  4438 
  4328         CleanupStack::PopAndDestroy( &stream );
  4439         CleanupStack::PopAndDestroy( &stream );
  4329         CleanupStack::PopAndDestroy( store );
  4440         CleanupStack::PopAndDestroy( store );
  4330         }
  4441         }
  4331 
  4442 
  4332     }
  4443     // for corrupted Media
  4333 
  4444     TMPXItemId id=aMedia->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId);    
       
  4445     if ( id.iId1 == 0 )
       
  4446         {
       
  4447         aMedia->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, KMPXInvalidItemId );
       
  4448         }
       
  4449     }
       
  4450 
       
  4451 void CMPXCollectionViewHgContainer::HandleGainingForeground()
       
  4452     {
       
  4453     iIsForeground = ETrue;
       
  4454     }
       
  4455 
       
  4456 void CMPXCollectionViewHgContainer::HandleLosingForeground()
       
  4457     {
       
  4458     iIsForeground = EFalse;
       
  4459     }
       
  4460 
       
  4461 TInt CMPXCollectionViewHgContainer::AsyncCallback( TAny* aPtr )
       
  4462     {
       
  4463     CMPXCollectionViewHgContainer* self = static_cast<CMPXCollectionViewHgContainer*>(aPtr);
       
  4464     if( self )
       
  4465         {
       
  4466         self->HandleLbxItemAdditionL();
       
  4467         }
       
  4468     return KErrNone;
       
  4469     }
  4334 
  4470 
  4335 //  End of File
  4471 //  End of File