application/src/PodcastAppui.cpp
changeset 24 ca50ea154990
parent 16 7a4b769d94c8
child 35 66c5303f3610
child 48 f8fd68d71cfd
child 64 b52f6033af15
equal deleted inserted replaced
23:cf4b850bbffb 24:ca50ea154990
    77     DP("CPodcastAppUi::ConstructL() END");
    77     DP("CPodcastAppUi::ConstructL() END");
    78     }
    78     }
    79 
    79 
    80 CPodcastAppUi::~CPodcastAppUi()
    80 CPodcastAppUi::~CPodcastAppUi()
    81     {
    81     {
    82     if(iNaviDecorator)
    82     if (iNaviStyle != ENaviEmpty)
    83     	{
    83     	{
    84     	iNaviPane->Pop(iNaviDecorator);
    84     	iNaviPane->Pop();
    85     	delete iNaviDecorator;
       
    86     	}
    85     	}
       
    86 
       
    87     if(iNaviTabGroup)
       
    88     	{
       
    89     	delete iNaviTabGroup;
       
    90     	}
       
    91     
       
    92     if (iNaviText)
       
    93     	{
       
    94     	delete iNaviText;
       
    95     	}
       
    96     
    87 	delete iStartTimer;
    97 	delete iStartTimer;
    88     }
    98     }
    89 
    99 
    90 // -----------------------------------------------------------------------------
   100 // -----------------------------------------------------------------------------
    91 // CPodcastAppUi::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
   101 // CPodcastAppUi::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
   147 	
   157 	
   148     CleanupStack::Pop(array);
   158     CleanupStack::Pop(array);
   149     return array;
   159     return array;
   150 	}
   160 	}
   151 
   161 
       
   162 void CPodcastAppUi::NaviSetTextL(TInt aResourceId)
       
   163 	{
       
   164 	
       
   165 	if (iNaviStyle != ENaviEmpty) {
       
   166 		iNaviPane->Pop();
       
   167 	}
       
   168 
       
   169 	HBufC* naviText =  iEikonEnv->AllocReadResourceLC(aResourceId);
       
   170 	iNaviText  = iNaviPane->CreateNavigationLabelL(*naviText);
       
   171 	
       
   172 	iNaviPane->PushL(*iNaviText);
       
   173 
       
   174 	CleanupStack::PopAndDestroy(naviText);	
       
   175 	
       
   176 	iNaviStyle = ENaviText;
       
   177 	}
       
   178 
   152 void CPodcastAppUi::NaviShowTabGroupL()
   179 void CPodcastAppUi::NaviShowTabGroupL()
   153 	{
   180 	{
   154 	iNaviDecorator = iNaviPane->CreateTabGroupL();
   181 	if (iNaviStyle != ENaviEmpty) {
   155 	
   182 		iNaviPane->Pop();
   156 	iTabGroup = STATIC_CAST(CAknTabGroup*, iNaviDecorator->DecoratedControl());
   183 	}
       
   184 	
       
   185 	iNaviTabGroup = iNaviPane->CreateTabGroupL();
       
   186 	
       
   187 	iTabGroup = STATIC_CAST(CAknTabGroup*, iNaviTabGroup->DecoratedControl());
   157 	iTabGroup->SetTabFixedWidthL(EAknTabWidthWithTwoTabs);
   188 	iTabGroup->SetTabFixedWidthL(EAknTabWidthWithTwoTabs);
   158 
   189 
   159 	HBufC *label1 = iEikonEnv->AllocReadResourceLC(R_TABGROUP_FEEDS);
   190 	HBufC *label1 = iEikonEnv->AllocReadResourceLC(R_TABGROUP_FEEDS);
   160 	iTabGroup->AddTabL(KTabIdFeeds,*label1);
   191 	iTabGroup->AddTabL(KTabIdFeeds,*label1);
   161 		
   192 		
   166 	CleanupStack::PopAndDestroy(label1);
   197 	CleanupStack::PopAndDestroy(label1);
   167 	
   198 	
   168 	iTabGroup->SetActiveTabByIndex(0);
   199 	iTabGroup->SetActiveTabByIndex(0);
   169 	iTabGroup->SetObserver(this);
   200 	iTabGroup->SetObserver(this);
   170 
   201 
   171 	iNaviPane->Pop();
   202 	iNaviPane->PushL(*iNaviTabGroup);
   172 	SetTabsVisibleL(ETrue);
   203 	iNaviStyle = ENaviTabGroup;
   173 	
   204 
   174 	UpdateQueueTab(iPodcastModel->ShowEngine().GetNumDownloadingShows());
   205 	UpdateQueueTab(iPodcastModel->ShowEngine().GetNumDownloadingShows());
   175 	}
   206 	}
   176 
   207 
   177 void CPodcastAppUi::TabChangedL (TInt aIndex)
   208 void CPodcastAppUi::TabChangedL (TInt aIndex)
   178 	{
   209 	{
   179 	DP("CPodcastListView::TabChangedL ");
   210 	DP("CPodcastListView::TabChangedL ");
   180 	
   211 	
   181 	if (!iTabsVisible)
   212 	if (iNaviStyle == ENaviTabGroup)
   182 		{
   213 		{
   183 		return;
   214 		TUid newview = TUid::Uid(0);
   184 		}
   215 		TUid messageUid = TUid::Uid(0);
   185 	
   216 		
   186 	TUid newview = TUid::Uid(0);
   217 		if (aIndex == KTabIdFeeds) {
   187 	TUid messageUid = TUid::Uid(0);
   218 			newview = KUidPodcastFeedViewID;
   188 	
   219 		} else if (aIndex == KTabIdQueue) {
   189 	if (aIndex == KTabIdFeeds) {
   220 			newview = KUidPodcastQueueViewID;
   190 		newview = KUidPodcastFeedViewID;
   221 		} else {
   191 	} else if (aIndex == KTabIdQueue) {
   222 			User::Leave(KErrTooBig);
   192 		newview = KUidPodcastQueueViewID;
   223 		}
   193 	} else {
   224 		
   194 		User::Leave(KErrTooBig);
   225 		if(newview.iUid != 0)
   195 	}
   226 			{			
   196 	
   227 			ActivateLocalViewL(newview,  messageUid, KNullDesC8());
   197 	if(newview.iUid != 0)
   228 			}
   198 		{			
       
   199 		ActivateLocalViewL(newview,  messageUid, KNullDesC8());
       
   200 		}
   229 		}
   201 	}
   230 	}
   202 
   231 
   203 void CPodcastAppUi::SetActiveTab(TInt aIndex) {
   232 void CPodcastAppUi::SetActiveTab(TInt aIndex) {
   204 	iTabGroup->SetActiveTabByIndex(aIndex);
   233 	if (iNaviStyle == ENaviTabGroup)
       
   234 		{
       
   235 		iTabGroup->SetActiveTabByIndex(aIndex);
       
   236 		}
   205 }
   237 }
   206 
   238 
   207 void CPodcastAppUi::HandleTimeout(const CTimeout& /*aId*/, TInt /*aError*/)
   239 void CPodcastAppUi::HandleTimeout(const CTimeout& /*aId*/, TInt /*aError*/)
   208 	{
   240 	{
   209 	iFeedView->CheckResumeDownload();
   241 	iFeedView->CheckResumeDownload();
   210 	}
   242 	}
   211 
   243 
   212 void CPodcastAppUi::UpdateQueueTab(TInt aQueueLength)
   244 void CPodcastAppUi::UpdateQueueTab(TInt aQueueLength)
   213 	{
   245 	{
   214 	if (aQueueLength == 0)
   246 	if (iNaviStyle == ENaviTabGroup)
   215 		{
   247 		{
   216 		HBufC *queue = iEikonEnv->AllocReadResourceLC(R_TABGROUP_QUEUE);
   248 		if (aQueueLength == 0)
   217 		iTabGroup->ReplaceTabL(KTabIdQueue, *queue);
   249 			{
   218 		CleanupStack::PopAndDestroy(queue);
   250 			HBufC *queue = iEikonEnv->AllocReadResourceLC(R_TABGROUP_QUEUE);
   219 		}
   251 			iTabGroup->ReplaceTabL(KTabIdQueue, *queue);
   220 	else
   252 			CleanupStack::PopAndDestroy(queue);
   221 		{
   253 			}
   222 		HBufC *queueTemplate = iEikonEnv->AllocReadResourceLC(R_TABGROUP_QUEUE_COUNTER);
   254 		else
   223 		HBufC *queueCounter = HBufC::NewLC(queueTemplate->Length()+2);
   255 			{
   224 		queueCounter->Des().Format(*queueTemplate, aQueueLength);
   256 			HBufC *queueTemplate = iEikonEnv->AllocReadResourceLC(R_TABGROUP_QUEUE_COUNTER);
   225 		
   257 			HBufC *queueCounter = HBufC::NewLC(queueTemplate->Length()+2);
   226 		iTabGroup->ReplaceTabL(KTabIdQueue, *queueCounter);
   258 			queueCounter->Des().Format(*queueTemplate, aQueueLength);
   227 		CleanupStack::PopAndDestroy(queueCounter);
   259 			
   228 		CleanupStack::PopAndDestroy(queueTemplate);	
   260 			iTabGroup->ReplaceTabL(KTabIdQueue, *queueCounter);
       
   261 			CleanupStack::PopAndDestroy(queueCounter);
       
   262 			CleanupStack::PopAndDestroy(queueTemplate);	
       
   263 			}
   229 		}
   264 		}
   230 	}
   265 	}
   231 
   266 
   232 void CPodcastAppUi::TabLeft()
   267 void CPodcastAppUi::TabLeft()
   233 	{
   268 	{
   234 	if (!iTabsVisible)
   269 	if (iNaviStyle == ENaviTabGroup) 
   235 		{
   270 		{
   236 		return;
   271 		TInt ati = iTabGroup->ActiveTabIndex();
   237 		}
   272 		if(ati > 0)
   238 	
   273 			{
   239 	TInt ati = iTabGroup->ActiveTabIndex();
   274 			SetActiveTab(ati-1);
   240 	if(ati > 0) {
   275 			TabChangedL(ati-1);
   241 		SetActiveTab(ati-1);
   276 			}
   242 		TabChangedL(ati-1);
   277 		}
   243 	}
       
   244 	}
   278 	}
   245 
   279 
   246 void CPodcastAppUi::TabRight()
   280 void CPodcastAppUi::TabRight()
   247 	{
   281 	{
   248 	if (!iTabsVisible)
   282 	if (iNaviStyle == ENaviTabGroup) 
   249 		{
   283 		{
   250 		return;
   284 		TInt ati = iTabGroup->ActiveTabIndex();
   251 		}
   285 		if(ati < iTabGroup->TabCount()-1)
   252 	
       
   253 	TInt ati = iTabGroup->ActiveTabIndex();
       
   254 	if(ati < iTabGroup->TabCount()-1) {
       
   255 		SetActiveTab(ati+1);
       
   256 		TabChangedL(ati+1);
       
   257 	}
       
   258 	}
       
   259 
       
   260 void CPodcastAppUi::SetTabsVisibleL(TBool aVisible)
       
   261 	{
       
   262 	if (aVisible)
       
   263 		{
       
   264 		if(!iTabsVisible && iNaviDecorator)
       
   265 			{
   286 			{
   266 			iNaviPane->PushL(*iNaviDecorator);
   287 			SetActiveTab(ati+1);
   267 			}
   288 			TabChangedL(ati+1);
   268 		}
   289 			}
   269 	else if (iTabsVisible) {
   290 		}
   270 		iNaviPane->Pop(iNaviDecorator);
       
   271 	}
       
   272 	
       
   273 	iTabsVisible=aVisible;
       
   274 	}
   291 	}
   275 
   292 
   276 void CPodcastAppUi::ConnectionSelectionStart()
   293 void CPodcastAppUi::ConnectionSelectionStart()
   277 	{
   294 	{
   278 	DP("CPodcastAppUi::ConnectionSelectionStart()");
   295 	DP("CPodcastAppUi::ConnectionSelectionStart()");