1 /* |
|
2 * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Container class for Category view |
|
15 * |
|
16 */ |
|
17 |
|
18 /* --------------------------------------------------------------------------- |
|
19 * Version history: |
|
20 * Template version: |
|
21 * <ccm_history> |
|
22 * |
|
23 * Version: 2, Thurs March 20 15:50:00 2008 by Prabina |
|
24 * Ref: |
|
25 * Created new views for the Station Directory Views , Enabled the Touch toolbar functionality , |
|
26 * Help Options enabled |
|
27 * |
|
28 * </ccm_history> |
|
29 * ============================================================================ |
|
30 */ |
|
31 /* --------------------------------------------------------------------------- |
|
32 * Version history: |
|
33 * Template version: |
|
34 * <ccm_history> |
|
35 * |
|
36 * Version: 3, Fri March 21 17:20:00 2008 by Prabina |
|
37 * Ref: |
|
38 * Added WorkAround for supporting different Resolutions , Added Wait Dialog for Loading of stations , |
|
39 * Handled Single/Double tapping on the list itmes |
|
40 * |
|
41 * </ccm_history> |
|
42 * ============================================================================ |
|
43 */ |
|
44 /* --------------------------------------------------------------------------- |
|
45 * Version history: |
|
46 * Template version: |
|
47 * <ccm_history> |
|
48 * |
|
49 * Version: 4, Mon March 24 18:00:00 2008 by Prabina |
|
50 * Ref: |
|
51 * Added WorkAround for adding different stations to favourites list , Added Wait dialog for adding to favourites |
|
52 * |
|
53 * |
|
54 * </ccm_history> |
|
55 * ============================================================================ |
|
56 */ |
|
57 /* --------------------------------------------------------------------------- |
|
58 * Version history: |
|
59 * Template version: |
|
60 * <ccm_history> |
|
61 * |
|
62 * Version: 5, Tues March 25 17:30:00 2008 by Prabina |
|
63 * Ref: |
|
64 * Fixing the PCLint errors |
|
65 * |
|
66 * |
|
67 * </ccm_history> |
|
68 * ============================================================================ |
|
69 */ |
|
70 /* --------------------------------------------------------------------------- |
|
71 * Version history: |
|
72 * Template version: |
|
73 * <ccm_history> |
|
74 * |
|
75 * Version: 6, Tues March 29 10:30:00 2008 by Prabina |
|
76 * Ref: |
|
77 * Category View Container Derived from CCoeControl |
|
78 * |
|
79 * |
|
80 * </ccm_history> |
|
81 * ============================================================================ |
|
82 */ |
|
83 /* --------------------------------------------------------------------------- |
|
84 * Version history: |
|
85 * Template version: |
|
86 * <ccm_history> |
|
87 * |
|
88 * Version: 7, may 7 Wed 08:35:00 2008 by Neelima |
|
89 * Removed change Resoultion function. |
|
90 * changed code in HandleResourcechange and Size changed for handling layout changes |
|
91 * in dynamic filtering |
|
92 * ============================================================================ |
|
93 */ |
|
94 /* --------------------------------------------------------------------------- |
|
95 * Version history: |
|
96 * Template version: |
|
97 * <ccm_history> |
|
98 * |
|
99 * Version: 5, Thurs July 18 12:00:00 2008 by Prabina |
|
100 * Ref: |
|
101 * Code Review Comments Fixed |
|
102 * |
|
103 * |
|
104 * </ccm_history> |
|
105 * ============================================================================ |
|
106 */ |
|
107 |
|
108 #include <akniconarray.h> |
|
109 #include <aknlists.h> |
|
110 #include <aknview.h> |
|
111 #include <barsread.h> |
|
112 #include <eikenv.h> |
|
113 #include <eiklabel.h> |
|
114 #include <eikmenub.h> |
|
115 #include <stringloader.h> |
|
116 #include <internetradio.rsg> |
|
117 #include <eikenv.h> |
|
118 #include <apgcli.h> |
|
119 |
|
120 #include "irui.h" |
|
121 #include "ir.hrh" |
|
122 #include "ircommon.h" |
|
123 #include "irdebug.h" |
|
124 #include "irbaseview.h" |
|
125 #include "ircategoryviewcontainer.h" |
|
126 #include "irapplication.h" |
|
127 #include "ircategoryView.h" |
|
128 #include "iraap.hlp.hrh" |
|
129 #include "irisdswrapper.h" |
|
130 #include "irimageconverter.h" |
|
131 #include "irdataprovider.h" |
|
132 #include "irhttpdataprovider.h" |
|
133 #include "irlogodownloadengine.h" |
|
134 #include <aknsbasicbackgroundcontrolcontext.h> |
|
135 #include "irfilteredmodel.h" |
|
136 #include "mirlistboxarray.h" |
|
137 #include "iradvertisinglistbox.h" |
|
138 #include "irlayoututils.h" |
|
139 |
|
140 /** Mime type when opening web browser */ |
|
141 _LIT8( KIRHtmlMimeType, "text/html" ); |
|
142 /** Browser prefix: See browser API specification */ |
|
143 _LIT( KBrowserPrefix, "4 " ); |
|
144 |
|
145 const TInt KAdvSize = 30; |
|
146 const TSize KLogoSize = TSize(320,350); |
|
147 |
|
148 #define KCONTROLSCOUNT 0 |
|
149 |
|
150 // ==================== LOCAL FUNCTIONS ==================== |
|
151 |
|
152 // ================= MEMBER FUNCTIONS ======================= |
|
153 |
|
154 // ----------------------------------------------------------------------------- |
|
155 // CIRCategoryViewContainer::NewL() |
|
156 // Two-phased constructor. |
|
157 // ----------------------------------------------------------------------------- |
|
158 // |
|
159 CIRCategoryViewContainer* CIRCategoryViewContainer::NewL( CIRCategoryView& aCtaegoryView, |
|
160 const TRect& aRect ) |
|
161 { |
|
162 IRLOG_DEBUG( "CIRCategoryViewContainer::NewL" ); |
|
163 CIRCategoryViewContainer* self = CIRCategoryViewContainer::NewLC( aCtaegoryView, aRect ); |
|
164 CleanupStack::Pop( self ); |
|
165 IRLOG_DEBUG( "CIRCategoryViewContainer::NewL - Exiting" ); |
|
166 return self; |
|
167 } |
|
168 |
|
169 // ----------------------------------------------------------------------------- |
|
170 // CIRCategoryViewContainer::NewLC() |
|
171 // Two-phased constructor. |
|
172 // ----------------------------------------------------------------------------- |
|
173 // |
|
174 CIRCategoryViewContainer* CIRCategoryViewContainer::NewLC( CIRCategoryView& aCtaegoryView, |
|
175 const TRect& aRect ) |
|
176 { |
|
177 IRLOG_DEBUG( "CIRCategoryViewContainer::NewLC" ); |
|
178 CIRCategoryViewContainer* self = new ( ELeave ) CIRCategoryViewContainer(aCtaegoryView); |
|
179 CleanupStack::PushL( self ); |
|
180 self->ConstructL( aRect ); |
|
181 IRLOG_DEBUG( "CIRCategoryViewContainer::NewLC - Exiting" ); |
|
182 return self; |
|
183 } |
|
184 |
|
185 // --------------------------------------------------------------------------- |
|
186 // CIRCategoryViewContainer::CIRCategoryViewContainer() |
|
187 // C++ default constructor can NOT contain any code, that might leave. |
|
188 // --------------------------------------------------------------------------- |
|
189 // |
|
190 CIRCategoryViewContainer::CIRCategoryViewContainer(CIRCategoryView& aCtaegoryView): |
|
191 iCategoryView(aCtaegoryView) |
|
192 { |
|
193 IRLOG_DEBUG( "CIRCategoryViewContainer::CIRCategoryViewContainer" ); |
|
194 iFilteredFlag = EFalse; |
|
195 } |
|
196 |
|
197 // --------------------------------------------------------------------------- |
|
198 // CIRCategoryViewContainer::ConstructL |
|
199 // --------------------------------------------------------------------------- |
|
200 // |
|
201 void CIRCategoryViewContainer::ConstructL( const TRect& aRect) |
|
202 { |
|
203 IRLOG_DEBUG( "CIRCategoryViewContainer::ConstructL - Entering" ); |
|
204 CreateWindowL(); |
|
205 SetRect(aRect); |
|
206 |
|
207 iBgContext = CAknsBasicBackgroundControlContext::NewL(KAknsIIDQsnBgScreen , aRect, ETrue); |
|
208 |
|
209 iAdPresent = EFalse; |
|
210 iConverter = CIRImageConverter::NewL(); |
|
211 iConverter->EnableAnimations( EFalse ); |
|
212 iConverter->SetObserver( this ); |
|
213 |
|
214 iCurrentItemConverter = CIRImageConverter::NewL(); |
|
215 iCurrentItemConverter->SetObserver( this ); |
|
216 |
|
217 // Added For Dynamic Filtering |
|
218 iFilteredModel=new(ELeave) CIRFilteredModel; |
|
219 iFilteredModel->ConstructL(); |
|
220 |
|
221 iListBoxArray = MIRListBoxArray::NewL(); |
|
222 |
|
223 IRLOG_DEBUG( "CIRCategoryViewContainer::ConstructL - Exiting" ); |
|
224 } |
|
225 // --------------------------------------------------------------------------- |
|
226 // CIRCategoryViewContainer::CreateListBoxL() |
|
227 // Creates ListBox depending upon the presence of Advertisement |
|
228 // --------------------------------------------------------------------------- |
|
229 // |
|
230 void CIRCategoryViewContainer::CreateListBoxL() |
|
231 { |
|
232 IRLOG_DEBUG( "CIRCategoryViewContainer::CreateListBoxL - Entering" ); |
|
233 if (iCategoryView.iUi->iIsdsWrapper->iCatBannerUrl) |
|
234 { |
|
235 if((iCategoryView.iUi->iIsdsWrapper->iCatBannerUrl->Length()) != 0) |
|
236 { |
|
237 iAdPresent = ETrue; |
|
238 if(iAdvPreset) |
|
239 { |
|
240 delete iAdvPreset; |
|
241 iAdvPreset = NULL; |
|
242 } |
|
243 iAdvPreset=CIRIsdsPreset::NewL(); |
|
244 iAdvPreset->SetChannelType(1); |
|
245 iAdvPreset->SetImgUrl(*iCategoryView.iUi->iIsdsWrapper->iCatBannerUrl); |
|
246 CreateCustomListBoxL(); |
|
247 iFilteredModel->SetAdvFlag(EFalse,*iAdvString); |
|
248 iCategoryView.SetCurrentFocus(0); |
|
249 iLogoDownloadError = ETrue; |
|
250 iCategoryView.AdRequestL(); |
|
251 } |
|
252 else |
|
253 { |
|
254 iCategoryListBox = new (ELeave) CIRCategoryAdvertisingListBox; |
|
255 CreateCustomListBoxL(); |
|
256 iCategoryView.SetCurrentFocus(0); |
|
257 iLogoDownloadError = ETrue; |
|
258 iFilteredModel->SetAdvFlag(EFalse,*iAdvString); |
|
259 } |
|
260 } |
|
261 else |
|
262 { |
|
263 if(iCategoryView.iUi->iIsdsWrapper->iCatBannerTag) |
|
264 { |
|
265 iCategoryView.SetCurrentFocus(0); |
|
266 iLogoDownloadError = ETrue; |
|
267 iFilteredModel->SetAdvFlag(EFalse,*iAdvString); |
|
268 } |
|
269 iCategoryListBox = new (ELeave) CIRCategoryAdvertisingListBox; |
|
270 CreateCustomListBoxL(); |
|
271 } |
|
272 IRLOG_DEBUG( "CIRCategoryViewContainer::CreateListBoxL - Exiting" ); |
|
273 |
|
274 } |
|
275 // --------------------------------------------------------------------------- |
|
276 // CIRCategoryViewContainer::CreateCustomListBoxL() |
|
277 // Destructor |
|
278 // --------------------------------------------------------------------------- |
|
279 // |
|
280 void CIRCategoryViewContainer::CreateCustomListBoxL() |
|
281 { |
|
282 IRLOG_DEBUG( "CIRCategoryViewContainer::CreateCustomListBoxL - Entering" ); |
|
283 if(iAdPresent) |
|
284 { |
|
285 iCategoryListBox = new (ELeave) CIRCategoryAdvertisingListBox; |
|
286 } |
|
287 //For displaying Ads |
|
288 iCategoryListBox->SetContainerWindowL(*this); |
|
289 |
|
290 // Added For Dynamic Filtering |
|
291 iCategoryListBox->ConstructL (this,EAknListBoxSelectionList,iFilteredModel); |
|
292 |
|
293 // Construct list. |
|
294 TResourceReader rr; |
|
295 iCoeEnv->CreateResourceReaderLC( rr, R_IR_SEARCHRESULTS_LIST ); |
|
296 ConstructFromResourceL( rr ); |
|
297 CleanupStack::PopAndDestroy(); // rr |
|
298 |
|
299 |
|
300 iItemArray = static_cast<CDesCArray*>( iCategoryListBox->Model()->ItemTextArray()); |
|
301 iListBoxArray->SetListArray(iItemArray); |
|
302 |
|
303 iFilteredModel->SetListArray(iListBoxArray); |
|
304 if (iCategoryView.iUi->iIsdsWrapper->iCatBannerUrl) |
|
305 { |
|
306 // Added For Dynamic Filtering |
|
307 if(iAdvString) |
|
308 { |
|
309 delete iAdvString; |
|
310 iAdvString = NULL; |
|
311 } |
|
312 iAdvString = HBufC::NewL(KAdvSize); |
|
313 TPtr ptr(iAdvString->Des()); |
|
314 _LIT(KTabFormat,"\t \t "); |
|
315 ptr.Copy(KTabFormat); |
|
316 |
|
317 iFilteredModel->SetAdvFlag(iAdPresent,*iAdvString); |
|
318 iCategoryListBox->SetListItemFormat( iAdvString ); |
|
319 } |
|
320 iCategoryListBox->SetRect( Rect()); |
|
321 iCategoryListBox->ActivateL(); |
|
322 |
|
323 iCategoryListBox->CreateScrollBarFrameL( ETrue ); |
|
324 iCategoryListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, |
|
325 CEikScrollBarFrame::EAuto); |
|
326 iCategoryListBox->SetListBoxObserver( this ); |
|
327 UpdateCategoryViewL(iCategoryView.iIsdsWrapper->iCategoryData); |
|
328 iCategoryListBox->ItemDrawer()->FormattedCellData()->SetMarqueeParams |
|
329 (KLoop, KScrollAmount, KScrollDelay, KInterval); |
|
330 iCategoryListBox->ItemDrawer()->ColumnData()->EnableMarqueeL( ETrue ); |
|
331 IRLOG_DEBUG( "CIRCategoryViewContainer::CreateCustomListBoxL - Exiting" ); |
|
332 } |
|
333 // --------------------------------------------------------------------------- |
|
334 // CIRCategoryViewContainer::~CIRCategoryViewContainer() |
|
335 // Destructor |
|
336 // --------------------------------------------------------------------------- |
|
337 // |
|
338 CIRCategoryViewContainer::~CIRCategoryViewContainer() |
|
339 { |
|
340 IRLOG_DEBUG( "CIRCategoryViewContainer::~CIRCategoryViewContainer - Entering" ); |
|
341 |
|
342 delete iConverter; |
|
343 delete iCurrentItemConverter; |
|
344 |
|
345 if(iCategoryListBox) |
|
346 { |
|
347 delete iCategoryListBox; |
|
348 iCategoryListBox = NULL; |
|
349 } |
|
350 if(iSearchTextBox) |
|
351 { |
|
352 delete iSearchTextBox; |
|
353 iSearchTextBox = NULL; |
|
354 } |
|
355 if(iAdvPreset) |
|
356 { |
|
357 delete iAdvPreset; |
|
358 iAdvPreset = NULL; |
|
359 } |
|
360 if(iAdBitmap) |
|
361 { |
|
362 delete iAdBitmap; |
|
363 iAdBitmap = NULL; |
|
364 } |
|
365 if(iBgContext) |
|
366 { |
|
367 delete iBgContext; |
|
368 iBgContext = NULL; |
|
369 } |
|
370 if(iAdvString) |
|
371 { |
|
372 delete iAdvString; |
|
373 iAdvString = NULL; |
|
374 } |
|
375 if(iListBoxArray ) |
|
376 { |
|
377 delete iListBoxArray ; |
|
378 iListBoxArray = NULL; |
|
379 } |
|
380 IRLOG_DEBUG( "CIRCategoryViewContainer::~CIRCategoryViewContainer - Exiting" ); |
|
381 } |
|
382 |
|
383 // --------------------------------------------------------------------------- |
|
384 // TKeyResponse CIRCategoryViewContainer::OfferKeyEventL() |
|
385 // From class CCoeControl. |
|
386 // We need to catch the selection key event in order to do a couple of things |
|
387 // in moving state make the movement, and in normal state open channel |
|
388 // specific popup menu. Up and down buttons are forwarded to the list. |
|
389 // --------------------------------------------------------------------------- |
|
390 // |
|
391 TKeyResponse CIRCategoryViewContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
392 TEventCode aType ) |
|
393 { |
|
394 IRLOG_DEBUG( "CIRCategoryViewContainer::OfferKeyEventL - Entering" ); |
|
395 TInt currentIndex = 0; |
|
396 TKeyResponse keyResp( EKeyWasNotConsumed ); |
|
397 switch ( aKeyEvent.iCode ) |
|
398 { |
|
399 case EKeyLeftArrow: // fall-through intended here |
|
400 case EKeyRightArrow: |
|
401 { |
|
402 keyResp = EKeyWasNotConsumed; |
|
403 DrawNow(); |
|
404 break; |
|
405 } |
|
406 case EKeyOK: |
|
407 { |
|
408 currentIndex = GetCurrentItemIndex(); |
|
409 if (currentIndex == 0) |
|
410 { |
|
411 if (iCategoryView.iUi->iIsdsWrapper->iCatBannerUrl |
|
412 && !iLogoDownloadError) |
|
413 { |
|
414 if(iCategoryView.iUi->iIsdsWrapper->iCatBannerUrl->Length() != 0) |
|
415 { |
|
416 iCategoryView.HandleCommandL(EAdvertisementUrl); |
|
417 } |
|
418 } |
|
419 else |
|
420 { |
|
421 iCategoryView.HandleCommandL(ESelectCmd); |
|
422 } |
|
423 } |
|
424 else |
|
425 { |
|
426 iCategoryView.HandleCommandL(ESelectCmd); |
|
427 } |
|
428 keyResp = EKeyWasConsumed; |
|
429 break; |
|
430 } |
|
431 |
|
432 default: |
|
433 { |
|
434 if(iCategoryListBox) |
|
435 { |
|
436 if ( iSearchTextBox ) |
|
437 { |
|
438 iFilteredFlag = ETrue; |
|
439 keyResp = iSearchTextBox->OfferKeyEventL( aKeyEvent, aType ); |
|
440 if( keyResp == EKeyWasNotConsumed ) |
|
441 { |
|
442 keyResp = iCategoryListBox->OfferKeyEventL( aKeyEvent, aType ); |
|
443 } |
|
444 CAknFilteredTextListBoxModel* model = |
|
445 static_cast<CAknFilteredTextListBoxModel*>( iCategoryListBox->Model() ); |
|
446 model->Filter()->HandleOfferkeyEventL(); |
|
447 TInt filterModelCount = iFilteredModel->NumberOfItems(); |
|
448 if(filterModelCount == 0 && |
|
449 !(iCategoryView.iUi->iIsdsWrapper->iCatBannerUrl)) |
|
450 { |
|
451 HBufC* noMatchesTextResource = |
|
452 StringLoader::LoadLC(R_IRAPP_STATIONLIST_NOMATCHES); |
|
453 iCategoryListBox->View()->SetListEmptyTextL(*noMatchesTextResource); |
|
454 CleanupStack::PopAndDestroy( noMatchesTextResource ); |
|
455 } |
|
456 iSearchTextBox->GetSearchText(iFindString); |
|
457 if(iFindString.Length()!=0) |
|
458 { |
|
459 if(!iLogoDownloadError && |
|
460 iCategoryView.iUi->iIsdsWrapper->iCatBannerUrl |
|
461 && filterModelCount > 1 ) |
|
462 { |
|
463 iCategoryListBox->SetCurrentItemIndex(1); |
|
464 } |
|
465 else |
|
466 { |
|
467 iCategoryListBox->SetCurrentItemIndex(0); |
|
468 } |
|
469 } |
|
470 } |
|
471 } |
|
472 if( aKeyEvent.iScanCode==EStdKeyBackspace) |
|
473 { |
|
474 if(iSearchTextBox) |
|
475 { |
|
476 iSearchTextBox->GetSearchText(iFindString); |
|
477 if(iFindString.Length()==0) |
|
478 { |
|
479 iFilteredFlag = EFalse; |
|
480 } |
|
481 } |
|
482 } |
|
483 break; |
|
484 } |
|
485 } |
|
486 IRLOG_DEBUG( "CIRCategoryViewContainer::OfferKeyEventL - Exiting" ); |
|
487 return keyResp; |
|
488 } |
|
489 |
|
490 // --------------------------------------------------------------------------- |
|
491 // From class MEikListBoxObserver. |
|
492 // List box event handler. |
|
493 // --------------------------------------------------------------------------- |
|
494 // |
|
495 void CIRCategoryViewContainer::HandleListBoxEventL( CEikListBox* /*aListBox*/, TListBoxEvent aEventType ) |
|
496 { |
|
497 IRLOG_DEBUG( "CIRCategoryViewContainer::HandleListBoxEventL - Entering" ); |
|
498 TInt currentIndex = 0; |
|
499 switch ( aEventType ) |
|
500 { |
|
501 case EEventEnterKeyPressed:/** Keypress event. */ |
|
502 case EEventItemDoubleClicked: |
|
503 { |
|
504 currentIndex = GetCurrentItemIndex(); |
|
505 if (currentIndex == 0) |
|
506 { |
|
507 if (iCategoryView.iUi->iIsdsWrapper->iCatBannerUrl && !iLogoDownloadError) |
|
508 { |
|
509 if(iCategoryView.iUi->iIsdsWrapper->iCatBannerUrl->Length() != 0) |
|
510 { |
|
511 iCategoryView.HandleCommandL(EAdvertisementUrl); |
|
512 } |
|
513 } |
|
514 else |
|
515 { |
|
516 iCategoryView.SetCurrentFocus(GetCurrentItemIndex()); |
|
517 iCategoryView.HandleCommandL(ESelectCmd); |
|
518 } |
|
519 } |
|
520 else |
|
521 { |
|
522 iCategoryView.SetCurrentFocus(GetCurrentItemIndex()); |
|
523 iCategoryView.HandleCommandL(ESelectCmd); |
|
524 } |
|
525 |
|
526 } |
|
527 break; |
|
528 default: |
|
529 break; |
|
530 } |
|
531 IRLOG_DEBUG( "CIRCategoryViewContainer::HandleListBoxEventL - Exiting" ); |
|
532 } |
|
533 |
|
534 |
|
535 // --------------------------------------------------------------------------- |
|
536 // CIRCategoryViewContainer::Draw() |
|
537 // From class CCoeControl. |
|
538 // Draws the control. |
|
539 // --------------------------------------------------------------------------- |
|
540 // |
|
541 void CIRCategoryViewContainer::Draw( const TRect& /*aRect*/ ) const |
|
542 { |
|
543 IRLOG_DEBUG( "CIRCategoryViewContainer::Draw - Entering" ); |
|
544 CWindowGc& gc = SystemGc(); |
|
545 |
|
546 if(iCategoryListBox) |
|
547 { |
|
548 iCategoryListBox->SetGC(gc); |
|
549 iCategoryListBox->SetControlFlag(ETrue); |
|
550 } |
|
551 gc.SetPenStyle( CGraphicsContext::ENullPen ); |
|
552 gc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
553 |
|
554 // draw background skin first. |
|
555 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
556 |
|
557 TRect clientRect(((CEikAppUi*)(CCoeEnv::Static()->AppUi()))->ClientRect()); |
|
558 AknsDrawUtils::DrawBackground ( skin, iBgContext, this, gc, TPoint(0,0), |
|
559 TRect(TPoint(0,0),clientRect.iBr), KAknsDrawParamDefault ); |
|
560 |
|
561 IRLOG_DEBUG( "CIRCategoryViewContainer::Draw - Exiting" ); |
|
562 } |
|
563 |
|
564 |
|
565 // --------------------------------------------------------------------------- |
|
566 // CIRCategoryViewContainer::GetHelpContext() |
|
567 // From class CCoeControl. |
|
568 // Opens help by context. |
|
569 // --------------------------------------------------------------------------- |
|
570 // |
|
571 void CIRCategoryViewContainer::GetHelpContext( TCoeHelpContext& aContext ) const |
|
572 { |
|
573 IRLOG_DEBUG( "CIRCategoryViewContainer::GetHelpContext - Entering" ); |
|
574 if( iCategoryView.iUi->iCategoryViewTitleType == CIRCategoryView::EGenreData ) |
|
575 { |
|
576 aContext = TCoeHelpContext( KIRMCVUid, KIR_HELP_GENRE ); |
|
577 } |
|
578 else if( iCategoryView.iUi->iCategoryViewTitleType == CIRCategoryView::ELanguageData ) |
|
579 { |
|
580 aContext = TCoeHelpContext( KIRMCVUid, KIR_HELP_LANGUAGE ); |
|
581 } |
|
582 else if( iCategoryView.iUi->iCategoryViewTitleType == CIRCategoryView::ECountryData ) |
|
583 { |
|
584 aContext = TCoeHelpContext( KIRMCVUid, KIR_HELP_COUNTRY ); |
|
585 } |
|
586 else |
|
587 { |
|
588 // NOP |
|
589 } |
|
590 |
|
591 IRLOG_DEBUG( "CIRCategoryViewContainer::GetHelpContext - Exiting" ); |
|
592 } |
|
593 |
|
594 // --------------------------------------------------------------------------- |
|
595 // CIRCategoryViewContainer::UpdateSearchResultsViewL() |
|
596 // updates the search results data to the search results list |
|
597 // --------------------------------------------------------------------------- |
|
598 // |
|
599 void CIRCategoryViewContainer::UpdateCategoryViewL(CDesCArray* aCategory) |
|
600 { |
|
601 IRLOG_DEBUG( "CIRCategoryViewContainer::UpdateCategoryViewL - Entering" ); |
|
602 CDesCArray* category = aCategory; |
|
603 TInt categoryDataCount = aCategory->Count(); |
|
604 for(TInt i = 0; i < categoryDataCount; i++) |
|
605 { |
|
606 iItemArray->AppendL(category->MdcaPoint(i)); |
|
607 } |
|
608 if(categoryDataCount>1) |
|
609 { |
|
610 if(iSearchTextBox) |
|
611 { |
|
612 delete iSearchTextBox; |
|
613 iSearchTextBox = NULL; |
|
614 } |
|
615 |
|
616 // Added For Dynamic Filtering |
|
617 iSearchTextBox = CreateFindBoxL(iCategoryListBox, iFilteredModel, |
|
618 CAknSearchField::ESearch); |
|
619 SizeChanged(); |
|
620 } |
|
621 else |
|
622 { |
|
623 DisableFindBox(); |
|
624 } |
|
625 if(iFilteredFlag) |
|
626 { |
|
627 TKeyEvent event; |
|
628 TEventCode type = EEventKey; |
|
629 event.iCode = EKeyDownArrow; |
|
630 TBool needRefresh( EFalse ); |
|
631 AknFind::HandleFindOfferKeyEventL( event, type, this, |
|
632 iCategoryListBox, iSearchTextBox,EFalse,needRefresh ); |
|
633 TInt filterModelCount = iFilteredModel->NumberOfItems(); |
|
634 if(filterModelCount ==1 && iCategoryView.iUi->iIsdsWrapper->iCatBannerUrl) |
|
635 { |
|
636 iCategoryListBox->SetCurrentItemIndex(0); |
|
637 } |
|
638 else |
|
639 { |
|
640 if(filterModelCount>1 && iCategoryView.iUi->iIsdsWrapper->iCatBannerUrl && !iLogoDownloadError) |
|
641 iCategoryListBox->SetCurrentItemIndex(1); |
|
642 } |
|
643 } |
|
644 else |
|
645 { |
|
646 iCategoryListBox->HandleItemAdditionL(); |
|
647 } |
|
648 |
|
649 IRLOG_DEBUG( "CIRCategoryViewContainer::UpdateCategoryViewL - Exiting" ); |
|
650 } |
|
651 |
|
652 // --------------------------------------------------------------------------- |
|
653 // CIRCategoryViewContainer::GetCurrentItemIndex() |
|
654 // returns the index of the currently selected item |
|
655 // --------------------------------------------------------------------------- |
|
656 // |
|
657 TInt CIRCategoryViewContainer::GetCurrentItemIndex() const |
|
658 { |
|
659 IRLOG_DEBUG( "CIRCategoryViewContainer::GetCurrentItemIndex" ); |
|
660 return iCategoryListBox->CurrentItemIndex(); |
|
661 } |
|
662 |
|
663 // --------------------------------------------------------------------------- |
|
664 // CIRCategoryViewContainer::GetListBoxTopIndex() |
|
665 // returns the index of the top item |
|
666 // --------------------------------------------------------------------------- |
|
667 // |
|
668 TInt CIRCategoryViewContainer::GetListBoxTopIndex() const |
|
669 { |
|
670 IRLOG_DEBUG( "CIRCategoryViewContainer::GetListBoxTopIndex" ); |
|
671 return iCategoryListBox->View()->TopItemIndex () ; |
|
672 } |
|
673 |
|
674 |
|
675 //---------------------------------------------------------------------------- |
|
676 // CIRCategoryViewContainer::CountComponentControls() const |
|
677 // returns the number of components in the view. |
|
678 //---------------------------------------------------------------------------- |
|
679 // |
|
680 TInt CIRCategoryViewContainer::CountComponentControls() const |
|
681 { |
|
682 IRLOG_DEBUG( "CIRCategoryViewContainer::CountComponentControls - Entering" ); |
|
683 IRLOG_DEBUG( "CIRCategoryViewContainer::CountComponentControls - Exiting" ); |
|
684 TInt count(KCONTROLSCOUNT); |
|
685 if(iCategoryListBox) |
|
686 { |
|
687 count++; |
|
688 } |
|
689 if(iSearchTextBox) |
|
690 { |
|
691 count++; |
|
692 } |
|
693 return count; |
|
694 } |
|
695 //---------------------------------------------------------------------------- |
|
696 // CIRCategoryViewContainer::ComponentControl() const |
|
697 // returns a pointer to the control under this view depending on the index |
|
698 // passed,to the framework. |
|
699 //---------------------------------------------------------------------------- |
|
700 // |
|
701 CCoeControl* CIRCategoryViewContainer::ComponentControl(TInt aIndex) const |
|
702 { |
|
703 IRLOG_DEBUG( "CIRCategoryViewContainer::ComponentControl - Entering" ); |
|
704 IRLOG_DEBUG( "CIRCategoryViewContainer::ComponentControl - Exiting" ); |
|
705 switch(aIndex) |
|
706 { |
|
707 case 0: |
|
708 { |
|
709 if(iCategoryListBox) |
|
710 return iCategoryListBox; |
|
711 } |
|
712 case 1: |
|
713 { |
|
714 if(iSearchTextBox) |
|
715 return iSearchTextBox; |
|
716 } |
|
717 default: |
|
718 return NULL; |
|
719 } |
|
720 } |
|
721 // --------------------------------------------------------------------------- |
|
722 // void CIRCategoryViewContainer::SizeChanged() |
|
723 // Responds to changes to the size and position of the contents of this control. |
|
724 // --------------------------------------------------------------------------- |
|
725 // |
|
726 |
|
727 void CIRCategoryViewContainer::SizeChanged() |
|
728 { |
|
729 IRLOG_DEBUG( "CIRCategoryViewContainer::SizeChanged - Entering" ); |
|
730 if(iCategoryView.iUi->IsLandscapeOrientation()) |
|
731 { |
|
732 if(iCategoryListBox && iSearchTextBox && iLandScapeCount ==0) |
|
733 { |
|
734 AknFind::HandlePopupFindSizeChanged(this,iCategoryListBox,iSearchTextBox); |
|
735 iLandScapeCount ++; |
|
736 } |
|
737 } |
|
738 if(iCategoryListBox && iSearchTextBox) |
|
739 { |
|
740 AknLayoutUtils::LayoutControl(iCategoryListBox, Rect(), |
|
741 AKN_LAYOUT_WINDOW_list_gen_pane(1)); |
|
742 AknLayoutUtils::LayoutControl(iSearchTextBox, Rect(), |
|
743 AKN_LAYOUT_WINDOW_find_pane); |
|
744 } |
|
745 else |
|
746 { |
|
747 if(iCategoryListBox) |
|
748 { |
|
749 AknLayoutUtils::LayoutControl(iCategoryListBox, Rect(), |
|
750 AKN_LAYOUT_WINDOW_list_gen_pane(0)); |
|
751 } |
|
752 } |
|
753 |
|
754 TRect clientRect(((CEikAppUi*)(CCoeEnv::Static()->AppUi()))->ClientRect()); |
|
755 TRect parentRectSize(TPoint(0,0),clientRect.iBr); |
|
756 |
|
757 if ( iBgContext ) |
|
758 { |
|
759 iBgContext->SetRect(parentRectSize); |
|
760 } |
|
761 |
|
762 DrawNow(); |
|
763 IRLOG_DEBUG( "CIRCategoryViewContainer::SizeChanged - Exiting" ); |
|
764 } |
|
765 |
|
766 // --------------------------------------------------------------------------- |
|
767 // void CIRCategoryViewContainer::HandleResourceChange(TInt aType) |
|
768 // Handles a change to the control's resources. |
|
769 // --------------------------------------------------------------------------- |
|
770 // |
|
771 void CIRCategoryViewContainer::HandleResourceChange(TInt aType) |
|
772 { |
|
773 IRLOG_DEBUG( "CIRCategoryViewContainer::HandleResourceChange" ); |
|
774 CCoeControl::HandleResourceChange( aType ); |
|
775 // application layout change request notification |
|
776 if ( aType == KEikDynamicLayoutVariantSwitch ) |
|
777 { |
|
778 // reconstruct controls if needed |
|
779 if(iCategoryListBox && iSearchTextBox) |
|
780 { |
|
781 AknFind::HandlePopupFindSizeChanged(this,iCategoryListBox,iSearchTextBox); |
|
782 SizeChanged(); |
|
783 } |
|
784 } |
|
785 } |
|
786 //---------------------------------------------------------------------------- |
|
787 // CIRCategoryViewContainer::CreateFindBoxL() |
|
788 // creates the Find box when any character is Pressed |
|
789 //---------------------------------------------------------------------------- |
|
790 // |
|
791 CAknSearchField* CIRCategoryViewContainer::CreateFindBoxL(CEikListBox* aListBox, |
|
792 CTextListBoxModel* aModel, CAknSearchField::TSearchFieldStyle aStyle) |
|
793 { |
|
794 IRLOG_DEBUG( "CIRCategoryViewContainer::CreateFindBoxL - Entering" ); |
|
795 CAknSearchField* findbox = NULL; |
|
796 if (aListBox && aModel) |
|
797 { |
|
798 // Gets pointer of CAknFilteredTextListBoxModel. |
|
799 // Added For Dynamic Filtering |
|
800 iFilteredModel = STATIC_CAST( CIRFilteredModel*, aModel ); |
|
801 |
|
802 // Creates FindBox. |
|
803 findbox = CAknSearchField::NewL( *this, aStyle, NULL, |
|
804 KAknExListFindBoxTextLength); |
|
805 CleanupStack::PushL(findbox); |
|
806 // Creates CAknListBoxFilterItems class. |
|
807 iFilteredModel->CreateFilterL( aListBox, findbox ); |
|
808 CleanupStack::Pop(findbox); // findbox |
|
809 } |
|
810 IRLOG_DEBUG( "CIRCategoryViewContainer::CreateFindBoxL - Exiting" ); |
|
811 return findbox; |
|
812 } |
|
813 //---------------------------------------------------------------------------- |
|
814 // CIRCategoryViewContainer::DisableFindBox() |
|
815 // Deletes the findbox |
|
816 //---------------------------------------------------------------------------- |
|
817 // |
|
818 void CIRCategoryViewContainer::DisableFindBox() |
|
819 { |
|
820 IRLOG_DEBUG( "CIRCategoryViewContainer::DisableFindBox - Entering" ); |
|
821 if (iSearchTextBox) |
|
822 { |
|
823 iFilteredModel->RemoveFilter(); |
|
824 // Important to set the find box non-focusing before |
|
825 // deleting it, otherwise the focus changes triggered |
|
826 // by the removal of the control from stack will focus |
|
827 // the find box which is under deletion |
|
828 iSearchTextBox->SetNonFocusing(); |
|
829 delete iSearchTextBox; |
|
830 iSearchTextBox = NULL; |
|
831 // Inform list box that find is hidden |
|
832 static_cast<CAknColumnListBoxView*>(iCategoryListBox->View())->SetFindEmptyListState(EFalse); |
|
833 SizeChanged(); |
|
834 } |
|
835 IRLOG_DEBUG( "CIRCategoryViewContainer::DisableFindBox - Exiting" ); |
|
836 } |
|
837 |
|
838 |
|
839 // --------------------------------------------------------------------------- |
|
840 // Function : Comparestrings |
|
841 // Function called to compare the filtered string inthe Itemarray |
|
842 // --------------------------------------------------------------------------- |
|
843 // |
|
844 void CIRCategoryViewContainer::Comparestrings() |
|
845 { |
|
846 IRLOG_DEBUG( "CIRCategoryViewContainer::Comparestrings - Entering" ); |
|
847 TInt count = iFilteredModel->NumberOfItems(); |
|
848 if(count) |
|
849 { |
|
850 if((count==1) && iAdvPreset &&!iLogoDownloadError ) |
|
851 { |
|
852 return; |
|
853 } |
|
854 else |
|
855 { |
|
856 TPtrC16 filteredString = iFilteredModel->ItemText (iCategoryView.GetFilteredIndex()); |
|
857 for(TInt i=0;i<iItemArray->Count();i++) |
|
858 { |
|
859 TPtrC16 matchString=iItemArray->MdcaPoint(i); |
|
860 if(filteredString==matchString) |
|
861 { |
|
862 iCategoryView.SetActualFilteredItemIndex(i); |
|
863 break; |
|
864 } |
|
865 } |
|
866 } |
|
867 } |
|
868 IRLOG_DEBUG( "CIRCategoryViewContainer::Comparestrings - Exiting" ); |
|
869 } |
|
870 // --------------------------------------------------------------------------- |
|
871 // void CIRCategoryViewContainer::HandleImageConversionEventL( MIRImageConverterObserver::TIRImageConversionEvent aEvent, |
|
872 // from base class MIRImageConverterObserver |
|
873 // --------------------------------------------------------------------------- |
|
874 // |
|
875 void CIRCategoryViewContainer::HandleImageConversionEventL( MIRImageConverterObserver:: |
|
876 TIRImageConversionEvent aEvent, |
|
877 TInt /*aId*/, |
|
878 TInt aError ) |
|
879 { |
|
880 IRLOG_DEBUG( "CIRCategoryViewContainer::HandleImageConversionEventL - Entering" ); |
|
881 iError = aError; |
|
882 if(aError == KErrNotSupported && iRequestForAdvertisement) |
|
883 { |
|
884 iFilteredModel->SetAdvFlag(EFalse,*iAdvString); |
|
885 iLogoDownloadError = ETrue; |
|
886 iRequestForAdvertisement = EFalse; |
|
887 } |
|
888 if ( !aError && (aEvent == MIRImageConverterObserver::EIRFrameConversionCompleted || |
|
889 aEvent == MIRImageConverterObserver::EIRImageConversionCompleted)) |
|
890 { |
|
891 IRLOG_DEBUG( "CIRSearchResultsViewContainer::HandleImageConversionEventL - Entered elseif" ); |
|
892 iLogoDownloadError = EFalse; |
|
893 CGulIcon* icon = iCategoryListBox->AdvertisementIcon(); |
|
894 if ( !icon ) |
|
895 { |
|
896 icon = CGulIcon::NewLC(); |
|
897 iCategoryListBox->SetAdvertisementIconL( icon ); |
|
898 CleanupStack::Pop( icon ); |
|
899 } |
|
900 icon->SetBitmap( const_cast<CFbsBitmap*>(iCurrentItemConverter->Bitmap())); |
|
901 icon->SetMask(const_cast<CFbsBitmap*>(iCurrentItemConverter->Mask() )); |
|
902 icon->SetBitmapsOwnedExternally( ETrue ); |
|
903 DrawDeferred(); |
|
904 } |
|
905 else |
|
906 { |
|
907 |
|
908 } |
|
909 if(iFilteredFlag) |
|
910 { |
|
911 TKeyEvent event; |
|
912 TEventCode type = EEventKey; |
|
913 event.iCode = EKeyDownArrow; |
|
914 TBool needRefresh( EFalse ); |
|
915 AknFind::HandleFindOfferKeyEventL( event, type, this, |
|
916 iCategoryListBox, iSearchTextBox,EFalse,needRefresh ); |
|
917 } |
|
918 iAdPresent = EFalse; |
|
919 IRLOG_DEBUG( "CIRCategoryViewContainer::HandleImageConversionEventL - Exiting" ); |
|
920 } |
|
921 |
|
922 // --------------------------------------------------------------------------- |
|
923 // CIRCategoryViewContainer::PresetLogoDownloadL() |
|
924 // |
|
925 // --------------------------------------------------------------------------- |
|
926 // |
|
927 void CIRCategoryViewContainer::PresetLogoDownloadL(CIRIsdsPreset* aPreset) |
|
928 { |
|
929 IRLOG_DEBUG( "CIRCategoryViewContainer::PresetLogoDownloadL - Entering" ); |
|
930 if(iAdPresent) |
|
931 { |
|
932 if (iCategoryView.iUi->iIsdsWrapper->iCatBannerUrl) |
|
933 { |
|
934 *iAdvPreset = *aPreset; |
|
935 if(iAdvPreset->GetLogoData()!=KNullDesC8 ) |
|
936 { |
|
937 iFilteredModel->SetAdvFlag(ETrue,*iAdvString); |
|
938 iError = KErrNone; |
|
939 iCurrentItemConverter->SetDataL(aPreset->GetLogoData()); |
|
940 if(iError==KErrNone) |
|
941 { |
|
942 iCurrentItemConverter->StartL( IRLayoutUtils::AdvertisementSizeL(), KErrUnknown ); //KLogoSize |
|
943 } |
|
944 iRequestForAdvertisement = ETrue; |
|
945 } |
|
946 } |
|
947 } |
|
948 IRLOG_DEBUG( "CIRCategoryViewContainer::PresetLogoDownloadL - Exiting" ); |
|
949 } |
|
950 |
|
951 // --------------------------------------------------------------------------- |
|
952 // CIRCategoryViewContainer::OpenUrlL( const TDesC& aHttpLink) |
|
953 // used to connect to the advertisement url. |
|
954 // --------------------------------------------------------------------------- |
|
955 // |
|
956 void CIRCategoryViewContainer::OpenUrlL( const TDesC& aHttpLink ) |
|
957 { |
|
958 IRLOG_DEBUG( "CIRCategoryViewContainer::OpenUrlL - Entering" ); |
|
959 |
|
960 TDataType htmlDataType( KIRHtmlMimeType ); |
|
961 TUid uid; |
|
962 |
|
963 RApaLsSession ls; |
|
964 User::LeaveIfError( ls.Connect() ); |
|
965 CleanupClosePushL( ls ); |
|
966 |
|
967 // Get UID of the browser. |
|
968 TInt retVal = ls.AppForDataType( htmlDataType, uid ); |
|
969 |
|
970 if ( retVal == KErrNone && uid != KNullUid ) |
|
971 { |
|
972 // We must check if the browser is already open and if it is, |
|
973 // switch its currently opened file to the correct URL. |
|
974 TApaTaskList taskList( iEikonEnv->WsSession() ); |
|
975 TApaTask task = taskList.FindApp( uid ); |
|
976 if ( task.Exists() ) |
|
977 { |
|
978 HBufC8* url8 = HBufC8::NewLC( aHttpLink.Length() ); |
|
979 url8->Des().Copy( aHttpLink ); |
|
980 task.SendMessage( TUid::Uid( 0 ), url8->Des() ); |
|
981 task.BringToForeground(); |
|
982 CleanupStack::PopAndDestroy( url8 ); |
|
983 } |
|
984 else |
|
985 { |
|
986 TThreadId threadId; |
|
987 HBufC* newUrl = HBufC::NewLC( aHttpLink.Length() + KBrowserPrefix().Length() ); |
|
988 newUrl->Des().Append( KBrowserPrefix ); |
|
989 newUrl->Des().Append( aHttpLink ); |
|
990 ls.StartDocument( newUrl->Des(), uid, threadId ); |
|
991 CleanupStack::PopAndDestroy( newUrl ); |
|
992 } |
|
993 } |
|
994 CleanupStack::PopAndDestroy( &ls ); |
|
995 |
|
996 IRLOG_DEBUG( "CIRCategoryViewContainer::OpenUrlL - Exiting" ); |
|
997 |
|
998 } |
|
999 //---------------------------------------------------------------------------- |
|
1000 // CIRCategoryViewContainer::GetLogoNotSupported() |
|
1001 // returns whether the advertisement is supported by the sdk r not |
|
1002 //---------------------------------------------------------------------------- |
|
1003 // |
|
1004 TBool CIRCategoryViewContainer::GetLogoNotSupported() |
|
1005 { |
|
1006 IRLOG_DEBUG( "CIRCategoryViewContainer::GetLogoNotSupported - Entering" ); |
|
1007 IRLOG_DEBUG( "CIRCategoryViewContainer::GetLogoNotSupported - Exiting" ); |
|
1008 return iLogoDownloadError; |
|
1009 } |
|
1010 // --------------------------------------------------------------------------- |
|
1011 // void CIRCategoryViewContainer::HandleLogoErrorL() |
|
1012 // called from the iCategoryView when the logo is not downloaded |
|
1013 // --------------------------------------------------------------------------- |
|
1014 // |
|
1015 void CIRCategoryViewContainer::HandleLogoErrorL() |
|
1016 { |
|
1017 iLogoDownloadError = ETrue; |
|
1018 iFilteredModel->SetAdvFlag(EFalse,*iAdvString); |
|
1019 } |
|