application/src/PodcastFeedView.cpp
branchtwolistboxes
changeset 314 e7776f6a2198
parent 313 0f30a75610de
child 315 091fa3bf3295
equal deleted inserted replaced
313:0f30a75610de 314:e7776f6a2198
    65 
    65 
    66 void CPodcastFeedView::SizeChanged()
    66 void CPodcastFeedView::SizeChanged()
    67 	{
    67 	{
    68 	DP("CPodcastFeedView::SizeChanged BEGIN");
    68 	DP("CPodcastFeedView::SizeChanged BEGIN");
    69 	iListContainer->Listbox()->SetListBoxObserver(this);
    69 	iListContainer->Listbox()->SetListBoxObserver(this);
       
    70 	iListContainer->DrawNow();
       
    71 	DP("CPodcastFeedView::SizeChanged END");
       
    72 	}
       
    73 
       
    74 void CPodcastFeedView::LoadIcons()
       
    75 	{
    70 	iFeedIdForIconArray.Reset();
    76 	iFeedIdForIconArray.Reset();
    71 	iItemArray->Reset();
    77 	iItemArray->Reset();
    72 	
    78 	
    73 	DP("before icons");
    79 	DP("before icons");
    74 	CFbsBitmap* bitmap = NULL;
    80 	CFbsBitmap* bitmap = NULL;
    97 	// Append the feed icon to icon array
   103 	// Append the feed icon to icon array
    98 	iIconArray->AppendL( CGulIcon::NewL( bitmap, mask ) );
   104 	iIconArray->AppendL( CGulIcon::NewL( bitmap, mask ) );
    99 	CleanupStack::Pop(2); // bitmap, mask
   105 	CleanupStack::Pop(2); // bitmap, mask
   100 	iListContainer->SetListboxIcons(iIconArray);
   106 	iListContainer->SetListboxIcons(iIconArray);
   101 	CleanupStack::Pop(iIconArray); // icons
   107 	CleanupStack::Pop(iIconArray); // icons
   102 	
       
   103 	UpdateListboxItemsL();
       
   104 	iListContainer->SetTextArray(iItemArray);
       
   105 	iListContainer->SetListboxIcons(iIconArray);
       
   106 	iListContainer->Listbox()->DrawNow();
       
   107 	DP("CPodcastFeedView::SizeChanged END");
       
   108 	}
   108 	}
   109 
   109 
   110 CPodcastFeedView::CPodcastFeedView(CPodcastModel& aPodcastModel):iPodcastModel(aPodcastModel)
   110 CPodcastFeedView::CPodcastFeedView(CPodcastModel& aPodcastModel):iPodcastModel(aPodcastModel)
   111 	{
   111 	{
   112 	iFirstActivateAfterLaunch = ETrue;
   112 	iFirstActivateAfterLaunch = ETrue;
   120 	iNeverUpdated = iEikonEnv->AllocReadResourceL(R_PODCAST_FEEDS_NEVER_UPDATED);
   120 	iNeverUpdated = iEikonEnv->AllocReadResourceL(R_PODCAST_FEEDS_NEVER_UPDATED);
   121 	iFeedsFormat = iEikonEnv->AllocReadResourceL(R_PODCAST_FEEDS_STATUS_FORMAT);
   121 	iFeedsFormat = iEikonEnv->AllocReadResourceL(R_PODCAST_FEEDS_STATUS_FORMAT);
   122 	CPodcastListView::ConstructL();
   122 	CPodcastListView::ConstructL();
   123 	iPodcastModel.FeedEngine().AddObserver(this);
   123 	iPodcastModel.FeedEngine().AddObserver(this);
   124 	SetEmptyTextL(R_PODCAST_NO_FEEDS);
   124 	SetEmptyTextL(R_PODCAST_NO_FEEDS);
   125 	SizeChanged();
   125 
   126 //	CFbsBitmap* bitmap = NULL;
   126 	LoadIcons();
   127 //	CFbsBitmap* mask = NULL;
       
   128 //	// Load the bitmap for empty icon	
       
   129 //	TFileName fname = KAsterisk;
       
   130 //	TParsePtr parser(fname);
       
   131 
       
   132 //	
       
   133 //	// Load svg.-image and mask with a single call
       
   134 //		AknIconUtils::CreateIconL(bitmap,
       
   135 //		                          mask,
       
   136 //		                          iEikonEnv->EikAppUi()->Application()->BitmapStoreName(),
       
   137 //		                          EMbmPodcastFeed,
       
   138 //		                          EMbmPodcastFeed_mask);
       
   139 //	    
       
   140 //	/*bitmap = iEikonEnv->CreateBitmapL(KAsterisk,EMbmPodcastFeed_40x40);
       
   141 //	 * */
       
   142 //	CleanupStack::PushL( bitmap );		
       
   143 //	// Load the mask for feed icon	
       
   144 //	//mask = iEikonEnv->CreateBitmapL(KAsterisk,EMbmPodcastFeed_40x40m );	
       
   145 //	CleanupStack::PushL( mask );
       
   146 //	// Append the feed icon to icon array
       
   147 //	iIconArray->AppendL( CGulIcon::NewL( bitmap, mask ) );
       
   148 //	CleanupStack::Pop(2); // bitmap, mask
       
   149 //	iListContainer->SetListboxIcons(iIconArray);
       
   150 //	CleanupStack::Pop(iIconArray); // icons
       
   151 //
       
   152 //	iListContainer->Listbox()->SetListBoxObserver(this);
       
   153 	
   127 	
   154     iUpdater = CPodcastFeedViewUpdater::NewL(*this);
   128     iUpdater = CPodcastFeedViewUpdater::NewL(*this);
   155 	DP("CPodcastFeedView::ConstructL END");
   129 	DP("CPodcastFeedView::ConstructL END");
   156 	}
   130 	}
   157     
   131     
   187 	// Something has changed, update the listbox item
   161 	// Something has changed, update the listbox item
   188 	TListItemProperties itemProps;			
   162 	TListItemProperties itemProps;			
   189 	itemProps.SetDimmed(EFalse);	
   163 	itemProps.SetDimmed(EFalse);	
   190 	iItemArray->Delete(aIndex);	
   164 	iItemArray->Delete(aIndex);	
   191 	iItemArray->InsertL(aIndex, iListboxFormatbuffer);
   165 	iItemArray->InsertL(aIndex, iListboxFormatbuffer);
       
   166 	iListContainer->SetTextArray(iItemArray);
   192 	iListContainer->Listbox()->ItemDrawer()->SetPropertiesL(aIndex, itemProps);
   167 	iListContainer->Listbox()->ItemDrawer()->SetPropertiesL(aIndex, itemProps);
   193 	// If item is visible, redraw it
   168 	// If item is visible, redraw it
   194 	if (iListContainer->Listbox()->TopItemIndex() <= aIndex
   169 	if (iListContainer->Listbox()->TopItemIndex() <= aIndex
   195 			&& iListContainer->Listbox()->BottomItemIndex() >= aIndex)
   170 			&& iListContainer->Listbox()->BottomItemIndex() >= aIndex)
   196 		{
   171 		{
   347 			{
   322 			{
   348 			iItemIdArray.Remove(listboxIdx);
   323 			iItemIdArray.Remove(listboxIdx);
   349 			iItemIdArray.InsertL(aFeedUid, feedsIdx);
   324 			iItemIdArray.InsertL(aFeedUid, feedsIdx);
   350 			iItemArray->Delete(listboxIdx);
   325 			iItemArray->Delete(listboxIdx);
   351 			iItemArray->InsertL(feedsIdx, KNullDesC);
   326 			iItemArray->InsertL(feedsIdx, KNullDesC);
       
   327 			iListContainer->SetTextArray(iItemArray);
   352 			iListContainer->Listbox()->HandleItemAdditionL();
   328 			iListContainer->Listbox()->HandleItemAdditionL();
   353 			}
   329 			}
   354 		// Update the listbox info
   330 		// Update the listbox info
   355 		UpdateFeedInfoDataL(feeds[feedsIdx], feedsIdx, aIsUpdating);
   331 		UpdateFeedInfoDataL(feeds[feedsIdx], feedsIdx, aIsUpdating);
   356 		//TODO sort the listbox after update
   332 		//TODO sort the listbox after update
   440 
   416 
   441 	if (unplayedShows.Length() > 0 && updatedDate.Length() > 0) {
   417 	if (unplayedShows.Length() > 0 && updatedDate.Length() > 0) {
   442 		unplayedShows.Insert(0,_L(", "));
   418 		unplayedShows.Insert(0,_L(", "));
   443 	}
   419 	}
   444 		
   420 		
   445 	if (iListContainer->IsLandscape())
   421 	iListboxFormatbuffer.Format(KFeedFormatPortrait(), iconIndex, &(aFeedInfo.Title()), &updatedDate,  &unplayedShows);
   446 		{
       
   447 		iListboxFormatbuffer.Format(KFeedFormatLandscape(), iconIndex, &(aFeedInfo.Title()));
       
   448 		}
       
   449 	else 
       
   450 		{
       
   451 		iListboxFormatbuffer.Format(KFeedFormatPortrait(), iconIndex, &(aFeedInfo.Title()), &updatedDate,  &unplayedShows);
       
   452 		}
       
   453 	}
   422 	}
   454 
   423 
   455 void CPodcastFeedView::ImageOperationCompleteL(TInt aError, TUint aHandle, CPodcastModel& /*aPodcastModel*/)
   424 void CPodcastFeedView::ImageOperationCompleteL(TInt aError, TUint aHandle, CPodcastModel& /*aPodcastModel*/)
   456 	{
   425 	{
   457 	if (aError == KErrNone) {
   426 	if (aError == KErrNone) {
   486 	{
   455 	{
   487 	DP("CPodcastFeedView::UpdateListboxItemsL BEGIN");
   456 	DP("CPodcastFeedView::UpdateListboxItemsL BEGIN");
   488 	// No reason to do any work if it isn't going to show..
   457 	// No reason to do any work if it isn't going to show..
   489 	if(!iListContainer->IsVisible())
   458 	if(!iListContainer->IsVisible())
   490 		{
   459 		{
   491 		DP("not visible");
       
   492 		return;
   460 		return;
   493 		}
   461 		}
   494 	
   462 	
   495 	TInt nbrItems = iPodcastModel.FeedEngine().GetSortedFeeds().Count();
   463 	TInt nbrItems = iPodcastModel.FeedEngine().GetSortedFeeds().Count();
   496 	if (nbrItems > 0)
   464 	if (nbrItems > 0)
   530 		TListItemProperties itemProps;
   498 		TListItemProperties itemProps;
   531 		itemProps.SetDimmed(ETrue);
   499 		itemProps.SetDimmed(ETrue);
   532 		itemProps.SetHiddenSelection(ETrue);								
   500 		itemProps.SetHiddenSelection(ETrue);								
   533 		iListContainer->Listbox()->ItemDrawer()->SetPropertiesL(0, itemProps);
   501 		iListContainer->Listbox()->ItemDrawer()->SetPropertiesL(0, itemProps);
   534 		}
   502 		}
       
   503 	iListContainer->SetTextArray(iItemArray);
   535 	iListContainer->Listbox()->HandleItemAdditionL();
   504 	iListContainer->Listbox()->HandleItemAdditionL();
   536 	DP("CPodcastFeedView::UpdateListboxItemsL END");
   505 	DP("CPodcastFeedView::UpdateListboxItemsL END");
   537 	}
   506 	}
   538 
   507 
   539 /** 
   508 /**