application/src/PodcastSearchView.cpp
branchsymbian1
changeset 336 3d6c1417e8bd
parent 138 6c8c5122867a
child 347 b8d687bb7ca1
equal deleted inserted replaced
296:80f1da5ac28b 336:3d6c1417e8bd
    24 #include "PodcastApp.h"
    24 #include "PodcastApp.h"
    25 #include "PodcastUtils.h"
    25 #include "PodcastUtils.h"
    26 #include <caknfileselectiondialog.h> 
    26 #include <caknfileselectiondialog.h> 
    27 #include <podcast.rsg>
    27 #include <podcast.rsg>
    28 #include <podcast.mbg>
    28 #include <podcast.mbg>
       
    29 #include <akntitle.h>
    29 #include <gulicon.h>
    30 #include <gulicon.h>
    30 #include <eikenv.h>
    31 #include <eikenv.h>
    31 #include <e32const.h>
    32 #include <e32const.h>
    32 #include <eikdialg.h>
    33 #include <eikdialg.h>
    33 #include <aknquerydialog.h>
    34 #include <aknquerydialog.h>
    40 
    41 
    41 const TInt KMaxFeedNameLength = 100;
    42 const TInt KMaxFeedNameLength = 100;
    42 #define KMaxMessageLength 200
    43 #define KMaxMessageLength 200
    43 #define KMaxTitleLength 100
    44 #define KMaxTitleLength 100
    44 _LIT(KSearchResultFormat, "%d\t%S\t%S");
    45 _LIT(KSearchResultFormat, "%d\t%S\t%S");
       
    46 _LIT(KSearchResultFormatLandscape, "%d\t%S");
    45 
    47 
    46 CPodcastSearchView* CPodcastSearchView::NewL(CPodcastModel& aPodcastModel)
    48 CPodcastSearchView* CPodcastSearchView::NewL(CPodcastModel& aPodcastModel)
    47     {
    49     {
    48     CPodcastSearchView* self = CPodcastSearchView::NewLC(aPodcastModel);
    50     CPodcastSearchView* self = CPodcastSearchView::NewLC(aPodcastModel);
    49     CleanupStack::Pop( self );
    51     CleanupStack::Pop( self );
    81 	CleanupStack::PushL( bitmap );		
    83 	CleanupStack::PushL( bitmap );		
    82 	CleanupStack::PushL( mask );		
    84 	CleanupStack::PushL( mask );		
    83 	icons->AppendL( CGulIcon::NewL( bitmap, mask ) );
    85 	icons->AppendL( CGulIcon::NewL( bitmap, mask ) );
    84 	CleanupStack::Pop(2); // bitmap, mask
    86 	CleanupStack::Pop(2); // bitmap, mask
    85 	
    87 	
    86 	iListContainer->Listbox()->ItemDrawer()->FormattedCellData()->SetIconArrayL( icons );
    88 	iListContainer->SetListboxIcons(icons);
    87 	CleanupStack::Pop(icons); // icons
    89 	CleanupStack::Pop(icons); // icons
    88 
       
    89 	iListContainer->Listbox()->SetListBoxObserver(this);
       
    90 	
    90 	
    91 	SetEmptyTextL(R_PODCAST_EMPTY_SEARCH);
    91 	SetEmptyTextL(R_PODCAST_EMPTY_SEARCH);
    92 }
    92 }
    93     
    93     
    94 CPodcastSearchView::~CPodcastSearchView()
    94 CPodcastSearchView::~CPodcastSearchView()
   112 	                                  TUid aCustomMessageId,
   112 	                                  TUid aCustomMessageId,
   113 	                                  const TDesC8& aCustomMessage)
   113 	                                  const TDesC8& aCustomMessage)
   114 {
   114 {
   115 	CPodcastListView::DoActivateL(aPrevViewId, aCustomMessageId, aCustomMessage);
   115 	CPodcastListView::DoActivateL(aPrevViewId, aCustomMessageId, aCustomMessage);
   116 	iPreviousView = TVwsViewId(KUidPodcast, KUidPodcastFeedViewID);
   116 	iPreviousView = TVwsViewId(KUidPodcast, KUidPodcastFeedViewID);
   117 	
   117 		
   118     ((CPodcastAppUi*)AppUi())->NaviSetTextL(R_SEARCH_RESULTS);
   118 	HBufC* text =  iEikonEnv->AllocReadResourceLC(R_SEARCH_RESULTS);
   119     
   119 	 
       
   120 	CAknTitlePane* titlePane = static_cast<CAknTitlePane*>
       
   121 		  ( StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
   122 	
       
   123 	titlePane->SetTextL(*text , ETrue );
       
   124 	CleanupStack::PopAndDestroy(text);
   120 	UpdateListboxItemsL();
   125 	UpdateListboxItemsL();
   121 }
   126 }
   122 
   127 
   123 void CPodcastSearchView::DoDeactivate()
   128 void CPodcastSearchView::DoDeactivate()
   124 {
   129 {
   125 	CPodcastListView::DoDeactivate();
   130 	CPodcastListView::DoDeactivate();
   126 	TRAP_IGNORE(((CPodcastAppUi*)AppUi())->NaviShowTabGroupL());
   131 	
       
   132 	CAknTitlePane* titlePane = static_cast<CAknTitlePane*>
       
   133 			  ( StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
   134 		
       
   135 	titlePane->SetTextToDefaultL();
   127 }
   136 }
   128 
   137 
   129 
   138 
   130 void CPodcastSearchView::HandleListBoxEventL(CEikListBox* /* aListBox */, TListBoxEvent aEventType)
   139 void CPodcastSearchView::HandleListBoxEventL(CEikListBox* /* aListBox */, TListBoxEvent aEventType)
   131 {
   140 {
   155 	const RFeedInfoArray* searchItems = NULL;
   164 	const RFeedInfoArray* searchItems = NULL;
   156 	searchItems = &iPodcastModel.FeedEngine().GetSearchResults();
   165 	searchItems = &iPodcastModel.FeedEngine().GetSearchResults();
   157 	TInt len = searchItems->Count();
   166 	TInt len = searchItems->Count();
   158 	TListItemProperties itemProps;
   167 	TListItemProperties itemProps;
   159 	iListContainer->Listbox()->Reset();
   168 	iListContainer->Listbox()->Reset();
   160 	iListContainer->Listbox()->ItemDrawer()->ClearAllPropertiesL();
   169 	//iListContainer->Listbox()->ItemDrawer()->ClearAllPropertiesL();
   161 	iItemIdArray.Reset();
   170 	iItemIdArray.Reset();
   162 	iItemArray->Reset();
   171 	iItemArray->Reset();
   163 		
   172 		
   164 	if (len > 0) 
   173 	if (len > 0) 
   165 		{
   174 		{
   172 			TBuf<512> descr;
   181 			TBuf<512> descr;
   173 			descr.Copy(fi->Description().Left(512));
   182 			descr.Copy(fi->Description().Left(512));
   174 			PodcastUtils::RemoveAllFormatting(descr);
   183 			PodcastUtils::RemoveAllFormatting(descr);
   175 			iListboxFormatbuffer.Format(KSearchResultFormat(), iconIndex, &fi->Title(), &descr);
   184 			iListboxFormatbuffer.Format(KSearchResultFormat(), iconIndex, &fi->Title(), &descr);
   176 			iItemArray->AppendL(iListboxFormatbuffer);
   185 			iItemArray->AppendL(iListboxFormatbuffer);
   177 			iListContainer->Listbox()->ItemDrawer()->SetPropertiesL(i, itemProps);
   186 			iListboxFormatbufferShort.Format(KSearchResultFormatLandscape(), iconIndex, &fi->Title());
       
   187 			iItemArrayShort->AppendL(iListboxFormatbufferShort);
       
   188 			//iListContainer->Listbox()->ItemDrawer()->SetPropertiesL(i, itemProps);
   178 			}
   189 			}
   179 		} 
   190 		} 
   180 	else 
   191 	else 
   181 		{					
   192 		{					
   182 		TBuf<KMaxFeedNameLength> itemName;
   193 		TBuf<KMaxFeedNameLength> itemName;
   183 		iEikonEnv->ReadResourceL(itemName, R_PODCAST_NO_SEARCH_RESULTS);
   194 		iEikonEnv->ReadResourceL(itemName, R_PODCAST_NO_SEARCH_RESULTS);
   184 		iItemArray->Reset();
   195 		iItemArray->Reset();
       
   196 		iItemArrayShort->Reset();
   185 		iItemIdArray.Reset();
   197 		iItemIdArray.Reset();
   186 
   198 
   187 		TListItemProperties itemProps;
   199 		TListItemProperties itemProps;
   188 		itemProps.SetDimmed(ETrue);
   200 		itemProps.SetDimmed(ETrue);
   189 		itemProps.SetHiddenSelection(ETrue);								
   201 		itemProps.SetHiddenSelection(ETrue);								
   190 		iListContainer->Listbox()->ItemDrawer()->SetPropertiesL(0, itemProps);
   202 		//iListContainer->Listbox()->ItemDrawer()->SetPropertiesL(0, itemProps);
   191 		}
   203 		}
   192 	iListContainer->Listbox()->HandleItemAdditionL();
   204 	iListContainer->Listbox()->HandleItemAdditionL();
   193 	DP("CPodcastSearchView::UpdateListboxItemsL END");
   205 	DP("CPodcastSearchView::UpdateListboxItemsL END");
   194 	}
   206 	}
   195 
   207 
   219 				message.Format(templ, &newInfo->Title());
   231 				message.Format(templ, &newInfo->Title());
   220 				if(ShowQueryMessageL(message)) {
   232 				if(ShowQueryMessageL(message)) {
   221 					TBool added = iPodcastModel.FeedEngine().AddFeedL(*newInfo);
   233 					TBool added = iPodcastModel.FeedEngine().AddFeedL(*newInfo);
   222 					
   234 					
   223 					if (added)
   235 					if (added)
   224 						{					
   236 						{
   225 						// ask if user wants to update it now
   237 						// this is a bit of a hack, first we activate the feeds view normally
   226 						TBuf<KMaxMessageLength> message;
   238 						AppUi()->ActivateLocalViewL(KUidPodcastFeedViewID,  TUid::Uid(0), KNullDesC8);
   227 						iEikonEnv->ReadResourceL(message, R_ADD_FEED_SUCCESS);
   239 						// and then we send the UID of the recently added feed back to feed view for updating
   228 						if(ShowQueryMessageL(message))
   240 						// this is needed so the update? query comes on top of feed view, not search view
   229 							{
   241 						AppUi()->ActivateLocalViewL(KUidPodcastFeedViewID,  TUid::Uid(newInfo->Uid()), KNullDesC8);
   230 							CFeedInfo *info = iPodcastModel.FeedEngine().GetFeedInfoByUid(newInfo->Uid());
       
   231 							
       
   232 							iPodcastModel.SetActiveFeedInfo(info);			
       
   233 							AppUi()->ActivateLocalViewL(KUidPodcastShowsViewID,  TUid::Uid(0), KNullDesC8());
       
   234 							iPodcastModel.FeedEngine().UpdateFeedL(info->Uid());
       
   235 							}
       
   236 						}
   242 						}
   237 					else
   243 					else
   238 						{
   244 						{
   239 						TBuf<KMaxMessageLength> message;
   245 						TBuf<KMaxMessageLength> message;
   240 						iEikonEnv->ReadResourceL(message, R_ADD_FEED_EXISTS);
   246 						iEikonEnv->ReadResourceL(message, R_ADD_FEED_EXISTS);