application/src/PodcastQueueView.cpp
branch3rded
changeset 175 cd124c4eb6b9
parent 173 8466fe8528b6
child 177 269e3f3e544a
equal deleted inserted replaced
174:982b1ad423f4 175:cd124c4eb6b9
    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 	
    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();
    70 	CleanupStack::PopAndDestroy();
    76 
    71 
    77 	SetEmptyTextL(R_PODCAST_EMPTY_QUEUE);
    72 	SetEmptyTextL(R_PODCAST_EMPTY_QUEUE);
    78 	}
    73 	}
    79 
    74 
    97 				HandleCommandL(EPodcastRemoveDownload);
    92 				HandleCommandL(EPodcastRemoveDownload);
    98 				break;
    93 				break;
    99 			default:
    94 			default:
   100 				break;
    95 				break;
   101 			}
    96 			}
   102 			UpdateToolbar();
       
   103 		}
    97 		}
   104 	}
    98 	}
   105 		return CPodcastListView::OfferKeyEventL(aKeyEvent, aType);
    99 		return CPodcastListView::OfferKeyEventL(aKeyEvent, aType);
   106 	}
   100 	}
   107 
   101 
   108 CPodcastQueueView::~CPodcastQueueView()
   102 CPodcastQueueView::~CPodcastQueueView()
   109 	{
   103 	{
   110 	iPodcastModel.ShowEngine().RemoveObserver(this);
   104 	iPodcastModel.ShowEngine().RemoveObserver(this);
   111 	iPodcastModel.FeedEngine().RemoveObserver(this);
   105 	iPodcastModel.FeedEngine().RemoveObserver(this);
   112 	
       
   113     if(iStylusPopupMenu)
       
   114         delete iStylusPopupMenu, iStylusPopupMenu = NULL;
       
   115 	}
   106 	}
   116 
   107 
   117 
   108 
   118 TUid CPodcastQueueView::Id() const
   109 TUid CPodcastQueueView::Id() const
   119 	{
   110 	{
   127 	
   118 	
   128 	CPodcastListView::DoActivateL(aPrevViewId, aCustomMessageId, aCustomMessage);
   119 	CPodcastListView::DoActivateL(aPrevViewId, aCustomMessageId, aCustomMessage);
   129 	iPreviousView = aPrevViewId;
   120 	iPreviousView = aPrevViewId;
   130 	
   121 	
   131 	UpdateFeedUpdateStateL();
   122 	UpdateFeedUpdateStateL();
   132 	UpdateToolbar();
       
   133 	DP("CPodcastQueueView::DoActivateL END");
   123 	DP("CPodcastQueueView::DoActivateL END");
   134 	}
   124 	}
   135 
   125 
   136 void CPodcastQueueView::DoDeactivate()
   126 void CPodcastQueueView::DoDeactivate()
   137 	{
   127 	{
   148 		case EEventItemDoubleClicked:
   138 		case EEventItemDoubleClicked:
   149 			break;
   139 			break;
   150 		default:
   140 		default:
   151 			break;
   141 			break;
   152 		}
   142 		}
   153 		UpdateToolbar();
       
   154 	}
   143 	}
   155 
   144 
   156 void CPodcastQueueView::UpdateListboxItemsL()
   145 void CPodcastQueueView::UpdateListboxItemsL()
   157 	{
   146 	{
   158 	if (iListContainer->IsVisible())
   147 	if (iListContainer->IsVisible())
   315 			break;
   304 			break;
   316 		default:
   305 		default:
   317 			CPodcastListView::HandleCommandL(aCommand);
   306 			CPodcastListView::HandleCommandL(aCommand);
   318 			break;
   307 			break;
   319 		}
   308 		}
   320 	iListContainer->SetLongTapDetectedL(EFalse); // in case we got here by long tapping
       
   321 	UpdateToolbar();
       
   322 	}
   309 	}
   323 	
   310 	
   324 void CPodcastQueueView::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
   311 void CPodcastQueueView::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
   325 	{
   312 	{
   326 	if(aResourceId == R_PODCAST_SHOWSVIEW_MENU)
   313 	if(aResourceId == R_PODCAST_SHOWSVIEW_MENU)
   327 		{
   314 		{
   328 		aMenuPane->SetItemDimmed(EPodcastMarkAllPlayed, ETrue);
   315 		aMenuPane->SetItemDimmed(EPodcastMarkAllPlayed, ETrue);
   329 		}
   316 		}
   330 	}
   317 	}
   331 
       
   332 void CPodcastQueueView::UpdateToolbar(TBool aVisible)
       
   333 	{
       
   334 	CAknToolbar* toolbar = Toolbar();
       
   335 	
       
   336 	if (toolbar)
       
   337 		{
       
   338 		RShowInfoArray &fItems = iPodcastModel.ActiveShowList();
       
   339 		TInt itemCnt = fItems.Count();
       
   340 		if (iListContainer->IsVisible()) 
       
   341 			{
       
   342 			toolbar->SetToolbarVisibility(aVisible);
       
   343 			}
       
   344 		
       
   345 		toolbar->HideItem(EPodcastRemoveAllDownloads, EFalse, ETrue);
       
   346 		toolbar->SetItemDimmed(EPodcastRemoveAllDownloads, itemCnt == 0, ETrue);
       
   347 		toolbar->HideItem(EPodcastSuspendDownloads,iPodcastModel.SettingsEngine().DownloadSuspended(), ETrue);
       
   348 		toolbar->HideItem(EPodcastResumeDownloads,!iPodcastModel.SettingsEngine().DownloadSuspended(), ETrue);	
       
   349 		toolbar->SetItemDimmed(EPodcastRemoveDownload, itemCnt == 0, ETrue);		
       
   350 		}
       
   351 	}
       
   352 
       
   353 void CPodcastQueueView::HandleLongTapEventL( const TPoint& aPenEventLocation, const TPoint& /* aPenEventScreenLocation */)
       
   354 {
       
   355 	DP("CPodcastQueueView::HandleLongTapEventL BEGIN");
       
   356 	iListContainer->SetLongTapDetectedL(ETrue);
       
   357 	
       
   358 	const TInt KListboxDefaultHeight = 19; // for some reason it returns 19 for an empty listbox in S^1
       
   359 	TInt lbHeight = iListContainer->Listbox()->CalcHeightBasedOnNumOfItems(
       
   360 			iListContainer->Listbox()->Model()->NumberOfItems()) - KListboxDefaultHeight;
       
   361 
       
   362     if(iStylusPopupMenu && aPenEventLocation.iY < lbHeight)
       
   363     {
       
   364 		TBool dimDown = (iListContainer->Listbox()->CurrentItemIndex() >= iPodcastModel.ActiveShowList().Count() - 1 ?
       
   365 				ETrue : EFalse);
       
   366 		TBool dimUp = (iListContainer->Listbox()->CurrentItemIndex() <= 0 ?
       
   367 				ETrue : EFalse);
       
   368 		
       
   369 		iStylusPopupMenu->SetItemDimmed(EPodcastMoveDownloadDown, dimDown);
       
   370 		iStylusPopupMenu->SetItemDimmed(EPodcastMoveDownloadUp, dimUp);
       
   371 		
       
   372 		iStylusPopupMenu->ShowMenu();
       
   373 		iStylusPopupMenu->SetPosition(aPenEventLocation);
       
   374     }
       
   375     
       
   376 	DP("CPodcastQueueView::HandleLongTapEventL END");
       
   377 }