|
1 /* |
|
2 * Copyright (c) 2006 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: Application UI class required by AVKON application architecture. |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <barsread.h> |
|
20 #include <StringLoader.h> |
|
21 #include <AknIconArray.h> |
|
22 #include <gulicon.h> |
|
23 #include <featmgr.h> |
|
24 #include <aknsfld.h> |
|
25 #include <AknUtils.h> |
|
26 #include <aknlists.h> |
|
27 #include <aknconsts.h> |
|
28 #include <avkon.mbg> |
|
29 #include <eikclbd.h> |
|
30 #include <eikcmobs.h> |
|
31 #include <bautils.h> |
|
32 #include <AknsBasicBackgroundControlContext.h> |
|
33 #include <s32file.h> |
|
34 |
|
35 #include <ganes/HgDoubleGraphicList.h> |
|
36 #include <ganes/HgSingleGraphicList.h> |
|
37 #include <ganes/HgItem.h> |
|
38 #include <ganes/HgScrollerWithTitle.h> |
|
39 |
|
40 #include <data_caging_path_literals.hrh> |
|
41 #include <mpxlog.h> |
|
42 #include <mpxuser.h> |
|
43 #include <mpxmedia.h> |
|
44 #include <mpxmediaarray.h> |
|
45 #include <mpxmediageneraldefs.h> |
|
46 #include <mpxmediamusicdefs.h> |
|
47 #include <mpxcommonuihelper.h> |
|
48 #include <mpxpodcastdefs.h> |
|
49 |
|
50 #include <mpxcommoncontainer.rsg> |
|
51 #include <mpxcollectionview.rsg> |
|
52 |
|
53 #include "mpxcommonlistboxarraybase.h" |
|
54 #include "mpxcommoncontainermediahelper.h" |
|
55 #include "mpxcommoncontainertexturemanager2.h" |
|
56 #include "mpxcommoncontainerhgimp.h" |
|
57 #include "mpxcommoncontainer.hrh" |
|
58 |
|
59 #include <thumbnaildata.h> |
|
60 #include <thumbnailobjectsource.h> |
|
61 #include <aknview.h> |
|
62 |
|
63 |
|
64 // CONSTANTS |
|
65 _LIT( KMPXCommonContainerRscPath, "mpxcommoncontainer.rsc" ); |
|
66 |
|
67 const TInt KMPXListSelectionCount = 5; |
|
68 const TInt KMPXMinSecSeparatorIndex = 2; |
|
69 const TInt KOneHourInSeconds = 3600; |
|
70 const TInt KMPXTimeIndicatorLength = 16; |
|
71 const TInt KMPXListBufferSize = 400; |
|
72 const TInt KMPXMaxFileLength = 256; |
|
73 const TReal KIconFactor = 0.7; |
|
74 const int KMaxThumbnailReq = 100; |
|
75 |
|
76 _LIT( KMPXDash, " - " ); |
|
77 #ifdef HG_MP_LOC_AVAILABLE |
|
78 _LIT( KMPXSpace, " "); |
|
79 #endif //HG_MP_LOC_AVAILABLE |
|
80 _LIT( KMPXZeroDurationMark, "--"); |
|
81 //_LIT( KMPXAlbumMimeType, "image/jpeg" ); |
|
82 _LIT( KMPXAlbumMimeType, "audio/mpeg3" ); |
|
83 |
|
84 //#ifndef HG_MP_LOC_AVAILABLE |
|
85 _LIT( KUnknown, "Unknown" ); |
|
86 _LIT( KSong, " song" ); |
|
87 _LIT( KSongs, " songs" ); |
|
88 _LIT( KEpisode, " episode" ); |
|
89 _LIT( KEpisodes, " episodes" ); |
|
90 _LIT( KAlbum, " album" ); |
|
91 _LIT( KAlbums, " albums" ); |
|
92 _LIT( KSongDash, " song - " ); |
|
93 _LIT( KSongsDash, " songs - " ); |
|
94 //#endif //HG_MP_LOC_AVAILABLE |
|
95 |
|
96 _LIT( KMPXDriveC, "c:" ); |
|
97 _LIT( KMPXSelectedAlbumItemFileName, "mpxalbumitem.dat"); |
|
98 |
|
99 #define DSA_PARAM NULL |
|
100 //#define DSA_PARAM &iEikonEnv->WsSession() |
|
101 |
|
102 |
|
103 |
|
104 // ======== MEMBER FUNCTIONS ======== |
|
105 |
|
106 // --------------------------------------------------------------------------- |
|
107 // C++ constructor can NOT contain any code that might leave. |
|
108 // --------------------------------------------------------------------------- |
|
109 // |
|
110 CMPXCommonContainerHgImp::CMPXCommonContainerHgImp() : |
|
111 iContext( EContextUnknown ), |
|
112 iTopIndex( 0 ), |
|
113 iBottomIndex( KErrNotFound ), |
|
114 iCurrentDefaultIcon( EMPXDefaultIconNotSet ), |
|
115 iRequestCount( 0 ), |
|
116 iAlbumArtRequest(NULL), |
|
117 iRequestQueue(_FOFF( TAlbumArtRequest, iLink )), |
|
118 iQueueCounter(0) |
|
119 { |
|
120 } |
|
121 |
|
122 |
|
123 // --------------------------------------------------------------------------- |
|
124 // Destructor |
|
125 // --------------------------------------------------------------------------- |
|
126 // |
|
127 CMPXCommonContainerHgImp::~CMPXCommonContainerHgImp() |
|
128 { |
|
129 MPX_FUNC( "CMPXCommonContainerHgImp::~CMPXCommonContainerHgImp" ); |
|
130 |
|
131 delete iEpisodeTitle; |
|
132 delete iSongTitle; |
|
133 delete iAlbumTitle; |
|
134 |
|
135 if ( iResourceOffset ) |
|
136 { |
|
137 iEikonEnv->DeleteResourceFile( iResourceOffset ); |
|
138 } |
|
139 delete iListSelections; |
|
140 delete iListBoxArray; |
|
141 delete iIconArray; |
|
142 if ( iScrollerWithTitle ) |
|
143 { |
|
144 // delete iListWidget; |
|
145 delete iScrollerWithTitle; |
|
146 if ( iPrevListWidget ) |
|
147 { |
|
148 delete iPrevListWidget; |
|
149 } |
|
150 } |
|
151 else |
|
152 { |
|
153 delete iListWidget; |
|
154 } |
|
155 /// delete iTextureManager; |
|
156 delete iCommonUiHelper; |
|
157 CancelTNRequest(); |
|
158 iThumbnailReqHashMap.Close(); |
|
159 iThumbnailReqMap.Close(); |
|
160 delete iThumbnailManager; |
|
161 delete iBgContext; |
|
162 delete iSelectedMediaInAlbumView; |
|
163 CleanAlbumArtReqQueue(); |
|
164 } |
|
165 |
|
166 |
|
167 // --------------------------------------------------------------------------- |
|
168 // Return Coe Control |
|
169 // --------------------------------------------------------------------------- |
|
170 // |
|
171 CCoeControl* CMPXCommonContainerHgImp::CoeControl() |
|
172 { |
|
173 MPX_FUNC( "CMPXCommonContainerHgImp::CoeControl" ); |
|
174 return this; |
|
175 } |
|
176 |
|
177 |
|
178 // --------------------------------------------------------------------------- |
|
179 // Set View Container |
|
180 // --------------------------------------------------------------------------- |
|
181 // |
|
182 void CMPXCommonContainerHgImp::SetViewContainer( |
|
183 MMPXViewContainer* aViewContainer ) |
|
184 { |
|
185 MPX_FUNC( "CMPXCommonContainerHgImp::SetViewContainer" ); |
|
186 iViewContainer = aViewContainer; |
|
187 } |
|
188 |
|
189 |
|
190 // --------------------------------------------------------------------------- |
|
191 // Set command observer for the container |
|
192 // --------------------------------------------------------------------------- |
|
193 // |
|
194 void CMPXCommonContainerHgImp::SetCommandObserver( |
|
195 MEikCommandObserver* aCommandObserver ) |
|
196 { |
|
197 MPX_FUNC( "CMPXCommonContainerHgImp::SetCommandObserver" ); |
|
198 iView = aCommandObserver; |
|
199 } |
|
200 |
|
201 |
|
202 // --------------------------------------------------------------------------- |
|
203 // C++ constructor can NOT contain any code that might leave. |
|
204 // --------------------------------------------------------------------------- |
|
205 // |
|
206 void CMPXCommonContainerHgImp::SetListBoxObserver( |
|
207 MEikListBoxObserver* aListBoxObserver ) |
|
208 { |
|
209 MPX_FUNC( "CMPXCommonContainerHgImp::SetListBoxObserver" ); |
|
210 iListBoxObserver = aListBoxObserver; |
|
211 } |
|
212 |
|
213 |
|
214 // --------------------------------------------------------------------------- |
|
215 // Set layout for all elements and set sizes for icons. |
|
216 // --------------------------------------------------------------------------- |
|
217 // |
|
218 void CMPXCommonContainerHgImp::UpdateLayout() |
|
219 { |
|
220 MPX_FUNC( "CMPXCommonContainerHgImp::UpdateLayout" ); |
|
221 } |
|
222 |
|
223 |
|
224 // ----------------------------------------------------------------------------- |
|
225 // Returns a pointer to the listboxarray |
|
226 // ----------------------------------------------------------------------------- |
|
227 // |
|
228 CMPXCommonListBoxArrayBase* CMPXCommonContainerHgImp::ListBoxArray() const |
|
229 { |
|
230 return iListBoxArray; |
|
231 } |
|
232 |
|
233 |
|
234 // ----------------------------------------------------------------------------- |
|
235 // Sets listbox array |
|
236 // ----------------------------------------------------------------------------- |
|
237 // |
|
238 void CMPXCommonContainerHgImp::SetListBoxArrayL( |
|
239 CMPXCommonListBoxArrayBase* aListBoxArray ) |
|
240 { |
|
241 MPX_FUNC( "CMPXCommonContainerHgImp::SetListBoxArrayL" ); |
|
242 iListBoxArray = aListBoxArray; |
|
243 } |
|
244 |
|
245 |
|
246 // ----------------------------------------------------------------------------- |
|
247 // Return number of listbox items shown in the current listbox. |
|
248 // ----------------------------------------------------------------------------- |
|
249 // |
|
250 TInt CMPXCommonContainerHgImp::CurrentListItemCount() const |
|
251 { |
|
252 MPX_FUNC( "CMPXCommonContainerHgImp::CurrentListItemCount" ); |
|
253 TInt count = 0; |
|
254 if ( iListWidget ) |
|
255 { |
|
256 count = iListWidget->ItemCount(); |
|
257 } |
|
258 return count; |
|
259 } |
|
260 |
|
261 |
|
262 // ----------------------------------------------------------------------------- |
|
263 // Return total number of listbox items in the listbox. |
|
264 // ----------------------------------------------------------------------------- |
|
265 // |
|
266 TInt CMPXCommonContainerHgImp::TotalListItemCount() const |
|
267 { |
|
268 MPX_FUNC( "CMPXCommonContainerHgImp::TotalListItemCount" ); |
|
269 TInt count = 0; |
|
270 if ( iListBoxArray ) |
|
271 { |
|
272 count = iListBoxArray->MediaArray().Count(); |
|
273 } |
|
274 return count; |
|
275 } |
|
276 |
|
277 |
|
278 // ----------------------------------------------------------------------------- |
|
279 // Gets top listbox item index (relative to the original listbox). |
|
280 // ----------------------------------------------------------------------------- |
|
281 // |
|
282 TInt CMPXCommonContainerHgImp::TopLbxItemIndex() const |
|
283 { |
|
284 MPX_FUNC( "CMPXCommonContainerHgImp::TopLbxItemIndex" ); |
|
285 return iTopIndex; |
|
286 } |
|
287 |
|
288 |
|
289 // ----------------------------------------------------------------------------- |
|
290 // Gets bottom listbox item index (relative to the original listbox). |
|
291 // ----------------------------------------------------------------------------- |
|
292 // |
|
293 TInt CMPXCommonContainerHgImp::BottomLbxItemIndex() const |
|
294 { |
|
295 MPX_FUNC( "CMPXCommonContainerHgImp::BottomLbxItemIndex" ); |
|
296 return iBottomIndex; |
|
297 } |
|
298 |
|
299 |
|
300 // ----------------------------------------------------------------------------- |
|
301 // Gets current listbox item index (relative to the original listbox). |
|
302 // ----------------------------------------------------------------------------- |
|
303 // |
|
304 TInt CMPXCommonContainerHgImp::CurrentLbxItemIndex() const |
|
305 { |
|
306 MPX_FUNC( "CMPXCommonContainerHgImp::CurrentLbxItemIndex" ); |
|
307 TInt index( KErrNotFound ); |
|
308 if ( iListWidget ) |
|
309 { |
|
310 const TInt count = CurrentListItemCount(); |
|
311 if ( count > 0 ) |
|
312 { |
|
313 index = iListWidget->SelectedIndex(); |
|
314 } |
|
315 } |
|
316 return index; |
|
317 } |
|
318 |
|
319 |
|
320 // ----------------------------------------------------------------------------- |
|
321 // Get current selected listbox items indices (relative to the original listbox) |
|
322 // ----------------------------------------------------------------------------- |
|
323 // |
|
324 const CArrayFix<TInt>* CMPXCommonContainerHgImp::CurrentSelectionIndicesL() const |
|
325 { |
|
326 MPX_FUNC( "CMPXCommonContainerHgImp::CurrentSelectionIndicesL" ); |
|
327 if ( iListWidget ) |
|
328 { |
|
329 iListSelections->Reset(); |
|
330 RArray<TInt> selectionArray; |
|
331 CleanupClosePushL( selectionArray ); |
|
332 iListWidget->GetMarkedItemsL(selectionArray); |
|
333 int count = selectionArray.Count(); |
|
334 for( int i = 0; i < count; i++ ) |
|
335 { |
|
336 iListSelections->AppendL( selectionArray[i] ); |
|
337 } |
|
338 CleanupStack::PopAndDestroy( &selectionArray ); |
|
339 } |
|
340 return iListSelections; |
|
341 } |
|
342 |
|
343 |
|
344 // ----------------------------------------------------------------------------- |
|
345 // Set current selected listbox items indices (relative to the original listbox) |
|
346 // ----------------------------------------------------------------------------- |
|
347 // |
|
348 void CMPXCommonContainerHgImp::SetCurrentSelectionIndicesL( |
|
349 CArrayFix<TInt>* aIndices ) const |
|
350 { |
|
351 MPX_FUNC( "CMPXCommonContainerHgImp::SetCurrentSelectionIndicesL" ); |
|
352 TInt count = aIndices->Count(); |
|
353 if ( count > 0 && iListWidget ) |
|
354 { |
|
355 for( TInt i = 0; i < count; i++ ) |
|
356 { |
|
357 iListWidget->Mark( (*aIndices)[i] ); |
|
358 } |
|
359 iListWidget->RefreshScreen( (*aIndices)[0] ); |
|
360 } |
|
361 } |
|
362 |
|
363 |
|
364 // ----------------------------------------------------------------------------- |
|
365 // Set top listbox item index. |
|
366 // ----------------------------------------------------------------------------- |
|
367 // |
|
368 void CMPXCommonContainerHgImp::SetLbxTopItemIndex( TInt /*aIndex*/ ) |
|
369 { |
|
370 MPX_FUNC( "CMPXCommonContainerHgImp::SetLbxTopItemIndex" ); |
|
371 } |
|
372 |
|
373 |
|
374 // ----------------------------------------------------------------------------- |
|
375 // Set current listbox item index. |
|
376 // ----------------------------------------------------------------------------- |
|
377 // |
|
378 void CMPXCommonContainerHgImp::SetLbxCurrentItemIndex( TInt aIndex ) |
|
379 { |
|
380 MPX_FUNC( "CMPXCommonContainerHgImp::SetLbxCurrentItemIndex" ); |
|
381 if ( iListWidget ) |
|
382 { |
|
383 iListWidget->SetSelectedIndex( aIndex ); |
|
384 } |
|
385 } |
|
386 |
|
387 |
|
388 // ----------------------------------------------------------------------------- |
|
389 // Set current listbox item index and highlight it. |
|
390 // ----------------------------------------------------------------------------- |
|
391 // |
|
392 void CMPXCommonContainerHgImp::SetLbxCurrentItemIndexAndDraw( |
|
393 TInt aIndex ) |
|
394 { |
|
395 MPX_FUNC( "CMPXCommonContainerHgImp::SetLbxCurrentItemIndexAndDraw" ); |
|
396 SetLbxCurrentItemIndex(aIndex); |
|
397 } |
|
398 |
|
399 |
|
400 // ----------------------------------------------------------------------------- |
|
401 // Clear listbox selection. |
|
402 // ----------------------------------------------------------------------------- |
|
403 // |
|
404 void CMPXCommonContainerHgImp::ClearLbxSelection() |
|
405 { |
|
406 MPX_FUNC( "CMPXCommonContainerHgImp::ClearLbxSelection" ); |
|
407 if ( iListWidget ) |
|
408 { |
|
409 iListWidget->UnMarkAll(); |
|
410 } |
|
411 } |
|
412 |
|
413 |
|
414 // ----------------------------------------------------------------------------- |
|
415 // Sets the text for an empty list box |
|
416 // ----------------------------------------------------------------------------- |
|
417 // |
|
418 void CMPXCommonContainerHgImp::SetLbxEmptyTextL( const TDesC& aText ) |
|
419 { |
|
420 MPX_FUNC( "CMPXCommonContainerHgImp::SetLbxEmptyTextL" ); |
|
421 |
|
422 if ( iListWidget && aText != KNullDesC ) |
|
423 { |
|
424 iListWidget->SetEmptyTextL( aText ); |
|
425 } |
|
426 } |
|
427 |
|
428 // ----------------------------------------------------------------------------- |
|
429 // Draws a list box item |
|
430 // ----------------------------------------------------------------------------- |
|
431 // |
|
432 void CMPXCommonContainerHgImp::DrawLbxItem( TInt aIndex ) |
|
433 { |
|
434 MPX_DEBUG2( "CMPXCommonContainerHgImp::DrawLbxItem (aIndex=%d)", aIndex ); |
|
435 if ( iListWidget && iBottomIndex > 0 ) |
|
436 { |
|
437 CHgItem* item = &iListWidget->ItemL(aIndex); |
|
438 SetDetailIndicatorL(item, aIndex); |
|
439 iListWidget->RefreshScreen(aIndex); |
|
440 } |
|
441 } |
|
442 |
|
443 |
|
444 // ----------------------------------------------------------------------------- |
|
445 // Set Find box's focus. |
|
446 // ----------------------------------------------------------------------------- |
|
447 // |
|
448 void CMPXCommonContainerHgImp::SetFindBoxFocus( TBool /*aFocus*/ ) |
|
449 { |
|
450 MPX_FUNC( "CMPXCommonContainerHgImp::SetFindBoxFocus" ); |
|
451 } |
|
452 |
|
453 |
|
454 // ----------------------------------------------------------------------------- |
|
455 // Handle listbox item addition. |
|
456 // ----------------------------------------------------------------------------- |
|
457 // |
|
458 void CMPXCommonContainerHgImp::HandleLbxItemAdditionL() |
|
459 { |
|
460 MPX_FUNC( "CMPXCommonContainerHgImp::HandleLbxItemAdditionL" ); |
|
461 SetCollectionContextL(); |
|
462 iLastValidMediaItemIndex = 0; |
|
463 if ( iListWidget ) |
|
464 { |
|
465 const CMPXMediaArray& mediaArray = iListBoxArray->MediaArray(); |
|
466 const TInt count( mediaArray.Count() ); |
|
467 MPX_DEBUG2( "CMPXCommonContainerHgImp::HandleLbxItemAdditionL count=%d", count); |
|
468 HandleLbxItemRemovalL(); |
|
469 |
|
470 iThumbnailReqMap.Reset(); |
|
471 for ( TInt i = 0; i < count; i++ ) |
|
472 { |
|
473 iThumbnailReqMap.Append( EFalse ); |
|
474 } |
|
475 |
|
476 if ( iContext == EContextItemAlbum && iContext != iPrevContext ) |
|
477 { |
|
478 // Save previous list so won't cause flickering when back. |
|
479 // If album view comes back again, we don't want to delete |
|
480 // title_list so skip this block for the same album track view. |
|
481 //iListWidget->SetFlags( CHgScroller::EHgScrollerScreenFreeze ); |
|
482 iListWidget->Reset(); |
|
483 iListWidget->SetFocus(EFalse); |
|
484 // this is needed to make list passive when we switch to list with title |
|
485 iListWidget->DisableScrollBuffer(); |
|
486 iPrevListWidget = iListWidget; |
|
487 iListWidget = NULL; |
|
488 CreateListBoxWithTitleL( count ); |
|
489 ProvideDataWithoutThumbnailsL(mediaArray); |
|
490 iListWidget->SetFocus(ETrue); |
|
491 } |
|
492 else |
|
493 { |
|
494 if ( iScrollerWithTitle && iContext != EContextItemAlbum ) |
|
495 { |
|
496 // Delete title_list when you are not in album_track view |
|
497 delete iScrollerWithTitle; |
|
498 iScrollerWithTitle = NULL; |
|
499 iListWidget = iPrevListWidget; |
|
500 // this is needed to make list active when we switch from list with title |
|
501 iListWidget->EnableScrollBufferL(*this, KMPXListBufferSize, KMPXListBufferSize/4); |
|
502 iListWidget->Reset(); |
|
503 iListWidget->SetFocus(ETrue); |
|
504 iListWidget->ResizeL( count ); |
|
505 ProvideDataWithoutThumbnailsL(mediaArray); |
|
506 } |
|
507 else |
|
508 { |
|
509 TInt index = iListWidget->SelectedIndex(); |
|
510 iListWidget->Reset(); |
|
511 if ( count ) |
|
512 { |
|
513 iListWidget->ResizeL( count ); |
|
514 ProvideDataWithoutThumbnailsL(mediaArray); |
|
515 iListWidget->SetSelectedIndex( index ); |
|
516 } |
|
517 else |
|
518 { |
|
519 iListWidget->RefreshScreen(0); |
|
520 } |
|
521 } |
|
522 } |
|
523 SetDefaultIconL(); |
|
524 SetScrollbarType(); |
|
525 } |
|
526 } |
|
527 |
|
528 |
|
529 // ----------------------------------------------------------------------------- |
|
530 // Handle listbox item addition, preserving the current display index |
|
531 // ----------------------------------------------------------------------------- |
|
532 // |
|
533 void CMPXCommonContainerHgImp::HandleLbxItemAdditionPreserveIndexL() |
|
534 { |
|
535 MPX_FUNC( "CMPXCommonContainerHgImp::HandleLbxItemAdditionPreserveIndexL" ); |
|
536 HandleLbxItemAdditionL(); |
|
537 } |
|
538 |
|
539 |
|
540 // ----------------------------------------------------------------------------- |
|
541 // Handle listbox item removal. |
|
542 // ----------------------------------------------------------------------------- |
|
543 // |
|
544 void CMPXCommonContainerHgImp::HandleLbxItemRemovalL() |
|
545 { |
|
546 MPX_FUNC( "CMPXCommonContainerHgImp::HandleLbxItemRemovalL" ); |
|
547 iTopIndex = 0; |
|
548 iBottomIndex = KErrNotFound; |
|
549 if ( iContext != iPrevContext ) |
|
550 { |
|
551 CancelTNRequest(); |
|
552 iThumbnailReqHashMap.Close(); |
|
553 iThumbnailReqMap.Close(); |
|
554 CleanAlbumArtReqQueue(); |
|
555 iRequestCount = 0; |
|
556 |
|
557 } |
|
558 } |
|
559 |
|
560 |
|
561 // ----------------------------------------------------------------------------- |
|
562 // Show/hide find box. |
|
563 // ----------------------------------------------------------------------------- |
|
564 // |
|
565 void CMPXCommonContainerHgImp::SetFindBoxVisibilityL( TBool /*aIsVisible*/ ) |
|
566 { |
|
567 } |
|
568 |
|
569 |
|
570 // ----------------------------------------------------------------------------- |
|
571 // Determine find box visibility |
|
572 // ----------------------------------------------------------------------------- |
|
573 // |
|
574 TBool CMPXCommonContainerHgImp::FindBoxVisibility() |
|
575 { |
|
576 return EFalse; |
|
577 } |
|
578 |
|
579 |
|
580 // ----------------------------------------------------------------------------- |
|
581 // Restore the PopupCBA of find box |
|
582 // ----------------------------------------------------------------------------- |
|
583 // |
|
584 void CMPXCommonContainerHgImp::RestoreFindBoxPopupCBA() |
|
585 { |
|
586 } |
|
587 |
|
588 |
|
589 // ----------------------------------------------------------------------------- |
|
590 // Calculate the top index of the visible items |
|
591 // ----------------------------------------------------------------------------- |
|
592 // |
|
593 TInt CMPXCommonContainerHgImp::CalculateTopIndex( TInt /*aBottomIndex*/ ) |
|
594 { |
|
595 MPX_FUNC( "CMPXCommonContainerHgImp::CalculateTopIndex" ); |
|
596 return 0; |
|
597 } |
|
598 |
|
599 |
|
600 // --------------------------------------------------------------------------- |
|
601 // Symbian 2nd phase constructor can leave. |
|
602 // --------------------------------------------------------------------------- |
|
603 // |
|
604 void CMPXCommonContainerHgImp::ConstructContainerL( TMPXCommonContainerCollectionType /*aCollectionType*/ ) |
|
605 { |
|
606 MPX_FUNC( "CMPXCommonContainerHgImp::ConstructContainerL" ); |
|
607 |
|
608 |
|
609 CCoeEnv* coeEnv( iEikonEnv ); |
|
610 TParse parse; |
|
611 parse.Set( KMPXCommonContainerRscPath, &KDC_APP_RESOURCE_DIR, NULL ); |
|
612 TFileName resourceFile( parse.FullName() ); |
|
613 User::LeaveIfError( MPXUser::CompleteWithDllPath( resourceFile ) ); |
|
614 BaflUtils::NearestLanguageFile( coeEnv->FsSession(), resourceFile ); |
|
615 iResourceOffset = coeEnv->AddResourceFileL( resourceFile ); |
|
616 |
|
617 #ifdef HG_MP_LOC_AVAILABLE |
|
618 iAlbumTitle = StringLoader::LoadL( R_MPX_COMMONCONTAINER_DETAILS_ONE_ALBUM ); |
|
619 iEpisodeTitle = StringLoader::LoadL( R_MPX_COMMONCONTAINER_DETAILS_ONE_EPISODE ); |
|
620 iSongTitle = StringLoader::LoadL( R_MPX_COMMONCONTAINER_DETAILS_ONE_SONG ); |
|
621 #endif //HG_MP_LOC_AVAILABLE |
|
622 |
|
623 |
|
624 CreateWindowL(); |
|
625 TRect mainPane( 0,0,0,0 ); |
|
626 iBgContext = CAknsBasicBackgroundControlContext::NewL( KAknsIIDQsnBgScreen, mainPane, ETrue); |
|
627 iBgContext->SetRect(CEikonEnv::Static()->EikAppUi()->ApplicationRect()); |
|
628 |
|
629 // Common methods used for 2-line list support |
|
630 iCommonUiHelper = CMPXCommonUiHelper::NewL(); |
|
631 iListSelections = new (ELeave) CArrayFixFlat<TInt>( KMPXListSelectionCount ); |
|
632 //// iTextureManager = new (ELeave) CMPXCommonContainerTextureManager2(); |
|
633 |
|
634 //Album art request queue |
|
635 //iRequestQueue = new TSglQue<TAlbumArtRequest>(_FOFF(TAlbumArtRequest, iLink)); |
|
636 iThumbnailManager = CThumbnailManager::NewL( *this ); |
|
637 iThumbnailManager->SetFlagsL( CThumbnailManager::EDefaultFlags ); |
|
638 iThumbnailManager->SetQualityPreferenceL( CThumbnailManager::EOptimizeForQuality ); |
|
639 iThumbnailManager->SetThumbnailSizeL( EAudioListThumbnailSize ); |
|
640 |
|
641 iImageSize = CHgDoubleGraphicList::PreferredImageSize(); |
|
642 |
|
643 TFileName pathWithoutDrive; |
|
644 iEikonEnv->FsSession().PrivatePath( pathWithoutDrive ); |
|
645 iSelectedAlbumItemFileName.Copy( KMPXDriveC ); |
|
646 iSelectedAlbumItemFileName.Append( pathWithoutDrive ); |
|
647 iSelectedAlbumItemFileName.Append( KMPXSelectedAlbumItemFileName ); |
|
648 |
|
649 |
|
650 CreateListBoxL( 0 ); |
|
651 } |
|
652 |
|
653 |
|
654 // --------------------------------------------------------------------------- |
|
655 // Enable/disable find box |
|
656 // --------------------------------------------------------------------------- |
|
657 // |
|
658 void CMPXCommonContainerHgImp::EnableFindBox( TBool /*aEnable*/ ) |
|
659 { |
|
660 MPX_FUNC( "CMPXCommonContainerHgImp::EnableFindBox" ); |
|
661 } |
|
662 |
|
663 |
|
664 // --------------------------------------------------------------------------- |
|
665 // Enable/disable marking |
|
666 // --------------------------------------------------------------------------- |
|
667 // |
|
668 void CMPXCommonContainerHgImp::EnableMarking( TBool /*aEnable*/ ) |
|
669 { |
|
670 MPX_FUNC( "CMPXCommonContainerHgImp::EnableMarking" ); |
|
671 } |
|
672 |
|
673 |
|
674 // --------------------------------------------------------------------------- |
|
675 // Custom handling of commands for markable lists. |
|
676 // --------------------------------------------------------------------------- |
|
677 // |
|
678 void CMPXCommonContainerHgImp::HandleMarkableListProcessCommandL( |
|
679 TInt aCommand ) |
|
680 { |
|
681 MPX_FUNC( "CMPXCommonContainerHgImp::HandleMarkableListProcessCommandL" ); |
|
682 |
|
683 if ( iListWidget ) |
|
684 { |
|
685 switch ( aCommand ) |
|
686 { |
|
687 case EAknCmdMark: |
|
688 iListWidget->Mark(iListWidget->SelectedIndex()); |
|
689 break; |
|
690 case EAknCmdUnmark: |
|
691 iListWidget->UnMark(iListWidget->SelectedIndex()); |
|
692 break; |
|
693 case EAknMarkAll: |
|
694 iListWidget->MarkAll(); |
|
695 break; |
|
696 case EAknUnmarkAll: |
|
697 iListWidget->UnMarkAll(); |
|
698 break; |
|
699 } |
|
700 iListWidget->RefreshScreen(iListWidget->SelectedIndex()); |
|
701 } |
|
702 } |
|
703 |
|
704 |
|
705 // --------------------------------------------------------------------------- |
|
706 // Custom handling of menu pane for markable lists |
|
707 // --------------------------------------------------------------------------- |
|
708 // |
|
709 void CMPXCommonContainerHgImp::HandleMarkableListDynInitMenuPane( |
|
710 TInt aResourceId, |
|
711 CEikMenuPane* aMenuPane ) |
|
712 { |
|
713 MPX_FUNC( "CMPXCommonContainerHgImp::HandleMarkableListDynInitMenuPane" ); |
|
714 |
|
715 if ( aResourceId == R_AVKON_MENUPANE_MARKABLE_LIST ) |
|
716 { |
|
717 TInt currentItem = CurrentLbxItemIndex(); |
|
718 if ( currentItem == KErrNotFound ) |
|
719 { |
|
720 aMenuPane->SetItemDimmed( EAknCmdEditListMenu, ETrue ); |
|
721 } |
|
722 else |
|
723 { |
|
724 aMenuPane->SetItemDimmed( EAknCmdEditListMenu, EFalse ); |
|
725 } |
|
726 } |
|
727 else if ( aResourceId == R_AVKON_MENUPANE_MARKABLE_LIST_IMPLEMENTATION ) |
|
728 { |
|
729 CurrentSelectionIndicesL(); |
|
730 TInt currentItem = CurrentLbxItemIndex(); |
|
731 if ( currentItem != KErrNotFound ) |
|
732 { |
|
733 TBool currentItemMarked = EFalse; |
|
734 for( int i = 0; i < iListSelections->Count(); i++ ) |
|
735 { |
|
736 if ( currentItem == iListSelections->At(i) ) |
|
737 { |
|
738 currentItemMarked = ETrue; |
|
739 break; |
|
740 } |
|
741 } |
|
742 |
|
743 aMenuPane->SetItemDimmed( EAknCmdMark, currentItemMarked ); |
|
744 aMenuPane->SetItemDimmed( EAknCmdUnmark, !currentItemMarked ); |
|
745 aMenuPane->SetItemDimmed( EAknMarkAll, iListSelections->Count() == iListWidget->ItemCount() ); |
|
746 aMenuPane->SetItemDimmed( EAknUnmarkAll, iListSelections->Count() == 0 ); |
|
747 } |
|
748 } |
|
749 } |
|
750 |
|
751 |
|
752 // --------------------------------------------------------------------------- |
|
753 // Handles key events. |
|
754 // --------------------------------------------------------------------------- |
|
755 // |
|
756 TKeyResponse CMPXCommonContainerHgImp::HandleKeyEventL( |
|
757 const TKeyEvent& aKeyEvent, |
|
758 TEventCode aType ) |
|
759 { |
|
760 MPX_DEBUG5( "CMPXCommonContainerHgImp::HandleKeyEventL(iCode=%d, iScanCode=%d, iModifiers=0x%x, aType=%d)", |
|
761 aKeyEvent.iCode, aKeyEvent.iScanCode, aKeyEvent.iModifiers, aType ); |
|
762 |
|
763 TKeyResponse response( EKeyWasNotConsumed ); |
|
764 if ( aKeyEvent.iCode == EKeyOK || aKeyEvent.iCode == EKeyEnter ) |
|
765 { |
|
766 if( CurrentLbxItemIndex() >= 0 ) |
|
767 { |
|
768 SaveSelectedAlbumItemL(); |
|
769 } |
|
770 // Handle enter key pressed |
|
771 iView->ProcessCommandL( EMPXCmdCommonEnterKey ); |
|
772 } |
|
773 if ( iListWidget ) |
|
774 { |
|
775 iListWidget->OfferKeyEventL( aKeyEvent, aType ); |
|
776 } |
|
777 |
|
778 if ( response == EKeyWasNotConsumed && |
|
779 aType == EEventKey && |
|
780 aKeyEvent.iCode == EKeyBackspace && iView ) |
|
781 { |
|
782 iView->ProcessCommandL( EMPXCmdCommonDelete ); |
|
783 response = EKeyWasConsumed; |
|
784 } |
|
785 |
|
786 return response; |
|
787 } |
|
788 |
|
789 // --------------------------------------------------------------------------- |
|
790 // Activate container |
|
791 // --------------------------------------------------------------------------- |
|
792 // |
|
793 void CMPXCommonContainerHgImp::ActivateContainerL() |
|
794 { |
|
795 // Nothing to do |
|
796 } |
|
797 |
|
798 |
|
799 // --------------------------------------------------------------------------- |
|
800 // From MMPXCommonListBoxArrayObserver |
|
801 // Handle listbox array events. |
|
802 // --------------------------------------------------------------------------- |
|
803 // |
|
804 void CMPXCommonContainerHgImp::HandleListBoxArrayEventL( |
|
805 MMPXCommonListBoxArrayObserver::TMPXCommonListBoxArrayEvents aEvent ) |
|
806 { |
|
807 MPX_FUNC( "CMPXCommonContainerHgImp::HandleListBoxArrayEventL" ); |
|
808 if ( aEvent == MMPXCommonListBoxArrayObserver::EMPXCommonListBoxArrayEventIconArrayChange ) |
|
809 { |
|
810 delete iIconArray; |
|
811 iIconArray = NULL; |
|
812 CreateIconArrayL(); |
|
813 } |
|
814 else if ( aEvent == MMPXCommonListBoxArrayObserver::EMPXCommonListBoxArrayEventMediaArrayChange ) |
|
815 { |
|
816 |
|
817 // Update list widget with new items in the media array. |
|
818 // We start the update from last valid media item index. |
|
819 if ( iListWidget ) |
|
820 { |
|
821 ProvideDataWithoutThumbnailsL(iListBoxArray->MediaArray(), iLastValidMediaItemIndex); |
|
822 |
|
823 if ( ( iLastValidMediaItemIndex >= iRequestStart ) |
|
824 && ( iLastValidMediaItemIndex >= iRequestEnd ) |
|
825 && ( iRequestStart != iRequestEnd ) ) |
|
826 { |
|
827 Request( iRequestStart, iRequestEnd, EHgBufferReset ); |
|
828 } |
|
829 |
|
830 iListWidget->RefreshScreen(iListWidget->FirstIndexOnScreen()); |
|
831 } |
|
832 } |
|
833 } |
|
834 |
|
835 |
|
836 // --------------------------------------------------------------------------- |
|
837 // From CCoeControl |
|
838 // Handles key events. |
|
839 // --------------------------------------------------------------------------- |
|
840 // |
|
841 TKeyResponse CMPXCommonContainerHgImp::OfferKeyEventL( |
|
842 const TKeyEvent& aKeyEvent, |
|
843 TEventCode aType ) |
|
844 { |
|
845 ASSERT( iViewContainer ); |
|
846 MPX_DEBUG5( "CMPXCommonContainerHgImp::OfferKeyEventL(iCode=%d, iScanCode=%d, iModifiers=0x%x, aType=%d)", |
|
847 aKeyEvent.iCode, aKeyEvent.iScanCode, aKeyEvent.iModifiers, aType ); |
|
848 |
|
849 // Let the view container handle the key event. |
|
850 return iViewContainer->HandleKeyEventL( aKeyEvent, aType ); |
|
851 } |
|
852 |
|
853 |
|
854 // --------------------------------------------------------------------------- |
|
855 // Gets the control's help context. |
|
856 // --------------------------------------------------------------------------- |
|
857 // |
|
858 void CMPXCommonContainerHgImp::GetHelpContext( |
|
859 TCoeHelpContext& aContext ) const |
|
860 { |
|
861 ASSERT( iViewContainer ); |
|
862 MPX_FUNC( "CMPXCommonContainerHgImp::GetHelpContext" ); |
|
863 // Let the view container handle the help context retrieval |
|
864 if ( iViewContainer ) |
|
865 { |
|
866 iViewContainer->HandleHelpContext( aContext ); |
|
867 } |
|
868 } |
|
869 |
|
870 // --------------------------------------------------------------------------- |
|
871 // From CCoeControl |
|
872 // Handles a change to the control's resources. |
|
873 // --------------------------------------------------------------------------- |
|
874 // |
|
875 void CMPXCommonContainerHgImp::HandleResourceChange( TInt aType ) |
|
876 { |
|
877 MPX_FUNC( "CMPXCommonContainerHgImp::HandleResourceChange" ); |
|
878 CCoeControl::HandleResourceChange( aType ); |
|
879 |
|
880 TRAP_IGNORE( |
|
881 if ( aType == KAknsMessageSkinChange ) |
|
882 { |
|
883 iListWidget->SetDefaultIconL(NULL); |
|
884 delete iIconArray; |
|
885 iIconArray = NULL; |
|
886 CreateIconArrayL(); |
|
887 iListWidget->EnableScrollBufferL(*this, KMPXListBufferSize, KMPXListBufferSize/4); |
|
888 } |
|
889 else if ( aType == KEikDynamicLayoutVariantSwitch ) |
|
890 { |
|
891 TRect clientRect = ((CAknView*)iView)->ClientRect(); |
|
892 iBgContext->SetRect(CEikonEnv::Static()->EikAppUi()->ApplicationRect()); |
|
893 if ( iScrollerWithTitle ) |
|
894 { |
|
895 iScrollerWithTitle->InitScreenL(clientRect); |
|
896 iPrevListWidget->InitScreenL(clientRect); |
|
897 } |
|
898 else |
|
899 { |
|
900 iListWidget->InitScreenL(clientRect); |
|
901 } |
|
902 SetScrollbarType(); |
|
903 } |
|
904 ); |
|
905 } |
|
906 |
|
907 |
|
908 // --------------------------------------------------------------------------- |
|
909 // Draw this application's view to the screen |
|
910 // --------------------------------------------------------------------------- |
|
911 // |
|
912 void CMPXCommonContainerHgImp::Draw(const TRect& /*aRect*/) const |
|
913 { |
|
914 // Do nothing so that list model will be drawn by hg list |
|
915 } |
|
916 |
|
917 |
|
918 // --------------------------------------------------------------------------- |
|
919 // From MCoeControlObserver |
|
920 // Handle control event |
|
921 // --------------------------------------------------------------------------- |
|
922 // |
|
923 void CMPXCommonContainerHgImp::HandleControlEventL( |
|
924 CCoeControl* /*aControl*/, |
|
925 TCoeEvent /*aEventType*/ ) |
|
926 { |
|
927 } |
|
928 |
|
929 |
|
930 // --------------------------------------------------------------------------- |
|
931 // From CCoeControl |
|
932 // Provide control input capabilities |
|
933 // --------------------------------------------------------------------------- |
|
934 // |
|
935 TCoeInputCapabilities CMPXCommonContainerHgImp::InputCapabilities() const |
|
936 { |
|
937 if( iListWidget ) |
|
938 { |
|
939 return iListWidget->InputCapabilities(); |
|
940 } |
|
941 return CCoeControl::InputCapabilities(); |
|
942 } |
|
943 |
|
944 |
|
945 // --------------------------------------------------------------------------- |
|
946 // From MHgSelectionObserver |
|
947 // Handle Item Selection |
|
948 // --------------------------------------------------------------------------- |
|
949 // |
|
950 void CMPXCommonContainerHgImp::HandleSelectL( TInt /*aIndex*/ ) |
|
951 { |
|
952 MPX_FUNC( "CMPXCommonContainerHgImp::HandleSelect" ); |
|
953 } |
|
954 |
|
955 |
|
956 // --------------------------------------------------------------------------- |
|
957 // From MHgSelectionObserver |
|
958 // Handle Item opened |
|
959 // --------------------------------------------------------------------------- |
|
960 // |
|
961 void CMPXCommonContainerHgImp::HandleOpenL( TInt /*aIndex*/ ) |
|
962 { |
|
963 MPX_FUNC( "CMPXCommonContainerHgImp::HandleOpenL" ); |
|
964 |
|
965 SaveSelectedAlbumItemL(); |
|
966 iView->ProcessCommandL( EMPXCmdCommonEnterKey ); |
|
967 } |
|
968 |
|
969 |
|
970 // ----------------------------------------------------------------------------- |
|
971 // Provides the data to the model |
|
972 // ----------------------------------------------------------------------------- |
|
973 // |
|
974 void CMPXCommonContainerHgImp::Request( |
|
975 TInt aBufferStart, |
|
976 TInt aBufferEnd, |
|
977 THgScrollDirection aDirection ) |
|
978 { |
|
979 MPX_FUNC( "CMPXCommonContainerHgImp::Request" ); |
|
980 MPX_DEBUG3( "CMPXCommonContainerHgImp::Request aBufferStart = %d, aBufferEnd = %d", |
|
981 aBufferStart, aBufferEnd ); |
|
982 |
|
983 // This should not happen but if not handled, bad things will happen. |
|
984 if ( aBufferStart < 0 || aBufferEnd < 0 ) |
|
985 return; |
|
986 |
|
987 |
|
988 |
|
989 //iBottomIndex = aBufferEnd; |
|
990 |
|
991 if ( aBufferStart > iLastValidMediaItemIndex || aBufferEnd > iLastValidMediaItemIndex ) |
|
992 { |
|
993 // We cannot provide data for the requested range at this time. |
|
994 // Remember the request so we can handle it when there's enough data. |
|
995 iRequestStart = aBufferStart; |
|
996 iRequestEnd = aBufferEnd; |
|
997 return; |
|
998 } |
|
999 iDirection = aDirection; |
|
1000 |
|
1001 for ( TInt i = aBufferStart; i <= aBufferEnd; i++ ) |
|
1002 { |
|
1003 iThumbnailReqMap[ i ] = EFalse; |
|
1004 } |
|
1005 |
|
1006 |
|
1007 if ( aDirection == EHgBufferReset || aDirection == EHgBufferScrollDown || aDirection == EHgBufferScrollUp) |
|
1008 { |
|
1009 // For index range in visible-area |
|
1010 ProvideDataIntersectL(aBufferStart, aBufferEnd); |
|
1011 // For index range elsewhere |
|
1012 ProvideDataDifferenceL(aBufferStart, aBufferEnd); |
|
1013 } |
|
1014 else |
|
1015 { |
|
1016 ProvideDataL(aBufferStart, aBufferEnd); |
|
1017 } |
|
1018 |
|
1019 //RefreshL(aBufferStart); |
|
1020 // When in main collection view, list can be refresh |
|
1021 // without waiting on thumbnails since this list doesn't |
|
1022 // require thumbnails. |
|
1023 if ( iContext == EContextGroupCollection || |
|
1024 iContext == EContextGroupPlaylist || |
|
1025 iContext == EContextGroupGenre || |
|
1026 iContext == EContextGroupComposer ) |
|
1027 { |
|
1028 iListWidget->RefreshScreen( aBufferStart ); |
|
1029 } |
|
1030 iTopIndex = aBufferStart; |
|
1031 iBottomIndex = aBufferEnd; |
|
1032 } |
|
1033 |
|
1034 // ----------------------------------------------------------------------------- |
|
1035 // Check if request range also covers the visible area and provide data |
|
1036 // to it first. |
|
1037 // ----------------------------------------------------------------------------- |
|
1038 // |
|
1039 void CMPXCommonContainerHgImp::ProvideDataIntersectL( |
|
1040 TInt aBufferStart, |
|
1041 TInt aBufferEnd ) |
|
1042 { |
|
1043 TInt firstOnScreen = iListWidget->FirstIndexOnScreen(); |
|
1044 TInt lastOnScreen = firstOnScreen + iListWidget->ItemsOnScreen(); |
|
1045 |
|
1046 const CMPXMediaArray& mediaArray = iListBoxArray->MediaArray(); |
|
1047 |
|
1048 for ( TInt i = firstOnScreen; i <= lastOnScreen; i++) |
|
1049 { |
|
1050 for ( TInt j = aBufferStart; j <= aBufferEnd; j++) |
|
1051 { |
|
1052 if ( i == j ) |
|
1053 { |
|
1054 // Just get the exiting item and update the fields + icon. |
|
1055 CHgItem* item = &iListWidget->ItemL(i); |
|
1056 |
|
1057 CMPXMedia* currentMedia( mediaArray.AtL( i ) ); |
|
1058 |
|
1059 // Add detailed text to the list item, if available |
|
1060 AddDetailToDisplayedItemL( item, currentMedia, i ); |
|
1061 AddThumbnailToDisplayedItemL( item, currentMedia, i ); |
|
1062 break; |
|
1063 } |
|
1064 } |
|
1065 } |
|
1066 } |
|
1067 |
|
1068 // ----------------------------------------------------------------------------- |
|
1069 // Handles request range outside of visible area. |
|
1070 // ----------------------------------------------------------------------------- |
|
1071 // |
|
1072 void CMPXCommonContainerHgImp::ProvideDataDifferenceL( |
|
1073 TInt aBufferStart, |
|
1074 TInt aBufferEnd) |
|
1075 { |
|
1076 TBool found = EFalse; |
|
1077 TInt firstOnScreen = iListWidget->FirstIndexOnScreen(); |
|
1078 TInt lastOnScreen = firstOnScreen + iListWidget->ItemsOnScreen(); |
|
1079 |
|
1080 if (aBufferStart == firstOnScreen && aBufferEnd == lastOnScreen) |
|
1081 return; |
|
1082 |
|
1083 const CMPXMediaArray& mediaArray = iListBoxArray->MediaArray(); |
|
1084 for ( TInt i = aBufferStart; i <= aBufferEnd; i++) |
|
1085 { |
|
1086 found = EFalse; |
|
1087 // look for index in visible range |
|
1088 for ( TInt j = firstOnScreen; j <= lastOnScreen; j++) |
|
1089 { |
|
1090 if ( i == j ) |
|
1091 { |
|
1092 found = ETrue; |
|
1093 break; |
|
1094 } |
|
1095 } |
|
1096 if (!found) |
|
1097 { |
|
1098 // Just get the exiting item and update the fields + icon. |
|
1099 CHgItem* item = &iListWidget->ItemL(i); |
|
1100 |
|
1101 CMPXMedia* currentMedia( mediaArray.AtL( i ) ); |
|
1102 |
|
1103 // Add detailed text to the list item, if available |
|
1104 AddDetailToDisplayedItemL( item, currentMedia, i ); |
|
1105 AddThumbnailToDisplayedItemL( item, currentMedia, i ); |
|
1106 } |
|
1107 } |
|
1108 } |
|
1109 // ----------------------------------------------------------------------------- |
|
1110 // CMPXCommonContainerHgImp::ProvideDataWithouThumbnailsL |
|
1111 // ----------------------------------------------------------------------------- |
|
1112 // |
|
1113 void CMPXCommonContainerHgImp::ProvideDataWithoutThumbnailsL( |
|
1114 const CMPXMediaArray& aMediaArray, |
|
1115 TInt aStartIndex ) |
|
1116 { |
|
1117 MPX_FUNC( "CMPXCommonContainerHgImp::ProvideDataWithouThumbnailsL" ); |
|
1118 |
|
1119 for ( TInt i = aStartIndex; i < aMediaArray.Count() ; i++ ) |
|
1120 { |
|
1121 CMPXMedia* currentMedia( aMediaArray.AtL( i ) ); |
|
1122 |
|
1123 if ( currentMedia->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) == |
|
1124 KMPXInvalidItemId ) |
|
1125 { |
|
1126 |
|
1127 break; |
|
1128 } |
|
1129 |
|
1130 // Just get the exiting item and update the fields + icon. |
|
1131 CHgItem* item = &iListWidget->ItemL(i); |
|
1132 SetTitleL( item, currentMedia ); |
|
1133 AddDetailToDisplayedItemL( item, currentMedia, i ); |
|
1134 iLastValidMediaItemIndex = i; |
|
1135 |
|
1136 } |
|
1137 } |
|
1138 |
|
1139 // ----------------------------------------------------------------------------- |
|
1140 // CMPXCommonContainerHgImp::ProvideDataL |
|
1141 // ----------------------------------------------------------------------------- |
|
1142 // |
|
1143 void CMPXCommonContainerHgImp::ProvideDataL( TInt aStart, TInt aEnd ) |
|
1144 { |
|
1145 MPX_FUNC( "CMPXCommonContainerHgImp::ProvideDataL" ); |
|
1146 MPX_DEBUG3( "CMPXCommonContainerHgImp::ProvideDataL aStart = %d, aEnd = %d", |
|
1147 aStart, aEnd ); |
|
1148 if ( aStart < 0 ) aStart = 0; |
|
1149 if ( aEnd < 0 ) aEnd = 0; |
|
1150 |
|
1151 const CMPXMediaArray& mediaArray = iListBoxArray->MediaArray(); |
|
1152 for ( TInt i = aStart; i <= aEnd ; i++ ) |
|
1153 { |
|
1154 // Just get the exiting item and update the fields + icon. |
|
1155 CHgItem* item = &iListWidget->ItemL(i); |
|
1156 |
|
1157 CMPXMedia* currentMedia( mediaArray.AtL( i ) ); |
|
1158 |
|
1159 // Add detailed text to the list item, if available |
|
1160 AddDetailToDisplayedItemL( item, currentMedia, i ); |
|
1161 AddThumbnailToDisplayedItemL( item, currentMedia, i ); |
|
1162 } |
|
1163 } |
|
1164 |
|
1165 // ----------------------------------------------------------------------------- |
|
1166 // CMPXCommonContainerHgImp::Release |
|
1167 // ----------------------------------------------------------------------------- |
|
1168 // |
|
1169 void CMPXCommonContainerHgImp::Release(TInt aReleaseStart, TInt aReleaseEnd) |
|
1170 { |
|
1171 MPX_FUNC( "CMPXCommonContainerHgImp::Release" ); |
|
1172 |
|
1173 TInt queuecount=0; |
|
1174 |
|
1175 if (iQueueCounter !=0) |
|
1176 { |
|
1177 for (TInt i=0; i<iQueueCounter; i++ ) |
|
1178 { |
|
1179 iAlbumArtRequest = iRequestQueue.First(); |
|
1180 iRequestQueue.Remove(*iAlbumArtRequest); |
|
1181 |
|
1182 if ( (iAlbumArtRequest->iIndex) >= aReleaseStart |
|
1183 && (iAlbumArtRequest->iIndex) <=aReleaseEnd ) |
|
1184 { |
|
1185 delete iAlbumArtRequest->iAlbumArtUri; //not sure needed or not |
|
1186 delete iAlbumArtRequest; |
|
1187 } |
|
1188 else |
|
1189 { |
|
1190 iRequestQueue.AddLast(*iAlbumArtRequest); |
|
1191 ++queuecount; |
|
1192 } |
|
1193 } |
|
1194 iQueueCounter = queuecount; |
|
1195 } |
|
1196 } |
|
1197 |
|
1198 |
|
1199 // ----------------------------------------------------------------------------- |
|
1200 // Preview thumbnail generation or loading is complete. |
|
1201 // ----------------------------------------------------------------------------- |
|
1202 // |
|
1203 void CMPXCommonContainerHgImp::ThumbnailPreviewReady( |
|
1204 MThumbnailData& /*aThumbnail*/, |
|
1205 TThumbnailRequestId /*aId*/ ) |
|
1206 { |
|
1207 MPX_FUNC( "CMPXCommonContainerHgImp::ThumbnailPreviewReady" ); |
|
1208 // Not used |
|
1209 } |
|
1210 |
|
1211 |
|
1212 // ----------------------------------------------------------------------------- |
|
1213 // Final thumbnail bitmap generation or loading is complete. |
|
1214 // ----------------------------------------------------------------------------- |
|
1215 // |
|
1216 void CMPXCommonContainerHgImp::ThumbnailReady( |
|
1217 TInt aError, MThumbnailData& aThumbnail, |
|
1218 TThumbnailRequestId aId ) |
|
1219 { |
|
1220 MPX_FUNC( "CMPXCommonContainerHgImp::ThumbnailReady" ); |
|
1221 MPX_DEBUG2( "CMPXCommonContainerHgImp::ThumbnailReady error = %d", aError); |
|
1222 |
|
1223 TInt index = 0; |
|
1224 // Find the index |
|
1225 const TInt *ret = iThumbnailReqHashMap.Find( (TInt)aId); |
|
1226 if ( ret ) |
|
1227 { |
|
1228 index = *ret; |
|
1229 } |
|
1230 |
|
1231 if ( aError == KErrNone && ret ) |
|
1232 { |
|
1233 const CMPXMediaArray& mediaArray = iListBoxArray->MediaArray(); |
|
1234 CMPXMedia* currentMedia( mediaArray.AtL( index ) ); |
|
1235 if ( currentMedia->IsSupported( KMPXMediaGeneralId ) ) |
|
1236 { |
|
1237 CFbsBitmap* bmap = aThumbnail.DetachBitmap(); |
|
1238 if ( bmap ) |
|
1239 { |
|
1240 CGulIcon* icon = CGulIcon::NewL(bmap, NULL); |
|
1241 |
|
1242 if ( iScrollerWithTitle && !iTitleSet ) |
|
1243 { |
|
1244 iScrollerWithTitle->TitleItem().SetIcon(icon); |
|
1245 iScrollerWithTitle->MakeVisible(ETrue); |
|
1246 iListWidget->MakeVisible( ETrue ); |
|
1247 |
|
1248 iScrollerWithTitle->DrawNow(); |
|
1249 iTitleSet = ETrue; |
|
1250 } |
|
1251 else |
|
1252 { |
|
1253 iListWidget->ItemL(index).SetIcon(icon); |
|
1254 iThumbnailReqMap[index] = ETrue; |
|
1255 RefreshL(index); |
|
1256 } |
|
1257 } |
|
1258 } |
|
1259 iThumbnailReqHashMap.Remove( (TInt)aId); |
|
1260 |
|
1261 // if request queue is not empty, we can send one or more requests |
|
1262 if ( !iRequestQueue.IsEmpty() ) |
|
1263 { |
|
1264 iAlbumArtRequest = iRequestQueue.First(); |
|
1265 iRequestQueue.Remove(*iAlbumArtRequest); |
|
1266 --iQueueCounter; |
|
1267 TInt index = iAlbumArtRequest->iIndex; |
|
1268 |
|
1269 const TDesC& albumArtUri = *(iAlbumArtRequest->iAlbumArtUri); |
|
1270 |
|
1271 CThumbnailObjectSource* source = CThumbnailObjectSource::NewLC( albumArtUri, KMPXAlbumMimeType ); |
|
1272 |
|
1273 delete iAlbumArtRequest->iAlbumArtUri; |
|
1274 delete iAlbumArtRequest; |
|
1275 // Using negative index as priority will ensure that thumbnail requests |
|
1276 // are processed in the order they were requested. |
|
1277 TInt ret = NULL; |
|
1278 TInt reqId; |
|
1279 TRAPD(err, reqId = (TInt) iThumbnailManager->GetThumbnailL( *source, (TAny*)ret, -index )); |
|
1280 if ( err == KErrNone) |
|
1281 { |
|
1282 iThumbnailReqHashMap.InsertL( reqId, index ); |
|
1283 } |
|
1284 CleanupStack::PopAndDestroy( source ); |
|
1285 } |
|
1286 else |
|
1287 { |
|
1288 //request queue is empty, decrease outstanding requests count |
|
1289 iRequestCount--; |
|
1290 } |
|
1291 } |
|
1292 |
|
1293 else |
|
1294 { |
|
1295 |
|
1296 if ( ret ) |
|
1297 { |
|
1298 index = *ret; |
|
1299 iThumbnailReqHashMap.Remove( (TInt)aId); |
|
1300 } |
|
1301 else |
|
1302 { |
|
1303 return; |
|
1304 } |
|
1305 |
|
1306 //no albumart supported |
|
1307 SetDefaultIconL(index); |
|
1308 if ( iScrollerWithTitle && !iTitleSet ) |
|
1309 { |
|
1310 iScrollerWithTitle->MakeVisible(ETrue); |
|
1311 iListWidget->MakeVisible( ETrue ); |
|
1312 iScrollerWithTitle->DrawNow(); |
|
1313 iTitleSet = ETrue; |
|
1314 } |
|
1315 else |
|
1316 { |
|
1317 iThumbnailReqMap[index] = ETrue; |
|
1318 RefreshL(index); |
|
1319 } |
|
1320 } |
|
1321 |
|
1322 } |
|
1323 |
|
1324 // --------------------------------------------------------------------------- |
|
1325 // Refresh for item without thumbnail |
|
1326 // --------------------------------------------------------------------------- |
|
1327 // |
|
1328 void CMPXCommonContainerHgImp::RefreshNoThumbnailL(TInt aIndex) |
|
1329 { |
|
1330 MPX_FUNC( "CMPXCommonContainerHgImp::RefreshNoThumbnail" ); |
|
1331 |
|
1332 if ( iScrollerWithTitle && !iTitleSet ) |
|
1333 { |
|
1334 iScrollerWithTitle->MakeVisible(ETrue); |
|
1335 iListWidget->MakeVisible( ETrue ); |
|
1336 iScrollerWithTitle->DrawNow(); |
|
1337 iTitleSet = ETrue; |
|
1338 } |
|
1339 else |
|
1340 { |
|
1341 RefreshL(aIndex); |
|
1342 } |
|
1343 } |
|
1344 // --------------------------------------------------------------------------- |
|
1345 // Refresh list as needed. |
|
1346 // This function tries to determine the best time to refresh the screen as to |
|
1347 // avoid too many redraws. In some cases, multiple refresh is unavoidable. |
|
1348 // --------------------------------------------------------------------------- |
|
1349 // |
|
1350 void CMPXCommonContainerHgImp::RefreshL(TInt aIndex) |
|
1351 { |
|
1352 MPX_FUNC( "CMPXCommonContainerHgImp::Refresh" ); |
|
1353 |
|
1354 TInt mediaCount = iListBoxArray->MediaArray().Count(); |
|
1355 |
|
1356 TInt firstOnScreen = iListWidget->FirstIndexOnScreen(); |
|
1357 TInt lastOnScreen = firstOnScreen + iListWidget->ItemsOnScreen(); |
|
1358 |
|
1359 if (lastOnScreen > (mediaCount - 1)) |
|
1360 lastOnScreen = mediaCount - 1; |
|
1361 |
|
1362 // Refresh screen if the item is within view and no more thumbnails expected. |
|
1363 if ( aIndex >= firstOnScreen && aIndex <= lastOnScreen ) |
|
1364 { |
|
1365 TBool canRefresh(ETrue); |
|
1366 for (TInt i= firstOnScreen; i <= lastOnScreen; i++) |
|
1367 { |
|
1368 if ( !iThumbnailReqMap[i] ) |
|
1369 { |
|
1370 canRefresh = EFalse; |
|
1371 break; |
|
1372 } |
|
1373 } |
|
1374 if ( canRefresh ) |
|
1375 { |
|
1376 iListWidget->RefreshScreen( firstOnScreen ); |
|
1377 } |
|
1378 } |
|
1379 } |
|
1380 // --------------------------------------------------------------------------- |
|
1381 // Create list box |
|
1382 // --------------------------------------------------------------------------- |
|
1383 // |
|
1384 void CMPXCommonContainerHgImp::CreateListBoxL(TInt count) |
|
1385 { |
|
1386 MPX_FUNC( "CMPXCommonContainerHgImp::CreateListBox" ); |
|
1387 |
|
1388 TRect clientRect = ((CAknView*)iView)->ClientRect(); |
|
1389 iListWidget = CHgDoubleGraphicList::NewL ( |
|
1390 clientRect, |
|
1391 count, |
|
1392 NULL, |
|
1393 DSA_PARAM ); |
|
1394 iListWidget->SetMopParent(this); |
|
1395 iListWidget->SetSelectionObserver(*this); |
|
1396 iListWidget->ClearFlags( CHgScroller::EHgScrollerKeyMarkingDisabled ); |
|
1397 iListWidget->SetFocus(ETrue); |
|
1398 iListWidget->EnableScrollBufferL(*this, KMPXListBufferSize, KMPXListBufferSize/4); |
|
1399 iListWidget->SetScrollBarTypeL( CHgScroller::EHgScrollerScrollBar ); |
|
1400 } |
|
1401 |
|
1402 |
|
1403 // --------------------------------------------------------------------------- |
|
1404 // Create list box with Title |
|
1405 // --------------------------------------------------------------------------- |
|
1406 // |
|
1407 void CMPXCommonContainerHgImp::CreateListBoxWithTitleL( TInt count ) |
|
1408 { |
|
1409 MPX_FUNC( "CMPXCommonContainerHgImp::CreateListBoxWithTitleL" ); |
|
1410 |
|
1411 TRect clientRect = ((CAknView*)iView)->ClientRect(); |
|
1412 iScrollerWithTitle = CHgScrollerWithTitle::NewL ( |
|
1413 clientRect, |
|
1414 count, |
|
1415 CHgScrollerWithTitle::EHgScrollerDoubleTextList, |
|
1416 NULL); |
|
1417 |
|
1418 if ( iSelectedMediaInAlbumView ) |
|
1419 { |
|
1420 delete iSelectedMediaInAlbumView; |
|
1421 iSelectedMediaInAlbumView = NULL; |
|
1422 } |
|
1423 |
|
1424 iSelectedMediaInAlbumView = CMPXMedia::NewL(); |
|
1425 |
|
1426 ReadFromStreamFileL( iSelectedMediaInAlbumView ); |
|
1427 |
|
1428 CHgItem *item = &iScrollerWithTitle->TitleItem(); |
|
1429 SetDetailAlbumL( item, iSelectedMediaInAlbumView ); |
|
1430 SetDetailArtistL( item, iSelectedMediaInAlbumView ); |
|
1431 SetDetailIconL( item, 1 ); |
|
1432 |
|
1433 |
|
1434 iTitleSet = EFalse; |
|
1435 |
|
1436 iScrollerWithTitle->SetMopParent(this); |
|
1437 iScrollerWithTitle->SetFocus(ETrue); |
|
1438 iScrollerWithTitle->InitScreenL( clientRect ); |
|
1439 iScrollerWithTitle->MakeVisible(EFalse); |
|
1440 |
|
1441 iListWidget = &iScrollerWithTitle->Scroller(); |
|
1442 iListWidget->SetSelectionObserver(*this); |
|
1443 iListWidget->EnableScrollBufferL(*this, KMPXListBufferSize, KMPXListBufferSize/4); |
|
1444 iListWidget->SetScrollBarTypeL( CHgScroller::EHgScrollerScrollBar ); |
|
1445 iListWidget->MakeVisible(EFalse); |
|
1446 } |
|
1447 |
|
1448 |
|
1449 // ----------------------------------------------------------------------------- |
|
1450 // Creates icon array, populates iIconArray to be used by listbox |
|
1451 // ----------------------------------------------------------------------------- |
|
1452 // |
|
1453 void CMPXCommonContainerHgImp::CreateIconArrayL() |
|
1454 { |
|
1455 MPX_FUNC( "CMPXCommonContainerHgImp::CreateIconArrayL" ); |
|
1456 if ( iListBoxArray ) |
|
1457 { |
|
1458 iIconArray = iListBoxArray->CreateIconArrayL(); |
|
1459 } |
|
1460 SetDefaultIconL(); |
|
1461 } |
|
1462 // ----------------------------------------------------------------------------- |
|
1463 // Sets default icon to the HgList |
|
1464 // ----------------------------------------------------------------------------- |
|
1465 // |
|
1466 void CMPXCommonContainerHgImp::SetDefaultIconL() |
|
1467 { |
|
1468 |
|
1469 TDefaultIcon defaultIcon( EMPXDefaultIconEmpty ); |
|
1470 TInt iconIndex( EMPXClvIconEmpty ); |
|
1471 |
|
1472 switch( iContext ) |
|
1473 { |
|
1474 case EContextGroupArtist: |
|
1475 case EContextItemArtist: |
|
1476 case EContextGroupAlbum: |
|
1477 { |
|
1478 break; |
|
1479 } |
|
1480 case EContextGroupPodcast: |
|
1481 case EContextItemPodcast: |
|
1482 { |
|
1483 defaultIcon = EMPXDefaultTitleIconPodcasts; |
|
1484 iconIndex = EMPXPodClvIconTitle; // Podcast default icon |
|
1485 break; |
|
1486 } |
|
1487 case EContextGroupPlaylist: |
|
1488 { |
|
1489 defaultIcon = EMPXDefaultIconPlaylist; |
|
1490 iconIndex = EMPXClvIconPlaylist; |
|
1491 break; |
|
1492 } |
|
1493 case EContextGroupGenre: |
|
1494 { |
|
1495 defaultIcon = EMPXDefaultIconGenre; |
|
1496 iconIndex = EMPXClvIconGenre; |
|
1497 break; |
|
1498 } |
|
1499 case EContextGroupComposer: |
|
1500 { |
|
1501 defaultIcon = EMPXDefaultIconComposer; |
|
1502 iconIndex = EMPXClvIconComposer; |
|
1503 break; |
|
1504 } |
|
1505 case EContextItemComposer: |
|
1506 case EContextGroupSong: |
|
1507 case EContextItemSong: |
|
1508 case EContextItemPlaylist: |
|
1509 case EContextItemGenre: |
|
1510 case EContextItemAlbum: |
|
1511 case EContextGroupCollection: |
|
1512 case EContextUnknown: |
|
1513 default: |
|
1514 { |
|
1515 // no default icon for main menu items |
|
1516 break; |
|
1517 } |
|
1518 } |
|
1519 |
|
1520 if ( iListWidget ) |
|
1521 { |
|
1522 |
|
1523 CGulIcon* icon = (*iIconArray)[iconIndex]; |
|
1524 CFbsBitmap* bitmap = icon->Bitmap(); |
|
1525 CFbsBitmap* mask = icon->Mask(); |
|
1526 |
|
1527 TSize size(iImageSize.iWidth, iImageSize.iHeight); |
|
1528 AknIconUtils::SetSize( bitmap, size ); |
|
1529 AknIconUtils::SetSize( mask, size ); |
|
1530 |
|
1531 CGulIcon* iconCopy = CGulIcon::NewL(bitmap, mask); |
|
1532 iconCopy->SetBitmapsOwnedExternally(ETrue); |
|
1533 |
|
1534 iListWidget->SetDefaultIconL(iconCopy); |
|
1535 iCurrentDefaultIcon = defaultIcon; |
|
1536 } |
|
1537 } |
|
1538 |
|
1539 // ----------------------------------------------------------------------------- |
|
1540 // Sets default icon to list item |
|
1541 // ----------------------------------------------------------------------------- |
|
1542 // |
|
1543 void CMPXCommonContainerHgImp::SetDefaultIconL(TInt aIndex) |
|
1544 { |
|
1545 |
|
1546 TDefaultIcon defaultIcon( EMPXDefaultIconNotSet ); |
|
1547 TInt iconIndex( EMPXClvIconNone ); |
|
1548 |
|
1549 switch( iContext ) |
|
1550 { |
|
1551 case EContextGroupArtist: |
|
1552 case EContextItemArtist: |
|
1553 { |
|
1554 defaultIcon = EMPXDefaultIconArtist; |
|
1555 iconIndex = EMPXClvIconArtist; |
|
1556 break; |
|
1557 } |
|
1558 case EContextGroupAlbum: |
|
1559 { |
|
1560 defaultIcon = EMPXDefaultIconAlbum; |
|
1561 iconIndex = EMPXClvIconAlbum; |
|
1562 break; |
|
1563 } |
|
1564 case EContextGroupPodcast: |
|
1565 case EContextItemPodcast: |
|
1566 { |
|
1567 defaultIcon = EMPXDefaultTitleIconPodcasts; |
|
1568 iconIndex = EMPXPodClvIconTitle; // Podcast default icon |
|
1569 break; |
|
1570 } |
|
1571 case EContextItemComposer: |
|
1572 case EContextGroupSong: |
|
1573 case EContextItemSong: |
|
1574 case EContextItemPlaylist: |
|
1575 case EContextItemGenre: |
|
1576 case EContextItemAlbum: |
|
1577 { |
|
1578 defaultIcon = EMPXDefaultIconSongs; |
|
1579 iconIndex = EMPXClvIconSongs; |
|
1580 break; |
|
1581 } |
|
1582 default: |
|
1583 { |
|
1584 break; |
|
1585 } |
|
1586 } |
|
1587 |
|
1588 if ( iListWidget && defaultIcon != EMPXDefaultIconNotSet ) |
|
1589 { |
|
1590 |
|
1591 |
|
1592 CGulIcon* icon = (*iIconArray)[iconIndex]; |
|
1593 CFbsBitmap* bitmap = icon->Bitmap(); |
|
1594 CFbsBitmap* mask = icon->Mask(); |
|
1595 |
|
1596 TSize size(iImageSize.iWidth, iImageSize.iHeight); |
|
1597 AknIconUtils::SetSize( bitmap, size ); |
|
1598 AknIconUtils::SetSize( mask, size ); |
|
1599 |
|
1600 CGulIcon* iconCopy = CGulIcon::NewL(bitmap, mask); |
|
1601 iconCopy->SetBitmapsOwnedExternally(ETrue); |
|
1602 iListWidget->ItemL(aIndex).SetIcon(iconCopy); |
|
1603 } |
|
1604 } |
|
1605 |
|
1606 |
|
1607 // ----------------------------------------------------------------------------- |
|
1608 // Adds detail to the list item at the specified index |
|
1609 // ----------------------------------------------------------------------------- |
|
1610 // |
|
1611 void CMPXCommonContainerHgImp::AddDetailToDisplayedItemL( |
|
1612 CHgItem* aVisualItem, |
|
1613 CMPXMedia* aMedia, |
|
1614 TInt aIndex ) |
|
1615 { |
|
1616 MPX_FUNC( "CMPXCommonContainerHgImp::AddDetailToDisplayedItemL" ); |
|
1617 |
|
1618 switch ( iContext ) |
|
1619 { |
|
1620 case EContextGroupCollection: |
|
1621 { |
|
1622 SetDetailIconL( aVisualItem, aIndex ); |
|
1623 SetDetailCountL( aVisualItem, aMedia ); |
|
1624 break; |
|
1625 } |
|
1626 case EContextGroupArtist: |
|
1627 { |
|
1628 SetDetailCountL( aVisualItem, aMedia ); |
|
1629 break; |
|
1630 } |
|
1631 case EContextGroupAlbum: |
|
1632 { |
|
1633 SetDetailArtistL( aVisualItem, aMedia ); |
|
1634 break; |
|
1635 } |
|
1636 case EContextGroupPlaylist: |
|
1637 { |
|
1638 SetDetailDurationL( aVisualItem, aMedia ); |
|
1639 SetDetailIndicatorL( aVisualItem, aIndex ); |
|
1640 // SetDetailIconL( aVisualItem, EMPXDefaultIconPlaylist ); // playlist icon |
|
1641 break; |
|
1642 } |
|
1643 case EContextItemAlbum: |
|
1644 { |
|
1645 SetDetailIndicatorL( aVisualItem, aIndex ); |
|
1646 break; |
|
1647 } |
|
1648 case EContextGroupSong: |
|
1649 case EContextItemPlaylist: |
|
1650 case EContextItemGenre: |
|
1651 case EContextItemComposer: |
|
1652 { |
|
1653 SetDetailArtistL( aVisualItem, aMedia ); |
|
1654 SetDetailIndicatorL( aVisualItem, aIndex ); |
|
1655 break; |
|
1656 } |
|
1657 case EContextGroupPodcast: |
|
1658 { |
|
1659 SetDetailCountL( aVisualItem, aMedia ); |
|
1660 // SetDetailIconL( aVisualItem, EMPXDefaultTitleIconPodcasts ); |
|
1661 break; |
|
1662 } |
|
1663 case EContextGroupGenre: |
|
1664 { |
|
1665 // SetDetailIconL( aVisualItem, EMPXDefaultIconGenre ); //genre icon |
|
1666 SetDetailCountL( aVisualItem, aMedia ); |
|
1667 break; |
|
1668 } |
|
1669 case EContextGroupComposer: |
|
1670 { |
|
1671 // SetDetailIconL( aVisualItem, EMPXDefaultIconComposer ); //composer icon |
|
1672 SetDetailCountL( aVisualItem, aMedia ); |
|
1673 break; |
|
1674 } |
|
1675 case EContextItemArtist: |
|
1676 { |
|
1677 SetDetailCountL(aVisualItem, aMedia); |
|
1678 break; |
|
1679 } |
|
1680 case EContextItemSong: |
|
1681 { |
|
1682 SetDetailAlbumL( aVisualItem, aMedia ); |
|
1683 SetDetailIndicatorL( aVisualItem, aIndex ); |
|
1684 break; |
|
1685 } |
|
1686 case EContextItemPodcast: |
|
1687 { |
|
1688 SetDetailIndicatorL( aVisualItem, aIndex ); |
|
1689 break; |
|
1690 } |
|
1691 } |
|
1692 } |
|
1693 |
|
1694 // ----------------------------------------------------------------------------- |
|
1695 // Adds thumbnail to the list item at the specified index |
|
1696 // ----------------------------------------------------------------------------- |
|
1697 // |
|
1698 void CMPXCommonContainerHgImp::AddThumbnailToDisplayedItemL( |
|
1699 CHgItem* aVisualItem, |
|
1700 CMPXMedia* aMedia, |
|
1701 TInt aIndex ) |
|
1702 { |
|
1703 MPX_FUNC( "CMPXCommonContainerHgImp::AddThumbnailToDisplayedItemL" ); |
|
1704 |
|
1705 |
|
1706 switch ( iContext ) |
|
1707 { |
|
1708 case EContextGroupCollection: |
|
1709 { |
|
1710 |
|
1711 SetDetailIconL( aVisualItem, aIndex ); |
|
1712 break; |
|
1713 } |
|
1714 case EContextGroupAlbum: |
|
1715 case EContextGroupArtist: |
|
1716 case EContextGroupSong: |
|
1717 case EContextItemPlaylist: |
|
1718 case EContextItemGenre: |
|
1719 case EContextItemComposer: |
|
1720 case EContextItemArtist: |
|
1721 case EContextItemSong: |
|
1722 case EContextItemPodcast: |
|
1723 { |
|
1724 SetDetailThumbnailL( aMedia, aIndex ); |
|
1725 break; |
|
1726 } |
|
1727 case EContextItemAlbum: |
|
1728 { |
|
1729 // This is needed for this context because we want the album art |
|
1730 // thumbnail to be in list title area. |
|
1731 SetDetailThumbnailL( iSelectedMediaInAlbumView, aIndex ); |
|
1732 break; |
|
1733 } |
|
1734 } |
|
1735 } |
|
1736 |
|
1737 // ----------------------------------------------------------------------------- |
|
1738 // Set title to the visual item |
|
1739 // ----------------------------------------------------------------------------- |
|
1740 // |
|
1741 void CMPXCommonContainerHgImp::SetTitleL( |
|
1742 CHgItem* aVisualItem, |
|
1743 CMPXMedia* aMedia ) |
|
1744 { |
|
1745 MPX_FUNC( "CMPXCommonContainerHgImp::SetTitleL" ); |
|
1746 if ( aMedia->IsSupported( KMPXMediaGeneralTitle ) ) |
|
1747 { |
|
1748 const TDesC& title = aMedia->ValueText( KMPXMediaGeneralTitle ); |
|
1749 #ifdef HG_MP_LOC_AVAILABLE |
|
1750 HBufC* unknownText = |
|
1751 StringLoader::LoadLC( R_MPX_COMMONCONTAINER_UNKNOWN ); |
|
1752 if ( title.Compare( KNullDesC ) != 0 ) |
|
1753 { |
|
1754 aVisualItem->SetTitleL( title ); |
|
1755 } |
|
1756 else |
|
1757 { |
|
1758 aVisualItem->SetTitleL( *unknownText ); |
|
1759 } |
|
1760 CleanupStack::PopAndDestroy( unknownText ); |
|
1761 #else //HG_MP_LOC_AVAILABLE |
|
1762 TBuf<KMPXMaxFileLength> titleText( KUnknown ); |
|
1763 if ( title.Compare( KNullDesC ) != 0 ) |
|
1764 { |
|
1765 titleText.Copy(title.Left(titleText.MaxLength())); |
|
1766 } |
|
1767 aVisualItem->SetTitleL( titleText ); |
|
1768 #endif //HG_MP_LOC_AVAILABLE |
|
1769 } |
|
1770 } |
|
1771 |
|
1772 // ----------------------------------------------------------------------------- |
|
1773 // Set Detail - Count to the visual item |
|
1774 // ----------------------------------------------------------------------------- |
|
1775 // |
|
1776 void CMPXCommonContainerHgImp::SetDetailCountL( |
|
1777 CHgItem* aVisualItem, |
|
1778 CMPXMedia* aMedia ) |
|
1779 { |
|
1780 MPX_FUNC( "CMPXCommonContainerHgImp::SetDetailCountL" ); |
|
1781 if ( aMedia->IsSupported( KMPXMediaGeneralCount ) ) |
|
1782 { |
|
1783 TInt count( aMedia->ValueTObjectL<TInt>( KMPXMediaGeneralCount ) ); |
|
1784 |
|
1785 #ifdef HG_MP_LOC_AVAILABLE |
|
1786 if ( iContext == EContextGroupPodcast ) |
|
1787 { |
|
1788 if ( count > 1 ) |
|
1789 { |
|
1790 HBufC* episodesTitle = StringLoader::LoadLC( R_MPX_COMMONCONTAINER_DETAILS_NUMBER_OF_EPISODES, count ); |
|
1791 TPtr ptr = episodesTitle->Des(); |
|
1792 AknTextUtils::LanguageSpecificNumberConversion( ptr ); |
|
1793 aVisualItem->SetTextL( ptr ); |
|
1794 CleanupStack::PopAndDestroy( episodesTitle ); |
|
1795 } |
|
1796 else |
|
1797 { |
|
1798 aVisualItem->SetTextL( *iEpisodeTitle ); |
|
1799 } |
|
1800 } |
|
1801 else if ( iContext == EContextGroupArtist ) |
|
1802 { |
|
1803 if ( count > 1 ) |
|
1804 { |
|
1805 HBufC* albumsTitle = StringLoader::LoadLC( R_MPX_COMMONCONTAINER_DETAILS_NUMBER_OF_SONGS, // mod by anjokela |
|
1806 count ); |
|
1807 TPtr ptr = albumsTitle->Des(); |
|
1808 AknTextUtils::LanguageSpecificNumberConversion( ptr ); |
|
1809 aVisualItem->SetTextL( ptr ); |
|
1810 CleanupStack::PopAndDestroy( albumsTitle ); |
|
1811 } |
|
1812 else |
|
1813 { |
|
1814 aVisualItem->SetTextL( *iSongTitle ); // mod by anjokela |
|
1815 } |
|
1816 } |
|
1817 else |
|
1818 { |
|
1819 if ( count > 1 ) |
|
1820 { |
|
1821 HBufC* songsTitle = StringLoader::LoadLC( R_MPX_COMMONCONTAINER_DETAILS_NUMBER_OF_SONGS, count ); |
|
1822 TPtr ptr = songsTitle->Des(); |
|
1823 AknTextUtils::LanguageSpecificNumberConversion( ptr ); |
|
1824 aVisualItem->SetTextL( ptr ); |
|
1825 CleanupStack::PopAndDestroy( songsTitle ); |
|
1826 } |
|
1827 else |
|
1828 { |
|
1829 aVisualItem->SetTextL( *iSongTitle ); |
|
1830 } |
|
1831 } |
|
1832 #else //HG_MP_LOC_AVAILABLE |
|
1833 |
|
1834 TBuf<10> temp; |
|
1835 temp.AppendNum( count ); |
|
1836 AknTextUtils::LanguageSpecificNumberConversion( temp ); |
|
1837 |
|
1838 TBuf<KMPXMaxFileLength> detailText; |
|
1839 detailText.Append( temp ); |
|
1840 if ( iContext == EContextGroupPodcast ) |
|
1841 { |
|
1842 detailText.Append( (count > 1 ) ? KEpisodes() : KEpisode() ); |
|
1843 } |
|
1844 else if ( iContext == EContextGroupArtist ) |
|
1845 { |
|
1846 detailText.Append( (count > 1 ) ? KAlbums() : KAlbum() ); |
|
1847 } |
|
1848 else |
|
1849 { |
|
1850 detailText.Append( (count > 1 ) ? KSongs() : KSong() ); |
|
1851 } |
|
1852 aVisualItem->SetTextL( detailText ); |
|
1853 #endif //HG_MP_LOC_AVAILABLE |
|
1854 |
|
1855 } |
|
1856 } |
|
1857 |
|
1858 // ----------------------------------------------------------------------------- |
|
1859 // Set Detail - Artist to the visual item |
|
1860 // ----------------------------------------------------------------------------- |
|
1861 // |
|
1862 void CMPXCommonContainerHgImp::SetDetailArtistL( |
|
1863 CHgItem* aVisualItem, |
|
1864 CMPXMedia* aMedia ) |
|
1865 { |
|
1866 MPX_FUNC( "CMPXCommonContainerHgImp::SetDetailArtistL" ); |
|
1867 if ( aMedia->IsSupported( KMPXMediaMusicArtist ) ) |
|
1868 { |
|
1869 // AK - Needs to be localized |
|
1870 TBuf<KMPXMaxFileLength> detailText; |
|
1871 const TDesC& artist = aMedia->ValueText( KMPXMediaMusicArtist ); |
|
1872 if ( artist.Compare( KNullDesC ) != 0 ) |
|
1873 { |
|
1874 detailText.Copy(artist.Left(detailText.MaxLength())); |
|
1875 aVisualItem->SetTextL( detailText ); |
|
1876 } |
|
1877 else |
|
1878 { |
|
1879 HBufC* unknownText = |
|
1880 StringLoader::LoadLC( R_MPX_COMMONCONTAINER_UNKNOWN ); |
|
1881 aVisualItem->SetTextL( *unknownText ); |
|
1882 CleanupStack::PopAndDestroy( unknownText ); |
|
1883 } |
|
1884 } |
|
1885 } |
|
1886 |
|
1887 // ----------------------------------------------------------------------------- |
|
1888 // Set Detail - Album to the visual item |
|
1889 // ----------------------------------------------------------------------------- |
|
1890 // |
|
1891 void CMPXCommonContainerHgImp::SetDetailAlbumL( |
|
1892 CHgItem* aVisualItem, |
|
1893 CMPXMedia* aMedia ) |
|
1894 { |
|
1895 MPX_FUNC( "CMPXCommonContainerHgImp::SetDetailAlbumL" ); |
|
1896 if ( aMedia->IsSupported( KMPXMediaMusicAlbum ) ) |
|
1897 { |
|
1898 TBuf<KMPXMaxFileLength> detailText; |
|
1899 const TDesC& album = aMedia->ValueText( KMPXMediaMusicAlbum ); |
|
1900 if ( album.Compare( KNullDesC ) != 0 ) |
|
1901 { |
|
1902 detailText.Copy( album.Left(detailText.MaxLength())); |
|
1903 if ( iScrollerWithTitle ) |
|
1904 { |
|
1905 aVisualItem->SetTitleL( detailText ); |
|
1906 } |
|
1907 else |
|
1908 { |
|
1909 aVisualItem->SetTextL( detailText ); |
|
1910 } |
|
1911 } |
|
1912 else |
|
1913 { |
|
1914 HBufC* unknownText = |
|
1915 StringLoader::LoadLC( R_MPX_COMMONCONTAINER_UNKNOWN ); |
|
1916 aVisualItem->SetTextL( *unknownText ); |
|
1917 CleanupStack::PopAndDestroy( unknownText ); |
|
1918 } |
|
1919 } |
|
1920 } |
|
1921 |
|
1922 |
|
1923 // ----------------------------------------------------------------------------- |
|
1924 // Set Detail - Count + Duration to the visual item |
|
1925 // ----------------------------------------------------------------------------- |
|
1926 // |
|
1927 void CMPXCommonContainerHgImp::SetDetailDurationL( |
|
1928 CHgItem* aVisualItem, |
|
1929 CMPXMedia* aMedia ) |
|
1930 { |
|
1931 MPX_FUNC( "CMPXCommonContainerHgImp::SetDetailDurationL" ); |
|
1932 if ( iContext == EContextGroupPlaylist && |
|
1933 aMedia->IsSupported( KMPXMediaGeneralDuration ) && |
|
1934 aMedia->IsSupported( KMPXMediaGeneralCount ) ) |
|
1935 { |
|
1936 // AK - Needs to be localized |
|
1937 TBuf<KMPXMaxFileLength> detailText; |
|
1938 TInt count( aMedia->ValueTObjectL<TInt>( KMPXMediaGeneralCount ) ); |
|
1939 TInt duration = aMedia->ValueTObjectL<TInt>( KMPXMediaGeneralDuration ); |
|
1940 |
|
1941 #ifdef HG_MP_LOC_AVAILABLE |
|
1942 if ( count > 1 || count == 0 ) |
|
1943 { |
|
1944 HBufC* songsTitle = StringLoader::LoadLC( R_MPX_COMMONCONTAINER_DETAILS_NUMBER_OF_SONGS, count ); |
|
1945 detailText.Append(*songsTitle); |
|
1946 detailText.Append(KMPXDash); |
|
1947 UpdateTimeIndicatorsL(detailText, duration); |
|
1948 aVisualItem->SetTextL( detailText ); |
|
1949 CleanupStack::PopAndDestroy( songsTitle ); |
|
1950 } |
|
1951 else |
|
1952 { |
|
1953 detailText.Append(*iSongTitle); |
|
1954 detailText.Append(KMPXDash); |
|
1955 UpdateTimeIndicatorsL(detailText, duration); |
|
1956 aVisualItem->SetTextL( detailText ); |
|
1957 } |
|
1958 #else //HG_MP_LOC_AVAILABLE |
|
1959 TBuf<10> temp; |
|
1960 temp.AppendNum( count ); |
|
1961 AknTextUtils::LanguageSpecificNumberConversion( temp ); |
|
1962 detailText.Append( temp ); |
|
1963 detailText.Append( (count > 1 ) ? KSongsDash() : KSongDash() ); |
|
1964 UpdateTimeIndicatorsL(detailText, duration); |
|
1965 aVisualItem->SetTextL( detailText ); |
|
1966 #endif //HG_MP_LOC_AVAILABLE |
|
1967 } |
|
1968 else if ( iContext == EContextItemPodcast && |
|
1969 aMedia->IsSupported( KMPXMediaGeneralDuration ) && |
|
1970 aMedia->IsSupported( KMPXMediaGeneralSize ) ) |
|
1971 { |
|
1972 TBuf<KMPXMaxFileLength> detailText; |
|
1973 TInt duration = aMedia->ValueTObjectL<TInt>( KMPXMediaGeneralDuration ); |
|
1974 UpdateTimeIndicatorsL(detailText, duration); |
|
1975 detailText.Append( KMPXDash() ); |
|
1976 |
|
1977 TInt size( aMedia->ValueTObjectL<TInt>( KMPXMediaGeneralSize ) ); |
|
1978 HBufC* sizeBuf = iCommonUiHelper->UnitConversionL( size, ETrue ); |
|
1979 TPtr sizePtr( sizeBuf->Des() ); |
|
1980 detailText.Append( sizePtr ); |
|
1981 delete sizeBuf; |
|
1982 |
|
1983 aVisualItem->SetTextL( detailText ); |
|
1984 } |
|
1985 } |
|
1986 |
|
1987 |
|
1988 // ----------------------------------------------------------------------------- |
|
1989 // Format the duration to the visual item |
|
1990 // ----------------------------------------------------------------------------- |
|
1991 // |
|
1992 void CMPXCommonContainerHgImp::UpdateTimeIndicatorsL( |
|
1993 TDes& aBuf, |
|
1994 TInt aDuration ) |
|
1995 { |
|
1996 MPX_FUNC( "CMPXCommonContainerHgImp::UpdateTimeIndicatorsL" ); |
|
1997 TInt durationInSeconds = aDuration; |
|
1998 if ( durationInSeconds > 0 ) |
|
1999 { |
|
2000 durationInSeconds /= 1000; // MilliSeconds to second conversion |
|
2001 } |
|
2002 else if ( durationInSeconds < 0 ) |
|
2003 { |
|
2004 durationInSeconds = 0; |
|
2005 } |
|
2006 if ( durationInSeconds == 0 ) |
|
2007 { |
|
2008 TLocale locale; |
|
2009 TBuf<KMPXTimeIndicatorLength> pos; |
|
2010 TChar separator = locale.TimeSeparator( KMPXMinSecSeparatorIndex ); |
|
2011 aBuf.Append(KMPXZeroDurationMark); |
|
2012 aBuf.Append( separator ); |
|
2013 aBuf.Append(KMPXZeroDurationMark); |
|
2014 } |
|
2015 else |
|
2016 { |
|
2017 CMPXCommonUiHelper::TMPXDuratDisplayMode durationMode = CMPXCommonUiHelper::EMPXDuratAuto; |
|
2018 if ( durationInSeconds > KOneHourInSeconds ) |
|
2019 { |
|
2020 durationMode = CMPXCommonUiHelper::EMPXDuratHMS; |
|
2021 } |
|
2022 // Convert ellapsed time to texts |
|
2023 HBufC* position = iCommonUiHelper->DisplayableDurationL( durationInSeconds, durationMode ); |
|
2024 aBuf.Append(position->Des()); |
|
2025 delete position; |
|
2026 } |
|
2027 } |
|
2028 |
|
2029 |
|
2030 // ----------------------------------------------------------------------------- |
|
2031 // Set Detail - Indicator to the visual item |
|
2032 // ----------------------------------------------------------------------------- |
|
2033 // |
|
2034 void CMPXCommonContainerHgImp::SetDetailIndicatorL( |
|
2035 CHgItem* aVisualItem, |
|
2036 TInt aIndex ) |
|
2037 { |
|
2038 MPX_FUNC( "CMPXCommonContainerHgImp::SetDetailIndicatorL" ); |
|
2039 // Get icon indices |
|
2040 RArray<TInt> iconIndices = iViewContainer->IndicatorsL( aIndex ); |
|
2041 CleanupClosePushL( iconIndices ); |
|
2042 |
|
2043 const TInt iconCount = iconIndices.Count(); |
|
2044 TInt flags = aVisualItem->Flags() & CHgItem::EHgItemFlagMarked; |
|
2045 aVisualItem->ClearFlags(aVisualItem->Flags()); |
|
2046 if ( iconCount > 0 ) |
|
2047 { |
|
2048 TInt iconId = 0; |
|
2049 for ( TInt iconIndex = 0; iconIndex < iconCount; iconIndex++ ) |
|
2050 { |
|
2051 iconId = iconIndices[iconIndex]; |
|
2052 if ( !iPodcastContext ) |
|
2053 { |
|
2054 switch (iconId) |
|
2055 { |
|
2056 case EMPXClvIconMMC: |
|
2057 { |
|
2058 flags |= CHgItem::EHgItemFlagsMmc; |
|
2059 break; |
|
2060 } |
|
2061 case EMPXClvIconPlay: |
|
2062 { |
|
2063 flags |= CHgItem::EHgItemFlagsPlaybackIndicator; |
|
2064 break; |
|
2065 } |
|
2066 case EMPXClvIconPause: |
|
2067 { |
|
2068 flags |= CHgItem::EHgItemFlagsPauseIndicator; |
|
2069 break; |
|
2070 } |
|
2071 case EMPXClvIconBrokenTrack: |
|
2072 { |
|
2073 flags |= CHgItem::EHgItemFlagsBrokenTrackIndicator; |
|
2074 break; |
|
2075 } |
|
2076 case EMPXClvIconCorruptTrack: |
|
2077 { |
|
2078 flags |= CHgItem::EHgItemFlagsCorruptedTrackIndicator; |
|
2079 break; |
|
2080 } |
|
2081 case EMPXClvIconDrmExpired: |
|
2082 { |
|
2083 flags |= CHgItem::EHgItemFlagsDrmRightsExpired; |
|
2084 break; |
|
2085 } |
|
2086 case EMPXClvIconBrokenPlaylist: |
|
2087 { |
|
2088 flags |= CHgItem::EHgItemFlagsBrokenPlaylistIndicator; |
|
2089 break; |
|
2090 } |
|
2091 case EMPXClvIconReorderDown: |
|
2092 { |
|
2093 flags |= CHgItem::EHgItemFlagsMoveDownIndicator; |
|
2094 break; |
|
2095 } |
|
2096 case EMPXClvIconReorderUp: |
|
2097 { |
|
2098 flags |= CHgItem::EHgItemFlagsMoveUpIndicator; |
|
2099 break; |
|
2100 } |
|
2101 case EMPXClvIconReorderUpDown: |
|
2102 { |
|
2103 flags |= CHgItem::EHgItemFlagsMoveUpDownIndicator; |
|
2104 break; |
|
2105 } |
|
2106 } |
|
2107 } |
|
2108 else // podcast icons |
|
2109 { |
|
2110 switch (iconId) |
|
2111 { |
|
2112 case EMPXPodClvIconMMC: |
|
2113 { |
|
2114 flags |= CHgItem::EHgItemFlagsMmc; |
|
2115 break; |
|
2116 } |
|
2117 case EMPXPodClvIconPlay: |
|
2118 { |
|
2119 flags |= CHgItem::EHgItemFlagsPlaybackIndicator; |
|
2120 break; |
|
2121 } |
|
2122 case EMPXPodClvIconPause: |
|
2123 { |
|
2124 flags |= CHgItem::EHgItemFlagsPauseIndicator; |
|
2125 break; |
|
2126 } |
|
2127 case EMPXPodClvIconBroken: |
|
2128 { |
|
2129 flags |= CHgItem::EHgItemFlagsBrokenTrackIndicator; |
|
2130 break; |
|
2131 } |
|
2132 case EMPXPodClvIconCorrupt: |
|
2133 { |
|
2134 flags |= CHgItem::EHgItemFlagsCorruptedTrackIndicator; |
|
2135 break; |
|
2136 } |
|
2137 case EMPXPodClvIconNew: |
|
2138 { |
|
2139 flags |= CHgItem::EHgItemFlagsNewPodcastIndicator; |
|
2140 break; |
|
2141 } |
|
2142 case EMPXPodClvIconCompplay: |
|
2143 { |
|
2144 flags |= CHgItem::EHgItemFlagsCompletelyPlayedPodcastIndicator; |
|
2145 break; |
|
2146 } |
|
2147 case EMPXPodClvIconPartplay: |
|
2148 { |
|
2149 flags |= CHgItem::EHgItemFlagsPlayedPodcastIndicator; |
|
2150 break; |
|
2151 } |
|
2152 } |
|
2153 } |
|
2154 } |
|
2155 } |
|
2156 aVisualItem->SetFlags( flags ); |
|
2157 CleanupStack::PopAndDestroy(); |
|
2158 } |
|
2159 |
|
2160 |
|
2161 // ----------------------------------------------------------------------------- |
|
2162 // Set Detail - Icon to the visual item |
|
2163 // ----------------------------------------------------------------------------- |
|
2164 // |
|
2165 void CMPXCommonContainerHgImp::SetDetailIconL( |
|
2166 CHgItem* aVisualItem, |
|
2167 TInt aIndex ) |
|
2168 { |
|
2169 MPX_FUNC( "CMPXCommonContainerHgImp::SetDetailIconL" ); |
|
2170 |
|
2171 TInt iconIndex = aIndex; |
|
2172 switch ( aIndex ) |
|
2173 { |
|
2174 case 0: |
|
2175 iconIndex = EMPXClvIconArtist; |
|
2176 break; |
|
2177 case 1: |
|
2178 iconIndex = EMPXClvIconAlbum; |
|
2179 break; |
|
2180 case 2: |
|
2181 iconIndex = EMPXClvIconPlaylist; |
|
2182 break; |
|
2183 case 3: |
|
2184 iconIndex = EMPXClvIconSongs; |
|
2185 break; |
|
2186 case 4: |
|
2187 iconIndex = EMPXClvIconPodcasts; |
|
2188 break; |
|
2189 case 5: |
|
2190 iconIndex = EMPXClvIconGenre; |
|
2191 break; |
|
2192 case 6: |
|
2193 iconIndex = EMPXClvIconComposer; |
|
2194 break; |
|
2195 case 7: //EMPXDefaultTitleIconPodcasts |
|
2196 iconIndex = 10; |
|
2197 break; |
|
2198 } |
|
2199 |
|
2200 CGulIcon* icon = (*iIconArray)[iconIndex]; |
|
2201 |
|
2202 CFbsBitmap* bitmap = icon->Bitmap(); |
|
2203 CFbsBitmap* mask = icon->Mask(); |
|
2204 |
|
2205 TSize size(iImageSize.iWidth, iImageSize.iHeight); |
|
2206 if ( iContext == EContextGroupCollection ) |
|
2207 { // shrink smaller to look same as in Antriksh |
|
2208 size.iWidth = iImageSize.iWidth * KIconFactor; |
|
2209 size.iHeight = iImageSize.iHeight * KIconFactor; |
|
2210 } |
|
2211 |
|
2212 AknIconUtils::SetSize( bitmap, size ); |
|
2213 AknIconUtils::SetSize( mask, size ); |
|
2214 |
|
2215 CGulIcon* iconCopy = CGulIcon::NewL(bitmap, mask); |
|
2216 iconCopy->SetBitmapsOwnedExternally(ETrue); |
|
2217 aVisualItem->SetIcon( iconCopy ); |
|
2218 } |
|
2219 |
|
2220 // ----------------------------------------------------------------------------- |
|
2221 // Set Detail - Thumbnail to the visual item |
|
2222 // ----------------------------------------------------------------------------- |
|
2223 // |
|
2224 void CMPXCommonContainerHgImp::SetDetailThumbnailL( |
|
2225 CMPXMedia* aMedia, |
|
2226 TInt aIndex ) |
|
2227 { |
|
2228 MPX_FUNC("CMPXCommonContainerHgImp::SetDetailThumbnailL(CMPXMedia* aMedia,TInt aIndex)"); |
|
2229 TMPXItemId currentId( aMedia->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) ); |
|
2230 |
|
2231 if ( currentId == KMPXInvalidItemId ) |
|
2232 { |
|
2233 return; |
|
2234 } |
|
2235 |
|
2236 if ( aMedia->IsSupported( KMPXMediaMusicAlbumArtFileName ) ) |
|
2237 { |
|
2238 const TDesC& album = aMedia->ValueText( KMPXMediaMusicAlbumArtFileName ); |
|
2239 #ifdef _DEBUG |
|
2240 RDebug::RawPrint(album); |
|
2241 #endif |
|
2242 if ( album.Compare( KNullDesC ) != 0 ) |
|
2243 { |
|
2244 //send request only when under TNM max loads |
|
2245 |
|
2246 if ( iRequestCount < KMaxThumbnailReq ) |
|
2247 { |
|
2248 CThumbnailObjectSource* source = CThumbnailObjectSource::NewLC( album, KMPXAlbumMimeType ); |
|
2249 TInt reqId; |
|
2250 TInt ret = NULL; |
|
2251 // Set priority based on the index so that the smaller indexes are loaded first. |
|
2252 TRAPD(err, reqId = (TInt) iThumbnailManager->GetThumbnailL( *source, (TAny*)ret, -aIndex)); |
|
2253 iRequestCount++; |
|
2254 |
|
2255 if ( err == KErrNone) |
|
2256 { |
|
2257 iThumbnailReqHashMap.InsertL( reqId, aIndex ); |
|
2258 } |
|
2259 CleanupStack::PopAndDestroy( source ); |
|
2260 } |
|
2261 //can not send request since max TNM load, add album art requests to queue |
|
2262 else |
|
2263 { |
|
2264 TAlbumArtRequest* albumArtRequest = NULL; |
|
2265 |
|
2266 TRAPD(err, albumArtRequest = new (ELeave) TAlbumArtRequest;); |
|
2267 if ( err != KErrNone ) |
|
2268 { |
|
2269 return; |
|
2270 } |
|
2271 albumArtRequest->iIndex = aIndex; |
|
2272 albumArtRequest->iAlbumArtUri = album.AllocL(); |
|
2273 |
|
2274 // Outstanding request exits; add it to the queue |
|
2275 iRequestQueue.AddLast(*albumArtRequest); |
|
2276 ++iQueueCounter; |
|
2277 |
|
2278 } |
|
2279 } |
|
2280 else |
|
2281 { |
|
2282 //no albumart |
|
2283 SetDefaultIconL(aIndex); |
|
2284 iThumbnailReqMap[aIndex] = ETrue; |
|
2285 RefreshNoThumbnailL(aIndex); |
|
2286 } |
|
2287 } |
|
2288 else |
|
2289 { |
|
2290 // no album art supported |
|
2291 SetDefaultIconL(aIndex); |
|
2292 iThumbnailReqMap[aIndex] = ETrue; |
|
2293 RefreshNoThumbnailL(aIndex); |
|
2294 } |
|
2295 } |
|
2296 |
|
2297 |
|
2298 // ----------------------------------------------------------------------------- |
|
2299 // Sets the current category. |
|
2300 // ----------------------------------------------------------------------------- |
|
2301 // |
|
2302 void CMPXCommonContainerHgImp::SetCollectionContextL() |
|
2303 { |
|
2304 MPX_FUNC( "CMPXCommonContainerHgImp::SetCollectionContextL" ); |
|
2305 |
|
2306 const CMPXMedia& media = iListBoxArray->ContainerMedia(); |
|
2307 |
|
2308 TMPXGeneralType containerType( EMPXNoType ); |
|
2309 if ( media.IsSupported( KMPXMediaGeneralType ) ) |
|
2310 { |
|
2311 containerType = media.ValueTObjectL<TMPXGeneralType>( KMPXMediaGeneralType ); |
|
2312 } |
|
2313 |
|
2314 TMPXGeneralCategory containerCategory( EMPXNoCategory ); |
|
2315 if ( media.IsSupported( KMPXMediaGeneralCategory ) ) |
|
2316 { |
|
2317 containerCategory = media.ValueTObjectL<TMPXGeneralCategory>( KMPXMediaGeneralCategory ); |
|
2318 } |
|
2319 MPX_DEBUG3( "CMPXCommonContainerHgImp::SetCollectionContextL container type = %d, category = %d", |
|
2320 containerType, containerCategory ); |
|
2321 |
|
2322 iPodcastContext = EFalse; |
|
2323 TMPXPodcastCategory podcastCategory( EMPXUnknown ); |
|
2324 if ( media.IsSupported( KMPXMediaPodcastType ) ) |
|
2325 { |
|
2326 iPodcastContext = ETrue; |
|
2327 if ( media.IsSupported( KMPXMediaPodcastCategoryGroup ) ) |
|
2328 { |
|
2329 podcastCategory = media.ValueTObjectL<TMPXPodcastCategory>( KMPXMediaPodcastCategoryGroup ); |
|
2330 } |
|
2331 } |
|
2332 MPX_DEBUG3( "CMPXCommonContainerHitchcockImp::SetCollectionContextL container podcast = %d, category = %d", |
|
2333 iPodcastContext, podcastCategory ); |
|
2334 |
|
2335 iPrevContext = iContext; |
|
2336 |
|
2337 iListWidget->ClearFlags( CHgScroller::EHgScrollerKeyMarkingDisabled ); |
|
2338 if ( !iPodcastContext ) |
|
2339 { |
|
2340 if ( containerType == EMPXGroup ) |
|
2341 { |
|
2342 switch (containerCategory) |
|
2343 { |
|
2344 case EMPXCollection: |
|
2345 iContext = EContextGroupCollection; |
|
2346 iListWidget->SetFlags( CHgScroller::EHgScrollerKeyMarkingDisabled ); |
|
2347 break; |
|
2348 case EMPXArtist: |
|
2349 iContext = EContextGroupArtist; |
|
2350 break; |
|
2351 case EMPXAlbum: |
|
2352 iContext = EContextGroupAlbum; |
|
2353 break; |
|
2354 case EMPXPlaylist: |
|
2355 iContext = EContextGroupPlaylist; |
|
2356 break; |
|
2357 case EMPXSong: |
|
2358 iContext = EContextGroupSong; |
|
2359 break; |
|
2360 case EMPXGenre: |
|
2361 iContext = EContextGroupGenre; |
|
2362 break; |
|
2363 case EMPXComposer: |
|
2364 iContext = EContextGroupComposer; |
|
2365 break; |
|
2366 default: |
|
2367 User::Leave(KErrNotSupported); |
|
2368 break; |
|
2369 } |
|
2370 } |
|
2371 else if ( containerType == EMPXItem ) |
|
2372 { |
|
2373 switch (containerCategory) |
|
2374 { |
|
2375 case EMPXArtist: |
|
2376 iContext = EContextItemArtist; |
|
2377 break; |
|
2378 case EMPXAlbum: |
|
2379 iContext = EContextItemAlbum; |
|
2380 break; |
|
2381 case EMPXPlaylist: |
|
2382 iContext = EContextItemPlaylist; |
|
2383 break; |
|
2384 case EMPXSong: |
|
2385 iContext = EContextItemSong; |
|
2386 break; |
|
2387 case EMPXGenre: |
|
2388 iContext = EContextItemGenre; |
|
2389 break; |
|
2390 case EMPXComposer: |
|
2391 iContext = EContextItemComposer; |
|
2392 break; |
|
2393 default: |
|
2394 User::Leave(KErrNotSupported); |
|
2395 break; |
|
2396 } |
|
2397 } |
|
2398 } |
|
2399 else |
|
2400 { |
|
2401 if ( (containerType == EMPXGroup) && (podcastCategory == EMPXTitle) ) |
|
2402 { |
|
2403 iContext = EContextGroupPodcast; |
|
2404 iListWidget->SetFlags( CHgScroller::EHgScrollerKeyMarkingDisabled ); |
|
2405 } |
|
2406 else if ( (containerType == EMPXItem) && (podcastCategory == EMPXEpisode) ) |
|
2407 { |
|
2408 iContext = EContextItemPodcast; |
|
2409 } |
|
2410 else |
|
2411 { |
|
2412 User::Leave(KErrNotSupported); |
|
2413 } |
|
2414 } |
|
2415 } |
|
2416 |
|
2417 // ----------------------------------------------------------------------------- |
|
2418 // CMPXCommonContainerHgImp::MopSupplyObject |
|
2419 // ----------------------------------------------------------------------------- |
|
2420 // |
|
2421 TTypeUid::Ptr CMPXCommonContainerHgImp::MopSupplyObject( TTypeUid aId ) |
|
2422 { |
|
2423 MPX_FUNC( "CMPXCommonContainerHgImp::MopSupplyObject" ); |
|
2424 return MAknsControlContext::SupplyMopObject(aId, iBgContext ); |
|
2425 } |
|
2426 |
|
2427 // ----------------------------------------------------------------------------- |
|
2428 // CMPXCommonContainerHgImp::SetScrollbarType |
|
2429 // ----------------------------------------------------------------------------- |
|
2430 // |
|
2431 void CMPXCommonContainerHgImp::SetScrollbarType() |
|
2432 { |
|
2433 MPX_FUNC( "CMPXCommonContainerHgImp::SetScrollbarType" ); |
|
2434 |
|
2435 if ( iContext == EContextGroupCollection || |
|
2436 iContext == EContextGroupPlaylist || |
|
2437 iContext == EContextItemAlbum || |
|
2438 iContext == EContextItemPlaylist ) |
|
2439 { |
|
2440 iListWidget->SetScrollBarTypeL( CHgScroller::EHgScrollerScrollBar ); |
|
2441 } |
|
2442 else |
|
2443 { |
|
2444 iListWidget->SetScrollBarTypeL( CHgScroller::EHgScrollerLetterStripLite ); |
|
2445 } |
|
2446 } |
|
2447 |
|
2448 // ---------------------------------------------------------------------------- |
|
2449 // Clears the TN request if any |
|
2450 // ---------------------------------------------------------------------------- |
|
2451 void CMPXCommonContainerHgImp::CancelTNRequest() |
|
2452 { |
|
2453 MPX_FUNC("CMPXCommonContainerHgImp::CancelTNRequest"); |
|
2454 |
|
2455 if ( iThumbnailReqHashMap.Count() == 0 ) |
|
2456 { |
|
2457 return; |
|
2458 } |
|
2459 |
|
2460 THashMapIter<TInt, TInt> iter(iThumbnailReqHashMap); |
|
2461 TInt* id = iter.CurrentValue(); |
|
2462 if (id && *id >= 0) |
|
2463 { |
|
2464 iThumbnailManager->CancelRequest((TThumbnailRequestId)id); |
|
2465 } |
|
2466 while ( TInt const* id = iter.NextValue() ) |
|
2467 { |
|
2468 iThumbnailManager->CancelRequest((TThumbnailRequestId)*id); |
|
2469 } |
|
2470 } |
|
2471 |
|
2472 // ---------------------------------------------------------------------------- |
|
2473 // Save the selected album item |
|
2474 // ---------------------------------------------------------------------------- |
|
2475 void CMPXCommonContainerHgImp::SaveSelectedAlbumItemL() |
|
2476 { |
|
2477 if ( iContext == EContextGroupAlbum || iContext == EContextItemArtist ) |
|
2478 { |
|
2479 const CMPXMediaArray& mediaArray = iListBoxArray->MediaArray(); |
|
2480 |
|
2481 if ( iSelectedMediaInAlbumView ) |
|
2482 { |
|
2483 delete iSelectedMediaInAlbumView; |
|
2484 iSelectedMediaInAlbumView = NULL; |
|
2485 } |
|
2486 |
|
2487 iSelectedMediaInAlbumView = CMPXMedia::NewL( *mediaArray.AtL( CurrentLbxItemIndex() ) ); |
|
2488 |
|
2489 if ( iSelectedMediaInAlbumView->IsSupported( KMPXMediaGeneralTitle ) ) |
|
2490 { |
|
2491 const TDesC& title = iSelectedMediaInAlbumView->ValueText( KMPXMediaGeneralTitle ); |
|
2492 if ( title == KNullDesC ) |
|
2493 { |
|
2494 // Cannot use reference to KNullDesC, must |
|
2495 // use the literal directly. |
|
2496 iSelectedMediaInAlbumView->SetTextValueL( KMPXMediaMusicAlbum, KNullDesC ); |
|
2497 } |
|
2498 else |
|
2499 { |
|
2500 iSelectedMediaInAlbumView->SetTextValueL( KMPXMediaMusicAlbum, title ); |
|
2501 } |
|
2502 } |
|
2503 |
|
2504 if ( iContext == EContextItemArtist ) |
|
2505 { |
|
2506 const CMPXMedia& containerMedia = iListBoxArray->ContainerMedia(); |
|
2507 const TDesC& artist = containerMedia.ValueText( KMPXMediaGeneralTitle ); |
|
2508 |
|
2509 HBufC* unknownArtistText = |
|
2510 StringLoader::LoadLC( R_MPX_QTN_NMP_UNKNOWN_ARTIST ); |
|
2511 |
|
2512 if ( artist != unknownArtistText->Des() ) |
|
2513 { |
|
2514 iSelectedMediaInAlbumView->SetTextValueL( KMPXMediaMusicArtist, artist ); |
|
2515 } |
|
2516 else |
|
2517 { |
|
2518 iSelectedMediaInAlbumView->SetTextValueL( KMPXMediaMusicArtist, KNullDesC ); |
|
2519 } |
|
2520 |
|
2521 CleanupStack::PopAndDestroy( unknownArtistText ); |
|
2522 } |
|
2523 |
|
2524 WriteToStreamFileL( iSelectedMediaInAlbumView ); |
|
2525 } |
|
2526 } |
|
2527 |
|
2528 // ---------------------------------------------------------------------------- |
|
2529 // Write the album name, artist name and album art in media data to file |
|
2530 // ---------------------------------------------------------------------------- |
|
2531 void CMPXCommonContainerHgImp::WriteToStreamFileL( const CMPXMedia* aMedia ) |
|
2532 { |
|
2533 MPX_FUNC( "CMPXCommonContainerHgImp::WriteToStreamFileL" ); |
|
2534 |
|
2535 CCoeEnv* coeEnv( iEikonEnv ); |
|
2536 RFs& fs = coeEnv->FsSession(); |
|
2537 fs.MkDirAll( iSelectedAlbumItemFileName ); |
|
2538 TParse parsedName; |
|
2539 |
|
2540 fs.Parse( iSelectedAlbumItemFileName, parsedName ); |
|
2541 CFileStore* store( NULL ); |
|
2542 MPX_TRAPD( error, store = CDirectFileStore::ReplaceL(fs, |
|
2543 parsedName.FullName(), |
|
2544 EFileWrite); ); |
|
2545 |
|
2546 if ( error == KErrNone ) |
|
2547 { |
|
2548 CleanupStack::PushL( store ); |
|
2549 store->SetTypeL( KDirectFileStoreLayoutUid ); |
|
2550 |
|
2551 RStoreWriteStream wstream; |
|
2552 TStreamId stream = wstream.CreateLC( *store ); |
|
2553 store->SetRootL( stream ); |
|
2554 |
|
2555 if ( aMedia->IsSupported( KMPXMediaMusicAlbum ) ) |
|
2556 { |
|
2557 const TDesC& album = aMedia->ValueText( KMPXMediaMusicAlbum ); |
|
2558 wstream << album; |
|
2559 } |
|
2560 else |
|
2561 { |
|
2562 wstream << KNullDesC; |
|
2563 } |
|
2564 |
|
2565 if ( aMedia->IsSupported( KMPXMediaMusicAlbumArtFileName ) ) |
|
2566 { |
|
2567 const TDesC& art = aMedia->ValueText( KMPXMediaMusicAlbumArtFileName ); |
|
2568 wstream << art; |
|
2569 } |
|
2570 else |
|
2571 { |
|
2572 wstream << KNullDesC; |
|
2573 } |
|
2574 |
|
2575 if ( aMedia->IsSupported( KMPXMediaMusicArtist ) ) |
|
2576 { |
|
2577 const TDesC& artist = aMedia->ValueText( KMPXMediaMusicArtist ); |
|
2578 wstream << artist; |
|
2579 } |
|
2580 else |
|
2581 { |
|
2582 wstream << KNullDesC; |
|
2583 } |
|
2584 |
|
2585 wstream.CommitL(); |
|
2586 CleanupStack::PopAndDestroy( &wstream ); |
|
2587 CleanupStack::PopAndDestroy( store ); |
|
2588 } |
|
2589 else |
|
2590 { |
|
2591 fs.Delete( iSelectedAlbumItemFileName ); |
|
2592 } |
|
2593 } |
|
2594 |
|
2595 // ---------------------------------------------------------------------------- |
|
2596 // Read the album name, artist name and album art from file |
|
2597 // ---------------------------------------------------------------------------- |
|
2598 void CMPXCommonContainerHgImp::ReadFromStreamFileL( CMPXMedia* aMedia ) |
|
2599 { |
|
2600 MPX_FUNC("CMPXCommonContainerHgImp::ReadFromStreamFileL"); |
|
2601 |
|
2602 CCoeEnv* coeEnv( iEikonEnv ); |
|
2603 RFs& fs = coeEnv->FsSession(); |
|
2604 fs.MkDirAll( iSelectedAlbumItemFileName ); |
|
2605 TParse parsedName; |
|
2606 |
|
2607 fs.Parse( iSelectedAlbumItemFileName, parsedName ); |
|
2608 CFileStore* store( NULL ); |
|
2609 MPX_TRAPD( error, store = CDirectFileStore::OpenL(fs, |
|
2610 parsedName.FullName(), |
|
2611 EFileRead ); ); |
|
2612 if ( error == KErrNone ) |
|
2613 { |
|
2614 CleanupStack::PushL( store ); |
|
2615 |
|
2616 RStoreReadStream stream; |
|
2617 stream.OpenLC( *store, store->Root() ); |
|
2618 |
|
2619 TBuf<KMPXMaxFileLength> album( KNullDesC ); |
|
2620 stream >> album; |
|
2621 aMedia->SetTextValueL( KMPXMediaMusicAlbum, album ); |
|
2622 |
|
2623 TBuf<KMPXMaxFileLength> art( KNullDesC ); |
|
2624 stream >> art; |
|
2625 aMedia->SetTextValueL( KMPXMediaMusicAlbumArtFileName, art ); |
|
2626 |
|
2627 TBuf<KMPXMaxFileLength> artist( KNullDesC ); |
|
2628 stream >> artist; |
|
2629 aMedia->SetTextValueL( KMPXMediaMusicArtist, artist ); |
|
2630 |
|
2631 CleanupStack::PopAndDestroy( &stream ); |
|
2632 CleanupStack::PopAndDestroy( store ); |
|
2633 } |
|
2634 else |
|
2635 { |
|
2636 aMedia->SetTextValueL( KMPXMediaMusicAlbum, KNullDesC ); |
|
2637 aMedia->SetTextValueL( KMPXMediaMusicAlbumArtFileName, KNullDesC ); |
|
2638 aMedia->SetTextValueL( KMPXMediaMusicArtist, KNullDesC ); |
|
2639 } |
|
2640 } |
|
2641 |
|
2642 // ---------------------------------------------------------------------------- |
|
2643 // Clean Albumart request queue |
|
2644 // ---------------------------------------------------------------------------- |
|
2645 void CMPXCommonContainerHgImp::CleanAlbumArtReqQueue() |
|
2646 { |
|
2647 MPX_FUNC("CMPXCommonContainerHgImp::CleanAlbumArtReqQueue"); |
|
2648 while ( !iRequestQueue.IsEmpty() ) |
|
2649 { |
|
2650 iAlbumArtRequest = iRequestQueue.First(); |
|
2651 iRequestQueue.Remove(*iAlbumArtRequest); |
|
2652 delete iAlbumArtRequest->iAlbumArtUri; //not sure needed or not |
|
2653 delete iAlbumArtRequest; |
|
2654 } |
|
2655 iQueueCounter = 0; |
|
2656 } |
|
2657 |
|
2658 // End of File |
|
2659 |