|
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: Implementation of Collection view container |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <e32cmn.h> |
|
21 #include <e32math.h> |
|
22 #include <s32file.h> |
|
23 #include <gulicon.h> |
|
24 #include <hlplch.h> |
|
25 #include <StringLoader.h> |
|
26 #include <aknview.h> |
|
27 #include <aknappui.h> |
|
28 #include <AknIconArray.h> |
|
29 #include <aknlists.h> |
|
30 #include <aknPopup.h> |
|
31 #include <akncontext.h> |
|
32 #include <AknsBasicBackgroundControlContext.h> |
|
33 #include <data_caging_path_literals.hrh> |
|
34 |
|
35 #include <mpxlog.h> |
|
36 #include <mpxuser.h> |
|
37 #include <mpxmedia.h> |
|
38 #include <mpxmediaarray.h> |
|
39 #include <mpxconstants.h> |
|
40 #include <mpxmediageneraldefs.h> |
|
41 #include <mpxplaybackframeworkdefs.h> |
|
42 #include <mpxmediacontainerdefs.h> |
|
43 #include <mpxmediageneraldefs.h> |
|
44 #include <mpxmediamusicdefs.h> |
|
45 #include <mpxmediacollectiondetaildefs.h> |
|
46 #include <mpxcommandgeneraldefs.h> |
|
47 #include <mpxpodcastdefs.h> |
|
48 #include <mpxcommonuihelper.h> |
|
49 #include <mpxcollectionplaylist.h> |
|
50 #include <mpxcollectionuihelper.h> |
|
51 #include <mpxcollectionhelperfactory.h> |
|
52 #include <mpxcollectionutility.h> |
|
53 #include <mpxcollectionpath.h> |
|
54 #include <mpxplaybackutility.h> |
|
55 #include <mpxcollectionviewhg.rsg> |
|
56 #include <mpxcollectionviewhg.mbg> |
|
57 #include <mpxappui.hrh> |
|
58 |
|
59 #include <ganes/HgDoubleGraphicListFlat.h> |
|
60 #include <ganes/HgSingleGraphicList.h> |
|
61 #include <ganes/HgSingleTextListWithIcon.h> |
|
62 #include <ganes/HgVgItem.h> |
|
63 #include <ganes/HgItem.h> |
|
64 #include <ganes/HgScrollerWithTitle.h> |
|
65 #include <ganes/HgVgMediaWall.h> |
|
66 |
|
67 #include <layoutmetadata.cdl.h> |
|
68 |
|
69 #include "mpxcommoncontainer.hrh" |
|
70 #include "mpxcollectionviewhg.hrh" |
|
71 #include "mpxcollectionviewhglistboxarray.h" |
|
72 #include "mpxcollectionviewhg.hlp.hrh" |
|
73 #include "mpxcollectionviewhgcontainer.h" |
|
74 #include "mpxcollectionviewhgplaylisthelper.h" |
|
75 #include "mpxcollectionviewhgtnloader.h" |
|
76 #include "mpxcbahandler.h" |
|
77 |
|
78 // CONSTANTS |
|
79 _LIT( KMPXCollectionViewRscPath, "mpxcollectionviewhg.rsc" ); |
|
80 _LIT( KMPXCollectionViewIconFile, "mpxcollectionviewhg.mbm" ); |
|
81 const TInt KMPXListSelectionCount = 5; |
|
82 const TInt KMPXMinSecSeparatorIndex = 2; |
|
83 const TInt KOneHourInSeconds = 3600; |
|
84 const TInt KMPXTimeIndicatorLength = 16; |
|
85 #ifdef __WINS__ |
|
86 const TInt KMPXListBufferSize = 20; |
|
87 #else |
|
88 const TInt KMPXListBufferSize = 400; |
|
89 #endif |
|
90 // Added by Harri. Buffer size has to be smaller with mediawall, otherwise IVE3 runs out of memory |
|
91 #ifdef __WINS__ |
|
92 const TInt KMPXListBufferSizeWithMediaWall = 20; |
|
93 #else |
|
94 const TInt KMPXListBufferSizeWithMediaWall = 80; |
|
95 #endif |
|
96 const TInt KMPXMaxFileLength = 256; |
|
97 const TReal KIconFactor = 0.7; |
|
98 |
|
99 _LIT( KMPXDash, " - " ); |
|
100 #ifdef HG_MP_LOC_AVAILABLE |
|
101 _LIT( KMPXSpace, " "); |
|
102 #endif //HG_MP_LOC_AVAILABLE |
|
103 _LIT( KMPXZeroDurationMark, "--"); |
|
104 |
|
105 _LIT( KSong, " song" ); |
|
106 _LIT( KSongs, " songs" ); |
|
107 _LIT( KEpisode, " episode" ); |
|
108 _LIT( KEpisodes, " episodes" ); |
|
109 _LIT( KAlbum, " album" ); |
|
110 _LIT( KAlbums, " albums" ); |
|
111 _LIT( KSongDash, " song - " ); |
|
112 _LIT( KSongsDash, " songs - " ); |
|
113 |
|
114 _LIT( KMPXDriveC, "c:" ); |
|
115 _LIT( KMPXSelectedAlbumItemFileName, "mpxalbumitem.dat"); |
|
116 |
|
117 // ======== MEMBER FUNCTIONS ======== |
|
118 |
|
119 // --------------------------------------------------------------------------- |
|
120 // Two-phased constructor. |
|
121 // --------------------------------------------------------------------------- |
|
122 // |
|
123 CMPXCollectionViewHgContainer* CMPXCollectionViewHgContainer::NewL( |
|
124 MEikCommandObserver* aView, |
|
125 MEikListBoxObserver* aObserver, |
|
126 TBool aIsEmbedded) |
|
127 { |
|
128 MPX_FUNC( "CMPXCollectionViewHgContainer::NewL" ); |
|
129 CMPXCollectionViewHgContainer* self = |
|
130 new ( ELeave ) CMPXCollectionViewHgContainer(aView, aObserver, aIsEmbedded); |
|
131 CleanupStack::PushL( self ); |
|
132 self->ConstructL(); |
|
133 CleanupStack::Pop( self ); |
|
134 return self; |
|
135 } |
|
136 |
|
137 // --------------------------------------------------------------------------- |
|
138 // C++ constructor can NOT contain any code that might leave. |
|
139 // --------------------------------------------------------------------------- |
|
140 // |
|
141 CMPXCollectionViewHgContainer::CMPXCollectionViewHgContainer( |
|
142 MEikCommandObserver* aView, |
|
143 MEikListBoxObserver* aObserver, |
|
144 TBool aIsEmbedded) : |
|
145 iView( aView ), |
|
146 iListBoxObserver( aObserver ), |
|
147 iReady( EFalse ), |
|
148 iIsEmbedded(aIsEmbedded), |
|
149 iCurrentDefaultIcon( EMPXDefaultIconNotSet ), |
|
150 iContext( EContextUnknown ), |
|
151 iTopIndex( 0 ), |
|
152 iBottomIndex( KErrNotFound ), |
|
153 iAlbumIndex(KErrNotFound), |
|
154 iSelectedAlbumIndex(KErrNotFound), |
|
155 iRestoredAlbumIndex(KErrNotFound) |
|
156 { |
|
157 } |
|
158 |
|
159 // --------------------------------------------------------------------------- |
|
160 // Destructor |
|
161 // --------------------------------------------------------------------------- |
|
162 // |
|
163 CMPXCollectionViewHgContainer::~CMPXCollectionViewHgContainer() |
|
164 { |
|
165 MPX_FUNC( "CMPXCollectionViewHgContainer::~CMPXCollectionViewHgContainer" ); |
|
166 delete iSongTitle; |
|
167 delete iAlbumTitle; |
|
168 |
|
169 if ( iResourceOffset ) |
|
170 { |
|
171 iEikonEnv->DeleteResourceFile( iResourceOffset ); |
|
172 } |
|
173 delete iListSelections; |
|
174 delete iListBoxArray; |
|
175 delete iIconArray; |
|
176 delete iMediaWall; |
|
177 delete iMwListWidget; |
|
178 delete iListWidget; |
|
179 delete iCommonUiHelper; |
|
180 CancelTNRequest(); |
|
181 iThumbnailReqMap.Close(); |
|
182 delete iThumbnailManager; |
|
183 delete iBgContext; |
|
184 delete iSelectedMediaInAlbumView; |
|
185 if ( iCollectionUtility ) |
|
186 { |
|
187 iCollectionUtility->Close(); |
|
188 } |
|
189 |
|
190 if ( iCollectionUiHelper) |
|
191 { |
|
192 iCollectionUiHelper->Close(); |
|
193 } |
|
194 |
|
195 if ( iPlaybackUtility ) |
|
196 { |
|
197 iPlaybackUtility->Close(); |
|
198 } |
|
199 |
|
200 delete iPlaylist; |
|
201 delete iPlaylistHelper; |
|
202 } |
|
203 |
|
204 // --------------------------------------------------------------------------- |
|
205 // Symbian 2nd phase constructor can leave. |
|
206 // --------------------------------------------------------------------------- |
|
207 // |
|
208 void CMPXCollectionViewHgContainer::ConstructL() |
|
209 { |
|
210 MPX_FUNC( "CMPXCollectionViewHgContainer::ConstructL" ); |
|
211 |
|
212 CCoeEnv* coeEnv( iEikonEnv ); |
|
213 TParse parse; |
|
214 parse.Set( KMPXCollectionViewRscPath, &KDC_APP_RESOURCE_DIR, NULL ); |
|
215 TFileName resourceFile( parse.FullName() ); |
|
216 User::LeaveIfError( MPXUser::CompleteWithDllPath( resourceFile ) ); |
|
217 BaflUtils::NearestLanguageFile( coeEnv->FsSession(), resourceFile ); |
|
218 iResourceOffset = coeEnv->AddResourceFileL( resourceFile ); |
|
219 |
|
220 iAlbumTitle = StringLoader::LoadL( R_MPX_COLLECTION_DETAILS_ONE_ALBUM ); |
|
221 iSongTitle = StringLoader::LoadL( R_MPX_COLLECTION_DETAILS_ONE_SONG ); |
|
222 |
|
223 if ( !iCollectionUiHelper ) |
|
224 { |
|
225 iCollectionUiHelper = CMPXCollectionHelperFactory:: NewCollectionUiHelperL(); |
|
226 } |
|
227 iCollectionUtility = MMPXCollectionUtility::NewL( NULL, KMcModeDefault ); |
|
228 iPlaybackUtility = MMPXPlaybackUtility::UtilityL( KPbModeDefault ); |
|
229 |
|
230 iPlaylistHelper = CMPXCollectionViewHgPlaylistHelper::NewL(iPlaybackUtility, iCollectionUiHelper); |
|
231 |
|
232 TRect mainPane( 0,0,0,0 ); |
|
233 iBgContext = CAknsBasicBackgroundControlContext::NewL( KAknsIIDQsnBgScreen, mainPane, ETrue); |
|
234 |
|
235 iBgContext->SetRect(((CAknAppUi*)iCoeEnv->AppUi())->ApplicationRect()); |
|
236 |
|
237 // Common methods used for 2-line list support |
|
238 iCommonUiHelper = CMPXCommonUiHelper::NewL(); |
|
239 iListSelections = new (ELeave) CArrayFixFlat<TInt>( KMPXListSelectionCount ); |
|
240 |
|
241 iThumbnailManager = CMpxTNLoader::NewL( *this, EAudioListThumbnailSize ); |
|
242 |
|
243 iImageSize = CHgDoubleGraphicListFlat::PreferredImageSize(); |
|
244 |
|
245 TFileName pathWithoutDrive; |
|
246 iEikonEnv->FsSession().PrivatePath( pathWithoutDrive ); |
|
247 iSelectedAlbumItemFileName.Copy( KMPXDriveC ); |
|
248 iSelectedAlbumItemFileName.Append( pathWithoutDrive ); |
|
249 iSelectedAlbumItemFileName.Append( KMPXSelectedAlbumItemFileName ); |
|
250 |
|
251 iListBoxArray = static_cast<CMPXCollectionViewListBoxArray*>( |
|
252 CreateListBoxArrayL() ); |
|
253 |
|
254 CreateIconArrayL(); |
|
255 |
|
256 CreateWindowL(); |
|
257 ActivateL(); |
|
258 DrawableWindow()->SetPointerCapture( RWindowBase::TCaptureDisabled ); |
|
259 SetPointerCapture( EFalse ); |
|
260 CapturesPointer(); |
|
261 } |
|
262 |
|
263 // ----------------------------------------------------------------------------- |
|
264 // CMPXCollectionViewHgContainer::MopSupplyObject |
|
265 // ----------------------------------------------------------------------------- |
|
266 // |
|
267 TTypeUid::Ptr CMPXCollectionViewHgContainer::MopSupplyObject( TTypeUid aId ) |
|
268 { |
|
269 MPX_FUNC( "CMPXCollectionViewHgContainer::MopSupplyObject" ); |
|
270 return MAknsControlContext::SupplyMopObject(aId, iBgContext ); |
|
271 } |
|
272 |
|
273 // --------------------------------------------------------------------------- |
|
274 // Sets playback status |
|
275 // --------------------------------------------------------------------------- |
|
276 // |
|
277 void CMPXCollectionViewHgContainer::SetPlaybackStatusByIdL( |
|
278 TMPXItemId aId, TMPXPlaybackState aStatus, TInt aIndex) |
|
279 { |
|
280 MPX_FUNC( "CMPXCollectionViewHgContainer::SetPlaybackStatusByIdL" ); |
|
281 if ( iListBoxArray ) |
|
282 { |
|
283 TInt index( iListBoxArray->SetPlaybackStatusByIdL( aId, aStatus, aIndex ) ); |
|
284 if ( index != KErrNotFound ) |
|
285 { |
|
286 // Update the previous item as not playing anymore |
|
287 DrawLbxItemL( index ); |
|
288 } |
|
289 index = iListBoxArray->GetPlaybackIndex(); |
|
290 if ( index != KErrNotFound ) |
|
291 { |
|
292 // Update new item as playing |
|
293 DrawLbxItemL( index ); |
|
294 } |
|
295 } |
|
296 } |
|
297 |
|
298 // --------------------------------------------------------------------------- |
|
299 // Get playback index |
|
300 // --------------------------------------------------------------------------- |
|
301 // |
|
302 TInt CMPXCollectionViewHgContainer::PlaybackIndex() |
|
303 { |
|
304 MPX_FUNC( "CMPXCollectionViewHgContainer::PlaybackIndex" ); |
|
305 return ( iListBoxArray ? iListBoxArray->GetPlaybackIndex() : KErrNotFound ); |
|
306 } |
|
307 |
|
308 // --------------------------------------------------------------------------- |
|
309 // Activate reorder mode |
|
310 // --------------------------------------------------------------------------- |
|
311 // |
|
312 void CMPXCollectionViewHgContainer::ActivateReorderMode( TBool aEnable ) |
|
313 { |
|
314 MPX_FUNC( "CMPXCollectionViewHgContainer::ActivateReorderMode" ); |
|
315 if ( iListBoxArray ) |
|
316 { |
|
317 iReorder = aEnable; |
|
318 iListBoxArray->ActivateReorderMode( iReorder ); |
|
319 } |
|
320 } |
|
321 |
|
322 // --------------------------------------------------------------------------- |
|
323 // Set reorder mode |
|
324 // --------------------------------------------------------------------------- |
|
325 // |
|
326 void CMPXCollectionViewHgContainer::SetReorderGrabbedMode( |
|
327 TBool aEnable, TInt aIndex ) |
|
328 { |
|
329 MPX_FUNC( "CMPXCollectionViewHgContainer::SetReorderGrabbedMode" ); |
|
330 if ( iListBoxArray ) |
|
331 { |
|
332 iListBoxArray->SetReorderGrabbedMode( aEnable, aIndex ); |
|
333 } |
|
334 } |
|
335 |
|
336 // --------------------------------------------------------------------------- |
|
337 // Determines if it's currently in reorder mode |
|
338 // --------------------------------------------------------------------------- |
|
339 // |
|
340 TBool CMPXCollectionViewHgContainer::IsInReorderMode() |
|
341 { |
|
342 MPX_FUNC( "CMPXCollectionViewHgContainer::IsInReorderMode" ); |
|
343 return iReorder; |
|
344 } |
|
345 |
|
346 // --------------------------------------------------------------------------- |
|
347 // Move current reorder index |
|
348 // --------------------------------------------------------------------------- |
|
349 // |
|
350 void CMPXCollectionViewHgContainer::MoveReorderIndex( TInt aDirection ) |
|
351 { |
|
352 MPX_FUNC( "CMPXCollectionViewHgContainer::MoveReorderIndex" ); |
|
353 if ( iListBoxArray ) |
|
354 { |
|
355 iListBoxArray->MoveReorderIndex( aDirection ); |
|
356 } |
|
357 } |
|
358 |
|
359 // --------------------------------------------------------------------------- |
|
360 // set current reorder index |
|
361 // --------------------------------------------------------------------------- |
|
362 // |
|
363 void CMPXCollectionViewHgContainer::SetReorderIndex( TInt aIndex ) |
|
364 { |
|
365 MPX_FUNC( "CMPXCollectionViewHgContainer::SetReorderIndex" ); |
|
366 if ( iListBoxArray ) |
|
367 { |
|
368 iListBoxArray->SetReorderIndex( aIndex ); |
|
369 } |
|
370 } |
|
371 |
|
372 // --------------------------------------------------------------------------- |
|
373 // Confirm reorder |
|
374 // --------------------------------------------------------------------------- |
|
375 // |
|
376 void CMPXCollectionViewHgContainer::ConfirmReorderL() |
|
377 { |
|
378 MPX_FUNC( "CMPXCollectionViewHgContainer::ConfirmReorderL" ); |
|
379 if ( iListBoxArray ) |
|
380 { |
|
381 iListBoxArray->ConfirmReorderL(); |
|
382 } |
|
383 } |
|
384 |
|
385 // --------------------------------------------------------------------------- |
|
386 // Cancel reorder |
|
387 // --------------------------------------------------------------------------- |
|
388 // |
|
389 void CMPXCollectionViewHgContainer::CancelReorder() |
|
390 { |
|
391 MPX_FUNC( "CMPXCollectionViewHgContainer::CancelReorder" ); |
|
392 TInt originalIndex( GetOriginalIndex() ); |
|
393 if ( iListBoxArray ) |
|
394 { |
|
395 iListBoxArray->CancelReorder(); |
|
396 } |
|
397 SetLbxCurrentItemIndexAndDraw( originalIndex ); |
|
398 } |
|
399 |
|
400 // --------------------------------------------------------------------------- |
|
401 // Gets original index of currently selected item |
|
402 // --------------------------------------------------------------------------- |
|
403 // |
|
404 TInt CMPXCollectionViewHgContainer::GetOriginalIndex() |
|
405 { |
|
406 MPX_FUNC( "CMPXCollectionViewHgContainer::GetOriginalIndex" ); |
|
407 TInt index( KErrNotFound ); |
|
408 if ( iListBoxArray ) |
|
409 { |
|
410 index = iListBoxArray->GetOriginalIndex(); |
|
411 } |
|
412 return index; |
|
413 } |
|
414 |
|
415 // ----------------------------------------------------------------------------- |
|
416 // Update Titlepane icon to reorder image |
|
417 // ----------------------------------------------------------------------------- |
|
418 // |
|
419 void CMPXCollectionViewHgContainer::UpdateReorderTitleIconL() |
|
420 { |
|
421 MPX_FUNC( "CMPXCollectionViewHgContainer::UpdateReorderTitleIconL" ); |
|
422 // For status changes |
|
423 CEikStatusPane* sp = iAvkonAppUi->StatusPane(); |
|
424 TParse parse; |
|
425 parse.Set( KMPXCollectionViewIconFile, &KDC_APP_RESOURCE_DIR, NULL ); |
|
426 TFileName iconFile( parse.FullName() ); |
|
427 User::LeaveIfError( MPXUser::CompleteWithDllPath( iconFile ) ); |
|
428 |
|
429 MAknsSkinInstance* skin( AknsUtils::SkinInstance() ); |
|
430 |
|
431 CFbsBitmap* bitmap( NULL ); |
|
432 CFbsBitmap* mask( NULL ); |
|
433 |
|
434 AknsUtils::CreateIconLC( |
|
435 skin, |
|
436 KAknsIIDNone, |
|
437 bitmap, |
|
438 mask, |
|
439 iconFile, |
|
440 EMbmMpxcollectionviewhgQgn_graf_mup_ctx_reordersong, |
|
441 EMbmMpxcollectionviewhgQgn_graf_mup_ctx_reordersong_mask ); |
|
442 |
|
443 CEikImage* newIcon = new ( ELeave ) CEikImage(); |
|
444 CleanupStack::PushL( newIcon ); |
|
445 newIcon->SetPicture( bitmap, mask ); |
|
446 newIcon->SetPictureOwnedExternally( EFalse ); |
|
447 iContextPane = static_cast<CAknContextPane*> |
|
448 ( sp->ControlL( TUid::Uid( EEikStatusPaneUidContext ) ) ); |
|
449 iOrigIcon = iContextPane->SwapPicture( newIcon ); |
|
450 CleanupStack::Pop( 3 ); // bitmap, mask, newIcon |
|
451 } |
|
452 |
|
453 // ----------------------------------------------------------------------------- |
|
454 // Update Titlepane icon to use original image |
|
455 // ----------------------------------------------------------------------------- |
|
456 // |
|
457 void CMPXCollectionViewHgContainer::RestoreOriginalTitleIconL() |
|
458 { |
|
459 MPX_FUNC( "CMPXCollectionViewHgContainer::RestoreOriginalTitleIconL" ); |
|
460 if ( iOrigIcon ) |
|
461 { |
|
462 CEikImage* newIcon = iContextPane->SwapPicture( iOrigIcon ); |
|
463 delete newIcon; |
|
464 } |
|
465 } |
|
466 |
|
467 // ----------------------------------------------------------------------------- |
|
468 // Creates listbox array |
|
469 // ----------------------------------------------------------------------------- |
|
470 // |
|
471 CMPXCommonListBoxArrayBase* CMPXCollectionViewHgContainer::CreateListBoxArrayL() |
|
472 { |
|
473 MPX_FUNC( "CMPXCollectionViewHgContainer::CreateListBoxArrayL" ); |
|
474 CMPXCollectionViewListBoxArray* array = CMPXCollectionViewListBoxArray::NewL(); |
|
475 array->ConstructListBoxArrayL(); |
|
476 array->SetObserver( this ); |
|
477 return array; |
|
478 } |
|
479 |
|
480 // --------------------------------------------------------------------------- |
|
481 // From CCoeControl |
|
482 // Handles key events. |
|
483 // --------------------------------------------------------------------------- |
|
484 // |
|
485 TKeyResponse CMPXCollectionViewHgContainer::OfferKeyEventL( |
|
486 const TKeyEvent& aKeyEvent, |
|
487 TEventCode aType ) |
|
488 { |
|
489 MPX_DEBUG4( "CMPXCollectionViewHgContainer::HandleKeyEventL(iCode=%d, iScanCode=%d, aType=%d)", |
|
490 aKeyEvent.iCode, aKeyEvent.iScanCode, aType ); |
|
491 |
|
492 if ( aKeyEvent.iCode == EKeyUpArrow || |
|
493 aKeyEvent.iCode == EKeyPrevious ) |
|
494 { |
|
495 iView->ProcessCommandL( EMPXCmdUpArrow ); |
|
496 } |
|
497 else if ( aKeyEvent.iCode == EKeyDownArrow || |
|
498 aKeyEvent.iCode == EKeyNext ) |
|
499 { |
|
500 iView->ProcessCommandL( EMPXCmdDownArrow ); |
|
501 } |
|
502 TKeyResponse response = EKeyWasNotConsumed; |
|
503 |
|
504 if( iReady ) |
|
505 { |
|
506 const CMPXMedia& containerMedia(iListBoxArray->ContainerMedia() ); |
|
507 TMPXGeneralType containerType( |
|
508 containerMedia.ValueTObjectL<TMPXGeneralType>( |
|
509 KMPXMediaGeneralType ) ); |
|
510 TMPXGeneralCategory containerCategory( |
|
511 containerMedia.ValueTObjectL<TMPXGeneralCategory>( |
|
512 KMPXMediaGeneralCategory ) ); |
|
513 |
|
514 // Hashkey mark/unmark works in all song's view and other tracks view, |
|
515 // not on other category views |
|
516 if( containerCategory == EMPXSong || |
|
517 (( containerCategory == EMPXPlaylist || |
|
518 containerCategory == EMPXAlbum || |
|
519 containerCategory == EMPXGenre || |
|
520 containerCategory == EMPXComposer ) && |
|
521 containerType == EMPXItem ) || |
|
522 aKeyEvent.iScanCode != EStdKeyHash ) |
|
523 { |
|
524 response = HandleKeyEventL( aKeyEvent, aType ); |
|
525 } |
|
526 } |
|
527 else |
|
528 { |
|
529 response = HandleKeyEventL( aKeyEvent, aType ); |
|
530 MPX_DEBUG2( "CMPXCollectionViewHgContainer::OfferKeyEventL commoncontainer offerkey res = %d", response); |
|
531 } |
|
532 |
|
533 if ( aKeyEvent.iCode == EKeyUpArrow || |
|
534 aKeyEvent.iCode == EKeyPrevious ) |
|
535 { |
|
536 iView->ProcessCommandL( EMPXCmdUpArrowAfterListboxHandled ); |
|
537 } |
|
538 else if ( aKeyEvent.iCode == EKeyDownArrow || |
|
539 aKeyEvent.iCode == EKeyNext ) |
|
540 { |
|
541 iView->ProcessCommandL( EMPXCmdDownArrowAfterListboxHandled ); |
|
542 } |
|
543 return response; |
|
544 } |
|
545 |
|
546 |
|
547 // --------------------------------------------------------------------------- |
|
548 // Handles key events. |
|
549 // --------------------------------------------------------------------------- |
|
550 // |
|
551 TKeyResponse CMPXCollectionViewHgContainer::HandleKeyEventL( |
|
552 const TKeyEvent& aKeyEvent, |
|
553 TEventCode aType ) |
|
554 { |
|
555 MPX_DEBUG5( "CMPXCollectionViewHgContainer::HandleKeyEventL(iCode=%d, iScanCode=%d, iModifiers=0x%x, aType=%d)", |
|
556 aKeyEvent.iCode, aKeyEvent.iScanCode, aKeyEvent.iModifiers, aType ); |
|
557 |
|
558 TKeyResponse response( EKeyWasNotConsumed ); |
|
559 if ( aKeyEvent.iCode == EKeyOK || aKeyEvent.iCode == EKeyEnter ) |
|
560 { |
|
561 SaveSelectedAlbumItemL(iAlbumIndex); |
|
562 // Handle enter key pressed |
|
563 iView->ProcessCommandL( EMPXCmdCommonEnterKey ); |
|
564 } |
|
565 if ( iListWidget ) |
|
566 { |
|
567 iListWidget->OfferKeyEventL( aKeyEvent, aType ); |
|
568 } |
|
569 else if( iMediaWall ) |
|
570 { |
|
571 iMediaWall->OfferKeyEventL( aKeyEvent, aType ); |
|
572 } |
|
573 if ( response == EKeyWasNotConsumed && |
|
574 aType == EEventKey && |
|
575 aKeyEvent.iCode == EKeyBackspace && iView ) |
|
576 { |
|
577 iView->ProcessCommandL( EMPXCmdCommonDelete ); |
|
578 response = EKeyWasConsumed; |
|
579 } |
|
580 |
|
581 return response; |
|
582 } |
|
583 |
|
584 // --------------------------------------------------------------------------- |
|
585 // From CCoeControl |
|
586 // Gets the control's help context. |
|
587 // --------------------------------------------------------------------------- |
|
588 // |
|
589 void CMPXCollectionViewHgContainer::GetHelpContext( |
|
590 TCoeHelpContext& aContext ) const |
|
591 { |
|
592 MPX_FUNC( "CMPXCollectionViewHgContainer::HandleHelpContext" ); |
|
593 aContext.iMajor = KAppUidMusicPlayerX; |
|
594 |
|
595 const CMPXMedia& containerMedia(iListBoxArray->ContainerMedia() ); |
|
596 TMPXGeneralType containerType( |
|
597 containerMedia.ValueTObjectL<TMPXGeneralType>( |
|
598 KMPXMediaGeneralType ) ); |
|
599 TMPXGeneralCategory containerCategory( |
|
600 containerMedia.ValueTObjectL<TMPXGeneralCategory>( |
|
601 KMPXMediaGeneralCategory ) ); |
|
602 MPX_DEBUG3( "CMPXCollectionViewHgContainer::HandleHelpContext containertype = %d, containercategory = %d", containerType, containerCategory ); |
|
603 |
|
604 switch ( containerCategory ) |
|
605 { |
|
606 case EMPXCollection: |
|
607 { |
|
608 // music menu view |
|
609 aContext.iContext = KMusHlpLibMainView; |
|
610 break; |
|
611 } |
|
612 case EMPXPlaylist: |
|
613 { |
|
614 if (iIsEmbedded) |
|
615 { |
|
616 aContext.iContext = KMusHlpEmbeddedPlaylistTracksView; |
|
617 } |
|
618 else |
|
619 { |
|
620 if ( containerType == EMPXGroup ) |
|
621 { |
|
622 // playlist view |
|
623 aContext.iContext = KMusHlpPlaylistView; |
|
624 } |
|
625 else if ( containerType == EMPXItem ) |
|
626 { |
|
627 // playlist tracks view |
|
628 aContext.iContext = KMusHlpPlaylistTracksView; |
|
629 } |
|
630 else |
|
631 { |
|
632 // default to music main view help context |
|
633 aContext.iContext = KMusHlpLibMainView; |
|
634 } |
|
635 } |
|
636 break; |
|
637 } |
|
638 case EMPXAlbum: |
|
639 case EMPXGenre: |
|
640 case EMPXComposer: |
|
641 { |
|
642 if ( containerType == EMPXGroup ) |
|
643 { |
|
644 // album, genre, composer view |
|
645 aContext.iContext = KMusHlpCategoryView; |
|
646 } |
|
647 else if ( containerType == EMPXItem ) |
|
648 { |
|
649 // album, genre, composer tracks view |
|
650 aContext.iContext = KMusHlpTracksView; |
|
651 } |
|
652 else |
|
653 { |
|
654 // default to music main view help context |
|
655 aContext.iContext = KMusHlpLibMainView; |
|
656 } |
|
657 break; |
|
658 } |
|
659 case EMPXArtist: |
|
660 { |
|
661 // artist view |
|
662 // artist/album view |
|
663 aContext.iContext = KMusHlpCategoryView; |
|
664 break; |
|
665 } |
|
666 case EMPXSong: |
|
667 { |
|
668 // all songs view |
|
669 aContext.iContext = KMusHlpTracksView; |
|
670 break; |
|
671 } |
|
672 default: |
|
673 { |
|
674 // default to music main view help context |
|
675 aContext.iContext = KMusHlpLibMainView; |
|
676 break; |
|
677 } |
|
678 } |
|
679 } |
|
680 |
|
681 // --------------------------------------------------------------------------- |
|
682 // From CCoeControl |
|
683 // Handles a change to the control's resources. |
|
684 // --------------------------------------------------------------------------- |
|
685 // |
|
686 void CMPXCollectionViewHgContainer::HandleResourceChange( TInt aType ) |
|
687 { |
|
688 MPX_FUNC( "CMPXCollectionViewHgContainer::HandleResourceChange" ); |
|
689 CCoeControl::HandleResourceChange( aType ); |
|
690 |
|
691 TBool landscapeOrientation = Layout_Meta_Data::IsLandscapeOrientation(); |
|
692 TRAP_IGNORE( |
|
693 if ( aType == KAknsMessageSkinChange ) |
|
694 { |
|
695 delete iIconArray; |
|
696 iIconArray = NULL; |
|
697 CreateIconArrayL(); |
|
698 |
|
699 if( iCurrentViewType == EMPXViewCoverFlow || iCurrentViewType == EMPXViewTBone ) |
|
700 { |
|
701 iMediaWall->SetDefaultIconL(NULL); |
|
702 iMediaWall->EnableScrollBufferL(*this, KMPXListBufferSize, KMPXListBufferSize/4); |
|
703 } |
|
704 else |
|
705 { |
|
706 CHgScroller* list = CurrentListWidget(); |
|
707 if( list ) |
|
708 { |
|
709 list->SetDefaultIconL(NULL); |
|
710 list->EnableScrollBufferL(*this, KMPXListBufferSizeWithMediaWall, KMPXListBufferSizeWithMediaWall/4); |
|
711 } |
|
712 } |
|
713 SetDetailIconShuffleL(); |
|
714 } |
|
715 else if ( aType == KEikDynamicLayoutVariantSwitch ) |
|
716 { |
|
717 TRect clientRect = ((CAknView*)iView)->ClientRect(); |
|
718 |
|
719 iBgContext->SetRect(((CAknAppUi*)iCoeEnv->AppUi())->ApplicationRect()); |
|
720 |
|
721 // In current design we switch to different type of control in |
|
722 // all orientation switches. |
|
723 HandleLbxItemAdditionL(); |
|
724 } |
|
725 ); |
|
726 } |
|
727 |
|
728 |
|
729 // --------------------------------------------------------------------------- |
|
730 // From CCoeControl |
|
731 // Draw this application's view to the screen |
|
732 // --------------------------------------------------------------------------- |
|
733 // |
|
734 void CMPXCollectionViewHgContainer::Draw(const TRect& /*aRect*/) const |
|
735 { |
|
736 if ( iContext == EContextUnknown ) |
|
737 { |
|
738 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
739 MAknsControlContext* cc = AknsDrawUtils::ControlContext( this ); |
|
740 AknsDrawUtils::DrawBackground( skin, cc, this, SystemGc(), |
|
741 TPoint(0,0), Rect(), KAknsDrawParamDefault ); |
|
742 } |
|
743 } |
|
744 |
|
745 // --------------------------------------------------------------------------- |
|
746 // From CCoeControl |
|
747 // Provide control input capabilities |
|
748 // --------------------------------------------------------------------------- |
|
749 // |
|
750 TCoeInputCapabilities CMPXCollectionViewHgContainer::InputCapabilities() const |
|
751 { |
|
752 switch( iCurrentViewType ) |
|
753 { |
|
754 case EMPXViewCoverFlow: |
|
755 case EMPXViewTBone: |
|
756 { |
|
757 return iMediaWall->InputCapabilities(); |
|
758 } |
|
759 case EMPXViewList: |
|
760 { |
|
761 return iListWidget->InputCapabilities(); |
|
762 } |
|
763 default: |
|
764 break; |
|
765 } |
|
766 return CCoeControl::InputCapabilities(); |
|
767 } |
|
768 |
|
769 // --------------------------------------------------------------------------- |
|
770 // From MCoeControlObserver |
|
771 // Handle control event |
|
772 // --------------------------------------------------------------------------- |
|
773 // |
|
774 void CMPXCollectionViewHgContainer::HandleControlEventL( |
|
775 CCoeControl* /*aControl*/, |
|
776 TCoeEvent /*aEventType*/ ) |
|
777 { |
|
778 } |
|
779 // --------------------------------------------------------------------------- |
|
780 // From MMPXViewContainer |
|
781 // Returns the indicators for the specified item within the view container |
|
782 // --------------------------------------------------------------------------- |
|
783 // |
|
784 RArray<TInt> CMPXCollectionViewHgContainer::IndicatorsL( TInt aIndex ) |
|
785 { |
|
786 return iListBoxArray->IndicatorIconIndicesL( aIndex ); |
|
787 } |
|
788 |
|
789 // --------------------------------------------------------------------------- |
|
790 // From MMPXCommonListBoxArrayObserver |
|
791 // Handle listbox array events. |
|
792 // --------------------------------------------------------------------------- |
|
793 // |
|
794 void CMPXCollectionViewHgContainer::HandleListBoxArrayEventL( |
|
795 TMPXCommonListBoxArrayEvents aEvent ) |
|
796 { |
|
797 MPX_FUNC( "CMPXCollectionViewHgContainer::HandleListBoxArrayEventL" ); |
|
798 |
|
799 if ( aEvent == MMPXCommonListBoxArrayObserver::EMPXCommonListBoxArrayEventIconArrayChange ) |
|
800 { |
|
801 delete iIconArray; |
|
802 iIconArray = NULL; |
|
803 CreateIconArrayL(); |
|
804 } |
|
805 else if ( aEvent == MMPXCommonListBoxArrayObserver::EMPXCommonListBoxArrayEventMediaArrayChange ) |
|
806 { |
|
807 |
|
808 // Update list widget with new items in the media array. |
|
809 // We start the update from last valid media item index. |
|
810 if ( iListWidget ) |
|
811 { |
|
812 ProvideDataWithoutThumbnailsL(iListBoxArray->MediaArray(), iLastValidMediaItemIndex); |
|
813 |
|
814 |
|
815 if ( iLastValidMediaItemIndex >= iRequestStart && iLastValidMediaItemIndex >= iRequestEnd ) |
|
816 { |
|
817 |
|
818 Request(iRequestStart, iRequestEnd, EHgBufferReset ); |
|
819 } |
|
820 iListWidget->RefreshScreen(iListWidget->FirstIndexOnScreen()); |
|
821 } |
|
822 } |
|
823 } |
|
824 |
|
825 // --------------------------------------------------------------------------- |
|
826 // Content is ready. |
|
827 // --------------------------------------------------------------------------- |
|
828 // |
|
829 void CMPXCollectionViewHgContainer::ContentIsReady( TBool aReady ) |
|
830 { |
|
831 iReady = aReady; |
|
832 } |
|
833 |
|
834 |
|
835 void CMPXCollectionViewHgContainer::SetCbaHandler( MMpxCbaHandler* aCbaHandler ) |
|
836 { |
|
837 iCbaHandler = aCbaHandler; |
|
838 } |
|
839 |
|
840 // ----------------------------------------------------------------------------- |
|
841 // Creates icon array, populates iIconArray to be used by listbox |
|
842 // ----------------------------------------------------------------------------- |
|
843 // |
|
844 void CMPXCollectionViewHgContainer::CreateIconArrayL() |
|
845 { |
|
846 MPX_FUNC( "CMPXCollectionViewHgContainer::CreateIconArrayL" ); |
|
847 if ( iListBoxArray ) |
|
848 { |
|
849 iIconArray = iListBoxArray->CreateIconArrayL(); |
|
850 } |
|
851 SetDefaultIconL(); |
|
852 } |
|
853 |
|
854 // ----------------------------------------------------------------------------- |
|
855 // Returns a pointer to the listboxarray |
|
856 // ----------------------------------------------------------------------------- |
|
857 // |
|
858 CMPXCommonListBoxArrayBase* CMPXCollectionViewHgContainer::ListBoxArray() const |
|
859 { |
|
860 return iListBoxArray; |
|
861 } |
|
862 |
|
863 // ----------------------------------------------------------------------------- |
|
864 // Return number of listbox items shown in the current listbox. |
|
865 // ----------------------------------------------------------------------------- |
|
866 // |
|
867 TInt CMPXCollectionViewHgContainer::CurrentListItemCount() const |
|
868 { |
|
869 MPX_FUNC( "CMPXCollectionViewHgContainer::CurrentListItemCount" ); |
|
870 TInt count = 0; |
|
871 |
|
872 switch( iCurrentViewType ) |
|
873 { |
|
874 case EMPXViewCoverFlow: |
|
875 case EMPXViewTBone: |
|
876 { |
|
877 count = iMediaWall->ItemCount(); |
|
878 break; |
|
879 } |
|
880 case EMPXViewList: |
|
881 { |
|
882 count = iListWidget->ItemCount(); |
|
883 break; |
|
884 } |
|
885 default: |
|
886 break; |
|
887 } |
|
888 |
|
889 return count; |
|
890 } |
|
891 |
|
892 |
|
893 // ----------------------------------------------------------------------------- |
|
894 // Return total number of listbox items in the listbox. |
|
895 // ----------------------------------------------------------------------------- |
|
896 // |
|
897 TInt CMPXCollectionViewHgContainer::TotalListItemCount() const |
|
898 { |
|
899 MPX_FUNC( "CMPXCollectionViewHgContainer::TotalListItemCount" ); |
|
900 TInt count = 0; |
|
901 if ( iListBoxArray ) |
|
902 { |
|
903 count = iListBoxArray->MediaArray().Count(); |
|
904 } |
|
905 return count; |
|
906 } |
|
907 |
|
908 |
|
909 // ----------------------------------------------------------------------------- |
|
910 // Gets top listbox item index (relative to the original listbox). |
|
911 // ----------------------------------------------------------------------------- |
|
912 // |
|
913 TInt CMPXCollectionViewHgContainer::TopLbxItemIndex() const |
|
914 { |
|
915 MPX_FUNC( "CMPXCollectionViewHgContainer::TopLbxItemIndex" ); |
|
916 return iTopIndex; |
|
917 } |
|
918 |
|
919 |
|
920 // ----------------------------------------------------------------------------- |
|
921 // Gets bottom listbox item index (relative to the original listbox). |
|
922 // ----------------------------------------------------------------------------- |
|
923 // |
|
924 TInt CMPXCollectionViewHgContainer::BottomLbxItemIndex() const |
|
925 { |
|
926 MPX_FUNC( "CMPXCollectionViewHgContainer::BottomLbxItemIndex" ); |
|
927 return iBottomIndex; |
|
928 } |
|
929 |
|
930 |
|
931 // ----------------------------------------------------------------------------- |
|
932 // Gets current listbox item index (relative to the original listbox). |
|
933 // ----------------------------------------------------------------------------- |
|
934 // |
|
935 TInt CMPXCollectionViewHgContainer::CurrentLbxItemIndex() const |
|
936 { |
|
937 MPX_FUNC( "CMPXCollectionViewHgContainer::CurrentLbxItemIndex" ); |
|
938 TInt index( KErrNotFound ); |
|
939 |
|
940 const TInt count = CurrentListItemCount(); |
|
941 |
|
942 if ( count <= 0 ) |
|
943 return index; |
|
944 |
|
945 switch( iCurrentViewType ) |
|
946 { |
|
947 case EMPXViewCoverFlow: |
|
948 case EMPXViewTBone: |
|
949 { |
|
950 index = iMediaWall->SelectedIndex(); |
|
951 break; |
|
952 } |
|
953 case EMPXViewList: |
|
954 { |
|
955 index = iListWidget->SelectedIndex(); |
|
956 break; |
|
957 } |
|
958 default: |
|
959 break; |
|
960 } |
|
961 |
|
962 return index; |
|
963 } |
|
964 |
|
965 |
|
966 // ----------------------------------------------------------------------------- |
|
967 // Get current selected listbox items indices (relative to the original listbox) |
|
968 // ----------------------------------------------------------------------------- |
|
969 // |
|
970 const CArrayFix<TInt>* CMPXCollectionViewHgContainer::CurrentSelectionIndicesL() const |
|
971 { |
|
972 MPX_FUNC( "CMPXCollectionViewHgContainer::CurrentSelectionIndicesL" ); |
|
973 |
|
974 // TODO, check if selection is available only with views that have only list. |
|
975 if ( iListWidget ) |
|
976 { |
|
977 iListSelections->Reset(); |
|
978 RArray<TInt> selectionArray; |
|
979 CleanupClosePushL( selectionArray ); |
|
980 iListWidget->GetMarkedItemsL(selectionArray); |
|
981 int count = selectionArray.Count(); |
|
982 for( int i = 0; i < count; i++ ) |
|
983 { |
|
984 iListSelections->AppendL( selectionArray[i] ); |
|
985 } |
|
986 CleanupStack::PopAndDestroy( &selectionArray ); |
|
987 } |
|
988 return iListSelections; |
|
989 } |
|
990 |
|
991 |
|
992 // ----------------------------------------------------------------------------- |
|
993 // Set current selected listbox items indices (relative to the original listbox) |
|
994 // ----------------------------------------------------------------------------- |
|
995 // |
|
996 void CMPXCollectionViewHgContainer::SetCurrentSelectionIndicesL( |
|
997 CArrayFix<TInt>* aIndices ) const |
|
998 { |
|
999 MPX_FUNC( "CMPXCollectionViewHgContainer::SetCurrentSelectionIndicesL" ); |
|
1000 TInt count = aIndices->Count(); |
|
1001 if ( count > 0 && iListWidget ) |
|
1002 { |
|
1003 for( TInt i = 0; i < count; i++ ) |
|
1004 { |
|
1005 iListWidget->Mark( (*aIndices)[i] ); |
|
1006 } |
|
1007 iListWidget->RefreshScreen( (*aIndices)[0] ); |
|
1008 } |
|
1009 } |
|
1010 |
|
1011 |
|
1012 // ----------------------------------------------------------------------------- |
|
1013 // Set top listbox item index. |
|
1014 // ----------------------------------------------------------------------------- |
|
1015 // |
|
1016 void CMPXCollectionViewHgContainer::SetLbxTopItemIndex( TInt /*aIndex*/ ) |
|
1017 { |
|
1018 MPX_FUNC( "CMPXCollectionViewHgContainer::SetLbxTopItemIndex" ); |
|
1019 } |
|
1020 |
|
1021 |
|
1022 // ----------------------------------------------------------------------------- |
|
1023 // Set current listbox item index. |
|
1024 // ----------------------------------------------------------------------------- |
|
1025 // |
|
1026 void CMPXCollectionViewHgContainer::SetLbxCurrentItemIndex( TInt aIndex ) |
|
1027 { |
|
1028 MPX_FUNC( "CMPXCollectionViewHgContainer::SetLbxCurrentItemIndex" ); |
|
1029 |
|
1030 // TODO, check if we need to support this with other view types also |
|
1031 // David: This needs to be supported for Mediawall and Tbone |
|
1032 if ( iListWidget ) |
|
1033 { |
|
1034 iListWidget->SetSelectedIndex( aIndex ); |
|
1035 } |
|
1036 } |
|
1037 |
|
1038 |
|
1039 // ----------------------------------------------------------------------------- |
|
1040 // Set current listbox item index and highlight it. |
|
1041 // ----------------------------------------------------------------------------- |
|
1042 // |
|
1043 void CMPXCollectionViewHgContainer::SetLbxCurrentItemIndexAndDraw( |
|
1044 TInt aIndex ) |
|
1045 { |
|
1046 MPX_FUNC( "CMPXCollectionViewHgContainer::SetLbxCurrentItemIndexAndDraw" ); |
|
1047 SetLbxCurrentItemIndex(aIndex); |
|
1048 } |
|
1049 |
|
1050 |
|
1051 // ----------------------------------------------------------------------------- |
|
1052 // Clear listbox selection. |
|
1053 // ----------------------------------------------------------------------------- |
|
1054 // |
|
1055 void CMPXCollectionViewHgContainer::ClearLbxSelection() |
|
1056 { |
|
1057 MPX_FUNC( "CMPXCollectionViewHgContainer::ClearLbxSelection" ); |
|
1058 if ( iListWidget ) |
|
1059 { |
|
1060 iListWidget->UnMarkAll(); |
|
1061 } |
|
1062 } |
|
1063 |
|
1064 // ----------------------------------------------------------------------------- |
|
1065 // Sets the text for an empty list box |
|
1066 // ----------------------------------------------------------------------------- |
|
1067 // |
|
1068 void CMPXCollectionViewHgContainer::SetLbxEmptyTextL( const TDesC& aText ) |
|
1069 { |
|
1070 MPX_FUNC( "CMPXCollectionViewHgContainer::SetLbxEmptyTextL" ); |
|
1071 |
|
1072 if ( iListWidget && aText != KNullDesC ) |
|
1073 { |
|
1074 iListWidget->SetEmptyTextL( aText ); |
|
1075 } |
|
1076 } |
|
1077 |
|
1078 // ----------------------------------------------------------------------------- |
|
1079 // Draws a list box item |
|
1080 // ----------------------------------------------------------------------------- |
|
1081 // |
|
1082 void CMPXCollectionViewHgContainer::DrawLbxItemL( TInt aIndex ) |
|
1083 { |
|
1084 MPX_DEBUG2( "CMPXCollectionViewHgContainer::DrawLbxItem (aIndex=%d)", aIndex ); |
|
1085 |
|
1086 CHgScroller* list = CurrentListWidget(); |
|
1087 |
|
1088 if( list ) |
|
1089 { |
|
1090 CHgItem* item = &list->ItemL(aIndex); |
|
1091 SetDetailIndicatorL(item, aIndex); |
|
1092 list->RefreshScreen(aIndex); |
|
1093 } |
|
1094 } |
|
1095 |
|
1096 |
|
1097 // ----------------------------------------------------------------------------- |
|
1098 // Set Find box's focus. |
|
1099 // ----------------------------------------------------------------------------- |
|
1100 // |
|
1101 void CMPXCollectionViewHgContainer::SetFindBoxFocus( TBool /*aFocus*/ ) |
|
1102 { |
|
1103 MPX_FUNC( "CMPXCollectionViewHgContainer::SetFindBoxFocus" ); |
|
1104 } |
|
1105 |
|
1106 |
|
1107 // ----------------------------------------------------------------------------- |
|
1108 // Handle listbox item addition. |
|
1109 // ----------------------------------------------------------------------------- |
|
1110 // |
|
1111 void CMPXCollectionViewHgContainer::HandleLbxItemAdditionL() |
|
1112 { |
|
1113 MPX_FUNC( "CMPXCollectionViewHgContainer::HandleLbxItemAdditionL" ); |
|
1114 SetCollectionContextL(); |
|
1115 iLastValidMediaItemIndex = 0; |
|
1116 |
|
1117 const CMPXMediaArray& mediaArray = iListBoxArray->MediaArray(); |
|
1118 const TInt count( mediaArray.Count() ); |
|
1119 MPX_DEBUG2( "CMPXCollectionViewHgContainer::HandleLbxItemAdditionL count=%d", count); |
|
1120 HandleLbxItemRemovalL(); |
|
1121 |
|
1122 iThumbnailReqMap.Reset(); |
|
1123 iThumbnailReqMap.ReserveL(count); |
|
1124 for ( TInt i = 0; i < count; i++ ) |
|
1125 { |
|
1126 iThumbnailReqMap.Append( EFalse ); |
|
1127 } |
|
1128 |
|
1129 iThumbnailManager->CancelAll(); |
|
1130 |
|
1131 TViewType prevViewType = iCurrentViewType; |
|
1132 ResolveCurrentViewType(); |
|
1133 |
|
1134 if( prevViewType == iCurrentViewType && iContext == iPrevContext ) |
|
1135 { |
|
1136 ResizeListL( mediaArray, count ); |
|
1137 } |
|
1138 else |
|
1139 { |
|
1140 // MediaWall sets the default icon in the construction phase. |
|
1141 iDefaultIconSet = EFalse; |
|
1142 switch (iCurrentViewType) |
|
1143 { |
|
1144 case EMPXViewCoverFlow: |
|
1145 { |
|
1146 TMPXPlaybackState pbState( iPlaybackUtility->StateL() ); |
|
1147 if ( pbState == EPbStatePlaying || pbState == EPbStatePaused ) |
|
1148 RestoreSelectedAlbumItemL(mediaArray); |
|
1149 PrepareMediaWallL(mediaArray, count); |
|
1150 break; |
|
1151 } |
|
1152 case EMPXViewTBone: |
|
1153 { |
|
1154 RestoreSelectedAlbumItemL(mediaArray); |
|
1155 PrepareMediaWallWithListL( mediaArray, count ); |
|
1156 break; |
|
1157 } |
|
1158 case EMPXViewList: |
|
1159 { |
|
1160 PrepareListL(mediaArray, count); |
|
1161 break; |
|
1162 } |
|
1163 default: |
|
1164 User::Leave( KErrGeneral ); |
|
1165 break; |
|
1166 } |
|
1167 |
|
1168 } |
|
1169 |
|
1170 DrawableWindow()->SetOrdinalPosition( -1 ); |
|
1171 |
|
1172 CleanPrevView(); |
|
1173 |
|
1174 iPrevViewType = iCurrentViewType; |
|
1175 iPrevContext = iContext; |
|
1176 if( !iDefaultIconSet ) |
|
1177 { |
|
1178 SetDefaultIconL(); |
|
1179 } |
|
1180 |
|
1181 } |
|
1182 |
|
1183 // ----------------------------------------------------------------------------- |
|
1184 // Handle listbox item addition, preserving the current display index |
|
1185 // ----------------------------------------------------------------------------- |
|
1186 // |
|
1187 void CMPXCollectionViewHgContainer::HandleLbxItemAdditionPreserveIndexL() |
|
1188 { |
|
1189 MPX_FUNC( "CMPXCollectionViewHgContainer::HandleLbxItemAdditionPreserveIndexL" ); |
|
1190 HandleLbxItemAdditionL(); |
|
1191 } |
|
1192 |
|
1193 |
|
1194 // ----------------------------------------------------------------------------- |
|
1195 // Handle listbox item removal. |
|
1196 // ----------------------------------------------------------------------------- |
|
1197 // |
|
1198 void CMPXCollectionViewHgContainer::HandleLbxItemRemovalL() |
|
1199 { |
|
1200 MPX_FUNC( "CMPXCollectionViewHgContainer::HandleLbxItemRemovalL" ); |
|
1201 iTopIndex = 0; |
|
1202 iBottomIndex = KErrNotFound; |
|
1203 if ( iContext != iPrevContext ) |
|
1204 { |
|
1205 CancelTNRequest(); |
|
1206 iThumbnailReqMap.Close(); |
|
1207 |
|
1208 } |
|
1209 } |
|
1210 |
|
1211 |
|
1212 // ----------------------------------------------------------------------------- |
|
1213 // Show/hide find box. |
|
1214 // ----------------------------------------------------------------------------- |
|
1215 // |
|
1216 void CMPXCollectionViewHgContainer::SetFindBoxVisibilityL( TBool /*aIsVisible*/ ) |
|
1217 { |
|
1218 } |
|
1219 |
|
1220 |
|
1221 // ----------------------------------------------------------------------------- |
|
1222 // Determine find box visibility |
|
1223 // ----------------------------------------------------------------------------- |
|
1224 // |
|
1225 TBool CMPXCollectionViewHgContainer::FindBoxVisibility() |
|
1226 { |
|
1227 return EFalse; |
|
1228 } |
|
1229 |
|
1230 |
|
1231 // ----------------------------------------------------------------------------- |
|
1232 // Restore the PopupCBA of find box |
|
1233 // ----------------------------------------------------------------------------- |
|
1234 // |
|
1235 void CMPXCollectionViewHgContainer::RestoreFindBoxPopupCBA() |
|
1236 { |
|
1237 } |
|
1238 |
|
1239 |
|
1240 // ----------------------------------------------------------------------------- |
|
1241 // Calculate the top index of the visible items |
|
1242 // ----------------------------------------------------------------------------- |
|
1243 // |
|
1244 TInt CMPXCollectionViewHgContainer::CalculateTopIndex( TInt /*aBottomIndex*/ ) |
|
1245 { |
|
1246 MPX_FUNC( "CMPXCollectionViewHgContainer::CalculateTopIndex" ); |
|
1247 return 0; |
|
1248 } |
|
1249 |
|
1250 // --------------------------------------------------------------------------- |
|
1251 // Enable/disable find box |
|
1252 // --------------------------------------------------------------------------- |
|
1253 // |
|
1254 void CMPXCollectionViewHgContainer::EnableFindBox( TBool /*aEnable*/ ) |
|
1255 { |
|
1256 MPX_FUNC( "CMPXCollectionViewHgContainer::EnableFindBox" ); |
|
1257 } |
|
1258 |
|
1259 |
|
1260 // --------------------------------------------------------------------------- |
|
1261 // Enable/disable marking |
|
1262 // --------------------------------------------------------------------------- |
|
1263 // |
|
1264 void CMPXCollectionViewHgContainer::EnableMarking( TBool /*aEnable*/ ) |
|
1265 { |
|
1266 MPX_FUNC( "CMPXCollectionViewHgContainer::EnableMarking" ); |
|
1267 } |
|
1268 |
|
1269 // --------------------------------------------------------------------------- |
|
1270 // Custom handling of commands for markable lists. |
|
1271 // --------------------------------------------------------------------------- |
|
1272 // |
|
1273 void CMPXCollectionViewHgContainer::HandleMarkableListProcessCommandL( |
|
1274 TInt aCommand ) |
|
1275 { |
|
1276 MPX_FUNC( "CMPXCollectionViewHgContainer::HandleMarkableListProcessCommandL" ); |
|
1277 |
|
1278 if ( iListWidget ) |
|
1279 { |
|
1280 switch ( aCommand ) |
|
1281 { |
|
1282 case EAknCmdMark: |
|
1283 iListWidget->Mark(iListWidget->SelectedIndex()); |
|
1284 break; |
|
1285 case EAknCmdUnmark: |
|
1286 iListWidget->UnMark(iListWidget->SelectedIndex()); |
|
1287 break; |
|
1288 case EAknMarkAll: |
|
1289 iListWidget->MarkAll(); |
|
1290 break; |
|
1291 case EAknUnmarkAll: |
|
1292 iListWidget->UnMarkAll(); |
|
1293 break; |
|
1294 } |
|
1295 iListWidget->RefreshScreen(iListWidget->SelectedIndex()); |
|
1296 } |
|
1297 } |
|
1298 |
|
1299 |
|
1300 // --------------------------------------------------------------------------- |
|
1301 // Custom handling of menu pane for markable lists |
|
1302 // --------------------------------------------------------------------------- |
|
1303 // |
|
1304 void CMPXCollectionViewHgContainer::HandleMarkableListDynInitMenuPane( |
|
1305 TInt aResourceId, |
|
1306 CEikMenuPane* aMenuPane ) |
|
1307 { |
|
1308 MPX_FUNC( "CMPXCollectionViewHgContainer::HandleMarkableListDynInitMenuPane" ); |
|
1309 |
|
1310 if ( aResourceId == R_AVKON_MENUPANE_MARKABLE_LIST ) |
|
1311 { |
|
1312 TInt currentItem = CurrentLbxItemIndex(); |
|
1313 if ( currentItem == KErrNotFound ) |
|
1314 { |
|
1315 aMenuPane->SetItemDimmed( EAknCmdEditListMenu, ETrue ); |
|
1316 } |
|
1317 else |
|
1318 { |
|
1319 aMenuPane->SetItemDimmed( EAknCmdEditListMenu, EFalse ); |
|
1320 } |
|
1321 } |
|
1322 else if ( aResourceId == R_AVKON_MENUPANE_MARKABLE_LIST_IMPLEMENTATION ) |
|
1323 { |
|
1324 TRAP_IGNORE(CurrentSelectionIndicesL()); |
|
1325 TInt currentItem = CurrentLbxItemIndex(); |
|
1326 if ( currentItem != KErrNotFound ) |
|
1327 { |
|
1328 TBool currentItemMarked = EFalse; |
|
1329 for( int i = 0; i < iListSelections->Count(); i++ ) |
|
1330 { |
|
1331 if ( currentItem == iListSelections->At(i) ) |
|
1332 { |
|
1333 currentItemMarked = ETrue; |
|
1334 break; |
|
1335 } |
|
1336 } |
|
1337 |
|
1338 TInt count = 0; |
|
1339 if( iListWidget ) |
|
1340 { |
|
1341 count = iListWidget->ItemCount(); |
|
1342 } |
|
1343 else if ( iMediaWall ) |
|
1344 { |
|
1345 count = iMediaWall->ItemCount(); |
|
1346 } |
|
1347 aMenuPane->SetItemDimmed( EAknCmdMark, currentItemMarked ); |
|
1348 aMenuPane->SetItemDimmed( EAknCmdUnmark, !currentItemMarked ); |
|
1349 aMenuPane->SetItemDimmed( EAknMarkAll, iListSelections->Count() == count ); |
|
1350 aMenuPane->SetItemDimmed( EAknUnmarkAll, iListSelections->Count() == 0 ); |
|
1351 } |
|
1352 } |
|
1353 } |
|
1354 |
|
1355 |
|
1356 |
|
1357 |
|
1358 // --------------------------------------------------------------------------- |
|
1359 // Resize the list when contents of media array changed. |
|
1360 // --------------------------------------------------------------------------- |
|
1361 // |
|
1362 void CMPXCollectionViewHgContainer::ResizeListL(const CMPXMediaArray& aMediaArray, TInt aCount) |
|
1363 { |
|
1364 TRect clientRect = ((CAknView*)iView)->ClientRect(); |
|
1365 if( iListWidget ) |
|
1366 { |
|
1367 TInt index = iListWidget->SelectedIndex(); |
|
1368 iListWidget->InitScreenL( clientRect ); |
|
1369 iListWidget->Reset(); |
|
1370 if ( aCount ) |
|
1371 { |
|
1372 iListWidget->ResizeL( aCount ); |
|
1373 ProvideDataWithoutThumbnailsL(aMediaArray); |
|
1374 iListWidget->SetSelectedIndex( CurrentLbxItemIndex() ); |
|
1375 } |
|
1376 else |
|
1377 { |
|
1378 iListWidget->RefreshScreen(0); |
|
1379 } |
|
1380 } |
|
1381 else if( iMediaWall ) |
|
1382 { |
|
1383 TInt index = iMediaWall->SelectedIndex(); |
|
1384 iMediaWall->InitScreenL( clientRect ); |
|
1385 iMediaWall->Reset(); |
|
1386 if ( aCount ) |
|
1387 { |
|
1388 iMediaWall->ResizeL( aCount ); |
|
1389 ProvideDataWithoutThumbnailsMwL(aMediaArray); |
|
1390 iMediaWall->SetSelectedIndex( CurrentLbxItemIndex() ); |
|
1391 } |
|
1392 else |
|
1393 { |
|
1394 iMediaWall->RefreshScreen(0); |
|
1395 } |
|
1396 } |
|
1397 } |
|
1398 |
|
1399 // ---------------------------------------------------------------------------- |
|
1400 // Prepare view for displaying data in list format. |
|
1401 // ---------------------------------------------------------------------------- |
|
1402 void CMPXCollectionViewHgContainer::PrepareListL(const CMPXMediaArray& aMediaArray, TInt aCount) |
|
1403 { |
|
1404 MPX_FUNC("CMPXCollectionViewHgContainer::PrepareListL"); |
|
1405 |
|
1406 if (!((CAknAppUi*)iCoeEnv->AppUi())->StatusPane()->IsVisible()) |
|
1407 ((CAknAppUi*)iCoeEnv->AppUi())->StatusPane()->MakeVisible(ETrue); |
|
1408 |
|
1409 TRect clientRect = ((CAknView*)iView)->ClientRect(); |
|
1410 iThumbnailManager->SetSizeL( EAudioListThumbnailSize ); |
|
1411 |
|
1412 if( !iListWidget ) |
|
1413 { |
|
1414 iListWidget = CHgDoubleGraphicListFlat::NewL ( |
|
1415 clientRect, |
|
1416 aCount, |
|
1417 NULL, |
|
1418 NULL ); |
|
1419 iListWidget->SetMopParent(this); |
|
1420 iListWidget->SetSelectionObserver(*this); |
|
1421 // TODO. check if this is correct for all lists |
|
1422 iListWidget->ClearFlags( CHgScroller::EHgScrollerKeyMarkingDisabled ); |
|
1423 iListWidget->SetFocus(ETrue); |
|
1424 iListWidget->SetScrollBarTypeL( CHgScroller::EHgScrollerLetterStripLite ); |
|
1425 ProvideDataWithoutThumbnailsL(aMediaArray); |
|
1426 } |
|
1427 else |
|
1428 { |
|
1429 iListWidget->Reset(); |
|
1430 iListWidget->ResizeL( aCount ); |
|
1431 iListWidget->SetFocus(ETrue); |
|
1432 ProvideDataWithoutThumbnailsL(aMediaArray); |
|
1433 iListWidget->MakeVisible(ETrue); |
|
1434 iListWidget->InitScreenL(clientRect); |
|
1435 } |
|
1436 |
|
1437 |
|
1438 // TODO. Define here in which views we need to have buffering enabled in the list |
|
1439 if( iContext == EContextGroupAlbum || |
|
1440 iContext == EContextGroupArtist || |
|
1441 iContext == EContextGroupSong || |
|
1442 iContext == EContextGroupGenre ) |
|
1443 { |
|
1444 iListWidget->EnableScrollBufferL(*this, KMPXListBufferSize, KMPXListBufferSize/4); |
|
1445 } |
|
1446 else |
|
1447 { |
|
1448 iListWidget->RefreshScreen(0); |
|
1449 } |
|
1450 iDefaultIconSet = EFalse; |
|
1451 } |
|
1452 |
|
1453 // ---------------------------------------------------------------------------- |
|
1454 // Prepare view for displaying data in media wall with list |
|
1455 // ---------------------------------------------------------------------------- |
|
1456 void CMPXCollectionViewHgContainer::PrepareMediaWallWithListL(const CMPXMediaArray& aMediaArray, TInt aCount) |
|
1457 { |
|
1458 MPX_FUNC("CMPXCollectionViewHgContainer::PrepareMediaWallWithListL"); |
|
1459 |
|
1460 // Now create the media wall & the list |
|
1461 |
|
1462 ((CAknAppUi*)iCoeEnv->AppUi())->StatusPane()->MakeVisible(EFalse); |
|
1463 iThumbnailManager->SetSizeL( EAudioGridThumbnailSize ); |
|
1464 |
|
1465 TRect clientRect = ((CAknView*)iView)->ClientRect(); |
|
1466 |
|
1467 // Temporary until we have real layout data |
|
1468 TRect mediaWallRect = TRect(clientRect.iTl, TPoint(clientRect.iBr.iX, 250)); |
|
1469 TRect mwListRect = TRect(TPoint(clientRect.iTl.iX, 250), clientRect.iBr); |
|
1470 |
|
1471 if ( !iMediaWall ) |
|
1472 { |
|
1473 iMediaWall = CHgVgMediaWall::NewL ( |
|
1474 mediaWallRect, |
|
1475 aCount, |
|
1476 CHgVgMediaWall::EHgVgMediaWallStyleCoverflowTBonePortrait, |
|
1477 EFalse, |
|
1478 this, |
|
1479 DefaultIconL() ); |
|
1480 |
|
1481 iMediaWall->SetMopParent(this); |
|
1482 iMediaWall->EnableScrollBufferL(*this, KMPXListBufferSizeWithMediaWall, KMPXListBufferSizeWithMediaWall/4); |
|
1483 iMediaWall->SetSelectionObserver(*this); |
|
1484 ProvideDataWithoutThumbnailsMwL(aMediaArray); |
|
1485 |
|
1486 // Create the list to be used with Media wall view |
|
1487 iMwListWidget = CHgSingleTextListWithIcon::NewL(mwListRect, 0, NULL, NULL); |
|
1488 iMwListWidget->SetMopParent(this); |
|
1489 iMwListWidget->ClearFlags( CHgScroller::EHgScrollerKeyMarkingDisabled ); |
|
1490 iMwListWidget->SetScrollBarTypeL( CHgScroller::EHgScrollerScrollBar ); |
|
1491 iMwListWidget->SetSelectionObserver(*this); |
|
1492 } |
|
1493 else |
|
1494 { |
|
1495 // Lets just reuse the mediawall item and resize it. |
|
1496 if( iMediaWall->Style() != CHgVgMediaWall::EHgVgMediaWallStyleCoverflowTBonePortrait ) |
|
1497 iMediaWall->ChangeStyleL( CHgVgMediaWall::EHgVgMediaWallStyleCoverflowTBonePortrait, mediaWallRect, ETrue ); |
|
1498 |
|
1499 iMediaWall->EnableScrollBufferL(*this, KMPXListBufferSizeWithMediaWall, KMPXListBufferSizeWithMediaWall/4); |
|
1500 iMediaWall->MakeVisible( ETrue ); |
|
1501 if ( !iMwListWidget ) |
|
1502 { |
|
1503 iMwListWidget = CHgSingleTextListWithIcon::NewL(mwListRect, 0, NULL, NULL); |
|
1504 iMwListWidget->SetMopParent(this); |
|
1505 iMwListWidget->ClearFlags( CHgScroller::EHgScrollerKeyMarkingDisabled ); |
|
1506 iMwListWidget->SetScrollBarTypeL( CHgScroller::EHgScrollerScrollBar ); |
|
1507 iMwListWidget->SetSelectionObserver(*this); |
|
1508 } |
|
1509 else |
|
1510 { |
|
1511 iMwListWidget->MakeVisible( ETrue ); |
|
1512 iMwListWidget->SetFocus( ETrue ); |
|
1513 iMwListWidget->SetRect( mwListRect ); |
|
1514 iMwListWidget->DrawNow(); |
|
1515 } |
|
1516 } |
|
1517 |
|
1518 if ( iAlbumIndex == KErrNotFound ) |
|
1519 { |
|
1520 iMediaWall->SetSelectedIndex( iRestoredAlbumIndex ); |
|
1521 iMediaWall->RefreshScreen(iRestoredAlbumIndex); |
|
1522 OpenAlbumL(iRestoredAlbumIndex); |
|
1523 } |
|
1524 else |
|
1525 { |
|
1526 iMediaWall->SetSelectedIndex( iAlbumIndex ); |
|
1527 iMediaWall->RefreshScreen(iAlbumIndex); |
|
1528 OpenAlbumL(iAlbumIndex); |
|
1529 } |
|
1530 iMwListWidget->RefreshScreen(0); |
|
1531 iDefaultIconSet = ETrue; |
|
1532 } |
|
1533 |
|
1534 // ---------------------------------------------------------------------------- |
|
1535 // Prepare view for displaying data in Media wall format. |
|
1536 // ---------------------------------------------------------------------------- |
|
1537 void CMPXCollectionViewHgContainer::PrepareMediaWallL(const CMPXMediaArray& aMediaArray, TInt aCount) |
|
1538 { |
|
1539 MPX_FUNC("CMPXCollectionViewHgContainer::PrepareMediaWallL"); |
|
1540 TRect appRect = ((CAknAppUi*)iCoeEnv->AppUi())->ApplicationRect(); |
|
1541 ((CAknAppUi*)iCoeEnv->AppUi())->StatusPane()->MakeVisible(EFalse); |
|
1542 iThumbnailManager->SetSizeL( EAudioFullScreenThumbnailSize ); |
|
1543 |
|
1544 if (!iMediaWall) |
|
1545 { |
|
1546 iMediaWall = CHgVgMediaWall::NewL( |
|
1547 appRect, |
|
1548 aCount, |
|
1549 CHgVgMediaWall::EHgVgMediaWallStyleCoverflowFullScreen, |
|
1550 ETrue, |
|
1551 this, |
|
1552 DefaultIconL() ); |
|
1553 iMediaWall->SetMopParent(this); |
|
1554 iMediaWall->SetSelectionObserver(*this); |
|
1555 iMediaWall->SetObserver( this ); // softkey visibility event observer |
|
1556 iMediaWall->SetOpeningAnimationType( CHgVgMediaWall::EHgVgOpeningAnimationFlipToFront ); |
|
1557 iMediaWall->EnableScrollBufferL( |
|
1558 *this, |
|
1559 KMPXListBufferSizeWithMediaWall, |
|
1560 KMPXListBufferSizeWithMediaWall / 4); |
|
1561 // We want softkeys to be drawn on top of mediawall, thats we need to manipulate window pos |
|
1562 iMediaWall->DrawableWindow()->SetOrdinalPosition( -1 ); |
|
1563 ProvideDataWithoutThumbnailsMwL(aMediaArray); |
|
1564 if( iAlbumIndex == KErrNotFound ) |
|
1565 iMediaWall->SetSelectedIndex( iRestoredAlbumIndex ); |
|
1566 else |
|
1567 iMediaWall->SetSelectedIndex( iAlbumIndex ); |
|
1568 } |
|
1569 else |
|
1570 { |
|
1571 // TODO, do we need to refill the data or are the items same in fullscreen coverflow and tbone coverflow???? |
|
1572 // David: Yes because there will be an extra shuffle item in the coverflow list but not in tbone coverflow. |
|
1573 // Index will be off. |
|
1574 if( iMediaWall->Style() != CHgVgMediaWall::EHgVgMediaWallStyleCoverflowFullScreen ) |
|
1575 iMediaWall->ChangeStyleL( CHgVgMediaWall::EHgVgMediaWallStyleCoverflowFullScreen, appRect, ETrue ); |
|
1576 |
|
1577 iMediaWall->MakeVisible( ETrue ); |
|
1578 iMediaWall->SetFocus( ETrue ); |
|
1579 iMediaWall->EnableScrollBufferL( |
|
1580 *this, |
|
1581 KMPXListBufferSizeWithMediaWall, |
|
1582 KMPXListBufferSizeWithMediaWall / 4); |
|
1583 if( iAlbumIndex == KErrNotFound ) |
|
1584 iMediaWall->SetSelectedIndex( iRestoredAlbumIndex ); |
|
1585 else |
|
1586 iMediaWall->SetSelectedIndex( iAlbumIndex ); |
|
1587 |
|
1588 iMediaWall->DrawDeferred(); |
|
1589 iMediaWall->RefreshScreen(0); |
|
1590 } |
|
1591 |
|
1592 iDefaultIconSet = ETrue; |
|
1593 } |
|
1594 |
|
1595 // ---------------------------------------------------------------------------- |
|
1596 // Add shuffle list item to the top of the list. |
|
1597 // ---------------------------------------------------------------------------- |
|
1598 void CMPXCollectionViewHgContainer::SetShuffleItemToListL(CHgScroller* aScroller ) |
|
1599 { |
|
1600 CHgItem* item = CHgItem::NewL(); |
|
1601 // Todo: Localize |
|
1602 item->SetTitleL( _L("Shuffle All") ); |
|
1603 |
|
1604 CGulIcon* icon = (*iIconArray)[EMPXClvIconShuffle]; |
|
1605 CFbsBitmap* bitmap = icon->Bitmap(); |
|
1606 CFbsBitmap* mask = icon->Mask(); |
|
1607 |
|
1608 // Icon needs to be bigger! |
|
1609 TSize size(35, 35); |
|
1610 AknIconUtils::SetSize( bitmap, size ); |
|
1611 AknIconUtils::SetSize( mask, size ); |
|
1612 |
|
1613 CGulIcon* iconCopy = CGulIcon::NewL(bitmap, mask); |
|
1614 iconCopy->SetBitmapsOwnedExternally(ETrue); |
|
1615 item->SetIcon( iconCopy ); |
|
1616 aScroller->SetItem( item, 0 ); |
|
1617 } |
|
1618 |
|
1619 // ---------------------------------------------------------------------------- |
|
1620 // Retreive the current list widget |
|
1621 // ---------------------------------------------------------------------------- |
|
1622 CHgScroller* CMPXCollectionViewHgContainer::CurrentListWidget() |
|
1623 { |
|
1624 CHgScroller* current = 0; |
|
1625 switch (iCurrentViewType) |
|
1626 { |
|
1627 case EMPXViewTBone: |
|
1628 { |
|
1629 current = iMwListWidget; |
|
1630 break; |
|
1631 } |
|
1632 case EMPXViewList: |
|
1633 { |
|
1634 current = iListWidget; |
|
1635 break; |
|
1636 } |
|
1637 default: |
|
1638 break; |
|
1639 } |
|
1640 |
|
1641 return current; |
|
1642 } |
|
1643 |
|
1644 // ---------------------------------------------------------------------------- |
|
1645 // Resolve the current view type based on the browsing context |
|
1646 // ---------------------------------------------------------------------------- |
|
1647 void CMPXCollectionViewHgContainer::ResolveCurrentViewType() |
|
1648 { |
|
1649 iCurrentViewType = EMPXViewUnknown; |
|
1650 TBool landscapeOrientation = Layout_Meta_Data::IsLandscapeOrientation(); |
|
1651 switch (iContext) |
|
1652 { |
|
1653 case EContextGroupAlbum: |
|
1654 { |
|
1655 if( landscapeOrientation ) |
|
1656 iCurrentViewType = EMPXViewCoverFlow; |
|
1657 else |
|
1658 iCurrentViewType = EMPXViewList; |
|
1659 break; |
|
1660 } |
|
1661 case EContextItemAlbum: |
|
1662 case EContextItemArtist: |
|
1663 { |
|
1664 // TODO, Change by Harri. Is this correct? |
|
1665 if( landscapeOrientation ) |
|
1666 iCurrentViewType = EMPXViewCoverFlow; |
|
1667 else |
|
1668 iCurrentViewType = EMPXViewTBone; |
|
1669 break; |
|
1670 } |
|
1671 default: |
|
1672 iCurrentViewType = EMPXViewList; |
|
1673 break; |
|
1674 } |
|
1675 } |
|
1676 |
|
1677 // ---------------------------------------------------------------------------- |
|
1678 // Clears the previous view content. |
|
1679 // ---------------------------------------------------------------------------- |
|
1680 void CMPXCollectionViewHgContainer::CleanPrevView() |
|
1681 { |
|
1682 if( iCurrentViewType == iPrevViewType ) |
|
1683 return; |
|
1684 |
|
1685 switch (iPrevViewType) |
|
1686 { |
|
1687 case EMPXViewCoverFlow: |
|
1688 { |
|
1689 iMediaWall->MakeVisible( EFalse ); |
|
1690 iMediaWall->SetFocus( EFalse ); |
|
1691 iMediaWall->DisableScrollBuffer(); |
|
1692 break; |
|
1693 } |
|
1694 case EMPXViewTBone: |
|
1695 { |
|
1696 iMediaWall->MakeVisible( EFalse ); |
|
1697 iMediaWall->DisableScrollBuffer(); |
|
1698 iMwListWidget->MakeVisible( EFalse ); |
|
1699 iMwListWidget->Reset(); |
|
1700 break; |
|
1701 } |
|
1702 case EMPXViewList: |
|
1703 { |
|
1704 iListWidget->MakeVisible( EFalse ); |
|
1705 iListWidget->SetFocus( EFalse ); |
|
1706 iListWidget->DisableScrollBuffer(); |
|
1707 iListWidget->Reset(); |
|
1708 break; |
|
1709 } |
|
1710 default: |
|
1711 break; |
|
1712 } |
|
1713 } |
|
1714 |
|
1715 // --------------------------------------------------------------------------- |
|
1716 // Check if the selected item is a song. |
|
1717 // --------------------------------------------------------------------------- |
|
1718 // |
|
1719 TBool CMPXCollectionViewHgContainer::IsSelectedItemASong() |
|
1720 { |
|
1721 MPX_FUNC( "CMPXCollectionViewHgContainer::IsSelectedItemASong" ); |
|
1722 |
|
1723 TBool res(EFalse); |
|
1724 if ( iContext == EContextItemAlbum ) |
|
1725 { |
|
1726 CHgScroller* listWidget = CurrentListWidget(); |
|
1727 if ( listWidget->SelectedIndex() == 0 && |
|
1728 listWidget->ItemCount() > 1 ) |
|
1729 { |
|
1730 res = EFalse; |
|
1731 } |
|
1732 else |
|
1733 { |
|
1734 res = ETrue; |
|
1735 } |
|
1736 } |
|
1737 return res; |
|
1738 } |
|
1739 |
|
1740 |
|
1741 // ----------------------------------------------------------------------------- |
|
1742 // Retreives the selected item's media. |
|
1743 // ----------------------------------------------------------------------------- |
|
1744 // |
|
1745 CMPXMedia* CMPXCollectionViewHgContainer::SelectedItemMediaL() |
|
1746 { |
|
1747 MPX_FUNC( "CMPXCollectionViewHgImp::SelectedItemMediaL" ); |
|
1748 CMPXMedia* song = NULL; |
|
1749 const CMPXMediaArray& albums = iListBoxArray->MediaArray(); |
|
1750 CMPXMedia* album( albums.AtL( iSelectedAlbumIndex ) ); |
|
1751 const CMPXMediaArray* songs = album->Value<CMPXMediaArray>(KMPXMediaArrayContents); |
|
1752 CHgScroller* listWidget = CurrentListWidget(); |
|
1753 if (listWidget && songs) |
|
1754 { |
|
1755 song = songs->AtL(listWidget->SelectedIndex()); |
|
1756 } |
|
1757 return song; |
|
1758 } |
|
1759 |
|
1760 |
|
1761 // --------------------------------------------------------------------------- |
|
1762 // Handle item command |
|
1763 // --------------------------------------------------------------------------- |
|
1764 // |
|
1765 void CMPXCollectionViewHgContainer::HandleItemCommandL( TInt aCommand ) |
|
1766 { |
|
1767 MPX_FUNC( "CMPXCollectionViewHgContainer::HandleItemCommanddL" ); |
|
1768 |
|
1769 if ( iContext == EContextGroupAlbum && aCommand == EMPXCmdPlay ) |
|
1770 { |
|
1771 CHgScroller* listWidget = CurrentListWidget(); |
|
1772 iSelectedAlbumIndex = listWidget->SelectedIndex(); |
|
1773 SaveSelectedAlbumItemL(iSelectedAlbumIndex); |
|
1774 // Open first song of album & playlist for entire album is created. |
|
1775 PlayAlbumL(iSelectedAlbumIndex); |
|
1776 } |
|
1777 else if ( iContext == EContextGroupPlaylist && aCommand == EMPXCmdPlay ) |
|
1778 { |
|
1779 CHgScroller* listWidget = CurrentListWidget(); |
|
1780 TInt index = listWidget->SelectedIndex(); |
|
1781 PlayPlaylistL(index); |
|
1782 } |
|
1783 else if ( iContext == EContextGroupGenre && aCommand == EMPXCmdPlay ) |
|
1784 { |
|
1785 CHgScroller* listWidget = CurrentListWidget(); |
|
1786 TInt index = listWidget->SelectedIndex(); |
|
1787 PlayGenreL(index); |
|
1788 } |
|
1789 } |
|
1790 |
|
1791 // --------------------------------------------------------------------------- |
|
1792 // From MHgSelectionObserver |
|
1793 // Handle Item Selection |
|
1794 // --------------------------------------------------------------------------- |
|
1795 // |
|
1796 void CMPXCollectionViewHgContainer::HandleSelectL( TInt /*aIndex*/ ) |
|
1797 { |
|
1798 MPX_FUNC( "CMPXCollectionViewHgContainer::HandleSelect" ); |
|
1799 |
|
1800 } |
|
1801 |
|
1802 // --------------------------------------------------------------------------- |
|
1803 // From MHgSelectionObserver |
|
1804 // Handle Item Selection |
|
1805 // --------------------------------------------------------------------------- |
|
1806 // |
|
1807 void CMPXCollectionViewHgContainer::HandleSelectL( TInt aIndex, CCoeControl* aControl ) |
|
1808 { |
|
1809 MPX_FUNC( "CMPXCollectionViewHgContainer::HandleSelect" ); |
|
1810 if( iCurrentViewType == EMPXViewTBone && iSelectedAlbumIndex != aIndex ) |
|
1811 { |
|
1812 if ( aControl == iMediaWall ) |
|
1813 { |
|
1814 iSelectedAlbumIndex = aIndex; |
|
1815 OpenAlbumL(aIndex); |
|
1816 } |
|
1817 } |
|
1818 else if( iCurrentViewType == EMPXViewCoverFlow ) |
|
1819 { |
|
1820 iSelectedAlbumIndex = aIndex; |
|
1821 } |
|
1822 } |
|
1823 |
|
1824 |
|
1825 // --------------------------------------------------------------------------- |
|
1826 // From MHgSelectionObserver |
|
1827 // Handle Item opened |
|
1828 // --------------------------------------------------------------------------- |
|
1829 // |
|
1830 void CMPXCollectionViewHgContainer::HandleOpenL( TInt aIndex ) |
|
1831 { |
|
1832 MPX_FUNC( "CMPXCollectionViewHgContainer::HandleOpenL" ); |
|
1833 |
|
1834 // Mod by harri, had to enable this block since ganes list components still |
|
1835 // uses this version of the HandleOpen |
|
1836 if ( iContext == EContextItemAlbum ) |
|
1837 { |
|
1838 SaveSelectedAlbumItemL(iSelectedAlbumIndex); |
|
1839 UpdatePathAndOpenL(aIndex); |
|
1840 } |
|
1841 else if ( iContext == EContextGroupAlbum ) |
|
1842 { |
|
1843 SaveSelectedAlbumItemL(aIndex); |
|
1844 // Check if shuffle play all was selected. |
|
1845 if (!ShufflePlayAllL(aIndex)) |
|
1846 { |
|
1847 // To open the selected album. |
|
1848 iView->ProcessCommandL( EMPXCmdCommonEnterKey ); |
|
1849 } |
|
1850 } |
|
1851 else if ( iContext == EContextGroupSong ) |
|
1852 { |
|
1853 // Check if shuffle play all was selected. |
|
1854 if (!ShufflePlayAllL(aIndex)) |
|
1855 { |
|
1856 // To open the selected album. |
|
1857 iView->ProcessCommandL( EMPXCmdCommonEnterKey ); |
|
1858 } |
|
1859 } |
|
1860 else |
|
1861 { |
|
1862 iView->ProcessCommandL( EMPXCmdCommonEnterKey ); |
|
1863 } |
|
1864 } |
|
1865 |
|
1866 // --------------------------------------------------------------------------- |
|
1867 // From MHgSelectionObserver |
|
1868 // Handle Item opened |
|
1869 // --------------------------------------------------------------------------- |
|
1870 // |
|
1871 void CMPXCollectionViewHgContainer::HandleOpenL( TInt aIndex, CCoeControl* aControl ) |
|
1872 { |
|
1873 MPX_FUNC( "CMPXCollectionViewHgContainer::HandleOpenL" ); |
|
1874 |
|
1875 if( iContext == EContextGroupAlbum ) |
|
1876 { |
|
1877 iAlbumIndex = aIndex; |
|
1878 SaveSelectedAlbumItemL(aIndex); |
|
1879 } |
|
1880 |
|
1881 if ( iContext == EContextItemAlbum ) |
|
1882 { |
|
1883 if ( aControl == iMediaWall ) |
|
1884 { |
|
1885 // If album was opened, we will play all tracks in the album. |
|
1886 SaveSelectedAlbumItemL(aIndex); |
|
1887 // Open first song of album & playlist for entire album is created. |
|
1888 UpdatePathAndOpenL(0, ETrue); |
|
1889 } |
|
1890 else if ( aControl == iMwListWidget ) |
|
1891 { |
|
1892 // If item in list was opened, we only play the selected one. |
|
1893 SaveSelectedAlbumItemL(iSelectedAlbumIndex); |
|
1894 // Open the selected song of album |
|
1895 UpdatePathAndOpenL(aIndex); |
|
1896 } |
|
1897 } |
|
1898 else if ( iContext == EContextGroupAlbum ) |
|
1899 { |
|
1900 if ( aControl == iMediaWall ) |
|
1901 { |
|
1902 // Check if shuffle play all was selected. |
|
1903 if (!ShufflePlayAllL(aIndex)) |
|
1904 { |
|
1905 OpenAlbumL(aIndex); |
|
1906 } |
|
1907 } |
|
1908 } |
|
1909 else |
|
1910 { |
|
1911 iView->ProcessCommandL( EMPXCmdCommonEnterKey ); |
|
1912 } |
|
1913 } |
|
1914 |
|
1915 // ----------------------------------------------------------------------------- |
|
1916 // Handle media wall event |
|
1917 // ----------------------------------------------------------------------------- |
|
1918 // |
|
1919 void CMPXCollectionViewHgContainer::HandleMediaWallEvent( |
|
1920 TInt aEvent, |
|
1921 CHgVgMediaWall* /*aSender*/) |
|
1922 { |
|
1923 switch( aEvent ) |
|
1924 { |
|
1925 case CHgVgMediaWall::EHgVgMediaWallEventRequestShowSoftkeys: |
|
1926 { |
|
1927 if( iCbaHandler ) |
|
1928 iCbaHandler->ChangeCbaVisibility( ETrue ); |
|
1929 break; |
|
1930 } |
|
1931 case CHgVgMediaWall::EHgVgMediaWallEventRequestHideSoftkeys: |
|
1932 { |
|
1933 if( iCbaHandler ) |
|
1934 iCbaHandler->ChangeCbaVisibility( EFalse ); |
|
1935 break; |
|
1936 } |
|
1937 default: |
|
1938 break; |
|
1939 } |
|
1940 } |
|
1941 // ----------------------------------------------------------------------------- |
|
1942 // Provides the data to the model |
|
1943 // ----------------------------------------------------------------------------- |
|
1944 // |
|
1945 void CMPXCollectionViewHgContainer::Request( |
|
1946 TInt aBufferStart, |
|
1947 TInt aBufferEnd, |
|
1948 THgScrollDirection aDirection ) |
|
1949 { |
|
1950 MPX_FUNC( "CMPXCollectionViewHgContainer::Request" ); |
|
1951 MPX_DEBUG3( "CMPXCollectionViewHgContainer::Request aBufferStart = %d, aBufferEnd = %d", |
|
1952 aBufferStart, aBufferEnd ); |
|
1953 |
|
1954 // This should not happen but if not handled, bad things will happen. |
|
1955 if ( aBufferStart < 0 || aBufferEnd < 0 ) |
|
1956 return; |
|
1957 |
|
1958 // TODO, add support for last valid media item index later |
|
1959 if ( aBufferStart > iLastValidMediaItemIndex || aBufferEnd > iLastValidMediaItemIndex ) |
|
1960 { |
|
1961 // We cannot provide data for the requested range at this time. |
|
1962 // Remember the request so we can handle it when there's enough data. |
|
1963 iRequestStart = aBufferStart; |
|
1964 iRequestEnd = aBufferEnd; |
|
1965 return; |
|
1966 } |
|
1967 |
|
1968 iDirection = aDirection; |
|
1969 |
|
1970 for ( TInt i = aBufferStart; i <= aBufferEnd; i++ ) |
|
1971 { |
|
1972 iThumbnailReqMap[ i ] = EFalse; |
|
1973 } |
|
1974 |
|
1975 |
|
1976 if ( aDirection == EHgBufferReset || aDirection == EHgBufferScrollDown || aDirection == EHgBufferScrollUp) |
|
1977 { |
|
1978 // For index range in visible-area |
|
1979 TRAP_IGNORE(ProvideDataIntersectL(aBufferStart, aBufferEnd)); |
|
1980 // For index range elsewhere |
|
1981 TRAP_IGNORE(ProvideDataDifferenceL(aBufferStart, aBufferEnd)); |
|
1982 } |
|
1983 else |
|
1984 { |
|
1985 TRAP_IGNORE(ProvideDataL(aBufferStart, aBufferEnd)); |
|
1986 } |
|
1987 |
|
1988 // When in main collection view, list can be refresh |
|
1989 // without waiting on thumbnails since this list doesn't |
|
1990 // require thumbnails. |
|
1991 if ( iCurrentViewType == EMPXViewList && ( |
|
1992 iContext == EContextGroupCollection || |
|
1993 iContext == EContextGroupPlaylist || |
|
1994 iContext == EContextGroupGenre || |
|
1995 iContext == EContextGroupComposer ) || |
|
1996 iContext == EContextGroupArtist ) |
|
1997 { |
|
1998 iListWidget->RefreshScreen( aBufferStart ); |
|
1999 } |
|
2000 iTopIndex = aBufferStart; |
|
2001 iBottomIndex = aBufferEnd; |
|
2002 } |
|
2003 |
|
2004 // ----------------------------------------------------------------------------- |
|
2005 // Check if request range also covers the visible area and provide data |
|
2006 // to it first. |
|
2007 // ----------------------------------------------------------------------------- |
|
2008 // |
|
2009 void CMPXCollectionViewHgContainer::ProvideDataIntersectL( |
|
2010 TInt aBufferStart, |
|
2011 TInt aBufferEnd ) |
|
2012 { |
|
2013 TInt firstOnScreen = 0; |
|
2014 TInt lastOnScreen = 0; |
|
2015 if( iMediaWall ) |
|
2016 { |
|
2017 firstOnScreen = iMediaWall->FirstIndexOnScreen(); |
|
2018 lastOnScreen = firstOnScreen + iMediaWall->ItemsOnScreen(); |
|
2019 } |
|
2020 else |
|
2021 { |
|
2022 firstOnScreen = iListWidget->FirstIndexOnScreen(); |
|
2023 lastOnScreen = firstOnScreen + iListWidget->ItemsOnScreen(); |
|
2024 } |
|
2025 const CMPXMediaArray& mediaArray = iListBoxArray->MediaArray(); |
|
2026 |
|
2027 TInt startIndex = Max( firstOnScreen, aBufferStart ); |
|
2028 TInt endIndex = Min( lastOnScreen, aBufferEnd ); |
|
2029 |
|
2030 ProvideDataForRangeL( startIndex, endIndex ); |
|
2031 } |
|
2032 |
|
2033 // ----------------------------------------------------------------------------- |
|
2034 // Handles request range outside of visible area. |
|
2035 // ----------------------------------------------------------------------------- |
|
2036 // |
|
2037 void CMPXCollectionViewHgContainer::ProvideDataDifferenceL( |
|
2038 TInt aBufferStart, |
|
2039 TInt aBufferEnd) |
|
2040 { |
|
2041 TInt firstOnScreen = 0; |
|
2042 TInt lastOnScreen = 0; |
|
2043 if( iMediaWall ) |
|
2044 { |
|
2045 firstOnScreen = iMediaWall->FirstIndexOnScreen(); |
|
2046 lastOnScreen = firstOnScreen + iMediaWall->ItemsOnScreen(); |
|
2047 } |
|
2048 else |
|
2049 { |
|
2050 firstOnScreen = iListWidget->FirstIndexOnScreen(); |
|
2051 lastOnScreen = firstOnScreen + iListWidget->ItemsOnScreen(); |
|
2052 } |
|
2053 if (aBufferStart == firstOnScreen && aBufferEnd == lastOnScreen) |
|
2054 return; |
|
2055 |
|
2056 // Start block |
|
2057 ProvideDataForRangeL( aBufferStart, firstOnScreen-1 ); |
|
2058 |
|
2059 // End block |
|
2060 ProvideDataForRangeL( lastOnScreen+1, aBufferEnd ); |
|
2061 |
|
2062 } |
|
2063 |
|
2064 |
|
2065 // ----------------------------------------------------------------------------- |
|
2066 // Generic data provider for the requested range. |
|
2067 // ----------------------------------------------------------------------------- |
|
2068 // |
|
2069 void CMPXCollectionViewHgContainer::ProvideDataForRangeL( TInt aBufferStart, TInt aBufferEnd ) |
|
2070 { |
|
2071 const CMPXMediaArray& mediaArray = iListBoxArray->MediaArray(); |
|
2072 for( TInt i = aBufferStart; i <= aBufferEnd; i++ ) |
|
2073 { |
|
2074 // Just get the exiting item and update the fields + icon. |
|
2075 CHgItem* item = NULL; |
|
2076 if( iMediaWall ) |
|
2077 item = &iMediaWall->ItemL(i); |
|
2078 else |
|
2079 item = &iListWidget->ItemL(i); |
|
2080 |
|
2081 CMPXMedia* currentMedia( mediaArray.AtL( i ) ); |
|
2082 AddThumbnailToDisplayedItemL( item, currentMedia, i ); |
|
2083 } |
|
2084 } |
|
2085 |
|
2086 // ----------------------------------------------------------------------------- |
|
2087 // CMPXCollectionViewHgContainer::ProvideDataWithouThumbnailsL |
|
2088 // ----------------------------------------------------------------------------- |
|
2089 // |
|
2090 void CMPXCollectionViewHgContainer::ProvideDataWithoutThumbnailsL( |
|
2091 const CMPXMediaArray& aMediaArray, |
|
2092 TInt aStartIndex ) |
|
2093 { |
|
2094 MPX_FUNC( "CMPXCollectionViewHgContainer::ProvideDataWithoutThumbnailsL" ); |
|
2095 |
|
2096 TInt mediaCount = aMediaArray.Count(); |
|
2097 |
|
2098 for ( TInt i = aStartIndex; i < mediaCount ; i++ ) |
|
2099 { |
|
2100 CMPXMedia* currentMedia( aMediaArray.AtL( i ) ); |
|
2101 |
|
2102 if ( currentMedia->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) == |
|
2103 KMPXInvalidItemId ) |
|
2104 { |
|
2105 break; |
|
2106 } |
|
2107 |
|
2108 // Just get the exiting item and update the fields + icon. |
|
2109 CHgItem* item = &iListWidget->ItemL(i); |
|
2110 |
|
2111 TBool shuffleItem(EFalse); |
|
2112 if ( i == 0 ) |
|
2113 { |
|
2114 shuffleItem = SetShuffleItemTextL(item, currentMedia); |
|
2115 } |
|
2116 |
|
2117 if (!shuffleItem) |
|
2118 { |
|
2119 SetTitleL( item, currentMedia ); |
|
2120 AddDetailToDisplayedItemL( item, currentMedia, i ); |
|
2121 } |
|
2122 iLastValidMediaItemIndex = i; |
|
2123 } |
|
2124 } |
|
2125 |
|
2126 // ----------------------------------------------------------------------------- |
|
2127 // CMPXCollectionViewHgContainer::ProvideDataWithoutThumbnailsMwL |
|
2128 // ----------------------------------------------------------------------------- |
|
2129 // |
|
2130 void CMPXCollectionViewHgContainer::ProvideDataWithoutThumbnailsMwL( |
|
2131 const CMPXMediaArray& aMediaArray, |
|
2132 TInt aStartIndex ) |
|
2133 { |
|
2134 MPX_FUNC( "CMPXCollectionViewHgContainer::ProvideDataWithoutThumbnailsMwL" ); |
|
2135 |
|
2136 TInt mediaCount = aMediaArray.Count(); |
|
2137 |
|
2138 for ( TInt i = aStartIndex; i < mediaCount ; i++ ) |
|
2139 { |
|
2140 // Just get the exiting item and update the fields + icon. |
|
2141 CMPXMedia* currentMedia( aMediaArray.AtL( i ) ); |
|
2142 |
|
2143 if ( currentMedia->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) == |
|
2144 KMPXInvalidItemId ) |
|
2145 { |
|
2146 break; |
|
2147 } |
|
2148 |
|
2149 // Just get the exiting item and update the fields + icon. |
|
2150 |
|
2151 CHgVgItem* item = &iMediaWall->ItemL(i); |
|
2152 TBool shuffleItem(EFalse); |
|
2153 if ( i == 0 ) |
|
2154 { |
|
2155 shuffleItem = SetShuffleItemTextL(item, currentMedia); |
|
2156 } |
|
2157 |
|
2158 if (!shuffleItem) |
|
2159 { |
|
2160 SetTitleL( item, currentMedia ); |
|
2161 AddDetailToDisplayedItemL( item, currentMedia, i ); |
|
2162 } |
|
2163 iLastValidMediaItemIndex = i; |
|
2164 } |
|
2165 } |
|
2166 // ----------------------------------------------------------------------------- |
|
2167 // CMPXCollectionViewHgContainer::ProvideDataL |
|
2168 // ----------------------------------------------------------------------------- |
|
2169 // |
|
2170 void CMPXCollectionViewHgContainer::ProvideDataL( TInt aStart, TInt aEnd ) |
|
2171 { |
|
2172 MPX_FUNC( "CMPXCollectionViewHgContainer::ProvideDataL" ); |
|
2173 MPX_DEBUG3( "CMPXCollectionViewHgContainer::ProvideDataL aStart = %d, aEnd = %d", |
|
2174 aStart, aEnd ); |
|
2175 if ( aStart < 0 ) aStart = 0; |
|
2176 if ( aEnd < 0 ) aEnd = 0; |
|
2177 |
|
2178 const CMPXMediaArray& mediaArray = iListBoxArray->MediaArray(); |
|
2179 for ( TInt i = aStart; i <= aEnd ; i++ ) |
|
2180 { |
|
2181 // Just get the exiting item and update the fields + icon. |
|
2182 CHgItem* item = NULL; |
|
2183 if( iCurrentViewType == EMPXViewCoverFlow || iCurrentViewType == EMPXViewTBone ) |
|
2184 item = &iMediaWall->ItemL(i); |
|
2185 else |
|
2186 item = &iListWidget->ItemL(i); |
|
2187 |
|
2188 CMPXMedia* currentMedia( mediaArray.AtL( i ) ); |
|
2189 |
|
2190 AddThumbnailToDisplayedItemL( item, currentMedia, i ); |
|
2191 } |
|
2192 } |
|
2193 |
|
2194 // ----------------------------------------------------------------------------- |
|
2195 // CMPXCollectionViewHgContainer::Release |
|
2196 // ----------------------------------------------------------------------------- |
|
2197 // |
|
2198 void CMPXCollectionViewHgContainer::Release(TInt aReleaseStart, TInt aReleaseEnd) |
|
2199 { |
|
2200 MPX_FUNC( "CMPXCollectionViewHgContainer::Release" ); |
|
2201 |
|
2202 for(; aReleaseStart <= aReleaseEnd; ++aReleaseStart) |
|
2203 { |
|
2204 MPX_DEBUG2( "-->CMPXCollectionViewHgContainer::Release aReleaseStart = %d", aReleaseStart ); |
|
2205 iThumbnailManager->CancelThumb( aReleaseStart ); |
|
2206 } |
|
2207 |
|
2208 } |
|
2209 |
|
2210 // --------------------------------------------------------------------------- |
|
2211 // Refresh for item without thumbnail |
|
2212 // --------------------------------------------------------------------------- |
|
2213 // |
|
2214 void CMPXCollectionViewHgContainer::RefreshNoThumbnailL(TInt aIndex) |
|
2215 { |
|
2216 MPX_FUNC( "CMPXCollectionViewHgContainer::RefreshNoThumbnail" ); |
|
2217 |
|
2218 RefreshL(aIndex); |
|
2219 } |
|
2220 // --------------------------------------------------------------------------- |
|
2221 // Refresh list as needed. |
|
2222 // This function tries to determine the best time to refresh the screen as to |
|
2223 // avoid too many redraws. In some cases, multiple refresh is unavoidable. |
|
2224 // --------------------------------------------------------------------------- |
|
2225 // |
|
2226 void CMPXCollectionViewHgContainer::RefreshL(TInt aIndex) |
|
2227 { |
|
2228 MPX_FUNC( "CMPXCollectionViewHgContainer::Refresh" ); |
|
2229 |
|
2230 TInt mediaCount = iListBoxArray->MediaArray().Count(); |
|
2231 |
|
2232 TInt firstOnScreen = 0; |
|
2233 TInt lastOnScreen = 0; |
|
2234 |
|
2235 TBool landscapeOrientation = Layout_Meta_Data::IsLandscapeOrientation(); |
|
2236 CHgScroller* listWidget = CurrentListWidget(); |
|
2237 |
|
2238 if( iCurrentViewType == EMPXViewTBone || iCurrentViewType == EMPXViewCoverFlow ) |
|
2239 { |
|
2240 firstOnScreen = iMediaWall->FirstIndexOnScreen(); |
|
2241 lastOnScreen = firstOnScreen + iMediaWall->ItemsOnScreen(); |
|
2242 } |
|
2243 else |
|
2244 { |
|
2245 firstOnScreen = listWidget->FirstIndexOnScreen(); |
|
2246 lastOnScreen = firstOnScreen + listWidget->ItemsOnScreen(); |
|
2247 } |
|
2248 |
|
2249 // Added by Harri |
|
2250 if( firstOnScreen < 0 ) |
|
2251 firstOnScreen = 0; |
|
2252 if (lastOnScreen > (mediaCount - 1)) |
|
2253 lastOnScreen = mediaCount - 1; |
|
2254 |
|
2255 // Refresh screen if the item is within view and no more thumbnails expected. |
|
2256 if ( aIndex >= firstOnScreen && aIndex <= lastOnScreen ) |
|
2257 { |
|
2258 TBool canRefresh(ETrue); |
|
2259 for (TInt i= firstOnScreen; i <= lastOnScreen; i++) |
|
2260 { |
|
2261 if ( !iThumbnailReqMap[i] ) |
|
2262 { |
|
2263 canRefresh = EFalse; |
|
2264 break; |
|
2265 } |
|
2266 } |
|
2267 if ( canRefresh ) |
|
2268 { |
|
2269 if( iCurrentViewType == EMPXViewTBone || iCurrentViewType == EMPXViewCoverFlow ) |
|
2270 iMediaWall->RefreshScreen( firstOnScreen ); |
|
2271 else |
|
2272 listWidget->RefreshScreen( firstOnScreen ); |
|
2273 } |
|
2274 } |
|
2275 } |
|
2276 |
|
2277 // ---------------------------------------------------------------------------- |
|
2278 // Get the default icon for the current browsing context. |
|
2279 // ---------------------------------------------------------------------------- |
|
2280 CGulIcon* CMPXCollectionViewHgContainer::DefaultIconL() |
|
2281 { |
|
2282 |
|
2283 TInt iconIndex( EMPXClvIconEmpty ); |
|
2284 |
|
2285 switch( iContext ) |
|
2286 { |
|
2287 case EContextGroupArtist: |
|
2288 case EContextItemArtist: |
|
2289 { |
|
2290 iconIndex = EMPXClvIconArtist; |
|
2291 break; |
|
2292 } |
|
2293 case EContextGroupAlbum: |
|
2294 case EContextItemAlbum: |
|
2295 { |
|
2296 // Mod by Harri. Lampainen wanted to try default icon in album view. |
|
2297 iconIndex = EMPXClvIconAlbum; |
|
2298 break; |
|
2299 } |
|
2300 case EContextGroupPodcast: |
|
2301 case EContextItemPodcast: |
|
2302 { |
|
2303 iconIndex = EMPXPodClvIconTitle; // Podcast default icon |
|
2304 break; |
|
2305 } |
|
2306 case EContextGroupPlaylist: |
|
2307 { |
|
2308 iconIndex = EMPXClvIconPlaylist; |
|
2309 break; |
|
2310 } |
|
2311 case EContextGroupGenre: |
|
2312 { |
|
2313 iconIndex = EMPXClvIconGenre; |
|
2314 break; |
|
2315 } |
|
2316 case EContextGroupComposer: |
|
2317 { |
|
2318 iconIndex = EMPXClvIconComposer; |
|
2319 break; |
|
2320 } |
|
2321 case EContextItemComposer: |
|
2322 case EContextGroupSong: |
|
2323 case EContextItemSong: |
|
2324 case EContextItemPlaylist: |
|
2325 case EContextItemGenre: |
|
2326 case EContextGroupCollection: |
|
2327 case EContextUnknown: |
|
2328 default: |
|
2329 { |
|
2330 // no default icon for main menu items |
|
2331 break; |
|
2332 } |
|
2333 } |
|
2334 |
|
2335 CGulIcon* icon = (*iIconArray)[iconIndex]; |
|
2336 CFbsBitmap* bitmap = icon->Bitmap(); |
|
2337 CFbsBitmap* mask = icon->Mask(); |
|
2338 |
|
2339 TSize size(iImageSize.iWidth, iImageSize.iHeight); |
|
2340 AknIconUtils::SetSize( bitmap, size ); |
|
2341 AknIconUtils::SetSize( mask, size ); |
|
2342 |
|
2343 CGulIcon* iconCopy = CGulIcon::NewL(bitmap, mask); |
|
2344 iconCopy->SetBitmapsOwnedExternally(ETrue); |
|
2345 return iconCopy; |
|
2346 } |
|
2347 |
|
2348 // ----------------------------------------------------------------------------- |
|
2349 // Sets default icon to the HgList |
|
2350 // ----------------------------------------------------------------------------- |
|
2351 // |
|
2352 void CMPXCollectionViewHgContainer::SetDefaultIconL() |
|
2353 { |
|
2354 |
|
2355 TDefaultIcon defaultIcon( EMPXDefaultIconEmpty ); |
|
2356 TInt iconIndex( EMPXClvIconEmpty ); |
|
2357 |
|
2358 switch( iContext ) |
|
2359 { |
|
2360 case EContextGroupArtist: |
|
2361 case EContextItemArtist: |
|
2362 { |
|
2363 defaultIcon = EMPXDefaultIconArtist; |
|
2364 iconIndex = EMPXClvIconArtist; |
|
2365 break; |
|
2366 } |
|
2367 case EContextGroupAlbum: |
|
2368 case EContextItemAlbum: |
|
2369 { |
|
2370 // Mod by Harri. Lampainen wanted to try default icon in album view. |
|
2371 defaultIcon = EMPXDefaultIconAlbum; |
|
2372 iconIndex = EMPXClvIconAlbum; |
|
2373 break; |
|
2374 } |
|
2375 case EContextGroupPodcast: |
|
2376 case EContextItemPodcast: |
|
2377 { |
|
2378 defaultIcon = EMPXDefaultTitleIconPodcasts; |
|
2379 iconIndex = EMPXPodClvIconTitle; // Podcast default icon |
|
2380 break; |
|
2381 } |
|
2382 case EContextGroupPlaylist: |
|
2383 { |
|
2384 defaultIcon = EMPXDefaultIconPlaylist; |
|
2385 iconIndex = EMPXClvIconPlaylist; |
|
2386 break; |
|
2387 } |
|
2388 case EContextGroupGenre: |
|
2389 { |
|
2390 defaultIcon = EMPXDefaultIconGenre; |
|
2391 iconIndex = EMPXClvIconGenre; |
|
2392 break; |
|
2393 } |
|
2394 case EContextGroupComposer: |
|
2395 { |
|
2396 defaultIcon = EMPXDefaultIconComposer; |
|
2397 iconIndex = EMPXClvIconComposer; |
|
2398 break; |
|
2399 } |
|
2400 case EContextGroupSong: |
|
2401 case EContextItemPlaylist: |
|
2402 case EContextItemGenre: |
|
2403 { |
|
2404 defaultIcon = EMPXDefaultIconSongs; |
|
2405 iconIndex = EMPXClvIconSongs; |
|
2406 break; |
|
2407 } |
|
2408 case EContextItemComposer: |
|
2409 case EContextItemSong: |
|
2410 case EContextGroupCollection: |
|
2411 case EContextUnknown: |
|
2412 default: |
|
2413 { |
|
2414 // no default icon for main menu items |
|
2415 break; |
|
2416 } |
|
2417 } |
|
2418 |
|
2419 CGulIcon* icon = (*iIconArray)[iconIndex]; |
|
2420 CFbsBitmap* bitmap = icon->Bitmap(); |
|
2421 CFbsBitmap* mask = icon->Mask(); |
|
2422 |
|
2423 TSize size(iImageSize.iWidth, iImageSize.iHeight); |
|
2424 AknIconUtils::SetSize( bitmap, size ); |
|
2425 AknIconUtils::SetSize( mask, size ); |
|
2426 |
|
2427 CGulIcon* iconCopy = CGulIcon::NewL(bitmap, mask); |
|
2428 iconCopy->SetBitmapsOwnedExternally(ETrue); |
|
2429 |
|
2430 if ( iMediaWall ) |
|
2431 { |
|
2432 iMediaWall->SetDefaultIconL(iconCopy); |
|
2433 } |
|
2434 else if ( iListWidget ) |
|
2435 { |
|
2436 iListWidget->SetDefaultIconL(iconCopy); |
|
2437 } |
|
2438 iCurrentDefaultIcon = defaultIcon; |
|
2439 } |
|
2440 |
|
2441 // ----------------------------------------------------------------------------- |
|
2442 // Sets default icon to list item |
|
2443 // ----------------------------------------------------------------------------- |
|
2444 // |
|
2445 void CMPXCollectionViewHgContainer::SetDefaultIconL(TInt aIndex) |
|
2446 { |
|
2447 |
|
2448 TDefaultIcon defaultIcon( EMPXDefaultIconNotSet ); |
|
2449 TInt iconIndex( EMPXClvIconNone ); |
|
2450 |
|
2451 switch( iContext ) |
|
2452 { |
|
2453 |
|
2454 case EContextGroupAlbum: |
|
2455 { |
|
2456 defaultIcon = EMPXDefaultIconAlbum; |
|
2457 iconIndex = EMPXClvIconAlbum; |
|
2458 break; |
|
2459 } |
|
2460 case EContextGroupPodcast: |
|
2461 case EContextItemPodcast: |
|
2462 { |
|
2463 defaultIcon = EMPXDefaultTitleIconPodcasts; |
|
2464 iconIndex = EMPXPodClvIconTitle; // Podcast default icon |
|
2465 break; |
|
2466 } |
|
2467 case EContextItemComposer: |
|
2468 case EContextGroupSong: |
|
2469 case EContextItemSong: |
|
2470 case EContextItemPlaylist: |
|
2471 case EContextItemGenre: |
|
2472 case EContextItemAlbum: |
|
2473 { |
|
2474 defaultIcon = EMPXDefaultIconSongs; |
|
2475 iconIndex = EMPXClvIconSongs; |
|
2476 break; |
|
2477 } |
|
2478 default: |
|
2479 { |
|
2480 break; |
|
2481 } |
|
2482 } |
|
2483 |
|
2484 CGulIcon* icon = (*iIconArray)[iconIndex]; |
|
2485 CFbsBitmap* bitmap = icon->Bitmap(); |
|
2486 CFbsBitmap* mask = icon->Mask(); |
|
2487 |
|
2488 TSize size(iImageSize.iWidth, iImageSize.iHeight); |
|
2489 AknIconUtils::SetSize( bitmap, size ); |
|
2490 AknIconUtils::SetSize( mask, size ); |
|
2491 |
|
2492 CGulIcon* iconCopy = CGulIcon::NewL(bitmap, mask); |
|
2493 iconCopy->SetBitmapsOwnedExternally(ETrue); |
|
2494 |
|
2495 |
|
2496 // TODO, fix this to use currentviewtype |
|
2497 if ( iMediaWall && defaultIcon != EMPXDefaultIconNotSet ) |
|
2498 { |
|
2499 iMediaWall->ItemL(aIndex).SetIcon(iconCopy); |
|
2500 } |
|
2501 else if ( iListWidget && defaultIcon != EMPXDefaultIconNotSet ) |
|
2502 { |
|
2503 iListWidget->ItemL(aIndex).SetIcon(iconCopy); |
|
2504 } |
|
2505 } |
|
2506 |
|
2507 |
|
2508 // ----------------------------------------------------------------------------- |
|
2509 // Adds detail to the list item at the specified index |
|
2510 // ----------------------------------------------------------------------------- |
|
2511 // |
|
2512 void CMPXCollectionViewHgContainer::AddDetailToDisplayedItemL( |
|
2513 CHgItem* aVisualItem, |
|
2514 CMPXMedia* aMedia, |
|
2515 TInt aIndex ) |
|
2516 { |
|
2517 MPX_FUNC( "CMPXCollectionViewHgContainer::AddDetailToDisplayedItemL" ); |
|
2518 |
|
2519 switch ( iContext ) |
|
2520 { |
|
2521 case EContextGroupCollection: |
|
2522 { |
|
2523 SetDetailIconL( aVisualItem, aIndex ); |
|
2524 SetDetailCountL( aVisualItem, aMedia ); |
|
2525 break; |
|
2526 } |
|
2527 case EContextGroupArtist: |
|
2528 { |
|
2529 SetDetailCountL( aVisualItem, aMedia ); |
|
2530 break; |
|
2531 } |
|
2532 case EContextGroupAlbum: |
|
2533 { |
|
2534 SetDetailAlbumL( aVisualItem, aMedia ); |
|
2535 //SetDetailArtistL( aVisualItem, aMedia ); |
|
2536 break; |
|
2537 } |
|
2538 case EContextGroupPlaylist: |
|
2539 { |
|
2540 SetDetailDurationL( aVisualItem, aMedia ); |
|
2541 SetDetailIndicatorL( aVisualItem, aIndex ); |
|
2542 // SetDetailIconL( aVisualItem, EMPXDefaultIconPlaylist ); // playlist icon |
|
2543 break; |
|
2544 } |
|
2545 case EContextItemAlbum: |
|
2546 { |
|
2547 SetDetailAlbumL( aVisualItem, aMedia ); |
|
2548 //SetDetailArtistL( aVisualItem, aMedia ); |
|
2549 SetDetailIndicatorL( aVisualItem, aIndex ); |
|
2550 break; |
|
2551 } |
|
2552 case EContextGroupSong: |
|
2553 case EContextItemPlaylist: |
|
2554 case EContextItemGenre: |
|
2555 case EContextItemComposer: |
|
2556 { |
|
2557 SetDetailArtistL( aVisualItem, aMedia ); |
|
2558 SetDetailIndicatorL( aVisualItem, aIndex ); |
|
2559 break; |
|
2560 } |
|
2561 case EContextGroupPodcast: |
|
2562 { |
|
2563 SetDetailCountL( aVisualItem, aMedia ); |
|
2564 // SetDetailIconL( aVisualItem, EMPXDefaultTitleIconPodcasts ); |
|
2565 break; |
|
2566 } |
|
2567 case EContextGroupGenre: |
|
2568 { |
|
2569 // SetDetailIconL( aVisualItem, EMPXDefaultIconGenre ); //genre icon |
|
2570 SetDetailCountL( aVisualItem, aMedia ); |
|
2571 break; |
|
2572 } |
|
2573 case EContextGroupComposer: |
|
2574 { |
|
2575 // SetDetailIconL( aVisualItem, EMPXDefaultIconComposer ); //composer icon |
|
2576 SetDetailCountL( aVisualItem, aMedia ); |
|
2577 break; |
|
2578 } |
|
2579 case EContextItemArtist: |
|
2580 { |
|
2581 SetDetailCountL(aVisualItem, aMedia); |
|
2582 break; |
|
2583 } |
|
2584 case EContextItemSong: |
|
2585 { |
|
2586 SetDetailAlbumL( aVisualItem, aMedia ); |
|
2587 SetDetailIndicatorL( aVisualItem, aIndex ); |
|
2588 break; |
|
2589 } |
|
2590 case EContextItemPodcast: |
|
2591 { |
|
2592 SetDetailIndicatorL( aVisualItem, aIndex ); |
|
2593 break; |
|
2594 } |
|
2595 } |
|
2596 } |
|
2597 |
|
2598 // ----------------------------------------------------------------------------- |
|
2599 // Adds thumbnail to the list item at the specified index |
|
2600 // ----------------------------------------------------------------------------- |
|
2601 // |
|
2602 void CMPXCollectionViewHgContainer::AddThumbnailToDisplayedItemL( |
|
2603 CHgItem* aVisualItem, |
|
2604 CMPXMedia* aMedia, |
|
2605 TInt aIndex ) |
|
2606 { |
|
2607 MPX_FUNC( "CMPXCollectionViewHgContainer::AddThumbnailToDisplayedItemL" ); |
|
2608 |
|
2609 |
|
2610 switch ( iContext ) |
|
2611 { |
|
2612 case EContextGroupCollection: |
|
2613 { |
|
2614 |
|
2615 SetDetailIconL( aVisualItem, aIndex ); |
|
2616 break; |
|
2617 } |
|
2618 case EContextGroupAlbum: |
|
2619 case EContextGroupSong: |
|
2620 case EContextItemPlaylist: |
|
2621 case EContextItemGenre: |
|
2622 case EContextItemComposer: |
|
2623 case EContextItemArtist: |
|
2624 case EContextItemSong: |
|
2625 case EContextItemPodcast: |
|
2626 case EContextItemAlbum: |
|
2627 { |
|
2628 SetDetailThumbnailL( aMedia, aIndex ); |
|
2629 break; |
|
2630 } |
|
2631 |
|
2632 } |
|
2633 } |
|
2634 |
|
2635 // ----------------------------------------------------------------------------- |
|
2636 // Set title to the visual item |
|
2637 // ----------------------------------------------------------------------------- |
|
2638 // |
|
2639 void CMPXCollectionViewHgContainer::SetTitleL( |
|
2640 CHgItem* aVisualItem, |
|
2641 CMPXMedia* aMedia ) |
|
2642 { |
|
2643 MPX_FUNC( "CMPXCollectionViewHgContainer::SetTitleL" ); |
|
2644 |
|
2645 |
|
2646 if ( iContext == EContextGroupAlbum || iContext == EContextItemAlbum ) |
|
2647 { |
|
2648 |
|
2649 if ( aMedia->IsSupported( KMPXMediaMusicArtist ) ) |
|
2650 { |
|
2651 const TDesC& title = aMedia->ValueText( KMPXMediaMusicArtist ); |
|
2652 if ( title.Compare( KNullDesC ) != 0 ) |
|
2653 { |
|
2654 aVisualItem->SetTitleL( title ); |
|
2655 } |
|
2656 else |
|
2657 { |
|
2658 HBufC* unknownText = |
|
2659 StringLoader::LoadLC( R_MPX_COLLECTION_UNKNOWN ); |
|
2660 aVisualItem->SetTitleL( *unknownText ); |
|
2661 CleanupStack::PopAndDestroy( unknownText ); |
|
2662 } |
|
2663 } |
|
2664 } |
|
2665 else |
|
2666 { |
|
2667 if ( aMedia->IsSupported( KMPXMediaGeneralTitle ) ) |
|
2668 { |
|
2669 const TDesC& title = aMedia->ValueText( KMPXMediaGeneralTitle ); |
|
2670 if ( title.Compare( KNullDesC ) != 0 ) |
|
2671 { |
|
2672 aVisualItem->SetTitleL( title ); |
|
2673 } |
|
2674 else |
|
2675 { |
|
2676 HBufC* unknownText = |
|
2677 StringLoader::LoadLC( R_MPX_COLLECTION_UNKNOWN ); |
|
2678 aVisualItem->SetTitleL( *unknownText ); |
|
2679 CleanupStack::PopAndDestroy( unknownText ); |
|
2680 } |
|
2681 } |
|
2682 } |
|
2683 } |
|
2684 |
|
2685 // ----------------------------------------------------------------------------- |
|
2686 // Set song title to the visual item |
|
2687 // ----------------------------------------------------------------------------- |
|
2688 // |
|
2689 void CMPXCollectionViewHgContainer::SetSongTitleL( |
|
2690 CHgItem* aVisualItem, |
|
2691 CMPXMedia* aMedia ) |
|
2692 { |
|
2693 MPX_FUNC( "CMPXCollectionViewHgContainer::SetSongTitleL" ); |
|
2694 |
|
2695 |
|
2696 if ( aMedia->IsSupported( KMPXMediaGeneralTitle ) ) |
|
2697 { |
|
2698 const TDesC& title = aMedia->ValueText( KMPXMediaGeneralTitle ); |
|
2699 if ( title.Compare( KNullDesC ) != 0 ) |
|
2700 { |
|
2701 aVisualItem->SetTitleL( title ); |
|
2702 } |
|
2703 else |
|
2704 { |
|
2705 HBufC* unknownText = |
|
2706 StringLoader::LoadLC( R_MPX_COLLECTION_UNKNOWN ); |
|
2707 aVisualItem->SetTitleL( *unknownText ); |
|
2708 CleanupStack::PopAndDestroy( unknownText ); |
|
2709 } |
|
2710 } |
|
2711 } |
|
2712 |
|
2713 // ----------------------------------------------------------------------------- |
|
2714 // Set Detail - Count to the visual item |
|
2715 // ----------------------------------------------------------------------------- |
|
2716 // |
|
2717 void CMPXCollectionViewHgContainer::SetDetailCountL( |
|
2718 CHgItem* aVisualItem, |
|
2719 CMPXMedia* aMedia ) |
|
2720 { |
|
2721 MPX_FUNC( "CMPXCollectionViewHgContainer::SetDetailCountL" ); |
|
2722 if ( aMedia->IsSupported( KMPXMediaGeneralCount ) ) |
|
2723 { |
|
2724 TInt count( aMedia->ValueTObjectL<TInt>( KMPXMediaGeneralCount ) ); |
|
2725 |
|
2726 #ifdef HG_MP_LOC_AVAILABLE |
|
2727 |
|
2728 if ( iContext == EContextGroupArtist ) |
|
2729 { |
|
2730 if ( count > 1 ) |
|
2731 { |
|
2732 HBufC* albumsTitle = StringLoader::LoadLC( R_MPX_COLLECTION_DETAILS_NUMBER_OF_SONGS, // mod by anjokela |
|
2733 count ); |
|
2734 TPtr ptr = albumsTitle->Des(); |
|
2735 AknTextUtils::LanguageSpecificNumberConversion( ptr ); |
|
2736 aVisualItem->SetTextL( ptr ); |
|
2737 CleanupStack::PopAndDestroy( albumsTitle ); |
|
2738 } |
|
2739 else |
|
2740 { |
|
2741 aVisualItem->SetTextL( *iSongTitle ); // mod by anjokela |
|
2742 } |
|
2743 } |
|
2744 else |
|
2745 { |
|
2746 if ( count > 1 ) |
|
2747 { |
|
2748 HBufC* songsTitle = StringLoader::LoadLC( R_MPX_COLLECTION_DETAILS_NUMBER_OF_SONGS, count ); |
|
2749 TPtr ptr = songsTitle->Des(); |
|
2750 AknTextUtils::LanguageSpecificNumberConversion( ptr ); |
|
2751 aVisualItem->SetTextL( ptr ); |
|
2752 CleanupStack::PopAndDestroy( songsTitle ); |
|
2753 } |
|
2754 else |
|
2755 { |
|
2756 aVisualItem->SetTextL( *iSongTitle ); |
|
2757 } |
|
2758 } |
|
2759 #else //HG_MP_LOC_AVAILABLE |
|
2760 |
|
2761 TBuf<10> temp; |
|
2762 temp.AppendNum( count ); |
|
2763 AknTextUtils::LanguageSpecificNumberConversion( temp ); |
|
2764 |
|
2765 TBuf<KMPXMaxFileLength> detailText; |
|
2766 detailText.Append( temp ); |
|
2767 if ( iContext == EContextGroupPodcast ) |
|
2768 { |
|
2769 detailText.Append( (count > 1 ) ? KEpisodes() : KEpisode() ); |
|
2770 } |
|
2771 else if ( iContext == EContextGroupArtist ) |
|
2772 { |
|
2773 detailText.Append( (count > 1 ) ? KAlbums() : KAlbum() ); |
|
2774 } |
|
2775 else |
|
2776 { |
|
2777 detailText.Append( (count > 1 ) ? KSongs() : KSong() ); |
|
2778 } |
|
2779 aVisualItem->SetTextL( detailText ); |
|
2780 #endif //HG_MP_LOC_AVAILABLE |
|
2781 |
|
2782 } |
|
2783 } |
|
2784 |
|
2785 // ----------------------------------------------------------------------------- |
|
2786 // Set Detail - Artist to the visual item |
|
2787 // ----------------------------------------------------------------------------- |
|
2788 // |
|
2789 void CMPXCollectionViewHgContainer::SetDetailArtistL( |
|
2790 CHgItem* aVisualItem, |
|
2791 CMPXMedia* aMedia ) |
|
2792 { |
|
2793 MPX_FUNC( "CMPXCollectionViewHgContainer::SetDetailArtistL" ); |
|
2794 if ( aMedia->IsSupported( KMPXMediaMusicArtist ) ) |
|
2795 { |
|
2796 // AK - Needs to be localized |
|
2797 TBuf<KMPXMaxFileLength> detailText; |
|
2798 const TDesC& artist = aMedia->ValueText( KMPXMediaMusicArtist ); |
|
2799 if ( artist.Compare( KNullDesC ) != 0 ) |
|
2800 { |
|
2801 detailText.Copy(artist.Left(detailText.MaxLength())); |
|
2802 aVisualItem->SetTextL( detailText ); |
|
2803 } |
|
2804 else |
|
2805 { |
|
2806 HBufC* unknownText = |
|
2807 StringLoader::LoadLC( R_MPX_COLLECTION_UNKNOWN ); |
|
2808 aVisualItem->SetTextL( *unknownText ); |
|
2809 CleanupStack::PopAndDestroy( unknownText ); |
|
2810 } |
|
2811 } |
|
2812 } |
|
2813 |
|
2814 // ----------------------------------------------------------------------------- |
|
2815 // Set Detail - Album to the visual item |
|
2816 // ----------------------------------------------------------------------------- |
|
2817 // |
|
2818 void CMPXCollectionViewHgContainer::SetDetailAlbumL( |
|
2819 CHgItem* aVisualItem, |
|
2820 CMPXMedia* aMedia ) |
|
2821 { |
|
2822 MPX_FUNC( "CMPXCollectionViewHgContainer::SetDetailAlbumL" ); |
|
2823 |
|
2824 TMPXGeneralCategory category( EMPXNoCategory ); |
|
2825 if ( aMedia->IsSupported( KMPXMediaGeneralCategory ) ) |
|
2826 { |
|
2827 category = aMedia->ValueTObjectL<TMPXGeneralCategory>( KMPXMediaGeneralCategory ); |
|
2828 } |
|
2829 |
|
2830 if ( aMedia->IsSupported( KMPXMediaMusicAlbum ) && category != EMPXCommand ) |
|
2831 { |
|
2832 TBuf<KMPXMaxFileLength> detailText; |
|
2833 const TDesC& album = aMedia->ValueText( KMPXMediaMusicAlbum ); |
|
2834 if ( album.Compare( KNullDesC ) != 0 ) |
|
2835 { |
|
2836 detailText.Copy( album.Left(detailText.MaxLength())); |
|
2837 aVisualItem->SetTextL( detailText ); |
|
2838 } |
|
2839 else |
|
2840 { |
|
2841 HBufC* unknownText = |
|
2842 StringLoader::LoadLC( R_MPX_COLLECTION_UNKNOWN ); |
|
2843 aVisualItem->SetTextL( *unknownText ); |
|
2844 CleanupStack::PopAndDestroy( unknownText ); |
|
2845 } |
|
2846 } |
|
2847 } |
|
2848 |
|
2849 |
|
2850 // ----------------------------------------------------------------------------- |
|
2851 // Set Detail - Count + Duration to the visual item |
|
2852 // ----------------------------------------------------------------------------- |
|
2853 // |
|
2854 void CMPXCollectionViewHgContainer::SetDetailDurationL( |
|
2855 CHgItem* aVisualItem, |
|
2856 CMPXMedia* aMedia ) |
|
2857 { |
|
2858 MPX_FUNC( "CMPXCollectionViewHgContainer::SetDetailDurationL" ); |
|
2859 if ( iContext == EContextGroupPlaylist && |
|
2860 aMedia->IsSupported( KMPXMediaGeneralDuration ) && |
|
2861 aMedia->IsSupported( KMPXMediaGeneralCount ) ) |
|
2862 { |
|
2863 // AK - Needs to be localized |
|
2864 TBuf<KMPXMaxFileLength> detailText; |
|
2865 TInt count( aMedia->ValueTObjectL<TInt>( KMPXMediaGeneralCount ) ); |
|
2866 TInt duration = aMedia->ValueTObjectL<TInt>( KMPXMediaGeneralDuration ); |
|
2867 |
|
2868 #ifdef HG_MP_LOC_AVAILABLE |
|
2869 if ( count > 1 || count == 0 ) |
|
2870 { |
|
2871 HBufC* songsTitle = StringLoader::LoadLC( R_MPX_COLLECTION_DETAILS_NUMBER_OF_SONGS, count ); |
|
2872 detailText.Append(*songsTitle); |
|
2873 detailText.Append(KMPXDash); |
|
2874 UpdateTimeIndicatorsL(detailText, duration); |
|
2875 aVisualItem->SetTextL( detailText ); |
|
2876 CleanupStack::PopAndDestroy( songsTitle ); |
|
2877 } |
|
2878 else |
|
2879 { |
|
2880 detailText.Append(*iSongTitle); |
|
2881 detailText.Append(KMPXDash); |
|
2882 UpdateTimeIndicatorsL(detailText, duration); |
|
2883 aVisualItem->SetTextL( detailText ); |
|
2884 } |
|
2885 #else //HG_MP_LOC_AVAILABLE |
|
2886 TBuf<10> temp; |
|
2887 temp.AppendNum( count ); |
|
2888 AknTextUtils::LanguageSpecificNumberConversion( temp ); |
|
2889 detailText.Append( temp ); |
|
2890 detailText.Append( (count > 1 ) ? KSongsDash() : KSongDash() ); |
|
2891 UpdateTimeIndicatorsL(detailText, duration); |
|
2892 aVisualItem->SetTextL( detailText ); |
|
2893 #endif //HG_MP_LOC_AVAILABLE |
|
2894 } |
|
2895 else if ( iContext == EContextItemPodcast && |
|
2896 aMedia->IsSupported( KMPXMediaGeneralDuration ) && |
|
2897 aMedia->IsSupported( KMPXMediaGeneralSize ) ) |
|
2898 { |
|
2899 TBuf<KMPXMaxFileLength> detailText; |
|
2900 TInt duration = aMedia->ValueTObjectL<TInt>( KMPXMediaGeneralDuration ); |
|
2901 UpdateTimeIndicatorsL(detailText, duration); |
|
2902 detailText.Append( KMPXDash() ); |
|
2903 |
|
2904 TInt size( aMedia->ValueTObjectL<TInt>( KMPXMediaGeneralSize ) ); |
|
2905 HBufC* sizeBuf = iCommonUiHelper->UnitConversionL( size, ETrue ); |
|
2906 TPtr sizePtr( sizeBuf->Des() ); |
|
2907 detailText.Append( sizePtr ); |
|
2908 delete sizeBuf; |
|
2909 |
|
2910 aVisualItem->SetTextL( detailText ); |
|
2911 } |
|
2912 } |
|
2913 |
|
2914 |
|
2915 // ----------------------------------------------------------------------------- |
|
2916 // Format the duration to the visual item |
|
2917 // ----------------------------------------------------------------------------- |
|
2918 // |
|
2919 void CMPXCollectionViewHgContainer::UpdateTimeIndicatorsL( |
|
2920 TDes& aBuf, |
|
2921 TInt aDuration ) |
|
2922 { |
|
2923 MPX_FUNC( "CMPXCollectionViewHgContainer::UpdateTimeIndicatorsL" ); |
|
2924 TInt durationInSeconds = aDuration; |
|
2925 if ( durationInSeconds > 0 ) |
|
2926 { |
|
2927 durationInSeconds /= 1000; // MilliSeconds to second conversion |
|
2928 } |
|
2929 else if ( durationInSeconds < 0 ) |
|
2930 { |
|
2931 durationInSeconds = 0; |
|
2932 } |
|
2933 if ( durationInSeconds == 0 ) |
|
2934 { |
|
2935 TLocale locale; |
|
2936 TBuf<KMPXTimeIndicatorLength> pos; |
|
2937 TChar separator = locale.TimeSeparator( KMPXMinSecSeparatorIndex ); |
|
2938 aBuf.Append(KMPXZeroDurationMark); |
|
2939 aBuf.Append( separator ); |
|
2940 aBuf.Append(KMPXZeroDurationMark); |
|
2941 } |
|
2942 else |
|
2943 { |
|
2944 CMPXCommonUiHelper::TMPXDuratDisplayMode durationMode = CMPXCommonUiHelper::EMPXDuratAuto; |
|
2945 if ( durationInSeconds > KOneHourInSeconds ) |
|
2946 { |
|
2947 durationMode = CMPXCommonUiHelper::EMPXDuratHMS; |
|
2948 } |
|
2949 // Convert ellapsed time to texts |
|
2950 HBufC* position = iCommonUiHelper->DisplayableDurationL( durationInSeconds, durationMode ); |
|
2951 aBuf.Append(position->Des()); |
|
2952 delete position; |
|
2953 } |
|
2954 } |
|
2955 |
|
2956 |
|
2957 // ----------------------------------------------------------------------------- |
|
2958 // Set Detail - Indicator to the visual item |
|
2959 // ----------------------------------------------------------------------------- |
|
2960 // |
|
2961 void CMPXCollectionViewHgContainer::SetDetailIndicatorL( |
|
2962 CHgItem* aVisualItem, |
|
2963 TInt aIndex ) |
|
2964 { |
|
2965 MPX_FUNC( "CMPXCollectionViewHgContainer::SetDetailIndicatorL" ); |
|
2966 // Get icon indices |
|
2967 RArray<TInt> iconIndices = iListBoxArray->IndicatorIconIndicesL( aIndex ); |
|
2968 CleanupClosePushL( iconIndices ); |
|
2969 |
|
2970 const TInt iconCount = iconIndices.Count(); |
|
2971 TInt flags = aVisualItem->Flags() & CHgItem::EHgItemFlagMarked; |
|
2972 aVisualItem->ClearFlags(aVisualItem->Flags()); |
|
2973 if ( iconCount > 0 ) |
|
2974 { |
|
2975 TInt iconId = 0; |
|
2976 for ( TInt iconIndex = 0; iconIndex < iconCount; iconIndex++ ) |
|
2977 { |
|
2978 iconId = iconIndices[iconIndex]; |
|
2979 if ( !iPodcastContext ) |
|
2980 { |
|
2981 switch (iconId) |
|
2982 { |
|
2983 case EMPXClvIconMMC: |
|
2984 { |
|
2985 flags |= CHgItem::EHgItemFlagsMmc; |
|
2986 break; |
|
2987 } |
|
2988 case EMPXClvIconPlay: |
|
2989 { |
|
2990 flags |= CHgItem::EHgItemFlagsPlaybackIndicator; |
|
2991 break; |
|
2992 } |
|
2993 case EMPXClvIconPause: |
|
2994 { |
|
2995 flags |= CHgItem::EHgItemFlagsPauseIndicator; |
|
2996 break; |
|
2997 } |
|
2998 case EMPXClvIconBrokenTrack: |
|
2999 { |
|
3000 flags |= CHgItem::EHgItemFlagsBrokenTrackIndicator; |
|
3001 break; |
|
3002 } |
|
3003 case EMPXClvIconCorruptTrack: |
|
3004 { |
|
3005 flags |= CHgItem::EHgItemFlagsCorruptedTrackIndicator; |
|
3006 break; |
|
3007 } |
|
3008 case EMPXClvIconDrmExpired: |
|
3009 { |
|
3010 flags |= CHgItem::EHgItemFlagsDrmRightsExpired; |
|
3011 break; |
|
3012 } |
|
3013 case EMPXClvIconBrokenPlaylist: |
|
3014 { |
|
3015 flags |= CHgItem::EHgItemFlagsBrokenPlaylistIndicator; |
|
3016 break; |
|
3017 } |
|
3018 } |
|
3019 } |
|
3020 else // podcast icons |
|
3021 { |
|
3022 switch (iconId) |
|
3023 { |
|
3024 case EMPXPodClvIconMMC: |
|
3025 { |
|
3026 flags |= CHgItem::EHgItemFlagsMmc; |
|
3027 break; |
|
3028 } |
|
3029 case EMPXPodClvIconPlay: |
|
3030 { |
|
3031 flags |= CHgItem::EHgItemFlagsPlaybackIndicator; |
|
3032 break; |
|
3033 } |
|
3034 case EMPXPodClvIconPause: |
|
3035 { |
|
3036 flags |= CHgItem::EHgItemFlagsPauseIndicator; |
|
3037 break; |
|
3038 } |
|
3039 case EMPXPodClvIconBroken: |
|
3040 { |
|
3041 flags |= CHgItem::EHgItemFlagsBrokenTrackIndicator; |
|
3042 break; |
|
3043 } |
|
3044 case EMPXPodClvIconCorrupt: |
|
3045 { |
|
3046 flags |= CHgItem::EHgItemFlagsCorruptedTrackIndicator; |
|
3047 break; |
|
3048 } |
|
3049 case EMPXPodClvIconNew: |
|
3050 { |
|
3051 flags |= CHgItem::EHgItemFlagsNewPodcastIndicator; |
|
3052 break; |
|
3053 } |
|
3054 case EMPXPodClvIconCompplay: |
|
3055 { |
|
3056 flags |= CHgItem::EHgItemFlagsCompletelyPlayedPodcastIndicator; |
|
3057 break; |
|
3058 } |
|
3059 case EMPXPodClvIconPartplay: |
|
3060 { |
|
3061 flags |= CHgItem::EHgItemFlagsPlayedPodcastIndicator; |
|
3062 break; |
|
3063 } |
|
3064 } |
|
3065 } |
|
3066 } |
|
3067 } |
|
3068 aVisualItem->SetFlags( flags ); |
|
3069 CleanupStack::PopAndDestroy(&iconIndices); |
|
3070 } |
|
3071 |
|
3072 |
|
3073 // ----------------------------------------------------------------------------- |
|
3074 // Set Detail - Icon to the visual item |
|
3075 // ----------------------------------------------------------------------------- |
|
3076 // |
|
3077 void CMPXCollectionViewHgContainer::SetDetailIconL( |
|
3078 CHgItem* aVisualItem, |
|
3079 TInt aIndex ) |
|
3080 { |
|
3081 MPX_FUNC( "CMPXCollectionViewHgContainer::SetDetailIconL" ); |
|
3082 |
|
3083 TInt iconIndex = aIndex; |
|
3084 switch ( aIndex ) |
|
3085 { |
|
3086 case 0: |
|
3087 iconIndex = EMPXClvIconArtist; |
|
3088 break; |
|
3089 case 1: |
|
3090 iconIndex = EMPXClvIconAlbum; |
|
3091 break; |
|
3092 case 2: |
|
3093 iconIndex = EMPXClvIconPlaylist; |
|
3094 break; |
|
3095 case 3: |
|
3096 iconIndex = EMPXClvIconSongs; |
|
3097 break; |
|
3098 case 4: |
|
3099 iconIndex = EMPXClvIconPodcasts; |
|
3100 break; |
|
3101 case 5: |
|
3102 iconIndex = EMPXClvIconGenre; |
|
3103 break; |
|
3104 case 6: |
|
3105 iconIndex = EMPXClvIconComposer; |
|
3106 break; |
|
3107 case 7: //EMPXDefaultTitleIconPodcasts |
|
3108 iconIndex = 10; |
|
3109 break; |
|
3110 } |
|
3111 |
|
3112 CGulIcon* icon = (*iIconArray)[iconIndex]; |
|
3113 |
|
3114 CFbsBitmap* bitmap = icon->Bitmap(); |
|
3115 CFbsBitmap* mask = icon->Mask(); |
|
3116 |
|
3117 TSize size(iImageSize.iWidth, iImageSize.iHeight); |
|
3118 if ( iContext == EContextGroupCollection ) |
|
3119 { // shrink smaller to look same as in Antriksh |
|
3120 size.iWidth = iImageSize.iWidth * KIconFactor; |
|
3121 size.iHeight = iImageSize.iHeight * KIconFactor; |
|
3122 } |
|
3123 |
|
3124 AknIconUtils::SetSize( bitmap, size ); |
|
3125 AknIconUtils::SetSize( mask, size ); |
|
3126 |
|
3127 CGulIcon* iconCopy = CGulIcon::NewL(bitmap, mask); |
|
3128 iconCopy->SetBitmapsOwnedExternally(ETrue); |
|
3129 aVisualItem->SetIcon( iconCopy ); |
|
3130 } |
|
3131 |
|
3132 // ----------------------------------------------------------------------------- |
|
3133 // Set Detail - Thumbnail to the visual item |
|
3134 // ----------------------------------------------------------------------------- |
|
3135 // |
|
3136 void CMPXCollectionViewHgContainer::SetDetailThumbnailL( |
|
3137 CMPXMedia* aMedia, |
|
3138 TInt aIndex ) |
|
3139 { |
|
3140 MPX_FUNC("CMPXCollectionViewHgContainer::SetDetailThumbnailL(CMPXMedia* aMedia,TInt aIndex)"); |
|
3141 TMPXItemId currentId( aMedia->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) ); |
|
3142 |
|
3143 if ( currentId == KMPXInvalidItemId ) |
|
3144 { |
|
3145 return; |
|
3146 } |
|
3147 |
|
3148 if ( aMedia->IsSupported( KMPXMediaMusicAlbumArtFileName ) ) |
|
3149 { |
|
3150 const TDesC& album = aMedia->ValueText( KMPXMediaMusicAlbumArtFileName ); |
|
3151 #ifdef _DEBUG |
|
3152 RDebug::RawPrint(album); |
|
3153 #endif |
|
3154 if ( album.Compare( KNullDesC ) != 0 ) |
|
3155 { |
|
3156 iThumbnailManager->LoadThumbL( aIndex , album); |
|
3157 } |
|
3158 else |
|
3159 { |
|
3160 //no albumart |
|
3161 // Default album art has already been set earlier. |
|
3162 iThumbnailReqMap[aIndex] = ETrue; |
|
3163 RefreshNoThumbnailL(aIndex); |
|
3164 } |
|
3165 } |
|
3166 else |
|
3167 { |
|
3168 // no album art supported |
|
3169 // Default album art has already been set earlier. |
|
3170 if ( iCurrentViewType == EMPXViewCoverFlow || |
|
3171 iCurrentViewType == EMPXViewList && aIndex == 0 ) |
|
3172 SetDetailIconShuffleL(); // BUG: temporarily called here because default icon is shown if SetDefaultIconL is called after. |
|
3173 iThumbnailReqMap[aIndex] = ETrue; |
|
3174 RefreshNoThumbnailL(aIndex); |
|
3175 } |
|
3176 } |
|
3177 |
|
3178 // ---------------------------------------------------------------------------- |
|
3179 // Set the shuffle item icon |
|
3180 // ---------------------------------------------------------------------------- |
|
3181 |
|
3182 void CMPXCollectionViewHgContainer::SetDetailIconShuffleL() |
|
3183 { |
|
3184 |
|
3185 const CMPXMediaArray& mediaArray = iListBoxArray->MediaArray(); |
|
3186 if (mediaArray.Count()) |
|
3187 { |
|
3188 CMPXMedia* currentMedia( mediaArray.AtL( 0 ) ); |
|
3189 |
|
3190 TMPXGeneralType type( EMPXNoType ); |
|
3191 if ( currentMedia->IsSupported( KMPXMediaGeneralType ) ) |
|
3192 { |
|
3193 type = currentMedia->ValueTObjectL<TMPXGeneralType>( KMPXMediaGeneralType ); |
|
3194 } |
|
3195 |
|
3196 TMPXGeneralCategory category( EMPXNoCategory ); |
|
3197 if ( currentMedia->IsSupported( KMPXMediaGeneralCategory ) ) |
|
3198 { |
|
3199 category = currentMedia->ValueTObjectL<TMPXGeneralCategory>( KMPXMediaGeneralCategory ); |
|
3200 } |
|
3201 |
|
3202 if ( type == EMPXItem && category == EMPXCommand ) |
|
3203 { |
|
3204 |
|
3205 CGulIcon* icon = (*iIconArray)[EMPXClvIconShuffle]; |
|
3206 CFbsBitmap* bitmap = icon->Bitmap(); |
|
3207 CFbsBitmap* mask = icon->Mask(); |
|
3208 |
|
3209 TSize size(240,240); |
|
3210 CHgItem* item = NULL; |
|
3211 if( iCurrentViewType == EMPXViewCoverFlow || iCurrentViewType == EMPXViewTBone ) |
|
3212 { |
|
3213 item = &iMediaWall->ItemL(0); |
|
3214 } |
|
3215 else if( iCurrentViewType == EMPXViewList ) |
|
3216 { |
|
3217 item = &iListWidget->ItemL(0); |
|
3218 size = CHgDoubleGraphicListFlat::PreferredImageSize(); |
|
3219 } |
|
3220 else |
|
3221 { |
|
3222 User::Leave( KErrNotSupported ); |
|
3223 } |
|
3224 |
|
3225 if ( item ) |
|
3226 { |
|
3227 AknIconUtils::SetSize( bitmap, size ); |
|
3228 AknIconUtils::SetSize( mask, size ); |
|
3229 |
|
3230 CGulIcon* iconCopy = CGulIcon::NewL(bitmap, mask); |
|
3231 iconCopy->SetBitmapsOwnedExternally(ETrue); |
|
3232 item->SetIcon( iconCopy ); |
|
3233 } |
|
3234 } |
|
3235 } |
|
3236 } |
|
3237 |
|
3238 // ---------------------------------------------------------------------------- |
|
3239 // Set the shuffle item text |
|
3240 // ---------------------------------------------------------------------------- |
|
3241 |
|
3242 TBool CMPXCollectionViewHgContainer::SetShuffleItemTextL(CHgItem* aItem, CMPXMedia* aMedia) |
|
3243 { |
|
3244 |
|
3245 TBool res(EFalse); |
|
3246 TMPXGeneralType type( EMPXNoType ); |
|
3247 if ( aMedia->IsSupported( KMPXMediaGeneralType ) ) |
|
3248 { |
|
3249 type = aMedia->ValueTObjectL<TMPXGeneralType>( KMPXMediaGeneralType ); |
|
3250 } |
|
3251 |
|
3252 TMPXGeneralCategory category( EMPXNoCategory ); |
|
3253 if ( aMedia->IsSupported( KMPXMediaGeneralCategory ) ) |
|
3254 { |
|
3255 category = aMedia->ValueTObjectL<TMPXGeneralCategory>( KMPXMediaGeneralCategory ); |
|
3256 } |
|
3257 |
|
3258 if ( type == EMPXItem && category == EMPXCommand ) |
|
3259 { |
|
3260 |
|
3261 if ( aMedia->IsSupported( KMPXMediaGeneralTitle ) ) |
|
3262 { |
|
3263 |
|
3264 const TDesC& title = aMedia->ValueText( KMPXMediaGeneralTitle ); |
|
3265 if ( title.Compare( KNullDesC ) != 0 ) |
|
3266 { |
|
3267 aItem->SetTitleL( title ); |
|
3268 } |
|
3269 else |
|
3270 { |
|
3271 HBufC* unknownText = |
|
3272 StringLoader::LoadLC( R_MPX_COLLECTION_UNKNOWN ); |
|
3273 aItem->SetTitleL( *unknownText ); |
|
3274 CleanupStack::PopAndDestroy( unknownText ); |
|
3275 } |
|
3276 } |
|
3277 |
|
3278 if ( aMedia->IsSupported( KMPXMediaColDetailNumberOfItems ) ) |
|
3279 { |
|
3280 TInt songsCount = aMedia->ValueTObjectL<TInt>( KMPXMediaColDetailNumberOfItems ); |
|
3281 |
|
3282 HBufC* songsTitle = StringLoader::LoadLC( R_MPX_COLLECTION_DETAILS_NUMBER_OF_SONGS, songsCount ); |
|
3283 TPtr ptr = songsTitle->Des(); |
|
3284 AknTextUtils::LanguageSpecificNumberConversion( ptr ); |
|
3285 aItem->SetTextL( ptr ); |
|
3286 CleanupStack::PopAndDestroy( songsTitle ); |
|
3287 } |
|
3288 |
|
3289 // We can try to set icon too. |
|
3290 SetDetailIconShuffleL(); |
|
3291 res = ETrue; |
|
3292 } |
|
3293 |
|
3294 return res; |
|
3295 } |
|
3296 |
|
3297 // ----------------------------------------------------------------------------- |
|
3298 // Sets the current category. |
|
3299 // ----------------------------------------------------------------------------- |
|
3300 // |
|
3301 void CMPXCollectionViewHgContainer::SetCollectionContextL() |
|
3302 { |
|
3303 MPX_FUNC( "CMPXCollectionViewHgContainer::SetCollectionContextL" ); |
|
3304 |
|
3305 const CMPXMedia& media = iListBoxArray->ContainerMedia(); |
|
3306 |
|
3307 TMPXGeneralType containerType( EMPXNoType ); |
|
3308 if ( media.IsSupported( KMPXMediaGeneralType ) ) |
|
3309 { |
|
3310 containerType = media.ValueTObjectL<TMPXGeneralType>( KMPXMediaGeneralType ); |
|
3311 } |
|
3312 |
|
3313 TMPXGeneralCategory containerCategory( EMPXNoCategory ); |
|
3314 if ( media.IsSupported( KMPXMediaGeneralCategory ) ) |
|
3315 { |
|
3316 containerCategory = media.ValueTObjectL<TMPXGeneralCategory>( KMPXMediaGeneralCategory ); |
|
3317 } |
|
3318 MPX_DEBUG3( "CMPXCollectionViewHgContainer::SetCollectionContextL container type = %d, category = %d", |
|
3319 containerType, containerCategory ); |
|
3320 |
|
3321 iPodcastContext = EFalse; |
|
3322 TMPXPodcastCategory podcastCategory( EMPXUnknown ); |
|
3323 if ( media.IsSupported( KMPXMediaPodcastType ) ) |
|
3324 { |
|
3325 iPodcastContext = ETrue; |
|
3326 if ( media.IsSupported( KMPXMediaPodcastCategoryGroup ) ) |
|
3327 { |
|
3328 podcastCategory = media.ValueTObjectL<TMPXPodcastCategory>( KMPXMediaPodcastCategoryGroup ); |
|
3329 } |
|
3330 } |
|
3331 MPX_DEBUG3( "CMPXCommonContainerHitchcockImp::SetCollectionContextL container podcast = %d, category = %d", |
|
3332 iPodcastContext, podcastCategory ); |
|
3333 |
|
3334 iPrevContext = iContext; |
|
3335 |
|
3336 if( iListWidget ) |
|
3337 { |
|
3338 iListWidget->ClearFlags( CHgScroller::EHgScrollerKeyMarkingDisabled ); |
|
3339 } |
|
3340 if ( !iPodcastContext ) |
|
3341 { |
|
3342 if ( containerType == EMPXGroup ) |
|
3343 { |
|
3344 switch (containerCategory) |
|
3345 { |
|
3346 case EMPXCollection: |
|
3347 iContext = EContextGroupCollection; |
|
3348 if( iListWidget ) |
|
3349 { |
|
3350 iListWidget->SetFlags( CHgScroller::EHgScrollerKeyMarkingDisabled ); |
|
3351 } |
|
3352 break; |
|
3353 case EMPXArtist: |
|
3354 iContext = EContextGroupArtist; |
|
3355 break; |
|
3356 case EMPXAlbum: |
|
3357 iContext = EContextGroupAlbum; |
|
3358 break; |
|
3359 case EMPXPlaylist: |
|
3360 iContext = EContextGroupPlaylist; |
|
3361 break; |
|
3362 case EMPXSong: |
|
3363 iContext = EContextGroupSong; |
|
3364 break; |
|
3365 case EMPXGenre: |
|
3366 iContext = EContextGroupGenre; |
|
3367 break; |
|
3368 case EMPXComposer: |
|
3369 iContext = EContextGroupComposer; |
|
3370 break; |
|
3371 default: |
|
3372 User::Leave(KErrNotSupported); |
|
3373 break; |
|
3374 } |
|
3375 } |
|
3376 else if ( containerType == EMPXItem ) |
|
3377 { |
|
3378 switch (containerCategory) |
|
3379 { |
|
3380 case EMPXArtist: |
|
3381 iContext = EContextItemArtist; |
|
3382 break; |
|
3383 case EMPXAlbum: |
|
3384 iContext = EContextItemAlbum; |
|
3385 break; |
|
3386 case EMPXPlaylist: |
|
3387 iContext = EContextItemPlaylist; |
|
3388 break; |
|
3389 case EMPXSong: |
|
3390 iContext = EContextItemSong; |
|
3391 break; |
|
3392 case EMPXGenre: |
|
3393 iContext = EContextItemGenre; |
|
3394 break; |
|
3395 case EMPXComposer: |
|
3396 iContext = EContextItemComposer; |
|
3397 break; |
|
3398 default: |
|
3399 User::Leave(KErrNotSupported); |
|
3400 break; |
|
3401 } |
|
3402 } |
|
3403 else if ( containerType == EMPXOtherType ) |
|
3404 { |
|
3405 |
|
3406 if (containerCategory == EMPXAlbum) |
|
3407 { |
|
3408 //iContext = EContextItemAlbum2; |
|
3409 } |
|
3410 |
|
3411 } |
|
3412 } |
|
3413 else |
|
3414 { |
|
3415 if ( (containerType == EMPXGroup) && (podcastCategory == EMPXTitle) ) |
|
3416 { |
|
3417 iContext = EContextGroupPodcast; |
|
3418 if( iListWidget ) |
|
3419 { |
|
3420 iListWidget->SetFlags( CHgScroller::EHgScrollerKeyMarkingDisabled ); |
|
3421 } |
|
3422 } |
|
3423 else if ( (containerType == EMPXItem) && (podcastCategory == EMPXEpisode) ) |
|
3424 { |
|
3425 iContext = EContextItemPodcast; |
|
3426 } |
|
3427 else |
|
3428 { |
|
3429 User::Leave(KErrNotSupported); |
|
3430 } |
|
3431 } |
|
3432 } |
|
3433 |
|
3434 |
|
3435 |
|
3436 void CMPXCollectionViewHgContainer::TNReadyL(TInt aError, CFbsBitmap* aBitmap, CFbsBitmap* /*aMask*/, TInt aIndex) |
|
3437 { |
|
3438 if ( aError == KErrNone ) |
|
3439 { |
|
3440 const CMPXMediaArray& mediaArray = iListBoxArray->MediaArray(); |
|
3441 CMPXMedia* currentMedia( mediaArray.AtL( aIndex ) ); |
|
3442 if ( currentMedia->IsSupported( KMPXMediaGeneralId ) ) |
|
3443 { |
|
3444 if ( aBitmap ) |
|
3445 { |
|
3446 CGulIcon* icon = CGulIcon::NewL(aBitmap, NULL); |
|
3447 |
|
3448 switch (iCurrentViewType) |
|
3449 { |
|
3450 case EMPXViewCoverFlow: |
|
3451 case EMPXViewTBone: |
|
3452 { |
|
3453 iMediaWall->ItemL(aIndex).SetIcon(icon); |
|
3454 iThumbnailReqMap[aIndex] = ETrue; |
|
3455 break; |
|
3456 } |
|
3457 case EMPXViewList: |
|
3458 { |
|
3459 iListWidget->ItemL(aIndex).SetIcon(icon); |
|
3460 iThumbnailReqMap[aIndex] = ETrue; |
|
3461 break; |
|
3462 } |
|
3463 default: |
|
3464 break; |
|
3465 } |
|
3466 |
|
3467 RefreshL(aIndex); |
|
3468 } |
|
3469 } |
|
3470 } |
|
3471 else |
|
3472 { |
|
3473 //no albumart supported |
|
3474 SetDefaultIconL(aIndex); |
|
3475 RefreshL(aIndex); |
|
3476 } |
|
3477 } |
|
3478 |
|
3479 // ---------------------------------------------------------------------------- |
|
3480 // Clears the TN request if any |
|
3481 // ---------------------------------------------------------------------------- |
|
3482 void CMPXCollectionViewHgContainer::CancelTNRequest() |
|
3483 { |
|
3484 MPX_FUNC("CMPXCollectionViewHgContainer::CancelTNRequest"); |
|
3485 |
|
3486 } |
|
3487 |
|
3488 |
|
3489 // ---------------------------------------------------------------------------- |
|
3490 // Construct a collection path with the current selection and open the |
|
3491 // path to start playback. |
|
3492 // ---------------------------------------------------------------------------- |
|
3493 void CMPXCollectionViewHgContainer::UpdatePathAndOpenL(TInt aIndex, TBool aSelectAll) |
|
3494 { |
|
3495 MPX_FUNC("CMPXCollectionViewHgContainer::UpdatePathAndOpenL"); |
|
3496 |
|
3497 RArray<TMPXItemId> ids; |
|
3498 CleanupClosePushL(ids); |
|
3499 const CMPXMediaArray& albums = iListBoxArray->MediaArray(); |
|
3500 CMPXMedia* album( albums.AtL( iSelectedAlbumIndex ) ); |
|
3501 |
|
3502 if( album->IsSupported(KMPXMediaArrayContents) ) |
|
3503 { |
|
3504 |
|
3505 // Get the current path |
|
3506 CMPXCollectionPath* cpath = iCollectionUtility->Collection().PathL(); |
|
3507 CleanupStack::PushL( cpath ); |
|
3508 |
|
3509 MPX_DEBUG_PATH(*cpath); |
|
3510 |
|
3511 if (cpath->Levels() == 3) |
|
3512 { |
|
3513 // go back one level before amending path with new levels |
|
3514 cpath->Back(); |
|
3515 } |
|
3516 |
|
3517 else if (cpath->Levels() == 4) |
|
3518 { |
|
3519 // go back 2 levels before appending new level |
|
3520 cpath->Back(); |
|
3521 cpath->Back(); |
|
3522 } |
|
3523 |
|
3524 |
|
3525 TInt albumCount = albums.Count(); |
|
3526 for (TInt i=0; i<albumCount; ++i) |
|
3527 { |
|
3528 CMPXMedia* album = albums.AtL(i); |
|
3529 const TMPXItemId id = album->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId); |
|
3530 ids.AppendL(id); |
|
3531 } |
|
3532 cpath->AppendL(ids.Array()); // top level items |
|
3533 cpath->Set(iSelectedAlbumIndex); |
|
3534 ids.Reset(); |
|
3535 |
|
3536 const CMPXMediaArray* songs = album->Value<CMPXMediaArray>(KMPXMediaArrayContents); |
|
3537 User::LeaveIfNull(const_cast<CMPXMediaArray*>(songs)); |
|
3538 TInt count = songs->Count(); |
|
3539 for (TInt i=0; i<count; ++i) |
|
3540 { |
|
3541 CMPXMedia* song = songs->AtL(i); |
|
3542 const TMPXItemId id = song->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId); |
|
3543 ids.AppendL(id); |
|
3544 } |
|
3545 |
|
3546 cpath->AppendL(ids.Array()); // top level items |
|
3547 |
|
3548 TBool shuffle(EFalse); |
|
3549 |
|
3550 if ( aSelectAll ) // Plays all songs without shuffle |
|
3551 { |
|
3552 cpath->Set(0); |
|
3553 } |
|
3554 else |
|
3555 { |
|
3556 if ( count > 1 ) // We need to adjust in case aIndex is the shuffle item |
|
3557 { |
|
3558 if ( aIndex == 0 ) // Plays all songs shuffled |
|
3559 { |
|
3560 shuffle = ETrue; |
|
3561 TTime time; |
|
3562 time.UniversalTime(); |
|
3563 TInt64 seed = time.Int64(); |
|
3564 TInt randIndex = Math::Rand(seed) % count; |
|
3565 cpath->Set(randIndex); |
|
3566 } |
|
3567 else |
|
3568 { |
|
3569 cpath->Set(aIndex-1); // actual selection |
|
3570 } |
|
3571 } |
|
3572 else |
|
3573 { |
|
3574 cpath->Set(aIndex); |
|
3575 } |
|
3576 } |
|
3577 |
|
3578 MPX_DEBUG_PATH(*cpath); |
|
3579 |
|
3580 TMPXPlaybackState pbState( iPlaybackUtility->StateL() ); |
|
3581 if ( pbState == EPbStatePlaying || pbState == EPbStatePaused ) |
|
3582 { |
|
3583 if ( IsPlayingCurrentIndexL(cpath) && !shuffle ) |
|
3584 { |
|
3585 if ( pbState == EPbStatePaused ) |
|
3586 { |
|
3587 iPlaybackUtility->CommandL( EPbCmdPlay ); |
|
3588 } |
|
3589 iPlaybackUtility->SetL( EPbPropertyRandomMode, shuffle ); |
|
3590 iView->ProcessCommandL( EMPXCmdGoToNowPlaying ); |
|
3591 } |
|
3592 else |
|
3593 { |
|
3594 iPlaylistHelper->InitPlaylistL(*cpath, shuffle); |
|
3595 } |
|
3596 } |
|
3597 else |
|
3598 { |
|
3599 iPlaylistHelper->InitPlaylistL(*cpath, shuffle); |
|
3600 } |
|
3601 |
|
3602 CleanupStack::PopAndDestroy( cpath ); |
|
3603 |
|
3604 // We need to restore the status pane before switching to playback view. |
|
3605 if (!((CAknAppUi*)iCoeEnv->AppUi())->StatusPane()->IsVisible()) |
|
3606 ((CAknAppUi*)iCoeEnv->AppUi())->StatusPane()->MakeVisible(ETrue); |
|
3607 |
|
3608 } |
|
3609 CleanupStack::PopAndDestroy(&ids); |
|
3610 } |
|
3611 |
|
3612 |
|
3613 // ---------------------------------------------------------------------------- |
|
3614 // Construct a collection path with the current selection and construct a |
|
3615 // playlist from path to start playback. |
|
3616 // ---------------------------------------------------------------------------- |
|
3617 void CMPXCollectionViewHgContainer::UpdatePathAndOpenPlaylistL( |
|
3618 const CMPXMedia& aFindResult ) |
|
3619 { |
|
3620 MPX_FUNC("CMPXCollectionViewHgContainer::UpdatePathAndOpenPlaylistL"); |
|
3621 |
|
3622 TInt selectedIndex(0); |
|
3623 CHgScroller* listWidget = CurrentListWidget(); |
|
3624 if ( iContext == EContextGroupPlaylist || |
|
3625 iContext == EContextGroupGenre && listWidget ) |
|
3626 { |
|
3627 selectedIndex = listWidget->SelectedIndex(); |
|
3628 } |
|
3629 else |
|
3630 { |
|
3631 return; |
|
3632 } |
|
3633 |
|
3634 RArray<TMPXItemId> ids; |
|
3635 CleanupClosePushL(ids); |
|
3636 |
|
3637 const CMPXMediaArray& mediaArray = iListBoxArray->MediaArray(); |
|
3638 |
|
3639 // Get the current path |
|
3640 CMPXCollectionPath* cpath = iCollectionUtility->Collection().PathL(); |
|
3641 CleanupStack::PushL( cpath ); |
|
3642 |
|
3643 MPX_DEBUG_PATH(*cpath); |
|
3644 if (cpath->Levels() == 3) |
|
3645 { |
|
3646 // go back one level before amending path with new levels |
|
3647 cpath->Back(); |
|
3648 } |
|
3649 |
|
3650 TInt mediaCount = mediaArray.Count(); |
|
3651 for (TInt i=0; i<mediaCount; ++i) |
|
3652 { |
|
3653 CMPXMedia* mediaItem = mediaArray.AtL(i); |
|
3654 const TMPXItemId id = mediaItem->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId); |
|
3655 ids.AppendL(id); |
|
3656 } |
|
3657 cpath->AppendL(ids.Array()); // top level items |
|
3658 cpath->Set(selectedIndex); // set the selected item |
|
3659 ids.Reset(); |
|
3660 |
|
3661 CMPXMediaArray* songArray(const_cast<CMPXMediaArray*>( aFindResult.Value<CMPXMediaArray>( |
|
3662 KMPXMediaArrayContents ) ) ); |
|
3663 User::LeaveIfNull( songArray ); |
|
3664 |
|
3665 TInt count = songArray->Count(); |
|
3666 for (TInt i=0; i<count; ++i) |
|
3667 { |
|
3668 CMPXMedia* song = songArray->AtL(i); |
|
3669 const TMPXItemId id = song->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId); |
|
3670 ids.AppendL(id); |
|
3671 } |
|
3672 |
|
3673 cpath->AppendL(ids.Array()); // top level items of songs |
|
3674 cpath->Set(0); // select 1st song |
|
3675 |
|
3676 MPX_DEBUG_PATH(*cpath); |
|
3677 |
|
3678 TMPXPlaybackState pbState( iPlaybackUtility->StateL() ); |
|
3679 if ( pbState == EPbStatePlaying || pbState == EPbStatePaused ) |
|
3680 { |
|
3681 if ( IsPlayingCurrentIndexL(cpath) ) |
|
3682 { |
|
3683 if ( pbState == EPbStatePaused ) |
|
3684 { |
|
3685 iPlaybackUtility->CommandL( EPbCmdPlay ); |
|
3686 } |
|
3687 iPlaybackUtility->SetL( EPbPropertyRandomMode, EFalse ); |
|
3688 iView->ProcessCommandL( EMPXCmdGoToNowPlaying ); |
|
3689 } |
|
3690 else |
|
3691 { |
|
3692 iPlaylistHelper->InitPlaylistL(*cpath, EFalse); |
|
3693 } |
|
3694 } |
|
3695 else |
|
3696 { |
|
3697 iPlaylistHelper->InitPlaylistL(*cpath, EFalse); |
|
3698 } |
|
3699 |
|
3700 CleanupStack::PopAndDestroy( cpath ); |
|
3701 |
|
3702 // We need to restore the status pane before switching to playback view. |
|
3703 if (!((CAknAppUi*)iCoeEnv->AppUi())->StatusPane()->IsVisible()) |
|
3704 ((CAknAppUi*)iCoeEnv->AppUi())->StatusPane()->MakeVisible(ETrue); |
|
3705 |
|
3706 CleanupStack::PopAndDestroy(&ids); |
|
3707 } |
|
3708 |
|
3709 |
|
3710 // ---------------------------------------------------------------------------- |
|
3711 // Handle opening the album to show songs |
|
3712 // ---------------------------------------------------------------------------- |
|
3713 void CMPXCollectionViewHgContainer::OpenAlbumL(TInt aIndex) |
|
3714 { |
|
3715 MPX_FUNC("CMPXCollectionViewHgContainer::OpenAlbumL"); |
|
3716 |
|
3717 const CMPXMediaArray& mediaArray = iListBoxArray->MediaArray(); |
|
3718 CMPXMedia* album( mediaArray.AtL( aIndex ) ); |
|
3719 if( album->IsSupported(KMPXMediaArrayContents) ) |
|
3720 { |
|
3721 // We've previously fetched the songs for this album so |
|
3722 // all we do now is populate the list with the song titles. |
|
3723 if( iCurrentViewType == EMPXViewCoverFlow ) |
|
3724 { |
|
3725 ShowAlbumSongsDialogL(*album); |
|
3726 } |
|
3727 else |
|
3728 { |
|
3729 ShowAlbumSongsL(*album); |
|
3730 } |
|
3731 } |
|
3732 else |
|
3733 { |
|
3734 // We'll find the songs for the selected album |
|
3735 iFindOp = EMPXOpenAlbum; |
|
3736 FindAlbumSongsL(aIndex); |
|
3737 } |
|
3738 |
|
3739 } |
|
3740 |
|
3741 // ---------------------------------------------------------------------------- |
|
3742 // Handle preparing playback of the selected album |
|
3743 // ---------------------------------------------------------------------------- |
|
3744 void CMPXCollectionViewHgContainer::PlayAlbumL(TInt aIndex) |
|
3745 { |
|
3746 MPX_FUNC("CMPXCollectionViewHgContainer::PlayAlbumL"); |
|
3747 |
|
3748 const CMPXMediaArray& mediaArray = iListBoxArray->MediaArray(); |
|
3749 CMPXMedia* album( mediaArray.AtL( aIndex ) ); |
|
3750 if( album->IsSupported(KMPXMediaArrayContents) ) |
|
3751 { |
|
3752 // We've previously fetched the songs for this album so |
|
3753 // all we do now is construct a playlist for the album |
|
3754 UpdatePathAndOpenL(0, ETrue); |
|
3755 } |
|
3756 else |
|
3757 { |
|
3758 // We'll find the songs for the selected album |
|
3759 iFindOp = EMPXPlayAlbum; |
|
3760 FindAlbumSongsL(aIndex); |
|
3761 } |
|
3762 } |
|
3763 |
|
3764 // ---------------------------------------------------------------------------- |
|
3765 // Handle preparing playback of the selected playlist |
|
3766 // ---------------------------------------------------------------------------- |
|
3767 void CMPXCollectionViewHgContainer::PlayPlaylistL(TInt aIndex) |
|
3768 { |
|
3769 MPX_FUNC("CMPXCollectionViewHgContainer::PlayPlaylistL"); |
|
3770 |
|
3771 // We'll find the songs for the selected playlist |
|
3772 iFindOp = EMPXPlayPlaylist; |
|
3773 FindPlaylistSongsL(aIndex); |
|
3774 } |
|
3775 |
|
3776 // ---------------------------------------------------------------------------- |
|
3777 // Handle preparing playback of the selected genre |
|
3778 // ---------------------------------------------------------------------------- |
|
3779 void CMPXCollectionViewHgContainer::PlayGenreL(TInt aIndex) |
|
3780 { |
|
3781 MPX_FUNC("CMPXCollectionViewHgContainer::PlayGenreL"); |
|
3782 |
|
3783 // We'll find the songs for the selected genre |
|
3784 iFindOp = EMPXPlayGenre; |
|
3785 FindGenreSongsL(aIndex); |
|
3786 } |
|
3787 |
|
3788 // ---------------------------------------------------------------------------- |
|
3789 // Check if shuffle item is selected and if so, initialize shuffle playback. |
|
3790 // ---------------------------------------------------------------------------- |
|
3791 TBool CMPXCollectionViewHgContainer::ShufflePlayAllL(TInt aIndex) |
|
3792 { |
|
3793 MPX_FUNC("CMPXCollectionViewHgContainer::ShufflePlayAllL"); |
|
3794 |
|
3795 TBool shuffle(EFalse); |
|
3796 const CMPXMediaArray& mediaArray = iListBoxArray->MediaArray(); |
|
3797 |
|
3798 CMPXMedia* currentMedia( mediaArray.AtL( aIndex ) ); |
|
3799 |
|
3800 TMPXGeneralType type( EMPXNoType ); |
|
3801 if ( currentMedia->IsSupported( KMPXMediaGeneralType ) ) |
|
3802 { |
|
3803 type = currentMedia->ValueTObjectL<TMPXGeneralType>( KMPXMediaGeneralType ); |
|
3804 } |
|
3805 |
|
3806 TMPXGeneralCategory category( EMPXNoCategory ); |
|
3807 if ( currentMedia->IsSupported( KMPXMediaGeneralCategory ) ) |
|
3808 { |
|
3809 category = currentMedia->ValueTObjectL<TMPXGeneralCategory>( KMPXMediaGeneralCategory ); |
|
3810 } |
|
3811 |
|
3812 if ( type == EMPXItem && category == EMPXCommand ) |
|
3813 { |
|
3814 shuffle = ETrue; |
|
3815 iPlaylistHelper->InitPlaylistL(shuffle); |
|
3816 } |
|
3817 |
|
3818 return shuffle; |
|
3819 } |
|
3820 |
|
3821 // ----------------------------------------------------------------------------- |
|
3822 // CMPXCollectionViewHgContainer::FindAlbumSongsL |
|
3823 // Find all the songs for the selected album index. |
|
3824 // If songs are already in the media array, we don't need to fetch them again. |
|
3825 // ----------------------------------------------------------------------------- |
|
3826 // |
|
3827 void CMPXCollectionViewHgContainer::FindAlbumSongsL( |
|
3828 TInt aIndex ) |
|
3829 { |
|
3830 MPX_FUNC( "CMPXCollectionViewHgContainer::FindAlbumSongsL" ); |
|
3831 const CMPXMediaArray& mediaArray = iListBoxArray->MediaArray(); |
|
3832 CMPXMedia* album( mediaArray.AtL( aIndex ) ); |
|
3833 |
|
3834 // Fetch the songs for the selected album |
|
3835 TMPXItemId albumId = album->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId); |
|
3836 CMPXMedia* findCriteria = CMPXMedia::NewL(); |
|
3837 CleanupStack::PushL( findCriteria ); |
|
3838 findCriteria->SetTObjectValueL<TMPXGeneralType>( KMPXMediaGeneralType, EMPXGroup ); |
|
3839 findCriteria->SetTObjectValueL<TMPXGeneralCategory>( KMPXMediaGeneralCategory, EMPXSong ); |
|
3840 findCriteria->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, albumId ); |
|
3841 RArray<TMPXAttribute> attrs; |
|
3842 CleanupClosePushL( attrs ); |
|
3843 attrs.Append( TMPXAttribute( KMPXMediaIdGeneral, |
|
3844 EMPXMediaGeneralTitle | |
|
3845 EMPXMediaGeneralId | |
|
3846 EMPXMediaGeneralType | |
|
3847 EMPXMediaGeneralCategory | |
|
3848 EMPXMediaGeneralFlags ) ); |
|
3849 attrs.Append( KMPXMediaMusicAlbumTrack ); |
|
3850 |
|
3851 |
|
3852 iCollectionUtility->Collection().FindAllL( *findCriteria, attrs.Array(), *this ); |
|
3853 CleanupStack::PopAndDestroy( &attrs ); |
|
3854 CleanupStack::PopAndDestroy( findCriteria ); |
|
3855 |
|
3856 } |
|
3857 |
|
3858 // ----------------------------------------------------------------------------- |
|
3859 // CMPXCollectionViewHgContainer::FindPlaylistSongsL |
|
3860 // Find all the songs for the selected playlist index. |
|
3861 // ----------------------------------------------------------------------------- |
|
3862 // |
|
3863 void CMPXCollectionViewHgContainer::FindPlaylistSongsL( |
|
3864 TInt aIndex ) |
|
3865 { |
|
3866 MPX_FUNC( "CMPXCollectionViewHgContainer::FindPlaylistSongsL" ); |
|
3867 const CMPXMediaArray& mediaArray = iListBoxArray->MediaArray(); |
|
3868 CMPXMedia* playlist( mediaArray.AtL( aIndex ) ); |
|
3869 |
|
3870 // Fetch the songs for the selected album |
|
3871 TMPXItemId playlistId = playlist->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId); |
|
3872 CMPXMedia* findCriteria = CMPXMedia::NewL(); |
|
3873 CleanupStack::PushL( findCriteria ); |
|
3874 findCriteria->SetTObjectValueL<TMPXGeneralType>( KMPXMediaGeneralType, EMPXGroup ); |
|
3875 findCriteria->SetTObjectValueL<TMPXGeneralCategory>( KMPXMediaGeneralCategory, EMPXSong ); |
|
3876 findCriteria->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, playlistId ); |
|
3877 RArray<TMPXAttribute> attrs; |
|
3878 CleanupClosePushL( attrs ); |
|
3879 attrs.Append( TMPXAttribute( KMPXMediaIdGeneral, |
|
3880 EMPXMediaGeneralTitle | |
|
3881 EMPXMediaGeneralId | |
|
3882 EMPXMediaGeneralType | |
|
3883 EMPXMediaGeneralCategory | |
|
3884 EMPXMediaGeneralFlags ) ); |
|
3885 |
|
3886 iCollectionUtility->Collection().FindAllL( *findCriteria, attrs.Array(), *this ); |
|
3887 CleanupStack::PopAndDestroy( &attrs ); |
|
3888 CleanupStack::PopAndDestroy( findCriteria ); |
|
3889 |
|
3890 } |
|
3891 |
|
3892 // ----------------------------------------------------------------------------- |
|
3893 // CMPXCollectionViewHgContainer::FindGenreSongsL |
|
3894 // Find all the songs for the selected genre index. |
|
3895 // ----------------------------------------------------------------------------- |
|
3896 // |
|
3897 void CMPXCollectionViewHgContainer::FindGenreSongsL( |
|
3898 TInt aIndex ) |
|
3899 { |
|
3900 MPX_FUNC( "CMPXCollectionViewHgContainer::FindPlaylistSongsL" ); |
|
3901 const CMPXMediaArray& mediaArray = iListBoxArray->MediaArray(); |
|
3902 CMPXMedia* genre( mediaArray.AtL( aIndex ) ); |
|
3903 |
|
3904 // Fetch the songs for the selected genre |
|
3905 TMPXItemId genreId = genre->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId); |
|
3906 CMPXMedia* findCriteria = CMPXMedia::NewL(); |
|
3907 CleanupStack::PushL( findCriteria ); |
|
3908 findCriteria->SetTObjectValueL<TMPXGeneralType>( KMPXMediaGeneralType, EMPXGroup ); |
|
3909 findCriteria->SetTObjectValueL<TMPXGeneralCategory>( KMPXMediaGeneralCategory, EMPXSong ); |
|
3910 findCriteria->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, genreId ); |
|
3911 RArray<TMPXAttribute> attrs; |
|
3912 CleanupClosePushL( attrs ); |
|
3913 attrs.Append( TMPXAttribute( KMPXMediaIdGeneral, |
|
3914 EMPXMediaGeneralTitle | |
|
3915 EMPXMediaGeneralId | |
|
3916 EMPXMediaGeneralType | |
|
3917 EMPXMediaGeneralCategory | |
|
3918 EMPXMediaGeneralFlags ) ); |
|
3919 |
|
3920 iCollectionUtility->Collection().FindAllL( *findCriteria, attrs.Array(), *this ); |
|
3921 CleanupStack::PopAndDestroy( &attrs ); |
|
3922 CleanupStack::PopAndDestroy( findCriteria ); |
|
3923 |
|
3924 } |
|
3925 |
|
3926 |
|
3927 // --------------------------------------------------------------------------- |
|
3928 // From MMPXCollectionFindObserver |
|
3929 // Handle callback for "find" operation |
|
3930 // Songs are saved back into the media array for subsequent use. |
|
3931 // --------------------------------------------------------------------------- |
|
3932 // |
|
3933 void CMPXCollectionViewHgContainer::HandleFindAllL( |
|
3934 const CMPXMedia& aResults, |
|
3935 TBool /*aComplete*/, |
|
3936 TInt aError ) |
|
3937 { |
|
3938 MPX_DEBUG2( "-->CMPXCollectionViewHgContainer::HandleFindAllL aError = %d", aError ); |
|
3939 |
|
3940 if ( aError == KErrNone ) |
|
3941 { |
|
3942 if ( iFindOp == EMPXOpenAlbum || iFindOp == EMPXPlayAlbum ) |
|
3943 { |
|
3944 CMPXMediaArray* songArray(const_cast<CMPXMediaArray*>( aResults.Value<CMPXMediaArray>( |
|
3945 KMPXMediaArrayContents ) ) ); |
|
3946 User::LeaveIfNull( songArray ); |
|
3947 |
|
3948 // save the songs to the album so that we don't need to find them again |
|
3949 // if the same album is selected again. |
|
3950 if ( songArray->Count() ) |
|
3951 { |
|
3952 const CMPXMediaArray& albumsArray = iListBoxArray->MediaArray(); |
|
3953 CMPXMedia* albumMedia( albumsArray.AtL( iSelectedAlbumIndex ) ); |
|
3954 albumMedia->SetCObjectValueL(KMPXMediaArrayContents, songArray); |
|
3955 albumMedia->SetTObjectValueL<TInt>(KMPXMediaArrayCount, songArray->Count()); |
|
3956 } |
|
3957 |
|
3958 if ( iFindOp == EMPXOpenAlbum ) |
|
3959 { |
|
3960 if( iCurrentViewType == EMPXViewCoverFlow ) |
|
3961 { |
|
3962 ShowAlbumSongsDialogL( aResults ); |
|
3963 } |
|
3964 else |
|
3965 { |
|
3966 ShowAlbumSongsL( aResults ); |
|
3967 } |
|
3968 } |
|
3969 else if ( iFindOp == EMPXPlayAlbum ) |
|
3970 { |
|
3971 PlayAlbumL(iSelectedAlbumIndex); |
|
3972 } |
|
3973 iFindOp = EMPXNoOp; |
|
3974 } |
|
3975 else if ( iFindOp == EMPXPlayPlaylist || iFindOp == EMPXPlayGenre ) |
|
3976 { |
|
3977 iFindOp = EMPXNoOp; |
|
3978 UpdatePathAndOpenPlaylistL(aResults); |
|
3979 } |
|
3980 } |
|
3981 else |
|
3982 { |
|
3983 // We don't do anything if there's error |
|
3984 return; |
|
3985 } |
|
3986 } |
|
3987 |
|
3988 // --------------------------------------------------------------------------- |
|
3989 // Check if the current playing song is the same as the selected song. |
|
3990 // --------------------------------------------------------------------------- |
|
3991 // |
|
3992 TBool CMPXCollectionViewHgContainer::IsPlayingCurrentIndexL(CMPXCollectionPath* aPath) |
|
3993 { |
|
3994 MPX_FUNC( "CMPXCollectionViewHgContainer::CurrentPlaybackIndexL" ); |
|
3995 TBool ret( EFalse ); |
|
3996 |
|
3997 MMPXSource* source( iPlaybackUtility->Source() ); |
|
3998 if ( source ) |
|
3999 { |
|
4000 CMPXCollectionPlaylist* playlist( source->PlaylistL() ); |
|
4001 if ( playlist ) |
|
4002 { |
|
4003 CleanupStack::PushL( playlist ); |
|
4004 CMPXCollectionPath* pbPath( |
|
4005 CMPXCollectionPath::NewL( playlist->Path() ) ); |
|
4006 CleanupStack::PushL( pbPath ); |
|
4007 MPX_DEBUG_PATH(*aPath); |
|
4008 MPX_DEBUG_PATH(*pbPath); |
|
4009 |
|
4010 TInt playbackPathCount( pbPath->Levels() ); |
|
4011 if ( aPath->Levels() == playbackPathCount ) |
|
4012 { |
|
4013 TBool isEqual( ETrue ); |
|
4014 for ( TInt i = 0; i < playbackPathCount - 1; i++ ) |
|
4015 { |
|
4016 if ( aPath->Id( i ) != pbPath->Id( i ) ) |
|
4017 { |
|
4018 isEqual = EFalse; |
|
4019 break; |
|
4020 } |
|
4021 } |
|
4022 if ( isEqual ) |
|
4023 { |
|
4024 if (pbPath->Index() == aPath->Index() ) |
|
4025 ret = ETrue; |
|
4026 } |
|
4027 } |
|
4028 CleanupStack::PopAndDestroy( pbPath ); |
|
4029 CleanupStack::PopAndDestroy( playlist ); |
|
4030 } |
|
4031 } |
|
4032 |
|
4033 return ret; |
|
4034 } |
|
4035 |
|
4036 // ----------------------------------------------------------------------------- |
|
4037 // Shows the album songs in songs dialog. |
|
4038 // ----------------------------------------------------------------------------- |
|
4039 // |
|
4040 void CMPXCollectionViewHgContainer::ShowAlbumSongsDialogL( const CMPXMedia& aResults ) |
|
4041 { |
|
4042 CAknSinglePopupMenuStyleListBox* listBox = new ( ELeave ) CAknSinglePopupMenuStyleListBox; |
|
4043 CleanupStack::PushL( listBox ); |
|
4044 |
|
4045 CAknPopupList* dialog = CAknPopupList::NewL(listBox, R_MPX_COLLECTION_ALBUMSONGS_LIST_CBA, |
|
4046 AknPopupLayouts::EDynMenuWindow ); |
|
4047 |
|
4048 listBox->ConstructL( dialog, |
|
4049 EAknListBoxSelectionList | EAknListBoxScrollBarSizeExcluded ); |
|
4050 |
|
4051 listBox->CreateScrollBarFrameL( ETrue ); |
|
4052 listBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, |
|
4053 CEikScrollBarFrame::EAuto ); |
|
4054 |
|
4055 // Set title |
|
4056 if ( iSelectedMediaInAlbumView && iSelectedMediaInAlbumView->IsSupported( KMPXMediaMusicAlbum ) ) |
|
4057 { |
|
4058 const TDesC& album = iSelectedMediaInAlbumView->ValueText( KMPXMediaMusicAlbum ); |
|
4059 if ( album.Compare( KNullDesC ) != 0 ) |
|
4060 { |
|
4061 dialog->SetTitleL( album ); |
|
4062 } |
|
4063 } |
|
4064 |
|
4065 CMPXMediaArray* songArray(const_cast<CMPXMediaArray*>( aResults.Value<CMPXMediaArray>( |
|
4066 KMPXMediaArrayContents ) ) ); |
|
4067 User::LeaveIfNull( songArray ); |
|
4068 TInt songCount = songArray->Count(); |
|
4069 |
|
4070 CDesC16ArrayFlat* songList = new (ELeave) CDesC16ArrayFlat(songCount); |
|
4071 |
|
4072 if ( songCount > 1 ) |
|
4073 { |
|
4074 songList->AppendL( _L("Shuffle All") ); |
|
4075 } |
|
4076 |
|
4077 for ( TInt i = 0; i < songCount; i++ ) |
|
4078 { |
|
4079 // Just get the exiting item and update the fields + icon. |
|
4080 CMPXMedia* currentMedia( songArray->AtL( i ) ); |
|
4081 |
|
4082 if ( currentMedia->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) == |
|
4083 KMPXInvalidItemId ) |
|
4084 { |
|
4085 break; |
|
4086 } |
|
4087 if ( currentMedia->IsSupported( KMPXMediaGeneralTitle ) ) |
|
4088 { |
|
4089 const TDesC& title = currentMedia->ValueText( KMPXMediaGeneralTitle ); |
|
4090 songList->AppendL( title ); |
|
4091 } |
|
4092 } |
|
4093 |
|
4094 CTextListBoxModel* model = listBox->Model(); |
|
4095 model->SetItemTextArray( songList ); |
|
4096 model->SetOwnershipType( ELbmOwnsItemArray ); |
|
4097 TBool play = dialog->ExecuteLD(); |
|
4098 TInt index = listBox->CurrentItemIndex(); |
|
4099 if( play ) |
|
4100 { |
|
4101 // If item in list was opened, we only play the selected one. |
|
4102 SaveSelectedAlbumItemL(iSelectedAlbumIndex); |
|
4103 // Open the selected song of album |
|
4104 UpdatePathAndOpenL(index); |
|
4105 } |
|
4106 else |
|
4107 { |
|
4108 // Do nothing if cancel was pressed. |
|
4109 } |
|
4110 |
|
4111 CleanupStack::PopAndDestroy( listBox ); |
|
4112 |
|
4113 // Close mediawall "flip animation" |
|
4114 iMediaWall->StartOpeningAnimationL( EFalse ); |
|
4115 } |
|
4116 |
|
4117 |
|
4118 // ----------------------------------------------------------------------------- |
|
4119 // Shows the album songs in the tbone list. |
|
4120 // ----------------------------------------------------------------------------- |
|
4121 // |
|
4122 void CMPXCollectionViewHgContainer::ShowAlbumSongsL( const CMPXMedia& aAlbum ) |
|
4123 { |
|
4124 |
|
4125 CMPXMediaArray* albumSongs = |
|
4126 const_cast<CMPXMediaArray*>(aAlbum.Value<CMPXMediaArray>( KMPXMediaArrayContents ) ); |
|
4127 TInt songCount = albumSongs->Count(); |
|
4128 TInt listSize = songCount; |
|
4129 TInt indexAddition = 0; |
|
4130 |
|
4131 CHgScroller* currentList = CurrentListWidget(); |
|
4132 User::LeaveIfNull( currentList ); |
|
4133 |
|
4134 if( currentList->ItemCount() > 1 ) |
|
4135 { |
|
4136 // There might be shuffle icon in the first item so lets reset it. |
|
4137 currentList->ItemL(0).SetIcon( NULL ); |
|
4138 } |
|
4139 if( songCount > 1 ) |
|
4140 { |
|
4141 listSize++; |
|
4142 indexAddition = 1; |
|
4143 } |
|
4144 // Add space for shuffle item if list contains more than one item. |
|
4145 currentList->ResizeL( listSize ); |
|
4146 |
|
4147 for ( TInt i = 0; i < songCount ; i++ ) |
|
4148 { |
|
4149 // Just get the exiting item and update the fields + icon. |
|
4150 CMPXMedia* song( albumSongs->AtL( i ) ); |
|
4151 |
|
4152 if ( song->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) == |
|
4153 KMPXInvalidItemId ) |
|
4154 { |
|
4155 break; |
|
4156 } |
|
4157 CHgItem* item = ¤tList->ItemL(i+indexAddition); |
|
4158 |
|
4159 // Just get the exiting item and update the fields + icon. |
|
4160 SetSongTitleL( item, song ); |
|
4161 // TODO, david has removed this line???? |
|
4162 // AddDetailToDisplayedItemL( item, song, i ); |
|
4163 //David: AddDetailToDisplayedItemL( item, currentMedia, i ); is broken |
|
4164 // will need to be fixed. |
|
4165 } |
|
4166 |
|
4167 if( songCount > 1 ) |
|
4168 { |
|
4169 SetShuffleItemToListL( currentList ); |
|
4170 } |
|
4171 currentList->SetSelectedIndex( 0 ); |
|
4172 currentList->SetFocus(ETrue, EDrawNow); |
|
4173 currentList->DrawNow(); |
|
4174 |
|
4175 } |
|
4176 |
|
4177 // ---------------------------------------------------------------------------- |
|
4178 // Save the selected album item |
|
4179 // ---------------------------------------------------------------------------- |
|
4180 void CMPXCollectionViewHgContainer::SaveSelectedAlbumItemL(TInt aIndex) |
|
4181 { |
|
4182 if ( iContext == EContextGroupAlbum || |
|
4183 iContext == EContextItemArtist || |
|
4184 iContext == EContextItemAlbum ) |
|
4185 { |
|
4186 const CMPXMediaArray& mediaArray = iListBoxArray->MediaArray(); |
|
4187 |
|
4188 if ( iSelectedMediaInAlbumView ) |
|
4189 { |
|
4190 delete iSelectedMediaInAlbumView; |
|
4191 iSelectedMediaInAlbumView = NULL; |
|
4192 } |
|
4193 |
|
4194 iSelectedMediaInAlbumView = CMPXMedia::NewL( *mediaArray.AtL( aIndex ) ); |
|
4195 |
|
4196 if ( iSelectedMediaInAlbumView->IsSupported( KMPXMediaGeneralTitle ) ) |
|
4197 { |
|
4198 const TDesC& title = iSelectedMediaInAlbumView->ValueText( KMPXMediaGeneralTitle ); |
|
4199 if ( title == KNullDesC ) |
|
4200 { |
|
4201 // Cannot use reference to KNullDesC, must |
|
4202 // use the literal directly. |
|
4203 iSelectedMediaInAlbumView->SetTextValueL( KMPXMediaMusicAlbum, KNullDesC ); |
|
4204 } |
|
4205 else |
|
4206 { |
|
4207 iSelectedMediaInAlbumView->SetTextValueL( KMPXMediaMusicAlbum, title ); |
|
4208 } |
|
4209 } |
|
4210 |
|
4211 if ( iContext == EContextItemArtist ) |
|
4212 { |
|
4213 const CMPXMedia& containerMedia = iListBoxArray->ContainerMedia(); |
|
4214 const TDesC& artist = containerMedia.ValueText( KMPXMediaGeneralTitle ); |
|
4215 |
|
4216 HBufC* unknownArtistText = |
|
4217 StringLoader::LoadLC( R_MPX_QTN_NMP_UNKNOWN_ARTIST ); |
|
4218 |
|
4219 if ( artist != unknownArtistText->Des() ) |
|
4220 { |
|
4221 iSelectedMediaInAlbumView->SetTextValueL( KMPXMediaMusicArtist, artist ); |
|
4222 } |
|
4223 else |
|
4224 { |
|
4225 iSelectedMediaInAlbumView->SetTextValueL( KMPXMediaMusicArtist, KNullDesC ); |
|
4226 } |
|
4227 |
|
4228 CleanupStack::PopAndDestroy( unknownArtistText ); |
|
4229 } |
|
4230 |
|
4231 WriteToStreamFileL( iSelectedMediaInAlbumView ); |
|
4232 } |
|
4233 } |
|
4234 |
|
4235 // ----------------------------------------------------------------------------- |
|
4236 // CMPXCollectionViewHgContainer::RestoreSelectedAlbumItemL |
|
4237 // When view is deactivated, all the current information about album selection |
|
4238 // were lost. So we restore the selected album. |
|
4239 // ----------------------------------------------------------------------------- |
|
4240 // |
|
4241 void CMPXCollectionViewHgContainer::RestoreSelectedAlbumItemL( |
|
4242 const CMPXMediaArray& aMediaArray ) |
|
4243 { |
|
4244 MPX_FUNC( "CMPXCollectionViewHgContainer::RestoreSelectedAlbumItemL" ); |
|
4245 |
|
4246 CMPXMedia* restoredAlbum = CMPXMedia::NewL(); |
|
4247 ReadFromStreamFileL(restoredAlbum); |
|
4248 TMPXItemId id=restoredAlbum->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId); |
|
4249 |
|
4250 for ( TInt i = 0; i < aMediaArray.Count() ; i++ ) |
|
4251 { |
|
4252 CMPXMedia* currentMedia( aMediaArray.AtL( i ) ); |
|
4253 |
|
4254 if ( currentMedia->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) == id ) |
|
4255 { |
|
4256 iRestoredAlbumIndex = i; |
|
4257 iSelectedAlbumIndex = i; |
|
4258 break; |
|
4259 } |
|
4260 } |
|
4261 } |
|
4262 |
|
4263 // ---------------------------------------------------------------------------- |
|
4264 // Write the album name, artist name and album art in media data to file |
|
4265 // ---------------------------------------------------------------------------- |
|
4266 void CMPXCollectionViewHgContainer::WriteToStreamFileL( const CMPXMedia* aMedia ) |
|
4267 { |
|
4268 MPX_FUNC( "CMPXCollectionViewHgContainer::WriteToStreamFileL" ); |
|
4269 |
|
4270 CCoeEnv* coeEnv( iEikonEnv ); |
|
4271 RFs& fs = coeEnv->FsSession(); |
|
4272 fs.MkDirAll( iSelectedAlbumItemFileName ); |
|
4273 TParse parsedName; |
|
4274 |
|
4275 fs.Parse( iSelectedAlbumItemFileName, parsedName ); |
|
4276 CFileStore* store( NULL ); |
|
4277 MPX_TRAPD( error, store = CDirectFileStore::ReplaceL(fs, |
|
4278 parsedName.FullName(), |
|
4279 EFileWrite); ); |
|
4280 |
|
4281 if ( error == KErrNone ) |
|
4282 { |
|
4283 CleanupStack::PushL( store ); |
|
4284 store->SetTypeL( KDirectFileStoreLayoutUid ); |
|
4285 |
|
4286 RStoreWriteStream wstream; |
|
4287 TStreamId stream = wstream.CreateLC( *store ); |
|
4288 store->SetRootL( stream ); |
|
4289 |
|
4290 aMedia->ExternalizeL(wstream); |
|
4291 |
|
4292 wstream.CommitL(); |
|
4293 CleanupStack::PopAndDestroy( &wstream ); |
|
4294 CleanupStack::PopAndDestroy( store ); |
|
4295 } |
|
4296 else |
|
4297 { |
|
4298 fs.Delete( iSelectedAlbumItemFileName ); |
|
4299 } |
|
4300 } |
|
4301 |
|
4302 // ---------------------------------------------------------------------------- |
|
4303 // Read the album name, artist name and album art from file |
|
4304 // ---------------------------------------------------------------------------- |
|
4305 void CMPXCollectionViewHgContainer::ReadFromStreamFileL( CMPXMedia* aMedia ) |
|
4306 { |
|
4307 MPX_FUNC("CMPXCollectionViewHgContainer::ReadFromStreamFileL"); |
|
4308 |
|
4309 CCoeEnv* coeEnv( iEikonEnv ); |
|
4310 RFs& fs = coeEnv->FsSession(); |
|
4311 fs.MkDirAll( iSelectedAlbumItemFileName ); |
|
4312 TParse parsedName; |
|
4313 |
|
4314 fs.Parse( iSelectedAlbumItemFileName, parsedName ); |
|
4315 CFileStore* store( NULL ); |
|
4316 MPX_TRAPD( error, store = CDirectFileStore::OpenL(fs, |
|
4317 parsedName.FullName(), |
|
4318 EFileRead ); ); |
|
4319 |
|
4320 if ( error == KErrNone ) |
|
4321 { |
|
4322 CleanupStack::PushL( store ); |
|
4323 |
|
4324 RStoreReadStream stream; |
|
4325 stream.OpenLC( *store, store->Root() ); |
|
4326 aMedia->InternalizeL(stream); |
|
4327 |
|
4328 CleanupStack::PopAndDestroy( &stream ); |
|
4329 CleanupStack::PopAndDestroy( store ); |
|
4330 } |
|
4331 |
|
4332 } |
|
4333 |
|
4334 |
|
4335 // End of File |