application/src/PodcastQueueView.cpp
branchsymbian1
changeset 145 cc0182a5da39
parent 70 0a94e3bc0ef2
child 146 78d1b03a94ff
equal deleted inserted replaced
90:d0c0c3e6f7a1 145:cc0182a5da39
    64 		
    64 		
    65 	iListContainer->Listbox()->SetListBoxObserver(this);
    65 	iListContainer->Listbox()->SetListBoxObserver(this);
    66 	
    66 	
    67 	iPodcastModel.FeedEngine().AddObserver(this);
    67 	iPodcastModel.FeedEngine().AddObserver(this);
    68 	iPodcastModel.ShowEngine().AddObserver(this);
    68 	iPodcastModel.ShowEngine().AddObserver(this);
       
    69 	
       
    70 	iStylusPopupMenu = CAknStylusPopUpMenu::NewL( this , TPoint(0,0));
       
    71 	TResourceReader reader;
       
    72 	iCoeEnv->CreateResourceReaderLC(reader,R_QUEUEVIEW_POPUP_MENU);
       
    73 	iStylusPopupMenu->ConstructFromResourceL(reader);
       
    74 
       
    75 	CleanupStack::PopAndDestroy();
    69 	
    76 	
    70 	SetEmptyTextL(R_PODCAST_EMPTY_QUEUE);
    77 	SetEmptyTextL(R_PODCAST_EMPTY_QUEUE);
    71 	}
    78 	}
    72 
    79 
    73 TKeyResponse CPodcastQueueView::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
    80 TKeyResponse CPodcastQueueView::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
   244 				{
   251 				{
   245 				TRAP_IGNORE(iPodcastModel.ShowEngine().RemoveDownloadL(iPodcastModel.ActiveShowList()[index]->Uid()));
   252 				TRAP_IGNORE(iPodcastModel.ShowEngine().RemoveDownloadL(iPodcastModel.ActiveShowList()[index]->Uid()));
   246 				}
   253 				}
   247 			}
   254 			}
   248 			break;
   255 			break;
       
   256 		case EPodcastMoveDownloadUp:
       
   257 			{
       
   258 			TInt index = iListContainer->Listbox()->CurrentItemIndex();
       
   259 			if (index >= 0 && index < iPodcastModel.ActiveShowList().Count())
       
   260 				{
       
   261 				TRAP_IGNORE(iPodcastModel.ShowEngine().MoveDownloadUpL(iPodcastModel.ActiveShowList()[index]->Uid()));
       
   262 				}
       
   263 			UpdateListboxItemsL();
       
   264 			}
       
   265 			break;
       
   266 		case EPodcastMoveDownloadDown:
       
   267 			{
       
   268 			TInt index = iListContainer->Listbox()->CurrentItemIndex();
       
   269 			if (index >= 0 && index < iPodcastModel.ActiveShowList().Count())
       
   270 				{
       
   271 				TRAP_IGNORE(iPodcastModel.ShowEngine().MoveDownloadDownL(iPodcastModel.ActiveShowList()[index]->Uid()));
       
   272 				}
       
   273 			UpdateListboxItemsL();
       
   274 			}
       
   275 			break;
   249 		case EPodcastSuspendDownloads:
   276 		case EPodcastSuspendDownloads:
   250 			{
   277 			{
   251 			iPodcastModel.ShowEngine().SuspendDownloads();
   278 			iPodcastModel.ShowEngine().SuspendDownloads();
   252 			UpdateListboxItemsL();
   279 			UpdateListboxItemsL();
   253 			}
   280 			}
   265 	iListContainer->SetLongTapDetectedL(EFalse); // in case we got here by long tapping
   292 	iListContainer->SetLongTapDetectedL(EFalse); // in case we got here by long tapping
   266 	UpdateToolbar();
   293 	UpdateToolbar();
   267 	}
   294 	}
   268 	
   295 	
   269 void CPodcastQueueView::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
   296 void CPodcastQueueView::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
   270 {
   297 	{
   271 	if(aResourceId == R_PODCAST_SHOWSVIEW_MENU)
   298 	if(aResourceId == R_PODCAST_SHOWSVIEW_MENU)
   272 		{
   299 		{
   273 		aMenuPane->SetItemDimmed(EPodcastMarkAllPlayed, ETrue);
   300 		aMenuPane->SetItemDimmed(EPodcastMarkAllPlayed, ETrue);
   274 		}
   301 		}
   275 }
   302 	}
   276 
   303 
   277 void CPodcastQueueView::UpdateToolbar(TBool aVisible)
   304 void CPodcastQueueView::UpdateToolbar(TBool aVisible)
   278 {
   305 	{
   279 	CAknToolbar* toolbar = Toolbar();
   306 	CAknToolbar* toolbar = Toolbar();
   280 	
   307 	
   281 	if (toolbar) {
   308 	if (toolbar)
       
   309 		{
   282 		RShowInfoArray &fItems = iPodcastModel.ActiveShowList();
   310 		RShowInfoArray &fItems = iPodcastModel.ActiveShowList();
   283 		TInt itemCnt = fItems.Count();
   311 		TInt itemCnt = fItems.Count();
   284 		if (iListContainer->IsVisible()) {
   312 		if (iListContainer->IsVisible()) 
       
   313 			{
   285 			toolbar->SetToolbarVisibility(aVisible);
   314 			toolbar->SetToolbarVisibility(aVisible);
   286 		}
   315 			}
       
   316 		
   287 		toolbar->HideItem(EPodcastRemoveAllDownloads, EFalse, ETrue);
   317 		toolbar->HideItem(EPodcastRemoveAllDownloads, EFalse, ETrue);
   288 		toolbar->SetItemDimmed(EPodcastRemoveAllDownloads, itemCnt == 0, ETrue);
   318 		toolbar->SetItemDimmed(EPodcastRemoveAllDownloads, itemCnt == 0, ETrue);
   289 		toolbar->HideItem(EPodcastSuspendDownloads,iPodcastModel.SettingsEngine().DownloadSuspended(), ETrue);
   319 		toolbar->HideItem(EPodcastSuspendDownloads,iPodcastModel.SettingsEngine().DownloadSuspended(), ETrue);
   290 		toolbar->HideItem(EPodcastResumeDownloads,!iPodcastModel.SettingsEngine().DownloadSuspended(), ETrue);	
   320 		toolbar->HideItem(EPodcastResumeDownloads,!iPodcastModel.SettingsEngine().DownloadSuspended(), ETrue);	
   291 		toolbar->SetItemDimmed(EPodcastRemoveDownload, itemCnt == 0, ETrue);		
   321 		toolbar->SetItemDimmed(EPodcastRemoveDownload, itemCnt == 0, ETrue);		
   292 	}
   322 		}
       
   323 	}
       
   324 
       
   325 void CPodcastQueueView::HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& /* aPenEventScreenLocation */)
       
   326 {
       
   327 	DP("CPodcastQueueView::HandleLongTapEventL BEGIN");
       
   328 	iListContainer->SetLongTapDetectedL(ETrue);
       
   329 	
       
   330 	const TInt KListboxDefaultHeight = 19; // for some reason it returns 19 for an empty listbox in S^1
       
   331 	TInt lbHeight = iListContainer->Listbox()->CalcHeightBasedOnNumOfItems(
       
   332 			iListContainer->Listbox()->Model()->NumberOfItems()) - KListboxDefaultHeight;
       
   333 
       
   334     if(iStylusPopupMenu && aPenEventLocation.iY < lbHeight)
       
   335     {
       
   336 		TBool dimDown = (iListContainer->Listbox()->CurrentItemIndex() >= iPodcastModel.ActiveShowList().Count() - 1 ?
       
   337 				ETrue : EFalse);
       
   338 		TBool dimUp = (iListContainer->Listbox()->CurrentItemIndex() <= 0 ?
       
   339 				ETrue : EFalse);
       
   340 		
       
   341 		iStylusPopupMenu->SetItemDimmed(EPodcastMoveDownloadDown, dimDown);
       
   342 		iStylusPopupMenu->SetItemDimmed(EPodcastMoveDownloadUp, dimUp);
       
   343 		
       
   344 		iStylusPopupMenu->ShowMenu();
       
   345 		iStylusPopupMenu->SetPosition(aPenEventLocation);
       
   346     }
       
   347     
       
   348 	DP("CPodcastQueueView::HandleLongTapEventL END");
   293 }
   349 }