mpxplugins/viewplugins/views/collectionviewhg/src/mpxcollectionviewhgcontainer.cpp
branchRCL_3
changeset 50 26a1709b9fec
parent 40 cb96c29156b2
equal deleted inserted replaced
49:455f89b7fcc5 50:26a1709b9fec
   105 const TReal KIconFactor = 0.7;
   105 const TReal KIconFactor = 0.7;
   106 
   106 
   107 const TInt KThumbLoadingPauseForTransition(500000);
   107 const TInt KThumbLoadingPauseForTransition(500000);
   108 const TInt KMPXInterviewTransition = 0;
   108 const TInt KMPXInterviewTransition = 0;
   109 const TInt KMPXIntraviewTransition = 1;
   109 const TInt KMPXIntraviewTransition = 1;
       
   110 const TInt KMPXNoTransition = 2;
   110 
   111 
   111 _LIT( KMPXDash, " - " );
   112 _LIT( KMPXDash, " - " );
   112 #ifdef HG_MP_LOC_AVAILABLE
   113 #ifdef HG_MP_LOC_AVAILABLE
   113 _LIT( KMPXSpace, " ");
   114 _LIT( KMPXSpace, " ");
   114 #endif //HG_MP_LOC_AVAILABLE
   115 #endif //HG_MP_LOC_AVAILABLE
   161 	iOpenAlbumTracks(EFalse),
   162 	iOpenAlbumTracks(EFalse),
   162 	iShuffleItem(0),
   163 	iShuffleItem(0),
   163 	iSetEmptyTextNeeded(EFalse),
   164 	iSetEmptyTextNeeded(EFalse),
   164 	iPopupListRect(TRect(0,0,0,0)),
   165 	iPopupListRect(TRect(0,0,0,0)),
   165 	iPreviousViewId(TUid::Uid(0)),
   166 	iPreviousViewId(TUid::Uid(0)),
   166 	iDrawBackGround(EFalse)
   167 	iDrawBackGround(EFalse),
       
   168 	iIsNowPlayingView(EFalse)
   167     {
   169     {
   168     }
   170     }
   169 
   171 
   170 // ---------------------------------------------------------------------------
   172 // ---------------------------------------------------------------------------
   171 // Destructor
   173 // Destructor
  1002     return iTopIndex;
  1004     return iTopIndex;
  1003     }
  1005     }
  1004 
  1006 
  1005 
  1007 
  1006 // -----------------------------------------------------------------------------
  1008 // -----------------------------------------------------------------------------
       
  1009 // Gets first listbox item index on screen(relative to the original listbox).
       
  1010 // -----------------------------------------------------------------------------
       
  1011 //
       
  1012 TInt CMPXCollectionViewHgContainer::FirstIndexOnScreen() const
       
  1013     {
       
  1014     MPX_FUNC( "CMPXCollectionViewHgContainer::FirstIndexOnScreen" );
       
  1015     TInt index = 0;
       
  1016     if ( iListWidget )
       
  1017         {
       
  1018         index = iListWidget->FirstIndexOnScreen();
       
  1019         }
       
  1020     return index;
       
  1021     }
       
  1022 
       
  1023 
       
  1024 // -----------------------------------------------------------------------------
  1007 // Gets bottom listbox item index (relative to the original listbox).
  1025 // Gets bottom listbox item index (relative to the original listbox).
  1008 // -----------------------------------------------------------------------------
  1026 // -----------------------------------------------------------------------------
  1009 //
  1027 //
  1010 TInt CMPXCollectionViewHgContainer::BottomLbxItemIndex() const
  1028 TInt CMPXCollectionViewHgContainer::BottomLbxItemIndex() const
  1011     {
  1029     {
  1256             // We only need to use this for one transition coming
  1274             // We only need to use this for one transition coming
  1257             // from playback view.
  1275             // from playback view.
  1258             TBool pbv = (iPreviousViewId == TUid::Uid(KMPXPluginTypePlaybackUid)) ? ETrue : EFalse;
  1276             TBool pbv = (iPreviousViewId == TUid::Uid(KMPXPluginTypePlaybackUid)) ? ETrue : EFalse;
  1259             if ( pbv )
  1277             if ( pbv )
  1260                 {
  1278                 {
       
  1279                 iIsNowPlayingView = ETrue;
  1261             	iPreviousViewId = TUid::Uid(0);
  1280             	iPreviousViewId = TUid::Uid(0);
  1262             	SetupTransitionType(KMPXInterviewTransition, pbv);
  1281             	SetupTransitionType(KMPXInterviewTransition, pbv);
  1263                 }
  1282                 }
  1264             else // intraview transitions
  1283             else // intraview transitions
  1265 				{
  1284 				{
  1497 //
  1516 //
  1498 void CMPXCollectionViewHgContainer::ResizeListL(const CMPXMediaArray& aMediaArray, TInt aCount)
  1517 void CMPXCollectionViewHgContainer::ResizeListL(const CMPXMediaArray& aMediaArray, TInt aCount)
  1499     {
  1518     {
  1500     MPX_FUNC( "CMPXCollectionViewHgContainer::ResizeListL" );
  1519     MPX_FUNC( "CMPXCollectionViewHgContainer::ResizeListL" );
  1501     TInt mediaCount = aMediaArray.Count();
  1520     TInt mediaCount = aMediaArray.Count();
  1502 
  1521     SetupTransitionType( KMPXNoTransition );
  1503     if( iListWidget )
  1522     if( iListWidget )
  1504         {
  1523         {
  1505         TRect clientRect = ((CAknView*)iView)->ClientRect();
  1524         TRect clientRect = ((CAknView*)iView)->ClientRect();
  1506         TInt index = MediaIndex(iListWidget->SelectedIndex()); 
  1525         TInt index = MediaIndex(iListWidget->SelectedIndex()); 
  1507         TInt mediaIndex (index);
  1526         TInt mediaIndex (index);
  1619         iListWidget->SetMenuProviderL(this);
  1638         iListWidget->SetMenuProviderL(this);
  1620         iListWidget->SetSelectionObserver(*this);
  1639         iListWidget->SetSelectionObserver(*this);
  1621         // TODO. check if this is correct for all lists
  1640         // TODO. check if this is correct for all lists
  1622         iListWidget->ClearFlags( CHgScroller::EHgScrollerKeyMarkingDisabled );
  1641         iListWidget->ClearFlags( CHgScroller::EHgScrollerKeyMarkingDisabled );
  1623         iListWidget->SetFocus(ETrue);
  1642         iListWidget->SetFocus(ETrue);
  1624         iListWidget->SetScrollBarTypeL( CHgScroller::EHgScrollerLetterStripLite );
  1643         if( iContext == EContextItemPlaylist )
       
  1644             {
       
  1645             iListWidget->SetScrollBarTypeL( CHgScroller::EHgScrollerScrollBar);
       
  1646             }   
       
  1647         else
       
  1648             {
       
  1649             iListWidget->SetScrollBarTypeL( CHgScroller::EHgScrollerLetterStripLite );
       
  1650             }
  1625         iListWidget->DrawableWindow()->SetOrdinalPosition( -1 );
  1651         iListWidget->DrawableWindow()->SetOrdinalPosition( -1 );
  1626         iListWidget->DrawableWindow()->SetFaded(((CAknAppUi*)iCoeEnv->AppUi())->IsFaded(), RWindowTreeNode::EFadeIncludeChildren);
  1652         iListWidget->DrawableWindow()->SetFaded(((CAknAppUi*)iCoeEnv->AppUi())->IsFaded(), RWindowTreeNode::EFadeIncludeChildren);
  1627         ProvideDataWithoutThumbnailsL(aMediaArray);
  1653         ProvideDataWithoutThumbnailsL(aMediaArray);
  1628         }
  1654         }
  1629     else
  1655     else
  1630         {
  1656         {
  1631         iListWidget->Reset();
  1657         iListWidget->Reset();
  1632         iListWidget->ResizeL( aCount );
  1658         iListWidget->ResizeL( aCount );
  1633         iListWidget->SetFocus(ETrue);
  1659         iListWidget->SetFocus(ETrue);
       
  1660         if( iContext == EContextItemPlaylist )
       
  1661             {
       
  1662             iListWidget->SetScrollBarTypeL( CHgScroller::EHgScrollerScrollBar);
       
  1663             }   
       
  1664         else
       
  1665             {
       
  1666             iListWidget->SetScrollBarTypeL( CHgScroller::EHgScrollerLetterStripLite );
       
  1667             }
  1634         ProvideDataWithoutThumbnailsL(aMediaArray);
  1668         ProvideDataWithoutThumbnailsL(aMediaArray);
  1635         iListWidget->MakeVisible(ETrue);
  1669         iListWidget->MakeVisible(ETrue);
  1636         iListWidget->InitScreenL(clientRect);
  1670         iListWidget->InitScreenL(clientRect);
  1637         }
  1671         }
  1638 
  1672 
  1820         switchBuffer = CMPXCollectionViewHgSwitchBuffer::CreateBufferLC( *iListWidget );
  1854         switchBuffer = CMPXCollectionViewHgSwitchBuffer::CreateBufferLC( *iListWidget );
  1821         }
  1855         }
  1822     else if ( iMediaWall && iPrevViewType == EMPXViewTBone )
  1856     else if ( iMediaWall && iPrevViewType == EMPXViewTBone )
  1823         {
  1857         {
  1824         switchBuffer = CMPXCollectionViewHgSwitchBuffer::CreateBufferLC( *iMediaWall );
  1858         switchBuffer = CMPXCollectionViewHgSwitchBuffer::CreateBufferLC( *iMediaWall );
  1825         switchBuffer->SetIndexOffset(1);
  1859         if (aMediaArray.Count()>1)
       
  1860             {
       
  1861             switchBuffer->SetIndexOffset(1);
       
  1862             }
  1826         }
  1863         }
  1827     if( iMediaWall )
  1864     if( iMediaWall )
  1828         {
  1865         {
  1829         delete iMediaWall;
  1866         delete iMediaWall;
  1830         iMediaWall = 0;
  1867         iMediaWall = 0;
  1832         iMwListWidget = 0;
  1869         iMwListWidget = 0;
  1833         }
  1870         }
  1834 
  1871 
  1835 	if (!iMediaWall)
  1872 	if (!iMediaWall)
  1836 	    {
  1873 	    {
  1837         iMediaWall = CHgVgMediaWall::NewL(
  1874 	    if ( iIsNowPlayingView )
  1838                 appRect,
  1875 	        {
  1839                 aCount,
  1876 			// back from now playing view, create mediawall with empty albumart icon to avoid flickering
  1840                 CHgVgMediaWall::EHgVgMediaWallStyleCoverflowFullScreen,
  1877 	        iMediaWall = CHgVgMediaWall::NewL(
  1841                 ETrue,
  1878 	                appRect,
  1842                 this,
  1879 	                aCount,
  1843                 DefaultIconL() );
  1880 	                CHgVgMediaWall::EHgVgMediaWallStyleCoverflowFullScreen,
  1844 
  1881 	                ETrue,
       
  1882 	                this,
       
  1883 	                CGulIcon::NewL( new CFbsBitmap()) );
       
  1884 	        }
       
  1885 	    else
       
  1886 	        {
       
  1887 	        iMediaWall = CHgVgMediaWall::NewL(
       
  1888 	                appRect,
       
  1889 	                aCount,
       
  1890 	                CHgVgMediaWall::EHgVgMediaWallStyleCoverflowFullScreen,
       
  1891 	                ETrue,
       
  1892 	                this,
       
  1893 	                DefaultIconL() );
       
  1894 	        }
       
  1895     
  1845         if( !iIsForeground )
  1896         if( !iIsForeground )
  1846             iMediaWall->HandleLosingForeground();
  1897             iMediaWall->HandleLosingForeground();
  1847 
  1898 
  1848         iMediaWall->SetMopParent(this);
  1899         iMediaWall->SetMopParent(this);
  1849         iMediaWall->SetSelectionObserver(*this);
  1900         iMediaWall->SetSelectionObserver(*this);
  1917         {
  1968         {
  1918         switchBuffer->FillFromBufferL( *iMediaWall );
  1969         switchBuffer->FillFromBufferL( *iMediaWall );
  1919         CleanupStack::PopAndDestroy( switchBuffer );
  1970         CleanupStack::PopAndDestroy( switchBuffer );
  1920         switchBuffer = NULL;
  1971         switchBuffer = NULL;
  1921         }
  1972         }
  1922 	iDefaultIconSet = ETrue;
  1973 	
       
  1974 	if ( iIsNowPlayingView )
       
  1975 	    {
       
  1976         iDefaultIconSet = EFalse;
       
  1977         iIsNowPlayingView = EFalse;
       
  1978 	    }
       
  1979 	else
       
  1980 	    {
       
  1981         iDefaultIconSet = ETrue;
       
  1982 	    }
  1923 	CleanPrevView();
  1983 	CleanPrevView();
  1924     }
  1984     }
  1925 
  1985 
  1926 // ----------------------------------------------------------------------------
  1986 // ----------------------------------------------------------------------------
  1927 // Add shuffle list item to the top of the list.
  1987 // Add shuffle list item to the top of the list.
  4813     MPX_FUNC( "CMPXCollectionViewHgContainer::RestoreSelectedAlbumItemL" );
  4873     MPX_FUNC( "CMPXCollectionViewHgContainer::RestoreSelectedAlbumItemL" );
  4814 
  4874 
  4815 	const CMPXMedia* restoredAlbum = iSelectedAlbumHandler->RestoreSelectedAlbum();
  4875 	const CMPXMedia* restoredAlbum = iSelectedAlbumHandler->RestoreSelectedAlbum();
  4816 	iRestoredAlbumIndex = 0;
  4876 	iRestoredAlbumIndex = 0;
  4817 	iSelectedAlbumIndex = 0;
  4877 	iSelectedAlbumIndex = 0;
  4818 	if ( restoredAlbum )
  4878 	TMPXItemId id(0);
  4819 		{
  4879 	if (!restoredAlbum)
  4820 	    TMPXItemId id=restoredAlbum->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId);
  4880 	    {        
  4821 
  4881 	    CMPXCollectionPath* cpath = iCollectionUtility->Collection().PathL();
  4822 	    for ( TInt i = 0; i < aMediaArray.Count() ; i++ )
  4882 		CleanupStack::PushL( cpath );
  4823 	        {
  4883 		id = (cpath->Id());  
  4824 	        CMPXMedia* currentMedia( aMediaArray.AtL( i ) );
  4884 		CleanupStack::PopAndDestroy( cpath ); 
  4825 
  4885 	    }
  4826 	        if ( (currentMedia->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) == id) ||
  4886     else
  4827 	             (id.iId1 == 0 && currentMedia->ValueText(KMPXMediaGeneralTitle).Compare( restoredAlbum->ValueText(KMPXMediaGeneralTitle) ) == 0 )  )
  4887         {
  4828 	            {
  4888         id=restoredAlbum->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId);   
  4829 	            iRestoredAlbumIndex = i;
  4889         }
  4830 	            iSelectedAlbumIndex = i;
  4890     for ( TInt i = 0; i < aMediaArray.Count() ; i++ )
  4831 	            break;
  4891         {
  4832 	            }
  4892         CMPXMedia* currentMedia( aMediaArray.AtL( i ) );
  4833 	        }
  4893 
  4834 		}
  4894         if ( (currentMedia->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) == id) ||
       
  4895              (id.iId1 == 0 && currentMedia->ValueText(KMPXMediaGeneralTitle).Compare( restoredAlbum->ValueText(KMPXMediaGeneralTitle) ) == 0 )  )
       
  4896             {
       
  4897             iRestoredAlbumIndex = i;
       
  4898             iSelectedAlbumIndex = i;
       
  4899             break;
       
  4900             }
       
  4901         } 
  4835     }
  4902     }
  4836 
  4903 
  4837 // ----------------------------------------------------------------------------
  4904 // ----------------------------------------------------------------------------
  4838 // Write the album name, artist name and album art in media data to file
  4905 // Write the album name, artist name and album art in media data to file
  4839 // ----------------------------------------------------------------------------
  4906 // ----------------------------------------------------------------------------
  5197 			{
  5264 			{
  5198 			iMediaWall->SetFlags( CHgVgMediaWall::EHgVgMediaWallDrawToWindowGC );
  5265 			iMediaWall->SetFlags( CHgVgMediaWall::EHgVgMediaWallDrawToWindowGC );
  5199 			iMediaWall->DrawNow();
  5266 			iMediaWall->DrawNow();
  5200 			}
  5267 			}
  5201 		}
  5268 		}
       
  5269 	else if ( aType == KMPXNoTransition )  // No transition  
       
  5270 	    {
       
  5271 	    iTranstionType = EMPXTranstionNotDefined;
       
  5272 	    }
  5202 	else // interview transition
  5273 	else // interview transition
  5203 		{
  5274 		{
  5204 
  5275 
  5205 		iTranstionType = EMPXTranstionToRight;
  5276 		iTranstionType = EMPXTranstionToRight;
  5206 		if ( (iPrevContext == EContextUnknown ||
  5277 		if ( (iPrevContext == EContextUnknown ||