application/src/PodcastShowsView.cpp
branch3rded
changeset 175 cd124c4eb6b9
parent 166 58268495eb35
child 177 269e3f3e544a
equal deleted inserted replaced
174:982b1ad423f4 175:cd124c4eb6b9
   113 	iListContainer->Listbox()->SetListBoxObserver(this);
   113 	iListContainer->Listbox()->SetListBoxObserver(this);
   114 	
   114 	
   115 	iPodcastModel.FeedEngine().AddObserver(this);
   115 	iPodcastModel.FeedEngine().AddObserver(this);
   116 	iPodcastModel.ShowEngine().AddObserver(this);
   116 	iPodcastModel.ShowEngine().AddObserver(this);
   117 	
   117 	
   118 	iStylusPopupMenu = CAknStylusPopUpMenu::NewL( this , TPoint(0,0));
       
   119 	TResourceReader reader;
       
   120 	iCoeEnv->CreateResourceReaderLC(reader,R_SHOWVIEW_POPUP_MENU);
       
   121 	iStylusPopupMenu->ConstructFromResourceL(reader);
       
   122 
       
   123 	CleanupStack::PopAndDestroy();	
   118 	CleanupStack::PopAndDestroy();	
   124 	}
   119 	}
   125 
   120 
   126 void CPodcastShowsView::CreateIconsL()
   121 void CPodcastShowsView::CreateIconsL()
   127 	{
   122 	{
   186 					HandleCommandL(EPodcastDeleteShow);
   181 					HandleCommandL(EPodcastDeleteShow);
   187 				break;
   182 				break;
   188 			default:
   183 			default:
   189 				break;
   184 				break;
   190 			}
   185 			}
   191 			UpdateToolbar();
       
   192 		}
   186 		}
   193 	}
   187 	}
   194 		return CPodcastListView::OfferKeyEventL(aKeyEvent, aType);
   188 		return CPodcastListView::OfferKeyEventL(aKeyEvent, aType);
   195 	}
   189 	}
   196 
   190 
   197 CPodcastShowsView::~CPodcastShowsView()
   191 CPodcastShowsView::~CPodcastShowsView()
   198 	{
   192 	{
   199 	iPodcastModel.ShowEngine().RemoveObserver(this);
   193 	iPodcastModel.ShowEngine().RemoveObserver(this);
   200 	iPodcastModel.FeedEngine().RemoveObserver(this);
   194 	iPodcastModel.FeedEngine().RemoveObserver(this);
   201 	
   195 	
   202     if(iStylusPopupMenu)
       
   203         delete iStylusPopupMenu, iStylusPopupMenu = NULL;
       
   204 	}
   196 	}
   205 
   197 
   206 
   198 
   207 TUid CPodcastShowsView::Id() const
   199 TUid CPodcastShowsView::Id() const
   208 	{
   200 	{
   217 	
   209 	
   218 	iPreviousView = TVwsViewId(KUidPodcast, KUidPodcastFeedViewID);
   210 	iPreviousView = TVwsViewId(KUidPodcast, KUidPodcastFeedViewID);
   219 	
   211 	
   220 	UpdateViewTitleL();
   212 	UpdateViewTitleL();
   221 	UpdateFeedUpdateStateL();
   213 	UpdateFeedUpdateStateL();
   222 	UpdateToolbar();
       
   223 	DP("CPodcastShowsView::DoActivateL END");
   214 	DP("CPodcastShowsView::DoActivateL END");
   224 	}
   215 	}
   225 
   216 
   226 void CPodcastShowsView::DoDeactivate()
   217 void CPodcastShowsView::DoDeactivate()
   227 	{
   218 	{
   288 	// started instead of checking feed engine states in UpdateFeedUpdateStateL.
   279 	// started instead of checking feed engine states in UpdateFeedUpdateStateL.
   289 	if (iPodcastModel.ActiveFeedInfo() != NULL
   280 	if (iPodcastModel.ActiveFeedInfo() != NULL
   290 			&& iPodcastModel.ActiveFeedInfo()->Uid() == aFeedUid)
   281 			&& iPodcastModel.ActiveFeedInfo()->Uid() == aFeedUid)
   291 		{
   282 		{
   292 		UpdateFeedUpdateStateL();
   283 		UpdateFeedUpdateStateL();
   293 		UpdateToolbar();
       
   294 		}	
   284 		}	
   295 	}
   285 	}
   296 
   286 
   297 void CPodcastShowsView::FeedDownloadFinishedL(TFeedState /*aState*/, TUint aFeedUid, TInt /*aError*/)
   287 void CPodcastShowsView::FeedDownloadFinishedL(TFeedState /*aState*/, TUint aFeedUid, TInt /*aError*/)
   298 	{
   288 	{
   352 			}
   342 			}
   353 			break;
   343 			break;
   354 		default:
   344 		default:
   355 			break;
   345 			break;
   356 		}
   346 		}
   357 		UpdateToolbar();
       
   358 	}
   347 	}
   359 
   348 
   360 void CPodcastShowsView::GetShowIcons(CShowInfo* aShowInfo, TInt& aIconIndex)
   349 void CPodcastShowsView::GetShowIcons(CShowInfo* aShowInfo, TInt& aIconIndex)
   361 	{
   350 	{
   362 	TBool dlStop = iPodcastModel.SettingsEngine().DownloadSuspended();
   351 	TBool dlStop = iPodcastModel.SettingsEngine().DownloadSuspended();
   408 	if ((iListContainer->Listbox()->IsDimmed() && !listboxDimmed) || (!iListContainer->Listbox()->IsDimmed() && listboxDimmed))
   397 	if ((iListContainer->Listbox()->IsDimmed() && !listboxDimmed) || (!iListContainer->Listbox()->IsDimmed() && listboxDimmed))
   409 		{
   398 		{
   410 		iListContainer->Listbox()->SetDimmed(listboxDimmed);
   399 		iListContainer->Listbox()->SetDimmed(listboxDimmed);
   411 		}
   400 		}
   412 	UpdateListboxItemsL();
   401 	UpdateListboxItemsL();
   413 	UpdateToolbar();
       
   414 	}
   402 	}
   415 
   403 
   416 void CPodcastShowsView::FormatShowInfoListBoxItemL(CShowInfo& aShowInfo, TInt aSizeDownloaded)
   404 void CPodcastShowsView::FormatShowInfoListBoxItemL(CShowInfo& aShowInfo, TInt aSizeDownloaded)
   417 	{
   405 	{
   418 	TBuf<32> infoSize;
   406 	TBuf<32> infoSize;
   642 			break;	
   630 			break;	
   643 		default:
   631 		default:
   644 			CPodcastListView::HandleCommandL(aCommand);
   632 			CPodcastListView::HandleCommandL(aCommand);
   645 			break;
   633 			break;
   646 		}
   634 		}
   647 	iListContainer->SetLongTapDetectedL(EFalse);
       
   648 
       
   649 	UpdateToolbar();
       
   650 	}
   635 	}
   651 	
   636 	
   652 void CPodcastShowsView::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
   637 void CPodcastShowsView::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
   653 {
   638 {
   654 	if(aResourceId == R_PODCAST_SHOWSVIEW_MENU)
   639 	if(aResourceId == R_PODCAST_SHOWSVIEW_MENU)
   672 							
   657 							
   673 		note->PrepareLC( R_SHOW_INFO_NOTE ); // Adds to CleanupStack
   658 		note->PrepareLC( R_SHOW_INFO_NOTE ); // Adds to CleanupStack
   674 		note->RunLD();
   659 		note->RunLD();
   675 		}
   660 		}
   676 	}
   661 	}
   677 
       
   678 void CPodcastShowsView::UpdateToolbar(TBool aVisible)
       
   679 {
       
   680 	CAknToolbar* toolbar = Toolbar();
       
   681 
       
   682 	if (toolbar) {
       
   683 		if (iListContainer->IsVisible()) {
       
   684 			toolbar->SetToolbarVisibility(aVisible);
       
   685 		}
       
   686 	
       
   687 		TBool updatingState = iPodcastModel.FeedEngine().ClientState() != EIdle && iPodcastModel.ActiveFeedInfo() && 
       
   688 				iPodcastModel.FeedEngine().ActiveClientUid() == iPodcastModel.ActiveFeedInfo()->Uid();
       
   689 	
       
   690 		toolbar->HideItem(EPodcastUpdateFeed, updatingState, ETrue ); 
       
   691 		toolbar->HideItem(EPodcastCancelUpdateAllFeeds, !updatingState, ETrue );
       
   692 		RShowInfoArray &fItems = iPodcastModel.ActiveShowList();
       
   693 		TInt itemCnt = fItems.Count();
       
   694 	
       
   695 		TBool hideDownloadShowCmd = EFalse;
       
   696 		TBool dimDownloadShowCmd = EFalse;
       
   697 		TBool hideSetPlayed = EFalse;
       
   698 	
       
   699 		if(iListContainer->Listbox() != NULL)
       
   700 		{
       
   701 			TInt index = iListContainer->Listbox()->CurrentItemIndex();
       
   702 			
       
   703 			if(index>= 0 && index < itemCnt)
       
   704 			{
       
   705 				switch(fItems[index]->DownloadState())
       
   706 					{
       
   707 					case ENotDownloaded:
       
   708 					case EFailedDownload:
       
   709 						hideDownloadShowCmd = EFalse;
       
   710 						dimDownloadShowCmd = EFalse;
       
   711 						break;
       
   712 					case EQueued:
       
   713 					case EDownloading:
       
   714 						hideDownloadShowCmd = EFalse;
       
   715 						dimDownloadShowCmd = ETrue;
       
   716 						break;
       
   717 					case EDownloaded:
       
   718 						hideDownloadShowCmd = ETrue;
       
   719 						break;
       
   720 					}
       
   721 					
       
   722 				if(fItems[index]->PlayState() == EPlayed) {
       
   723 					hideSetPlayed = ETrue;
       
   724 				}
       
   725 			}
       
   726 		}
       
   727 		
       
   728 		if (hideDownloadShowCmd) {
       
   729 			toolbar->HideItem(EPodcastDownloadShow, ETrue, ETrue );
       
   730 			toolbar->HideItem(EPodcastDeleteShow, EFalse, ETrue);
       
   731 			toolbar->SetItemDimmed(EPodcastDeleteShow, updatingState, ETrue);
       
   732 		} else {
       
   733 			toolbar->HideItem(EPodcastDownloadShow, EFalse, ETrue );
       
   734 			toolbar->HideItem(EPodcastDeleteShow, ETrue, ETrue);
       
   735 			toolbar->SetItemDimmed(EPodcastDownloadShow, updatingState || dimDownloadShowCmd, ETrue);	
       
   736 		}
       
   737 		
       
   738 		if (hideSetPlayed) {
       
   739 			toolbar->HideItem(EPodcastMarkAsPlayed, ETrue, ETrue );
       
   740 			toolbar->HideItem(EPodcastMarkAsUnplayed, EFalse, ETrue );
       
   741 			toolbar->SetItemDimmed(EPodcastMarkAsUnplayed, updatingState, ETrue);
       
   742 		} else {
       
   743 			toolbar->HideItem(EPodcastMarkAsPlayed, EFalse, ETrue );
       
   744 			toolbar->HideItem(EPodcastMarkAsUnplayed, ETrue, ETrue );
       
   745 			toolbar->SetItemDimmed(EPodcastMarkAsPlayed, updatingState, ETrue);
       
   746 		}
       
   747 	}
       
   748 }
       
   749 
       
   750 void CPodcastShowsView::HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& /* aPenEventScreenLocation */)
       
   751 {
       
   752 	DP("CPodcastShowsView::HandleLongTapEventL BEGIN");
       
   753 
       
   754 	iListContainer->SetLongTapDetectedL(ETrue);
       
   755 
       
   756 	const TInt KListboxDefaultHeight = 19; // for some reason it returns 19 for an empty listbox in S^1
       
   757 	TInt lbHeight = iListContainer->Listbox()->CalcHeightBasedOnNumOfItems(
       
   758 			iListContainer->Listbox()->Model()->NumberOfItems()) - KListboxDefaultHeight;
       
   759 
       
   760     if(iStylusPopupMenu && aPenEventLocation.iY < lbHeight)
       
   761     {
       
   762 		TInt index = iListContainer->Listbox()->CurrentItemIndex();
       
   763 		if (index >= 0 && index < iPodcastModel.ActiveShowList().Count())
       
   764 			{
       
   765 			CShowInfo *info = iPodcastModel.ActiveShowList()[index];
       
   766 			TBool hideDownloadShowCmd = info->DownloadState() != ENotDownloaded;
       
   767 			TBool hideDeleteShowCmd = info->DownloadState() != EDownloaded;
       
   768 			TBool hideMarkOld = info->PlayState() == EPlayed;
       
   769 			
       
   770 			iStylusPopupMenu->SetItemDimmed(EPodcastMarkAsPlayed, hideMarkOld);
       
   771 			iStylusPopupMenu->SetItemDimmed(EPodcastMarkAsUnplayed, !hideMarkOld);
       
   772 						
       
   773 			iStylusPopupMenu->SetItemDimmed(EPodcastDownloadShow, hideDownloadShowCmd);
       
   774 			iStylusPopupMenu->SetItemDimmed(EPodcastDeleteShow, hideDeleteShowCmd);
       
   775 			}
       
   776 
       
   777 		iStylusPopupMenu->ShowMenu();
       
   778 		iStylusPopupMenu->SetPosition(aPenEventLocation);
       
   779     }
       
   780 	DP("CPodcastShowsView::HandleLongTapEventL END");
       
   781 }
       
   782 
   662 
   783 void CPodcastShowsView::HandleSetShowPlayedL(TBool aPlayed)
   663 void CPodcastShowsView::HandleSetShowPlayedL(TBool aPlayed)
   784 	{
   664 	{
   785 
   665 
   786 	TInt index = iListContainer->Listbox()->CurrentItemIndex();
   666 	TInt index = iListContainer->Listbox()->CurrentItemIndex();
   829 	}
   709 	}
   830 
   710 
   831 void CPodcastShowsView::FeedUpdateAllCompleteL(TFeedState /*aState*/)
   711 void CPodcastShowsView::FeedUpdateAllCompleteL(TFeedState /*aState*/)
   832 	{
   712 	{
   833 	UpdateListboxItemsL();
   713 	UpdateListboxItemsL();
   834 	UpdateToolbar();
       
   835 	}
   714 	}
   836 
   715 
   837 void CPodcastShowsView::UpdateViewTitleL()
   716 void CPodcastShowsView::UpdateViewTitleL()
   838 	{
   717 	{
   839 	DP("CPodcastShowsView::UpdateViewTitleL BEGIN");
   718 	DP("CPodcastShowsView::UpdateViewTitleL BEGIN");