application/src/PodcastQueueView.cpp
branchRCL_3
changeset 243 44d205147a83
parent 185 92eadaba67e6
child 265 72305c65726c
equal deleted inserted replaced
236:f952f3a1a786 243:44d205147a83
    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();
       
    76 
    69 
    77 	SetEmptyTextL(R_PODCAST_EMPTY_QUEUE);
    70 	SetEmptyTextL(R_PODCAST_EMPTY_QUEUE);
    78 	}
    71 	}
    79 
    72 
    80 TKeyResponse CPodcastQueueView::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
    73 TKeyResponse CPodcastQueueView::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
   107 
   100 
   108 CPodcastQueueView::~CPodcastQueueView()
   101 CPodcastQueueView::~CPodcastQueueView()
   109 	{
   102 	{
   110 	iPodcastModel.ShowEngine().RemoveObserver(this);
   103 	iPodcastModel.ShowEngine().RemoveObserver(this);
   111 	iPodcastModel.FeedEngine().RemoveObserver(this);
   104 	iPodcastModel.FeedEngine().RemoveObserver(this);
   112 	
       
   113     if(iStylusPopupMenu)
       
   114         delete iStylusPopupMenu, iStylusPopupMenu = NULL;
       
   115 	}
   105 	}
   116 
   106 
   117 
   107 
   118 TUid CPodcastQueueView::Id() const
   108 TUid CPodcastQueueView::Id() const
   119 	{
   109 	{
   326 			break;
   316 			break;
   327 		default:
   317 		default:
   328 			CPodcastListView::HandleCommandL(aCommand);
   318 			CPodcastListView::HandleCommandL(aCommand);
   329 			break;
   319 			break;
   330 		}
   320 		}
   331 	iListContainer->SetLongTapDetectedL(EFalse); // in case we got here by long tapping
       
   332 	UpdateToolbar();
   321 	UpdateToolbar();
   333 	}
   322 	}
   334 	
   323 	
   335 void CPodcastQueueView::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
   324 void CPodcastQueueView::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
   336 	{
   325 	{
   337 	if(aResourceId == R_PODCAST_SHOWSVIEW_MENU)
   326 	if(aResourceId == R_PODCAST_SHOWSVIEW_MENU)
   338 		{
   327 		{
   339 		aMenuPane->SetItemDimmed(EPodcastMarkAllPlayed, ETrue);
   328 		aMenuPane->SetItemDimmed(EPodcastMarkAllPlayed, ETrue);
       
   329 		
       
   330 		TBool dimDown = (iListContainer->Listbox()->CurrentItemIndex() >= iPodcastModel.ActiveShowList().Count() - 1 ?
       
   331 				ETrue : EFalse);
       
   332 		TBool dimUp = (iListContainer->Listbox()->CurrentItemIndex() <= 0 ?
       
   333 				ETrue : EFalse);
       
   334 		
       
   335 		TInt index = iListContainer->Listbox()->CurrentItemIndex();
       
   336 				
       
   337 		if (index >= 0 && index < iPodcastModel.ActiveShowList().Count())
       
   338 			{			
       
   339 			CShowInfo* info = iPodcastModel.ActiveShowList()[index];
       
   340 			
       
   341 			aMenuPane->SetItemDimmed(EPodcastMoveDownloadDown, dimDown);
       
   342 			aMenuPane->SetItemDimmed(EPodcastMoveDownloadUp, dimUp);
       
   343 			
       
   344 			}
   340 		}
   345 		}
   341 	}
   346 	}
   342 
   347 
   343 void CPodcastQueueView::UpdateToolbar(TBool aVisible)
   348 void CPodcastQueueView::UpdateToolbar(TBool aVisible)
   344 	{
   349 	{
   358 		toolbar->HideItem(EPodcastSuspendDownloads,iPodcastModel.SettingsEngine().DownloadSuspended(), ETrue);
   363 		toolbar->HideItem(EPodcastSuspendDownloads,iPodcastModel.SettingsEngine().DownloadSuspended(), ETrue);
   359 		toolbar->HideItem(EPodcastResumeDownloads,!iPodcastModel.SettingsEngine().DownloadSuspended(), ETrue);	
   364 		toolbar->HideItem(EPodcastResumeDownloads,!iPodcastModel.SettingsEngine().DownloadSuspended(), ETrue);	
   360 		toolbar->SetItemDimmed(EPodcastRemoveDownload, itemCnt == 0, ETrue);		
   365 		toolbar->SetItemDimmed(EPodcastRemoveDownload, itemCnt == 0, ETrue);		
   361 		}
   366 		}
   362 	}
   367 	}
   363 
       
   364 void CPodcastQueueView::HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& /* aPenEventScreenLocation */)
       
   365 {
       
   366 	DP("CPodcastQueueView::HandleLongTapEventL BEGIN");
       
   367 	iListContainer->SetLongTapDetectedL(ETrue);
       
   368 	
       
   369 	const TInt KListboxDefaultHeight = 19; // for some reason it returns 19 for an empty listbox in S^1
       
   370 	TInt lbHeight = iListContainer->Listbox()->CalcHeightBasedOnNumOfItems(
       
   371 			iListContainer->Listbox()->Model()->NumberOfItems()) - KListboxDefaultHeight;
       
   372 
       
   373     if(iStylusPopupMenu && aPenEventLocation.iY < lbHeight)
       
   374     {
       
   375 		TBool dimDown = (iListContainer->Listbox()->CurrentItemIndex() >= iPodcastModel.ActiveShowList().Count() - 1 ?
       
   376 				ETrue : EFalse);
       
   377 		TBool dimUp = (iListContainer->Listbox()->CurrentItemIndex() <= 0 ?
       
   378 				ETrue : EFalse);
       
   379 		
       
   380 		iStylusPopupMenu->SetItemDimmed(EPodcastMoveDownloadDown, dimDown);
       
   381 		iStylusPopupMenu->SetItemDimmed(EPodcastMoveDownloadUp, dimUp);
       
   382 		
       
   383 		iStylusPopupMenu->ShowMenu();
       
   384 		iStylusPopupMenu->SetPosition(aPenEventLocation);
       
   385     }
       
   386     
       
   387 	DP("CPodcastQueueView::HandleLongTapEventL END");
       
   388 }