|
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 mpxaddtracksdialogimp |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <eikclb.h> |
|
21 #include <eikclbd.h> |
|
22 #include <eikimage.h> |
|
23 #include <eiktxlbx.h> |
|
24 #include <aknappui.h> |
|
25 #include <aknnavi.h> |
|
26 #include <aknnavide.h> |
|
27 #include <akntitle.h> |
|
28 #include <akncontext.h> |
|
29 #include <aknlists.h> |
|
30 #include <aknsfld.h> |
|
31 #include <gulicon.h> |
|
32 #include <AknIconArray.h> |
|
33 #include <AknIconUtils.h> |
|
34 #include <StringLoader.h> |
|
35 #include <aknnotewrappers.h> |
|
36 #include <e32base.h> |
|
37 #include <barsread.h> |
|
38 #include <bautils.h> |
|
39 #include <aknnavilabel.h> |
|
40 #include <data_caging_path_literals.hrh> |
|
41 #include <textresolver.h> |
|
42 |
|
43 #include <mpxlog.h> |
|
44 #include <mpxcollectionutility.h> |
|
45 #include <mpxcollectionplaylist.h> |
|
46 #include <mpxaddtracksdialog.rsg> |
|
47 #include <mpxaddtracksdialog.mbg> |
|
48 |
|
49 #include <mpxcollectionhelperfactory.h> |
|
50 #include <mpxcollectionplaylist.h> |
|
51 #include <mpxmediageneraldefs.h> |
|
52 #include <mpxmediacontainerdefs.h> |
|
53 #include <mpxmedia.h> |
|
54 #include <mpxmediamusicdefs.h> |
|
55 #include <mpxmediaarray.h> |
|
56 #include <mpxmessagegeneraldefs.h> |
|
57 #include <mpxcollectionmessage.h> |
|
58 #include <mpxuser.h> |
|
59 |
|
60 #include "mpxcommonuihelper.h" |
|
61 #include "mpxaddtracksdialogcommon.h" |
|
62 #include "mpxaddtracksdialog.hrh" |
|
63 #include "mpxaddtracksdialog.h" |
|
64 #include "mpxaddtrackslistmodel.h" |
|
65 #include "mpxaddtrackslbxarray.h" |
|
66 #include <mpxlbxextendedfeatures.h> |
|
67 |
|
68 // CONSTANTS |
|
69 const TInt KMPXATMaxExpandedGroupNum = 1; |
|
70 |
|
71 // Animation timer defined in UI spec |
|
72 const TInt KAnimationFrame1Timer = 50000; |
|
73 const TInt KAnimationFrame2Timer = 100000; |
|
74 const TInt KAnimationFrame3Timer = 100000; |
|
75 const TInt KAnimationFrame4Timer = 500000; |
|
76 const TInt KAnimationFrameTimerInterval = 1; |
|
77 |
|
78 const TInt KMaxTitleLength = 261; // 255 + 6 for tab |
|
79 |
|
80 _LIT( KMPXAddTracksDialogRscPath, "mpxaddtracksdialog.rsc" ); |
|
81 _LIT(KMPXSpace," "); |
|
82 |
|
83 // ============================ MEMBER FUNCTIONS =============================== |
|
84 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // CMPXAddTracksDialog::NewL |
|
87 // Two-phased constructor. |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 EXPORT_C CMPXAddTracksDialog* CMPXAddTracksDialog::NewL() |
|
91 { |
|
92 MPX_FUNC( "CMPXAddTracksDialog::NewL" ); |
|
93 CMPXAddTracksDialog* self = CMPXAddTracksDialog::NewLC(); |
|
94 CleanupStack::Pop(); |
|
95 return self; |
|
96 } |
|
97 |
|
98 // ----------------------------------------------------------------------------- |
|
99 // CMPXAddTracksDialog::NewLC |
|
100 // Two-phased constructor. |
|
101 // ----------------------------------------------------------------------------- |
|
102 // |
|
103 EXPORT_C CMPXAddTracksDialog* CMPXAddTracksDialog::NewLC() |
|
104 { |
|
105 MPX_FUNC( "CMPXAddTracksDialog::NewLC" ); |
|
106 CMPXAddTracksDialog* self = new ( ELeave ) CMPXAddTracksDialog(); |
|
107 CleanupStack::PushL( self ); |
|
108 self->LoadResourceL(); |
|
109 self->ConstructL( R_AVKON_SOFTKEYS_EMPTY ); |
|
110 return self; |
|
111 } |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // Destructor |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 EXPORT_C CMPXAddTracksDialog::~CMPXAddTracksDialog() |
|
118 { |
|
119 MPX_FUNC( "CMPXAddTracksDialog::~CMPXAddTracksDialog" ); |
|
120 |
|
121 TRAP_IGNORE( RestorePreviousStatusPaneL() ); |
|
122 |
|
123 if ( iCollectionUtility ) |
|
124 { |
|
125 iCollectionUtility->Close(); |
|
126 } |
|
127 if ( iCollectionUiHelper ) |
|
128 { |
|
129 iCollectionUiHelper->Close(); |
|
130 } |
|
131 if ( iOrigIcon ) |
|
132 { |
|
133 delete iOrigIcon; |
|
134 } |
|
135 if ( iNewIcon ) |
|
136 { |
|
137 delete iNewIcon; |
|
138 } |
|
139 if ( iLastFindTxt ) |
|
140 { |
|
141 delete iLastFindTxt; |
|
142 } |
|
143 iMatchedSongArray.Reset(); |
|
144 iMatchedGroupArray.Reset(); |
|
145 |
|
146 delete iNaviDecorator; |
|
147 delete iOrigTitle; |
|
148 delete iNaviLabelPane; |
|
149 delete iListModel; |
|
150 delete iNoSongText; |
|
151 delete iNoMatchText; |
|
152 |
|
153 if( iPeriodic ) |
|
154 { |
|
155 delete iPeriodic; |
|
156 } |
|
157 delete iLbxExtFeat; |
|
158 |
|
159 if ( iResourceOffset ) |
|
160 { |
|
161 iEikonEnv->DeleteResourceFile( iResourceOffset ); |
|
162 } |
|
163 |
|
164 if ( iCategoryArray ) |
|
165 { |
|
166 iCategoryArray->Reset(); |
|
167 delete iCategoryArray; |
|
168 } |
|
169 |
|
170 if ( iAllSongsArray ) |
|
171 { |
|
172 iAllSongsArray->Reset(); |
|
173 delete iAllSongsArray; |
|
174 } |
|
175 |
|
176 delete iCommonUiHelper; |
|
177 delete iIdle; |
|
178 } |
|
179 |
|
180 // ----------------------------------------------------------------------------- |
|
181 // CMPXAddTracksDialog::CMPXAddTracksDialog |
|
182 // C++ default constructor can NOT contain any code, that |
|
183 // might leave. |
|
184 // ----------------------------------------------------------------------------- |
|
185 // |
|
186 CMPXAddTracksDialog::CMPXAddTracksDialog(): |
|
187 CAknSelectionListDialog( iLastIndex, NULL, 0 ), |
|
188 iAnimIconIndex( 0 ), |
|
189 iSongAllGroupExist( ETrue ) |
|
190 { |
|
191 } |
|
192 |
|
193 // ----------------------------------------------------------------------------- |
|
194 // CMPXAddTracksDialog::ConstructL |
|
195 // (other items were commented in a header). |
|
196 // ----------------------------------------------------------------------------- |
|
197 // |
|
198 void CMPXAddTracksDialog::ConstructL( TInt aResource ) |
|
199 { |
|
200 MPX_FUNC( "CMPXAddTracksDialog::ConstructL" ); |
|
201 CAknSelectionListDialog::ConstructL( aResource ); |
|
202 iCollectionUtility = MMPXCollectionUtility::NewL( this, KMcModeDefault ); |
|
203 iCollectionUiHelper = CMPXCollectionHelperFactory::NewCollectionUiHelperL(); |
|
204 iCommonUiHelper = CMPXCommonUiHelper::NewL(); |
|
205 iNoSongText = StringLoader::LoadL( R_MPX_CUI_CATEGORY_ADDSONGVIEW_LBX_NOSONGTEXT ); |
|
206 iNoMatchText = StringLoader::LoadL( R_MPX_CUI_CATEGORY_ADDSONGVIEW_LBX_EMPTYTEXT ); |
|
207 } |
|
208 |
|
209 // ----------------------------------------------------------------------------- |
|
210 // CMPXAddTracksDialog::BackupPreviousStatusPaneL() |
|
211 // Backup previous status pane to internal members. |
|
212 // (other items were commented in a header). |
|
213 // ----------------------------------------------------------------------------- |
|
214 // |
|
215 void CMPXAddTracksDialog::BackupPreviousStatusPaneL() |
|
216 { |
|
217 MPX_FUNC( "CMPXAddTracksDialog::BackupPreviousStatusPaneL" ); |
|
218 CEikStatusPane* sp = iAvkonAppUi->StatusPane(); |
|
219 |
|
220 // Backup navi pane |
|
221 iNaviPane = static_cast<CAknNavigationControlContainer*> |
|
222 ( sp->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) ); |
|
223 iOrigNaviPane = iNaviPane->Top(); |
|
224 |
|
225 iNaviPane->PushDefaultL(); |
|
226 |
|
227 // Backup title pane |
|
228 iTitlePane = static_cast<CAknTitlePane*> |
|
229 ( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
|
230 iOrigTitle = iTitlePane->Text()->AllocL(); |
|
231 |
|
232 // Backup context pane only if new context icon is created |
|
233 if ( iNewIcon ) |
|
234 { |
|
235 iContextPane = static_cast<CAknContextPane*> |
|
236 ( sp->ControlL( TUid::Uid( EEikStatusPaneUidContext ) ) ); |
|
237 iOrigIcon = iContextPane->SwapPicture( iNewIcon ); |
|
238 iNewIcon = NULL; |
|
239 } |
|
240 } |
|
241 |
|
242 // ----------------------------------------------------------------------------- |
|
243 // CMPXAddTracksDialog::RestorePreviousStatusPaneL() |
|
244 // Restore previous status pane from internal members. |
|
245 // (other items were commented in a header). |
|
246 // ----------------------------------------------------------------------------- |
|
247 // |
|
248 void CMPXAddTracksDialog::RestorePreviousStatusPaneL() |
|
249 { |
|
250 MPX_FUNC( "CMPXAddTracksDialog::RestorePreviousStatusPaneL" ); |
|
251 if ( iOrigTitle ) |
|
252 { |
|
253 // Set original title pane |
|
254 iTitlePane->SetTextL( *iOrigTitle ); |
|
255 } |
|
256 |
|
257 // Set original navi pane |
|
258 iNaviPane->Pop( iNaviLabelPane ); |
|
259 if ( iOrigNaviPane ) |
|
260 { |
|
261 iNaviPane->PushL( *iOrigNaviPane ); |
|
262 } |
|
263 else |
|
264 { |
|
265 iNaviPane->PushDefaultL(); |
|
266 } |
|
267 |
|
268 // Restore original context icon |
|
269 if ( iOrigIcon ) |
|
270 { |
|
271 iNewIcon = iContextPane->SwapPicture( iOrigIcon ); |
|
272 iOrigIcon = NULL; |
|
273 } |
|
274 } |
|
275 |
|
276 // ----------------------------------------------------------------------------- |
|
277 // CMPXAddTracksDialog::CreateContextIconL() |
|
278 // Create context icon for add tracks dialog. |
|
279 // (other items were commented in a header). |
|
280 // ----------------------------------------------------------------------------- |
|
281 // |
|
282 void CMPXAddTracksDialog::CreateContextIconL() |
|
283 { |
|
284 MPX_FUNC( "CMPXAddTracksDialog::CreateContextIconL" ); |
|
285 TParse parse; |
|
286 parse.Set( KMPXAddTracksBmpFile, &KDC_APP_RESOURCE_DIR, NULL ); |
|
287 TFileName iconFile( parse.FullName() ); |
|
288 User::LeaveIfError( MPXUser::CompleteWithDllPath( iconFile ) ); |
|
289 |
|
290 MAknsSkinInstance* skin( AknsUtils::SkinInstance() ); |
|
291 CFbsBitmap* bitmap = NULL; |
|
292 CFbsBitmap* mask = NULL; |
|
293 |
|
294 AknsUtils::CreateIconLC( |
|
295 skin, |
|
296 KAknsIIDNone, |
|
297 bitmap, |
|
298 mask, |
|
299 iconFile, |
|
300 EMbmMpxaddtracksdialogQgn_graf_mup_ctx_addsong, |
|
301 EMbmMpxaddtracksdialogQgn_graf_mup_ctx_addsong_mask ); |
|
302 |
|
303 iNewIcon = new ( ELeave ) CEikImage(); |
|
304 iNewIcon->SetPicture( bitmap, mask ); |
|
305 iNewIcon->SetPictureOwnedExternally( EFalse ); |
|
306 |
|
307 CleanupStack::Pop( 2 ); // bitmap, mask |
|
308 } |
|
309 |
|
310 // ----------------------------------------------------------------------------- |
|
311 // CMPXAddTracksDialog::UpdateSoftkeyL() |
|
312 // Update softkey. |
|
313 // (other items were commented in a header). |
|
314 // ----------------------------------------------------------------------------- |
|
315 // |
|
316 void CMPXAddTracksDialog::UpdateSoftkeyL() |
|
317 { |
|
318 MPX_FUNC( "CMPXAddTracksDialog::UpdateSoftkeyL" ); |
|
319 TInt resId( 0 ); |
|
320 TInt index = CurrentLbxItemIndex(); |
|
321 CAknSearchField* findBox = FindBox(); |
|
322 TBool findBoxVisible = ( findBox->IsVisible() ) && ( findBox->IsFocused() ); |
|
323 |
|
324 MPX_DEBUG2( "CMPXAddTracksDialog::UpdateSoftkeyL index = %d", index); |
|
325 |
|
326 iListBox->View()->SetListEmptyTextL( |
|
327 findBoxVisible? *iNoMatchText : *iNoSongText ); |
|
328 if ( iListBox->Model()->NumberOfItems() == 0 ) |
|
329 { |
|
330 // redraw empty text |
|
331 iListBox->DrawDeferred(); |
|
332 } |
|
333 |
|
334 if ( index == KErrNotFound ) |
|
335 { |
|
336 resId = R_MPX_CUI_ADDTRACKS_SOFTKEYS_EMPTY_DONE; |
|
337 if ( findBoxVisible ) |
|
338 { |
|
339 resId = R_MPX_CUI_ADDTRACKS_SOFTKEYS_EMPTY_CANCEL; |
|
340 } |
|
341 } |
|
342 else |
|
343 { |
|
344 TInt id = iListModel->TrackTypeL( index ); |
|
345 if ( id == EMPXGroup ) |
|
346 { |
|
347 resId = R_MPX_CUI_ADDTRACKS_SOFTKEYS_EXPAND_DONE; |
|
348 if ( findBoxVisible ) |
|
349 { |
|
350 resId = R_MPX_CUI_ADDTRACKS_SOFTKEYS_EXPAND_CANCEL; |
|
351 } |
|
352 if ( iListModel->IsExpandedIndex( index ) ) |
|
353 { |
|
354 resId = R_MPX_CUI_ADDTRACKS_SOFTKEYS_COLLAPSE_DONE; |
|
355 if ( findBoxVisible ) |
|
356 { |
|
357 resId = R_MPX_CUI_ADDTRACKS_SOFTKEYS_COLLAPSE_CANCEL; |
|
358 } |
|
359 } |
|
360 } |
|
361 else |
|
362 { |
|
363 resId = R_MPX_CUI_ADDTRACKS_SOFTKEYS_ADD_DONE; |
|
364 if ( findBoxVisible ) |
|
365 { |
|
366 resId = R_MPX_CUI_ADDTRACKS_SOFTKEYS_ADD_CANCEL; |
|
367 } |
|
368 } |
|
369 } |
|
370 ButtonGroupContainer().SetCommandSetL( resId ); |
|
371 |
|
372 // A temporary RSK command observer is registered so that FindBox |
|
373 // cannot register its own RSK command observer. This way it will |
|
374 // not handle the RSK but the ProcessCommandL method in this dialog |
|
375 // will do it. The observer must not be removed, because if there |
|
376 // is no observer registered when the find box is closed, then |
|
377 // the execution of CAknSearchField::RestorePopupCBA will raise a |
|
378 // panic. |
|
379 if( !ButtonGroupContainer().UpdatedCommandObserverExists( |
|
380 CEikButtonGroupContainer::ERightSoftkeyPosition ) ) |
|
381 { |
|
382 MPX_DEBUG1( "CMPXAddTracksDialog::UpdateSoftkeyL: Adding RSK observer" ); |
|
383 ButtonGroupContainer().UpdateCommandObserverL( 2, *this ); |
|
384 } |
|
385 ButtonGroupContainer().DrawDeferred(); |
|
386 } |
|
387 |
|
388 // ----------------------------------------------------------------------------- |
|
389 // CMPXAddTracksDialog::UpdateListboxByCategoryL() |
|
390 // Update listbox content by category. |
|
391 // (other items were commented in a header). |
|
392 // ----------------------------------------------------------------------------- |
|
393 // |
|
394 void CMPXAddTracksDialog::UpdateListboxByCategoryL( const CMPXMedia& aMedia ) |
|
395 { |
|
396 MPX_FUNC( "CMPXAddTracksDialog::UpdateListboxByCategoryL" ); |
|
397 // Reset tracks list |
|
398 iListModel->ResetTracksList(); |
|
399 |
|
400 // Insert "Songs (all)" to model |
|
401 CMPXMediaArray* media = |
|
402 const_cast<CMPXMediaArray*>(aMedia.Value<CMPXMediaArray>( |
|
403 KMPXMediaArrayContents ) ); |
|
404 User::LeaveIfNull( media ); |
|
405 |
|
406 delete iCategoryArray; |
|
407 iCategoryArray = NULL; |
|
408 iCategoryArray = CMPXMediaArray::NewL(); |
|
409 TInt count = media->Count(); |
|
410 for ( TInt i = 0; i < count; i++ ) |
|
411 { |
|
412 CMPXMedia* orig( media->AtL( i ) ); |
|
413 User::LeaveIfNull( orig ); |
|
414 CMPXMedia* copy( CMPXMedia::NewL( *orig ) ); |
|
415 CleanupStack::PushL( copy ); |
|
416 iCategoryArray->AppendL( copy ); |
|
417 CleanupStack::Pop( copy ); |
|
418 } |
|
419 if ( count > 0 ) |
|
420 { |
|
421 // change display text to unknown if the last entry is null |
|
422 CMPXMedia* aryMedia( media->AtL( count - 1 ) ); |
|
423 User::LeaveIfNull( aryMedia ); |
|
424 if ( aryMedia->ValueText( KMPXMediaGeneralTitle ).Length() == 0 ) |
|
425 { |
|
426 HBufC* text = StringLoader::LoadLC( |
|
427 R_MPX_QTN_MP_UNKNOWN ); |
|
428 CMPXMedia* catMedia( iCategoryArray->AtL( count - 1 ) ); |
|
429 User::LeaveIfNull( catMedia ); |
|
430 catMedia->SetTextValueL( KMPXMediaGeneralTitle, *text ); |
|
431 aryMedia->SetTextValueL( KMPXMediaGeneralTitle, *text ); |
|
432 CleanupStack::PopAndDestroy( text ); |
|
433 } |
|
434 CMPXMedia* entry = CMPXMedia::NewL(); |
|
435 CleanupStack::PushL( entry ); |
|
436 HBufC* string = |
|
437 StringLoader::LoadLC( R_MPX_CUI_ADDSONGS_ADD_ALLSONGS_TXT ); |
|
438 entry->SetTextValueL( |
|
439 KMPXMediaGeneralTitle, *string ); |
|
440 media->Insert( entry, 0 ); |
|
441 CleanupStack::PopAndDestroy( string ); |
|
442 CleanupStack::Pop( entry ); |
|
443 // Insert artists to model |
|
444 iListModel->InsertGroupsL( *media, -1, EMPXSong ); |
|
445 HandleItemArrayChangeL(); |
|
446 iSongAllGroupExist = ETrue; |
|
447 } |
|
448 else |
|
449 { |
|
450 MPX_DEBUG1( "CMPXAddTracksDialog::UpdateListboxByCategoryL no song" ); |
|
451 // no song |
|
452 iSongAllGroupExist = EFalse; |
|
453 } |
|
454 } |
|
455 |
|
456 // ----------------------------------------------------------------------------- |
|
457 // CMPXAddTracksDialog::UpdateListboxByCategoryforFindL() |
|
458 // Update listbox content by category after find. |
|
459 // (other items were commented in a header). |
|
460 // ----------------------------------------------------------------------------- |
|
461 // |
|
462 void CMPXAddTracksDialog::UpdateListboxByCategoryforFindL( |
|
463 TBool aFind, TInt aSongNum) |
|
464 { |
|
465 MPX_FUNC( "CMPXAddTracksDialog::UpdateListboxByCategoryforFindL" ); |
|
466 if( aFind ) |
|
467 { |
|
468 if( aSongNum != 0 ) |
|
469 { |
|
470 // Insert "Songs (%N)" to list box model, change "%N" to matched songs' number |
|
471 CMPXMediaArray* media = CMPXMediaArray::NewL(); |
|
472 CleanupStack::PushL( media ); |
|
473 CMPXMedia* entry = CMPXMedia::NewL(); |
|
474 CleanupStack::PushL( entry ); |
|
475 HBufC* string = string = StringLoader::LoadLC( |
|
476 R_MPX_CUI_ADDSONGS_ADD_SONGS_NUM_TXT, aSongNum ); |
|
477 entry->SetTextValueL( KMPXMediaGeneralTitle, *string ); |
|
478 media->AppendL( entry ); |
|
479 iListModel->InsertGroupsL( *media, 0, EMPXSong ); |
|
480 CleanupStack::PopAndDestroy( string ); |
|
481 CleanupStack::Pop( entry ); |
|
482 CleanupStack::PopAndDestroy( media ); |
|
483 iSongAllGroupExist = ETrue; |
|
484 } |
|
485 else |
|
486 { |
|
487 iSongAllGroupExist = EFalse; |
|
488 } |
|
489 |
|
490 // Insert found groups |
|
491 TInt matchedGroupCount = iMatchedGroupArray.Count(); |
|
492 if( matchedGroupCount > 0 ) |
|
493 { |
|
494 CMPXMediaArray* media = CMPXMediaArray::NewL(); |
|
495 CleanupStack::PushL( media ); |
|
496 for ( TInt i = 0; i < matchedGroupCount; i++ ) |
|
497 { |
|
498 TInt catIndex = iMatchedGroupArray[ i ]; |
|
499 CMPXMedia* catMedia( iCategoryArray->AtL( catIndex ) ); |
|
500 User::LeaveIfNull( catMedia ); |
|
501 CMPXMedia* entry = CMPXMedia::NewL( *catMedia ); |
|
502 CleanupStack::PushL( entry ); |
|
503 media->AppendL( entry ); |
|
504 CleanupStack::Pop( entry ); |
|
505 } |
|
506 if( !iSongAllGroupExist ) |
|
507 { |
|
508 iListModel->InsertGroupsL( *media, 0 ); |
|
509 } |
|
510 else |
|
511 { |
|
512 iListModel->InsertGroupsL( *media, 1 ); |
|
513 } |
|
514 CleanupStack::PopAndDestroy( media ); |
|
515 } |
|
516 } |
|
517 else |
|
518 { |
|
519 iListModel->ResetTracksList(); |
|
520 } |
|
521 |
|
522 HandleItemArrayChangeL(); |
|
523 } |
|
524 |
|
525 // ----------------------------------------------------------------------------- |
|
526 // CMPXAddTracksDialog::CurrentLbxItemIndex |
|
527 // Gets current listbox item index. |
|
528 // (other items were commented in a header). |
|
529 // ----------------------------------------------------------------------------- |
|
530 // |
|
531 TInt CMPXAddTracksDialog::CurrentLbxItemIndex() const |
|
532 { |
|
533 MPX_FUNC( "CMPXAddTracksDialog::CurrentLbxItemIndex" ); |
|
534 CTextListBoxModel* lbxModel = iListBox->Model(); |
|
535 CAknSearchField* findBox = FindBox(); |
|
536 TInt currentItem = iListBox->CurrentItemIndex(); |
|
537 TInt count = lbxModel->NumberOfItems(); |
|
538 |
|
539 // Make sure there's at least one item in the listbox |
|
540 if ( findBox && count ) |
|
541 { |
|
542 CAknFilteredTextListBoxModel* filteredLbxModel = |
|
543 static_cast<CAknFilteredTextListBoxModel*>( lbxModel ); |
|
544 CAknListBoxFilterItems* filterItems = filteredLbxModel->Filter(); |
|
545 |
|
546 // Get the real listbox index |
|
547 currentItem = filterItems->FilteredItemIndex( currentItem ); |
|
548 } |
|
549 return currentItem; |
|
550 } |
|
551 |
|
552 // ----------------------------------------------------------------------------- |
|
553 // CMPXAddTracksDialog::CurrentListItemCount |
|
554 // Return number of listbox items shown in the current listbox. |
|
555 // (other items were commented in a header). |
|
556 // ----------------------------------------------------------------------------- |
|
557 // |
|
558 TInt CMPXAddTracksDialog::CurrentListItemCount() const |
|
559 { |
|
560 MPX_FUNC( "CMPXAddTracksDialog::CurrentListItemCount" ); |
|
561 CTextListBoxModel* lbxModel = iListBox->Model(); |
|
562 TInt count = lbxModel->NumberOfItems(); |
|
563 CAknSearchField* findBox = FindBox(); |
|
564 |
|
565 if ( findBox && count ) |
|
566 { |
|
567 CAknFilteredTextListBoxModel* filteredLbxModel = |
|
568 static_cast<CAknFilteredTextListBoxModel*>( lbxModel ); |
|
569 CAknListBoxFilterItems* filterItems = filteredLbxModel->Filter(); |
|
570 |
|
571 count = filterItems->FilteredNumberOfItems(); |
|
572 } |
|
573 return count; |
|
574 } |
|
575 |
|
576 // ----------------------------------------------------------------------------- |
|
577 // CMPXAddTracksDialog::HandleItemArrayChangeL |
|
578 // When you change the list item array you should call this method. |
|
579 // (other items were commented in a header). |
|
580 // ----------------------------------------------------------------------------- |
|
581 // |
|
582 void CMPXAddTracksDialog::HandleItemArrayChangeL() |
|
583 { |
|
584 MPX_FUNC( "CMPXAddTracksDialog::HandleItemArrayChangeL" ); |
|
585 TInt currentIdx = iListBox->CurrentItemIndex(); |
|
586 TInt topIdx = iListBox->TopItemIndex(); |
|
587 CListBoxView* lbxView = iListBox->View(); |
|
588 TInt offset = |
|
589 lbxView->NumberOfItemsThatFitInRect( lbxView->ViewRect() ) - 1; |
|
590 |
|
591 CAknFilteredTextListBoxModel* lbxModel = |
|
592 static_cast<CAknFilteredTextListBoxModel*>( iListBox->Model() ); |
|
593 CAknSearchField* tempSearchField = |
|
594 static_cast<CAknSearchField*>( lbxModel->Filter()->FindBox() ); |
|
595 lbxModel->Filter()->SetSearchField( NULL );//for find the items |
|
596 // Update item array |
|
597 iLbxFilterItems->HandleItemArrayChangeL(); |
|
598 lbxModel->Filter()->SetSearchField( tempSearchField );// for laylout of list |
|
599 |
|
600 TInt itemCount = CurrentListItemCount(); |
|
601 if ( itemCount ) |
|
602 { |
|
603 TInt lastItemIdx = itemCount - 1; |
|
604 if ( topIdx + offset > lastItemIdx ) |
|
605 { |
|
606 topIdx = lastItemIdx - offset; |
|
607 } |
|
608 if ( topIdx < 0 ) |
|
609 { |
|
610 topIdx = 0; |
|
611 } |
|
612 if ( currentIdx < 0 ) |
|
613 { |
|
614 currentIdx = 0; |
|
615 } |
|
616 if ( currentIdx > lastItemIdx ) |
|
617 { |
|
618 currentIdx = lastItemIdx; |
|
619 } |
|
620 |
|
621 iListBox->SetTopItemIndex( topIdx ); |
|
622 iListBox->SetCurrentItemIndexAndDraw( currentIdx ); |
|
623 iListBox->DrawDeferred(); |
|
624 } |
|
625 UpdateSoftkeyL(); |
|
626 } |
|
627 |
|
628 // ----------------------------------------------------------------------------- |
|
629 // CMPXAddTracksDialog::HighlightListItem |
|
630 // Highlight list item. |
|
631 // (other items were commented in a header). |
|
632 // ----------------------------------------------------------------------------- |
|
633 // |
|
634 void CMPXAddTracksDialog::HighlightListItem( TInt aIndex ) |
|
635 { |
|
636 MPX_FUNC( "CMPXAddTracksDialog::HighlightListItem" ); |
|
637 const TInt KMPItemOffset = 1; |
|
638 TInt itemCount = CurrentListItemCount(); |
|
639 |
|
640 if ( itemCount ) |
|
641 { |
|
642 TInt bottomIdx = iListBox->BottomItemIndex(); |
|
643 TInt topIdx = iListBox->TopItemIndex(); |
|
644 |
|
645 // Rearrange the index if aIndex is the bottom item |
|
646 if ( aIndex == bottomIdx ) |
|
647 { |
|
648 TInt lastItemIdx = itemCount - 1; |
|
649 if ( aIndex != lastItemIdx ) |
|
650 { |
|
651 topIdx += KMPItemOffset; |
|
652 if ( topIdx > lastItemIdx ) |
|
653 { |
|
654 topIdx = lastItemIdx; |
|
655 } |
|
656 } |
|
657 } |
|
658 |
|
659 if ( topIdx < 0 ) |
|
660 { |
|
661 topIdx = 0; |
|
662 } |
|
663 |
|
664 iListBox->SetTopItemIndex( topIdx ); |
|
665 iListBox->SetCurrentItemIndexAndDraw( aIndex ); |
|
666 iListBox->DrawDeferred(); |
|
667 } |
|
668 } |
|
669 |
|
670 // ----------------------------------------------------------------------------- |
|
671 // CMPXAddTracksDialog::ExpandCurrentGroupL() |
|
672 // Expand current group. |
|
673 // (other items were commented in a header). |
|
674 // ----------------------------------------------------------------------------- |
|
675 // |
|
676 void CMPXAddTracksDialog::ExpandCurrentGroupL() |
|
677 { |
|
678 MPX_FUNC( "CMPXAddTracksDialog::ExpandCurrentGroupL" ); |
|
679 TInt index = -1; |
|
680 if ( iExpandAllSongs ) |
|
681 { |
|
682 index = EMPXAddTracksAddAllSongs; |
|
683 } |
|
684 else |
|
685 { |
|
686 index = CurrentLbxItemIndex(); |
|
687 } |
|
688 TInt oldIndex = index; |
|
689 |
|
690 // Make sure current item is expandable |
|
691 if ( ( index != KErrNotFound ) && |
|
692 ( iListModel->TrackTypeL( index ) == EMPXGroup ) && |
|
693 ( !iListModel->IsExpandedIndex( index ) ) ) |
|
694 { |
|
695 // Make sure the expanded group count is |
|
696 // under KMPXATMaxExpandedGroupNum. |
|
697 while ( iListModel->ExpandedGroupsCount() >= |
|
698 KMPXATMaxExpandedGroupNum ) |
|
699 { |
|
700 // Remove all tracks from the oldest expanded group |
|
701 oldIndex = iListModel->OldestExpandedGroupIndex(); |
|
702 TInt count = iListModel->RemoveAllTracksFromGroupL( oldIndex ); |
|
703 // Update the index accordingly |
|
704 if ( index > oldIndex ) |
|
705 { |
|
706 index -= count; |
|
707 } |
|
708 } |
|
709 |
|
710 if ( index == EMPXAddTracksAddAllSongs && iSongAllGroupExist ) |
|
711 { |
|
712 if ( iAllSongsArray ) |
|
713 { |
|
714 // Insert tracks for all songs |
|
715 iExpandAllSongs = EFalse; |
|
716 TInt matchedSongCount = iMatchedSongArray.Count(); |
|
717 if ( matchedSongCount == 0 ) |
|
718 { |
|
719 iListModel->InsertTracksUnderGroupL( *iAllSongsArray, index ); |
|
720 TInt diff = oldIndex - index; |
|
721 TInt newCurrentIdx = iListBox->CurrentItemIndex() - diff; |
|
722 if ( newCurrentIdx < 0 ) |
|
723 { |
|
724 newCurrentIdx = 0; |
|
725 } |
|
726 TInt newTopIdx = iListBox->TopItemIndex() - diff; |
|
727 if ( newTopIdx < 0 ) |
|
728 { |
|
729 newTopIdx = 0; |
|
730 } |
|
731 iListBox->SetTopItemIndex( newTopIdx ); |
|
732 iListBox->SetCurrentItemIndex( newCurrentIdx ); |
|
733 } |
|
734 else |
|
735 { |
|
736 TInt matchedSongCount = iMatchedSongArray.Count(); |
|
737 for ( TInt i = 0; i < matchedSongCount; i++ ) |
|
738 { |
|
739 TInt songIndex = iMatchedSongArray[ i ]; |
|
740 CMPXMedia* origMedia( iAllSongsArray->AtL( songIndex ) ); |
|
741 User::LeaveIfNull( origMedia ); |
|
742 iListModel->InsertTrackL( *origMedia, index + 1 + i ); |
|
743 } |
|
744 iListModel->MarkExpandedL( index, matchedSongCount ); |
|
745 } |
|
746 HandleItemArrayChangeL(); |
|
747 HighlightListItem( index ); |
|
748 UpdateSoftkeyL(); |
|
749 } |
|
750 else |
|
751 { |
|
752 MPX_DEBUG1( "CMPXAddTracksDialog::ExpandCurrentGroupL all songs NOT READY" ); |
|
753 iExpandAllSongs = ETrue; |
|
754 HBufC* string = StringLoader::LoadLC( |
|
755 R_MPX_QTN_NMP_NOTE_OPENING ); |
|
756 iCommonUiHelper->ShowWaitNoteL( *string, |
|
757 R_AVKON_SOFTKEYS_EMPTY, EFalse, NULL ); |
|
758 CleanupStack::PopAndDestroy( string ); |
|
759 } |
|
760 } |
|
761 else |
|
762 { |
|
763 if ( iCurrentOp == EMPXOpIdle ) |
|
764 { |
|
765 HandleItemArrayChangeL(); |
|
766 HBufC* string = StringLoader::LoadLC( |
|
767 R_MPX_QTN_NMP_NOTE_OPENING ); |
|
768 iCommonUiHelper->ShowWaitNoteL( *string, |
|
769 R_AVKON_SOFTKEYS_EMPTY, EFalse, NULL ); |
|
770 CleanupStack::PopAndDestroy( string ); |
|
771 CMPXMedia* media = CMPXMedia::NewL(); |
|
772 CleanupStack::PushL( media ); |
|
773 media->SetTObjectValueL<TMPXGeneralType>( |
|
774 KMPXMediaGeneralType, EMPXGroup ); |
|
775 media->SetTObjectValueL<TMPXGeneralCategory>( |
|
776 KMPXMediaGeneralCategory, EMPXSong ); |
|
777 media->SetTObjectValueL<TMPXItemId>( |
|
778 KMPXMediaGeneralId, iListModel->TrackIdL( index ) ); |
|
779 RArray<TMPXAttribute> attrs; |
|
780 CleanupClosePushL( attrs ); |
|
781 attrs.Append( |
|
782 TMPXAttribute( KMPXMediaIdGeneral, |
|
783 EMPXMediaGeneralTitle | EMPXMediaGeneralId |
|
784 | EMPXMediaGeneralType | EMPXMediaGeneralCategory | |
|
785 EMPXMediaGeneralFlags ) ); |
|
786 iCurrentOp = EMPXOpGetSongs; |
|
787 iCurrentGroupIndex = index; |
|
788 iCollectionUtility->Collection().FindAllL( *media, attrs.Array(), *this ); |
|
789 CleanupStack::PopAndDestroy( &attrs ); |
|
790 CleanupStack::PopAndDestroy( media ); |
|
791 } |
|
792 else |
|
793 { |
|
794 MPX_DEBUG1( "CMPXAddTracksDialog::ExpandCurrentGroupL find all busy, ignoring" ); |
|
795 } |
|
796 } |
|
797 } |
|
798 } |
|
799 |
|
800 // ----------------------------------------------------------------------------- |
|
801 // CMPXAddTracksDialog::GotoClosestGroupL() |
|
802 // Goto the closest group. |
|
803 // (other items were commented in a header). |
|
804 // ----------------------------------------------------------------------------- |
|
805 // |
|
806 void CMPXAddTracksDialog::GotoClosestGroupL() |
|
807 { |
|
808 MPX_FUNC( "CMPXAddTracksDialog::GotoClosestGroupL" ); |
|
809 // Get the closest expanded index |
|
810 TInt origIndex = CurrentLbxItemIndex(); |
|
811 if ( origIndex != KErrNotFound ) |
|
812 { |
|
813 TInt index = iListModel->ClosestExpandedGroupIdx( origIndex ); |
|
814 if ( index != KErrNotFound ) |
|
815 { |
|
816 // Highlight on the group |
|
817 HighlightListItem( index ); |
|
818 |
|
819 UpdateSoftkeyL(); |
|
820 } |
|
821 } |
|
822 } |
|
823 |
|
824 // ----------------------------------------------------------------------------- |
|
825 // CMPXAddTracksDialog::CollapseCurrentGroupL() |
|
826 // Collapse current group. |
|
827 // (other items were commented in a header). |
|
828 // ----------------------------------------------------------------------------- |
|
829 // |
|
830 void CMPXAddTracksDialog::CollapseCurrentGroupL() |
|
831 { |
|
832 MPX_FUNC( "CMPXAddTracksDialog::CollapseCurrentGroupL" ); |
|
833 TInt index = CurrentLbxItemIndex(); |
|
834 |
|
835 if ( ( index != KErrNotFound ) && |
|
836 ( iListModel->IsExpandedIndex( index ) ) ) |
|
837 { |
|
838 // Remove all tracks from this group |
|
839 iListModel->RemoveAllTracksFromGroupL( index ); |
|
840 |
|
841 // Update listbox and softkey |
|
842 HandleItemArrayChangeL(); |
|
843 HighlightListItem( index ); |
|
844 UpdateSoftkeyL(); |
|
845 } |
|
846 } |
|
847 |
|
848 // ----------------------------------------------------------------------------- |
|
849 // CMPXAddTracksDialog::AddCurrentTrackToPlaylistL() |
|
850 // Add current track to playlist. |
|
851 // (other items were commented in a header). |
|
852 // ----------------------------------------------------------------------------- |
|
853 // |
|
854 void CMPXAddTracksDialog::AddCurrentTrackToPlaylistL() |
|
855 { |
|
856 MPX_FUNC( "CMPXAddTracksDialog::AddCurrentTrackToPlaylistL" ); |
|
857 TInt index = CurrentLbxItemIndex(); |
|
858 iSelectIndex = index; |
|
859 |
|
860 if ( index != KErrNotFound && iPlaylistId != 0 ) |
|
861 { |
|
862 CMPXMedia* media = CMPXMedia::NewL(); |
|
863 CleanupStack::PushL( media ); |
|
864 media->SetTObjectValueL<TMPXItemId>( |
|
865 KMPXMediaGeneralId, iPlaylistId ); |
|
866 media->SetTObjectValueL<TMPXGeneralType>( |
|
867 KMPXMediaGeneralType, EMPXItem ); |
|
868 media->SetTObjectValueL<TMPXGeneralCategory>( |
|
869 KMPXMediaGeneralCategory, EMPXPlaylist ); |
|
870 |
|
871 CMPXMediaArray* mediaArray = CMPXMediaArray::NewL(); |
|
872 CleanupStack::PushL( mediaArray ); |
|
873 CMPXMedia* song = CMPXMedia::NewL( iListModel->MediaL( index ) ); |
|
874 CleanupStack::PushL( song ); |
|
875 mediaArray->AppendL( song ); |
|
876 CleanupStack::Pop( song ); |
|
877 media->SetCObjectValueL( KMPXMediaArrayContents, mediaArray ); |
|
878 media->SetTObjectValueL( KMPXMediaArrayCount, 1 ); |
|
879 iCollectionUiHelper->AddL( *media, this ); |
|
880 CleanupStack::PopAndDestroy( 2, media ); |
|
881 |
|
882 // Enable animation |
|
883 // Animation icon index is 3 -> 5 |
|
884 iAnimIconIndex = CMPXAddTracksLbxArray::EMPXATLbxIconSongAddedAnim1; |
|
885 iListModel->SetAnimationIconNum( iSelectIndex, iAnimIconIndex ); |
|
886 HighlightListItem( iSelectIndex ); |
|
887 |
|
888 // first icon animation |
|
889 if ( iPeriodic->IsActive() ) |
|
890 { |
|
891 iPeriodic->Cancel(); |
|
892 } |
|
893 iPeriodic->Start( TTimeIntervalMicroSeconds32(KAnimationFrame1Timer), |
|
894 TTimeIntervalMicroSeconds32(KAnimationFrameTimerInterval), |
|
895 TCallBack( AnimExpireL, this ) ); |
|
896 } |
|
897 } |
|
898 |
|
899 // ----------------------------------------------------------------------------- |
|
900 // CMPXAddTracksDialog::DoFindL |
|
901 // Execute find for group and songs. |
|
902 // (other items were commented in a header). |
|
903 // ----------------------------------------------------------------------------- |
|
904 // |
|
905 void CMPXAddTracksDialog::DoFindL( void ) |
|
906 { |
|
907 MPX_FUNC( "CMPXAddTracksDialog::DoFindL" ); |
|
908 |
|
909 if ( !iAllSongsArray ) |
|
910 { |
|
911 iDoFind = ETrue; |
|
912 HBufC* string = StringLoader::LoadLC( |
|
913 R_MPX_QTN_NMP_NOTE_OPENING ); |
|
914 iCommonUiHelper->ShowWaitNoteL( *string, |
|
915 R_AVKON_SOFTKEYS_EMPTY, EFalse, NULL ); |
|
916 CleanupStack::PopAndDestroy( string ); |
|
917 return; |
|
918 } |
|
919 |
|
920 // reset all group to default state |
|
921 iListModel->ResetTracksList(); |
|
922 |
|
923 iMatchedSongArray.Reset(); |
|
924 iMatchedGroupArray.Reset(); |
|
925 |
|
926 // start find |
|
927 TInt searchTextNum = iLastFindTxt->Length(); |
|
928 TInt songAllMatchedNum = 0; |
|
929 |
|
930 TBufC<KMaxTitleLength> bufSearchText; |
|
931 TPtr searchText = bufSearchText.Des(); |
|
932 TBufC<KMaxTitleLength> bufSearchTextwithSpace; |
|
933 TPtr searchTextwithSpace = bufSearchTextwithSpace.Des(); |
|
934 TBool find = EFalse; |
|
935 |
|
936 |
|
937 // Reset find result |
|
938 iListModel->SetFindSongsFlag( EFalse ); |
|
939 // current searching is to compare the text string with list box text |
|
940 // if they are match, means found;otherwise, not found |
|
941 // searching way can be changed if needed |
|
942 if( searchTextNum != 0 ) |
|
943 { |
|
944 TInt listCount = iCategoryArray->Count(); |
|
945 for( TInt i = 0; i < listCount; i ++ ) |
|
946 { |
|
947 CMPXMedia* media( iCategoryArray->AtL( i ) ); |
|
948 User::LeaveIfNull( media ); |
|
949 const TDesC& constTitle = media->ValueText( |
|
950 KMPXMediaGeneralTitle ); |
|
951 TBufC<KMaxTitleLength> titleBuf( constTitle ); |
|
952 TPtr title = titleBuf.Des(); |
|
953 searchText = iLastFindTxt->Left( searchTextNum ); |
|
954 |
|
955 title.LowerCase(); |
|
956 searchText.LowerCase(); |
|
957 |
|
958 if( title.Find( KMPXSpace ) != KErrNotFound ) |
|
959 { |
|
960 searchTextwithSpace = searchText; |
|
961 // insert space if there is not, to make every search same |
|
962 searchTextwithSpace.Insert( 0, KMPXSpace ); |
|
963 } |
|
964 |
|
965 // find way: match first several characters, if there is space in the |
|
966 // middle of the track name, match the string also after the space |
|
967 if ( ( ( searchTextwithSpace.Length() > 0 ) && |
|
968 ( title.Find( searchTextwithSpace ) != KErrNotFound ) ) || |
|
969 ( title.Left( searchTextNum ) == searchText ) ) |
|
970 { |
|
971 iMatchedGroupArray.Append( i ); |
|
972 find = ETrue; |
|
973 } |
|
974 } |
|
975 |
|
976 TInt songCount = iAllSongsArray->Count(); |
|
977 for ( TInt i = 0; i < songCount; i++ ) |
|
978 { |
|
979 CMPXMedia* media( iAllSongsArray->AtL( i ) ); |
|
980 User::LeaveIfNull( media ); |
|
981 const TDesC& constTitle = media->ValueText( |
|
982 KMPXMediaGeneralTitle ); |
|
983 TBufC<KMaxTitleLength> titleBuf( constTitle ); |
|
984 TPtr title = titleBuf.Des(); |
|
985 searchText = iLastFindTxt->Left( searchTextNum ); |
|
986 |
|
987 title.LowerCase(); |
|
988 searchText.LowerCase(); |
|
989 |
|
990 if( title.Find( KMPXSpace ) != KErrNotFound ) |
|
991 { |
|
992 searchTextwithSpace = searchText; |
|
993 // insert space if there is not, to make every search same |
|
994 searchTextwithSpace.Insert( 0, KMPXSpace ); |
|
995 } |
|
996 |
|
997 // find way: match first several characters, if there is space in the |
|
998 // middle of the track name, match the string also after the space |
|
999 if ( ( ( searchTextwithSpace.Length() > 0 ) && |
|
1000 ( title.Find( searchTextwithSpace ) != KErrNotFound ) ) || |
|
1001 ( title.Left( searchTextNum ) == searchText ) ) |
|
1002 { |
|
1003 // matched songs |
|
1004 songAllMatchedNum ++; |
|
1005 iMatchedSongArray.Append( i ); |
|
1006 find = ETrue; |
|
1007 iListModel->SetFindSongsFlag( ETrue ); |
|
1008 } |
|
1009 } |
|
1010 // update according to searching result |
|
1011 UpdateListboxByCategoryforFindL( find, songAllMatchedNum ); |
|
1012 } |
|
1013 else if ( iAllSongsArray->Count() > 0 ) |
|
1014 { |
|
1015 // Songs(All) node is shown |
|
1016 iListModel->SetFindSongsFlag( ETrue ); |
|
1017 CMPXMediaArray* media = CMPXMediaArray::NewL(); |
|
1018 CleanupStack::PushL( media ); |
|
1019 CMPXMedia* entry = CMPXMedia::NewL(); |
|
1020 CleanupStack::PushL( entry ); |
|
1021 HBufC* string = |
|
1022 StringLoader::LoadLC( R_MPX_CUI_ADDSONGS_ADD_ALLSONGS_TXT ); |
|
1023 entry->SetTextValueL( KMPXMediaGeneralTitle, *string ); |
|
1024 media->Insert( entry, 0 ); |
|
1025 CleanupStack::PopAndDestroy( string ); |
|
1026 CleanupStack::Pop( entry ); |
|
1027 iListModel->InsertGroupsL( *media, 0, EMPXSong ); |
|
1028 iListModel->InsertGroupsL( *iCategoryArray, 1 ); |
|
1029 CleanupStack::PopAndDestroy( media ); |
|
1030 iSongAllGroupExist = ETrue; |
|
1031 HandleItemArrayChangeL(); |
|
1032 } |
|
1033 |
|
1034 // Always highlight the first item |
|
1035 HighlightListItem( 0 ); |
|
1036 } |
|
1037 |
|
1038 // ----------------------------------------------------------------------------- |
|
1039 // CMPXAddTracksDialog::DoAnimL |
|
1040 // Execute animation. |
|
1041 // (other items were commented in a header). |
|
1042 // ----------------------------------------------------------------------------- |
|
1043 // |
|
1044 void CMPXAddTracksDialog::DoAnimL(void) |
|
1045 { |
|
1046 MPX_FUNC( "CMPXAddTracksDialog::DoAnimL" ); |
|
1047 iPeriodic->Cancel(); |
|
1048 |
|
1049 // remove animation icon |
|
1050 if( iAnimIconIndex == |
|
1051 CMPXAddTracksLbxArray::EMPXATLbxIconSongAddedAnim4 ) |
|
1052 { |
|
1053 return; |
|
1054 } |
|
1055 iAnimIconIndex ++; |
|
1056 iListModel->SetAnimationIconNum( iSelectIndex, iAnimIconIndex ); |
|
1057 HighlightListItem(iSelectIndex); |
|
1058 |
|
1059 TTimeIntervalMicroSeconds32 interval = 0; |
|
1060 if( iAnimIconIndex == |
|
1061 CMPXAddTracksLbxArray::EMPXATLbxIconSongAddedAnim2 ) |
|
1062 { |
|
1063 interval = KAnimationFrame2Timer; |
|
1064 } |
|
1065 else if(iAnimIconIndex == |
|
1066 CMPXAddTracksLbxArray::EMPXATLbxIconSongAddedAnim3 ) |
|
1067 { |
|
1068 interval = KAnimationFrame3Timer; |
|
1069 } |
|
1070 else if(iAnimIconIndex == |
|
1071 CMPXAddTracksLbxArray::EMPXATLbxIconSongAddedAnim4 ) |
|
1072 { |
|
1073 interval = KAnimationFrame4Timer; |
|
1074 } |
|
1075 iPeriodic->Start( interval, |
|
1076 TTimeIntervalMicroSeconds32(KAnimationFrameTimerInterval ), |
|
1077 TCallBack( AnimExpireL, this ) ); |
|
1078 |
|
1079 } |
|
1080 |
|
1081 // ----------------------------------------------------------------------------- |
|
1082 // CMPXAddTracksDialog::AnimExpireL |
|
1083 // Animation call back method. |
|
1084 // (other items were commented in a header). |
|
1085 // ----------------------------------------------------------------------------- |
|
1086 // |
|
1087 TInt CMPXAddTracksDialog::AnimExpireL( TAny* aObject ) |
|
1088 { |
|
1089 MPX_FUNC( "CMPXAddTracksDialog::AnimExpireL" ); |
|
1090 ( ( CMPXAddTracksDialog* )( aObject ) )->DoAnimL(); |
|
1091 return KErrNone; |
|
1092 } |
|
1093 |
|
1094 // ----------------------------------------------------------------------------- |
|
1095 // CMPXAddTracksDialog::StopAnimL |
|
1096 // Stop animation. |
|
1097 // ----------------------------------------------------------------------------- |
|
1098 // |
|
1099 void CMPXAddTracksDialog::StopAnimL() |
|
1100 { |
|
1101 if( ( iPeriodic->IsActive() || |
|
1102 iAnimIconIndex == |
|
1103 CMPXAddTracksLbxArray::EMPXATLbxIconSongAddedAnim4 ) ) |
|
1104 { |
|
1105 iAnimIconIndex = 0; |
|
1106 iPeriodic->Cancel(); |
|
1107 iListModel->SetAnimationIconNum( iSelectIndex, 0 ); |
|
1108 HighlightListItem( iSelectIndex ); |
|
1109 // restore origional navi pane text |
|
1110 iNaviPane->Pop( iNaviLabelPane ); |
|
1111 iNaviPane->PushDefaultL(); |
|
1112 } |
|
1113 } |
|
1114 |
|
1115 // --------------------------------------------------------------------------- |
|
1116 // load resources |
|
1117 // --------------------------------------------------------------------------- |
|
1118 // |
|
1119 void CMPXAddTracksDialog::LoadResourceL() |
|
1120 { |
|
1121 MPX_FUNC( "CMPXAddTracksDialog::LoadResourceL" ); |
|
1122 CCoeEnv* coeEnv = iEikonEnv; |
|
1123 TParse parse; |
|
1124 parse.Set( KMPXAddTracksDialogRscPath, &KDC_APP_RESOURCE_DIR, NULL ); |
|
1125 TFileName resourceFile( parse.FullName() ); |
|
1126 User::LeaveIfError( MPXUser::CompleteWithDllPath( resourceFile ) ); |
|
1127 BaflUtils::NearestLanguageFile( coeEnv->FsSession(), resourceFile ); |
|
1128 iResourceOffset = coeEnv->AddResourceFileL( resourceFile ); |
|
1129 } |
|
1130 |
|
1131 // --------------------------------------------------------------------------- |
|
1132 // start find categories |
|
1133 // --------------------------------------------------------------------------- |
|
1134 // |
|
1135 void CMPXAddTracksDialog::LoadCategoriesL() |
|
1136 { |
|
1137 MPX_FUNC( "CMPXAddTracksDialog::LoadCategoriesL" ); |
|
1138 CMPXMedia* media = CMPXMedia::NewL(); |
|
1139 CleanupStack::PushL( media ); |
|
1140 media->SetTObjectValueL<TMPXGeneralType>( |
|
1141 KMPXMediaGeneralType, EMPXGroup ); |
|
1142 media->SetTObjectValueL<TMPXGeneralCategory>( |
|
1143 KMPXMediaGeneralCategory, EMPXArtist ); |
|
1144 RArray<TMPXAttribute> attrs; |
|
1145 CleanupClosePushL( attrs ); |
|
1146 attrs.Append( |
|
1147 TMPXAttribute( KMPXMediaIdGeneral, |
|
1148 EMPXMediaGeneralTitle | EMPXMediaGeneralId |
|
1149 | EMPXMediaGeneralType | EMPXMediaGeneralCategory | |
|
1150 EMPXMediaGeneralFlags ) ); |
|
1151 iCurrentOp = EMPXOpGetCategory; |
|
1152 iCollectionUtility->Collection().FindAllL( *media, attrs.Array(), *this ); |
|
1153 CleanupStack::PopAndDestroy( &attrs ); |
|
1154 CleanupStack::PopAndDestroy( media ); |
|
1155 } |
|
1156 |
|
1157 // ----------------------------------------------------------------------------- |
|
1158 // Handle collection message |
|
1159 // ----------------------------------------------------------------------------- |
|
1160 // |
|
1161 void CMPXAddTracksDialog::DoHandleCollectionMessageL( const CMPXMessage& aMessage ) |
|
1162 { |
|
1163 MPX_FUNC( "CMPXAddTracksDialog::DoHandleCollectionMessageL" ); |
|
1164 TMPXMessageId id( aMessage.ValueTObjectL<TMPXMessageId>( KMPXMessageGeneralId ) ); |
|
1165 if ( KMPXMessageGeneral == id ) |
|
1166 { |
|
1167 if( aMessage.ValueTObjectL<TInt>( KMPXMessageGeneralEvent ) == |
|
1168 TMPXCollectionMessage::EBroadcastEvent ) |
|
1169 { |
|
1170 TInt op( aMessage.ValueTObjectL<TInt>( KMPXMessageGeneralType ) ); |
|
1171 if ( op == EMcMsgUSBMTPEnd || op == EMcMsgRefreshEnd || op == EMcMsgUSBMassStorageEnd ) |
|
1172 { |
|
1173 MPX_DEBUG1( "CMPXAddTracksDialog::DoHandleCollectionMessageL Library updated, reloading" ); |
|
1174 // library updated, reload |
|
1175 LoadCategoriesL(); |
|
1176 } |
|
1177 else if ( op == EMcMsgDiskRemoved ) |
|
1178 { |
|
1179 // since collection view can't close this dialog due to CMPXCollectionViewImp::DoIncrementalOpenL |
|
1180 // later, schedule the dialog to be closed by itself |
|
1181 iIdle = CIdle::NewL( CActive::EPriorityStandard ); |
|
1182 iIdle->Start( TCallBack( CMPXAddTracksDialog::DeferredExitCallback, this ) ); |
|
1183 } |
|
1184 } |
|
1185 } |
|
1186 } |
|
1187 |
|
1188 // --------------------------------------------------------------------------- |
|
1189 // From MMPXCollectionObserver |
|
1190 // Handle collection message |
|
1191 // --------------------------------------------------------------------------- |
|
1192 // |
|
1193 void CMPXAddTracksDialog::HandleCollectionMessage( |
|
1194 CMPXMessage* aMessage, TInt aError ) |
|
1195 { |
|
1196 if ( aError == KErrNone && aMessage ) |
|
1197 { |
|
1198 TRAP_IGNORE( DoHandleCollectionMessageL( *aMessage ) ); |
|
1199 } |
|
1200 } |
|
1201 |
|
1202 // --------------------------------------------------------------------------- |
|
1203 // From MMPXCollectionObserver |
|
1204 // Handles the collection entries being opened. Typically called |
|
1205 // when client has Open()'d a folder |
|
1206 // --------------------------------------------------------------------------- |
|
1207 // |
|
1208 void CMPXAddTracksDialog::HandleOpenL( |
|
1209 const CMPXMedia& /*aEntries*/, |
|
1210 TInt /*aIndex*/, |
|
1211 TBool /*aComplete*/, |
|
1212 TInt /*aError*/ ) |
|
1213 { |
|
1214 // do nothing |
|
1215 } |
|
1216 |
|
1217 // --------------------------------------------------------------------------- |
|
1218 // From MMPXCollectionObserver |
|
1219 // Handles the collection entries being opened. Typically called |
|
1220 // when client has Open()'d an item. Client typically responds by |
|
1221 // 'playing' the item |
|
1222 // --------------------------------------------------------------------------- |
|
1223 // |
|
1224 void CMPXAddTracksDialog::HandleOpenL( |
|
1225 const CMPXCollectionPlaylist& /*aPlaylist*/, |
|
1226 TInt /*aError*/ ) |
|
1227 { |
|
1228 // do nothing |
|
1229 } |
|
1230 |
|
1231 // --------------------------------------------------------------------------- |
|
1232 // From MMPXCollectionObserver |
|
1233 // Handle collection media |
|
1234 // --------------------------------------------------------------------------- |
|
1235 // |
|
1236 void CMPXAddTracksDialog::HandleCollectionMediaL( |
|
1237 const CMPXMedia& aMedia, TInt aError) |
|
1238 { |
|
1239 MPX_FUNC( "CMPXAddTracksDialog::HandleCollectionMediaL" ); |
|
1240 |
|
1241 if ( aError == KErrNone ) |
|
1242 { |
|
1243 iPlaylistId = aMedia.ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ); |
|
1244 MPX_DEBUG2( "CMPXAddTracksDialog::HandleCollectionMediaL playlist ID = 0x%x", iPlaylistId.iId1 ); |
|
1245 } |
|
1246 } |
|
1247 |
|
1248 // --------------------------------------------------------------------------- |
|
1249 // From MMPXCollectionFindObserver |
|
1250 // Handle callback for "find" operation |
|
1251 // --------------------------------------------------------------------------- |
|
1252 // |
|
1253 void CMPXAddTracksDialog::HandleFindAllL( |
|
1254 const CMPXMedia& aResults, TBool /*aComplete*/, TInt aError ) |
|
1255 { |
|
1256 MPX_DEBUG2( "-->CMPXAddTracksDialog::HandleFindAllL aError = %d", aError ); |
|
1257 |
|
1258 if ( aError == KErrNone ) |
|
1259 { |
|
1260 switch ( iCurrentOp ) |
|
1261 { |
|
1262 case EMPXOpGetCategory: |
|
1263 { |
|
1264 UpdateListboxByCategoryL( aResults ); |
|
1265 CMPXMedia* media = CMPXMedia::NewL(); |
|
1266 CleanupStack::PushL( media ); |
|
1267 media->SetTObjectValueL<TMPXGeneralType>( |
|
1268 KMPXMediaGeneralType, EMPXGroup ); |
|
1269 media->SetTObjectValueL<TMPXGeneralCategory>( |
|
1270 KMPXMediaGeneralCategory, EMPXSong ); |
|
1271 RArray<TMPXAttribute> attrs; |
|
1272 CleanupClosePushL( attrs ); |
|
1273 attrs.Append( |
|
1274 TMPXAttribute( KMPXMediaIdGeneral, |
|
1275 EMPXMediaGeneralTitle | EMPXMediaGeneralId |
|
1276 | EMPXMediaGeneralType | EMPXMediaGeneralCategory |
|
1277 | EMPXMediaGeneralFlags ) ); |
|
1278 iCurrentOp = EMPXOpGetAllSongs; |
|
1279 iCollectionUtility->Collection().FindAllL( *media, attrs.Array(), *this ); |
|
1280 CleanupStack::PopAndDestroy( &attrs ); |
|
1281 CleanupStack::PopAndDestroy( media ); |
|
1282 break; |
|
1283 } |
|
1284 case EMPXOpGetAllSongs: |
|
1285 { |
|
1286 delete iAllSongsArray; |
|
1287 iAllSongsArray = NULL; |
|
1288 CMPXMediaArray* mediaAry( |
|
1289 const_cast<CMPXMediaArray*>( aResults.Value<CMPXMediaArray>( |
|
1290 KMPXMediaArrayContents ) ) ); |
|
1291 User::LeaveIfNull( mediaAry ); |
|
1292 iAllSongsArray = CMPXMediaArray::NewL( *mediaAry ); |
|
1293 iCurrentOp = EMPXOpIdle; |
|
1294 if ( iExpandAllSongs ) |
|
1295 { |
|
1296 iCommonUiHelper->DismissWaitNoteL(); |
|
1297 iDoFind = EFalse; |
|
1298 ExpandCurrentGroupL(); |
|
1299 } |
|
1300 else if ( iDoFind ) |
|
1301 { |
|
1302 iCommonUiHelper->DismissWaitNoteL(); |
|
1303 iDoFind = EFalse; |
|
1304 DoFindL(); |
|
1305 } |
|
1306 break; |
|
1307 } |
|
1308 case EMPXOpGetSongs: |
|
1309 { |
|
1310 CMPXMediaArray* media = |
|
1311 const_cast<CMPXMediaArray*>(aResults.Value<CMPXMediaArray>( |
|
1312 KMPXMediaArrayContents ) ); |
|
1313 User::LeaveIfNull( media ); |
|
1314 iListModel->InsertTracksUnderGroupL( *media, iCurrentGroupIndex ); |
|
1315 |
|
1316 TInt diff = iListModel->OldestExpandedGroupIndex() - iCurrentGroupIndex; |
|
1317 TInt newCurrentIdx = iListBox->CurrentItemIndex() - diff; |
|
1318 if ( newCurrentIdx < 0 ) |
|
1319 { |
|
1320 newCurrentIdx = 0; |
|
1321 } |
|
1322 TInt newTopIdx = iListBox->TopItemIndex() - diff; |
|
1323 if ( newTopIdx < 0 ) |
|
1324 { |
|
1325 newTopIdx = 0; |
|
1326 } |
|
1327 iListBox->SetTopItemIndex( newTopIdx ); |
|
1328 iListBox->SetCurrentItemIndex( newCurrentIdx ); |
|
1329 HandleItemArrayChangeL(); |
|
1330 HighlightListItem( iCurrentGroupIndex ); |
|
1331 UpdateSoftkeyL(); |
|
1332 iCurrentOp = EMPXOpIdle; |
|
1333 iCommonUiHelper->DismissWaitNoteL(); |
|
1334 break; |
|
1335 } |
|
1336 default: |
|
1337 { |
|
1338 iCurrentOp = EMPXOpIdle; |
|
1339 break; |
|
1340 } |
|
1341 } |
|
1342 } |
|
1343 MPX_DEBUG1( "<--CMPXAddTracksDialog::HandleFindAllL" ); |
|
1344 } |
|
1345 |
|
1346 // --------------------------------------------------------------------------- |
|
1347 // From MMPXCHelperObserver |
|
1348 // Handles the completion of adding a playlist event |
|
1349 // --------------------------------------------------------------------------- |
|
1350 // |
|
1351 void CMPXAddTracksDialog::HandleOperationCompleteL( TCHelperOperation /*aOperation*/, |
|
1352 TInt aError, |
|
1353 void* aArgument ) |
|
1354 { |
|
1355 MPX_DEBUG2("-->CMPXAddTracksDialog::HandleOperationCompleteL error = %d", aError); |
|
1356 if ( aError != KErrNone ) |
|
1357 { |
|
1358 StopAnimL(); |
|
1359 // Fix for err EJKG-7CFD89 & EJKG-7DZGGL |
|
1360 if (aError != KErrNotReady && aError != KErrArgument ) |
|
1361 { |
|
1362 iCommonUiHelper->HandleErrorL( aError ); |
|
1363 } |
|
1364 } |
|
1365 else |
|
1366 { |
|
1367 // Song added text display in navi pane |
|
1368 iNaviPane->PushL( *iNaviDecorator ); |
|
1369 } |
|
1370 CMPXMedia* media = (CMPXMedia*) aArgument; |
|
1371 delete media; |
|
1372 MPX_DEBUG1("<--CMPXAddTracksDialog::HandleOperationCompleteL"); |
|
1373 } |
|
1374 |
|
1375 // ----------------------------------------------------------------------------- |
|
1376 // CMPXAddTracksDialog::PreLayoutDynInitL() |
|
1377 // Prepare for layout. |
|
1378 // (other items were commented in a header). |
|
1379 // ----------------------------------------------------------------------------- |
|
1380 // |
|
1381 void CMPXAddTracksDialog::PreLayoutDynInitL() |
|
1382 { |
|
1383 MPX_FUNC( "CMPXAddTracksDialog::PreLayoutDynInitL" ); |
|
1384 // Create context icon |
|
1385 CreateContextIconL(); |
|
1386 |
|
1387 // Backup previous status pane |
|
1388 BackupPreviousStatusPaneL(); |
|
1389 |
|
1390 // Set new title pane |
|
1391 HBufC* title = StringLoader::LoadLC( R_MPX_CUI_ADDSONGS_TITLE ); |
|
1392 iTitlePane->SetTextL( *title ); |
|
1393 CleanupStack::PopAndDestroy( title ); |
|
1394 |
|
1395 // Set find type |
|
1396 CAknSelectionListDialog::PreLayoutDynInitL(); |
|
1397 |
|
1398 // Setup listbox content |
|
1399 iListBox = static_cast<CEikTextListBox*>( Control( ESelectionListControl ) ); |
|
1400 CAknFilteredTextListBoxModel* |
|
1401 lbxModel = static_cast<CAknFilteredTextListBoxModel*>( iListBox->Model() ); |
|
1402 iLbxFilterItems = lbxModel->Filter(); |
|
1403 |
|
1404 // Initialize last find text |
|
1405 iLastFindTxt = HBufC::NewL( 0 ); |
|
1406 |
|
1407 // Create tracks list model & listbox array |
|
1408 iListModel = CMPXAddTracksListModel::NewL(); |
|
1409 CMPXAddTracksLbxArray* lbxArray = CMPXAddTracksLbxArray::NewL( iListModel ); |
|
1410 |
|
1411 // Set item array to listbox model, transfer ownership |
|
1412 CTextListBoxModel* listboxModel = iListBox->Model(); |
|
1413 listboxModel->SetItemTextArray( lbxArray ); |
|
1414 listboxModel->SetOwnershipType( ELbmOwnsItemArray ); |
|
1415 |
|
1416 // Create and set icon array. Ownership transferred. |
|
1417 CArrayPtr<CGulIcon>* icons = lbxArray->CreateIconArrayL(); |
|
1418 SetIconArrayL( icons ); |
|
1419 |
|
1420 // Set scrollbar |
|
1421 iListBox->CreateScrollBarFrameL( ETrue ); |
|
1422 iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, |
|
1423 CEikScrollBarFrame::EAuto ); |
|
1424 |
|
1425 // Enable Marquee |
|
1426 static_cast<CEikColumnListBox*>( iListBox )->EnableExtendedDrawingL(); |
|
1427 static_cast<CEikColumnListBox*>( iListBox )->ItemDrawer()-> |
|
1428 ColumnData()->EnableMarqueeL( ETrue ); |
|
1429 |
|
1430 // Enable speed scrolling |
|
1431 iLbxExtFeat = CMPXLbxExtendedFeatures::NewL( iListBox, EFalse ); |
|
1432 iLbxExtFeat->EnableSpeedScrollL( ETrue ); |
|
1433 |
|
1434 CEikStatusPane* statusPane = iAvkonAppUi->StatusPane(); |
|
1435 iNaviPane = static_cast<CAknNavigationControlContainer*> |
|
1436 ( statusPane->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) ); |
|
1437 // read the navigation pane text resource |
|
1438 HBufC* text = StringLoader::LoadLC( R_MPX_CUI_ADDSONGS_SONG_ADDED ); |
|
1439 iNaviDecorator = iNaviPane->CreateNavigationLabelL( *text ); |
|
1440 CleanupStack::PopAndDestroy( text ); |
|
1441 |
|
1442 // Animation icon timer |
|
1443 iPeriodic = CPeriodic::NewL( CActive::EPriorityIdle ); |
|
1444 |
|
1445 // Set empty text |
|
1446 iListBox->View()->SetListEmptyTextL( *iNoSongText ); |
|
1447 iListModel->SetFindSongsFlag( ETrue ); |
|
1448 |
|
1449 // get current playlist ID |
|
1450 CMPXCollectionPath* cpath = iCollectionUtility->Collection().PathL(); |
|
1451 CleanupStack::PushL( cpath ); |
|
1452 cpath->Back(); |
|
1453 MPX_DEBUG_PATH( *cpath ); |
|
1454 RArray<TMPXAttribute> attrs; |
|
1455 CleanupClosePushL(attrs); |
|
1456 attrs.Append( KMPXMediaGeneralId ); |
|
1457 iCollectionUtility->Collection().MediaL( *cpath, attrs.Array() ); |
|
1458 CleanupStack::PopAndDestroy( &attrs ); |
|
1459 CleanupStack::PopAndDestroy( cpath ); |
|
1460 |
|
1461 // Update listbox |
|
1462 LoadCategoriesL(); |
|
1463 |
|
1464 // Update softkey |
|
1465 UpdateSoftkeyL(); |
|
1466 } |
|
1467 |
|
1468 // ----------------------------------------------------------------------------- |
|
1469 // CMPXAddTracksDialog::OkToExitL |
|
1470 // Check if it's ok to exit. |
|
1471 // (other items were commented in a header). |
|
1472 // ----------------------------------------------------------------------------- |
|
1473 // |
|
1474 TBool CMPXAddTracksDialog::OkToExitL( TInt aButtonId ) |
|
1475 { |
|
1476 MPX_FUNC( "CMPXAddTracksDialog::OkToExitL" ); |
|
1477 MPX_DEBUG2( "CMPXAddTracksDialog::OkToExitL aButtonId = 0x%x", aButtonId ); |
|
1478 TBool retVal = EFalse; |
|
1479 |
|
1480 switch (aButtonId) |
|
1481 { |
|
1482 case EMPXCmdAddTracksExpand: |
|
1483 { |
|
1484 ExpandCurrentGroupL(); |
|
1485 break; |
|
1486 } |
|
1487 case EMPXCmdAddTracksCollapse: |
|
1488 { |
|
1489 CollapseCurrentGroupL(); |
|
1490 break; |
|
1491 } |
|
1492 case EMPXCmdAddTracksAdd: |
|
1493 { |
|
1494 // Add track to the playlist |
|
1495 AddCurrentTrackToPlaylistL(); |
|
1496 break; |
|
1497 } |
|
1498 case EMPXCmdAddTracksDone: |
|
1499 { |
|
1500 retVal = ETrue; |
|
1501 break; |
|
1502 } |
|
1503 case EMPXCmdAddTracksFindCancel: |
|
1504 { |
|
1505 CAknSearchField* findBox = FindBox(); |
|
1506 findBox->MakeVisible( EFalse ); |
|
1507 findBox->SetFocus( EFalse ); |
|
1508 TRAP_IGNORE( findBox->ResetL() ); |
|
1509 iListBox->SetFocus( ETrue ); |
|
1510 |
|
1511 TRect mainPane; |
|
1512 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPane ); |
|
1513 SetSizeAndPosition( mainPane.Size() ); |
|
1514 break; |
|
1515 } |
|
1516 default: |
|
1517 { |
|
1518 retVal = CAknSelectionListDialog::OkToExitL( aButtonId ); |
|
1519 break; |
|
1520 } |
|
1521 } |
|
1522 |
|
1523 return retVal; |
|
1524 } |
|
1525 |
|
1526 // ----------------------------------------------------------------------------- |
|
1527 // CMPXAddTracksDialog::OfferKeyEventL |
|
1528 // Handles key-events. |
|
1529 // (other items were commented in a header). |
|
1530 // ----------------------------------------------------------------------------- |
|
1531 // |
|
1532 TKeyResponse CMPXAddTracksDialog::OfferKeyEventL( |
|
1533 const TKeyEvent& aKeyEvent, |
|
1534 TEventCode aType ) |
|
1535 { |
|
1536 MPX_FUNC( "CMPXAddTracksDialog::OfferKeyEventL" ); |
|
1537 TKeyResponse res = EKeyWasNotConsumed; |
|
1538 TBool updateCBA = EFalse; |
|
1539 CAknSearchField* findbox = FindBox(); |
|
1540 |
|
1541 if ( aType == EEventKey ) |
|
1542 { |
|
1543 StopAnimL(); |
|
1544 |
|
1545 switch ( aKeyEvent.iCode ) |
|
1546 { |
|
1547 case EKeyUpArrow: |
|
1548 case EKeyDownArrow: |
|
1549 { |
|
1550 updateCBA = ETrue; |
|
1551 break; |
|
1552 } |
|
1553 case EKeyLeftArrow: |
|
1554 { |
|
1555 TInt index = CurrentLbxItemIndex(); |
|
1556 if ( index != KErrNotFound ) |
|
1557 { |
|
1558 if ( iListModel->TrackTypeL( index ) != EMPXGroup ) |
|
1559 { |
|
1560 GotoClosestGroupL(); |
|
1561 } |
|
1562 else |
|
1563 { |
|
1564 CollapseCurrentGroupL(); |
|
1565 } |
|
1566 } |
|
1567 res = EKeyWasConsumed; |
|
1568 break; |
|
1569 } |
|
1570 case EKeyRightArrow: |
|
1571 { |
|
1572 ExpandCurrentGroupL(); |
|
1573 res = EKeyWasConsumed; |
|
1574 break; |
|
1575 } |
|
1576 case EKeyOK: |
|
1577 case EKeyEnter: |
|
1578 { |
|
1579 // Do the right thing on right item |
|
1580 TInt index = CurrentLbxItemIndex(); |
|
1581 if ( index != KErrNotFound ) |
|
1582 { |
|
1583 if ( iListModel->TrackTypeL( index ) == EMPXGroup ) |
|
1584 { |
|
1585 if ( iListModel->IsExpandedIndex( index ) ) |
|
1586 { |
|
1587 CollapseCurrentGroupL(); |
|
1588 } |
|
1589 else |
|
1590 { |
|
1591 ExpandCurrentGroupL(); |
|
1592 } |
|
1593 } |
|
1594 else |
|
1595 { |
|
1596 AddCurrentTrackToPlaylistL(); |
|
1597 } |
|
1598 } |
|
1599 res = EKeyWasConsumed; |
|
1600 break; |
|
1601 } |
|
1602 default: |
|
1603 { |
|
1604 break; |
|
1605 } |
|
1606 } |
|
1607 } |
|
1608 TBool offerEventToBaseClass( EFalse ); |
|
1609 |
|
1610 if ( res == EKeyWasNotConsumed ) |
|
1611 { |
|
1612 if ( ( aKeyEvent.iCode == EKeyUpArrow ) || |
|
1613 ( aKeyEvent.iScanCode == EStdKeyUpArrow ) || |
|
1614 ( aKeyEvent.iCode == EKeyDownArrow ) || |
|
1615 ( aKeyEvent.iScanCode == EStdKeyDownArrow ) ) |
|
1616 { |
|
1617 res = iLbxExtFeat->HandleLbxKeyEventL( aKeyEvent, aType ); |
|
1618 } |
|
1619 // handle right soft key |
|
1620 else if( findbox->IsVisible() && |
|
1621 ( aKeyEvent.iCode == EKeyDevice1 || |
|
1622 aKeyEvent.iScanCode == EStdKeyDevice1 ) ) |
|
1623 { |
|
1624 StopAnimL(); |
|
1625 res = EKeyWasConsumed; |
|
1626 } |
|
1627 else |
|
1628 { |
|
1629 if ( findbox ) |
|
1630 { |
|
1631 TName text; |
|
1632 findbox->GetSearchText( text ); |
|
1633 updateCBA = ETrue; |
|
1634 if ( *iLastFindTxt != text ) |
|
1635 { |
|
1636 // Update CBA if find text is changed |
|
1637 delete iLastFindTxt; |
|
1638 iLastFindTxt = NULL; |
|
1639 iLastFindTxt = text.AllocL(); |
|
1640 DoFindL(); |
|
1641 } |
|
1642 if ( iLastFindTxt->Length() == 0 && aKeyEvent.iCode == EKeyBackspace ) |
|
1643 { |
|
1644 CAknSearchField* findBox = FindBox(); |
|
1645 findBox->MakeVisible( EFalse ); |
|
1646 findBox->SetFocus( EFalse ); |
|
1647 TRAP_IGNORE( findBox->ResetL() ); |
|
1648 iListBox->SetFocus( ETrue ); |
|
1649 |
|
1650 TRect mainPane; |
|
1651 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPane ); |
|
1652 SetSizeAndPosition( mainPane.Size() ); |
|
1653 res = EKeyWasConsumed; |
|
1654 } |
|
1655 else |
|
1656 { |
|
1657 offerEventToBaseClass = ETrue; |
|
1658 } |
|
1659 } |
|
1660 else |
|
1661 { |
|
1662 offerEventToBaseClass = ETrue; |
|
1663 } |
|
1664 } |
|
1665 } |
|
1666 if ( updateCBA ) |
|
1667 { |
|
1668 UpdateSoftkeyL(); |
|
1669 } |
|
1670 if ( offerEventToBaseClass ) |
|
1671 { |
|
1672 // this has to be done after cba is updated |
|
1673 res = CAknSelectionListDialog::OfferKeyEventL( aKeyEvent, aType ); |
|
1674 } |
|
1675 return res; |
|
1676 } |
|
1677 |
|
1678 // --------------------------------------------------------------------------- |
|
1679 // From CCoeControl |
|
1680 // Handles a change to the control's resources. |
|
1681 // --------------------------------------------------------------------------- |
|
1682 // |
|
1683 void CMPXAddTracksDialog::HandleResourceChange( TInt aType ) |
|
1684 { |
|
1685 MPX_FUNC( "CMPXAddTracksDialog::HandleResourceChange" ); |
|
1686 CAknSelectionListDialog::HandleResourceChange( aType ); |
|
1687 |
|
1688 if ( aType == KEikDynamicLayoutVariantSwitch ) |
|
1689 { |
|
1690 TRect rect; |
|
1691 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, rect ); |
|
1692 SetRect( rect ); |
|
1693 } |
|
1694 |
|
1695 if ( aType == KAknsMessageSkinChange ) |
|
1696 { |
|
1697 // Create and set icon array. Ownership transferred. |
|
1698 CTextListBoxModel* listboxModel = iListBox->Model(); |
|
1699 MDesCArray* lbxArray = listboxModel->ItemTextArray(); |
|
1700 CMPXAddTracksLbxArray* addtracksLbxArray = |
|
1701 static_cast<CMPXAddTracksLbxArray*>( lbxArray ); |
|
1702 TRAP_IGNORE( |
|
1703 CArrayPtr<CGulIcon>* icons = addtracksLbxArray->CreateIconArrayL(); |
|
1704 SetIconArrayL( icons ); |
|
1705 ); |
|
1706 } |
|
1707 } |
|
1708 |
|
1709 // --------------------------------------------------------------------------- |
|
1710 // From MEikListBoxObserver |
|
1711 // Handles listbox events. |
|
1712 // --------------------------------------------------------------------------- |
|
1713 // |
|
1714 void CMPXAddTracksDialog::HandleListBoxEventL( |
|
1715 CEikListBox* /*aListBox*/, |
|
1716 TListBoxEvent aEventType) |
|
1717 { |
|
1718 MPX_FUNC( "CMPXAddTracksDialog::HandleListBoxEventL" ); |
|
1719 StopAnimL(); |
|
1720 if ( aEventType == EEventEnterKeyPressed || aEventType == EEventItemDoubleClicked |
|
1721 #ifdef SINGLE_CLICK_INCLUDED |
|
1722 || aEventType == EEventItemSingleClicked |
|
1723 #endif |
|
1724 ) |
|
1725 { |
|
1726 // Do the right thing on right item |
|
1727 TInt index = CurrentLbxItemIndex(); |
|
1728 if ( index != KErrNotFound ) |
|
1729 { |
|
1730 if ( iListModel->TrackTypeL( index ) == EMPXGroup ) |
|
1731 { |
|
1732 if ( iListModel->IsExpandedIndex( index ) ) |
|
1733 { |
|
1734 CollapseCurrentGroupL(); |
|
1735 } |
|
1736 else |
|
1737 { |
|
1738 ExpandCurrentGroupL(); |
|
1739 } |
|
1740 } |
|
1741 else |
|
1742 { |
|
1743 AddCurrentTrackToPlaylistL(); |
|
1744 } |
|
1745 } |
|
1746 } |
|
1747 else |
|
1748 { |
|
1749 iNaviPane->PushDefaultL(); |
|
1750 UpdateSoftkeyL(); |
|
1751 } |
|
1752 } |
|
1753 |
|
1754 // --------------------------------------------------------------------------- |
|
1755 // Function called by CIdle to close the dialog itself when collection view |
|
1756 // can not handle the closing of dialog due to waitnote displayed by |
|
1757 // CMPXCollectionViewImp::DoIncrementalOpenL |
|
1758 // --------------------------------------------------------------------------- |
|
1759 // |
|
1760 TInt CMPXAddTracksDialog::DeferredExitCallback( TAny* aPtr ) |
|
1761 { |
|
1762 MPX_DEBUG1( "CMPXAddTracksDialog::DeferredExitCallback" ); |
|
1763 CMPXAddTracksDialog* self = |
|
1764 static_cast<CMPXAddTracksDialog*>( aPtr ); |
|
1765 TRAP_IGNORE( self->TryExitL( EMPXCmdAddTracksDone ) ); |
|
1766 return KErrNone; |
|
1767 } |
|
1768 |
|
1769 // ProcessCommandL has been implemented here for the sole |
|
1770 // of handling RSK command when findbox is shown. For other |
|
1771 // cases it goes along the same path that is used by hardware |
|
1772 // keys, e.g. by call to TryToExitL. |
|
1773 void CMPXAddTracksDialog::ProcessCommandL( TInt aCommandId ) |
|
1774 { |
|
1775 CAknSelectionListDialog::ProcessCommandL( aCommandId ); |
|
1776 TryExitL( aCommandId ); |
|
1777 |
|
1778 // Check that the dialog is not being closed |
|
1779 if( aCommandId != EMPXCmdAddTracksDone ) |
|
1780 { |
|
1781 // Reset view so that all songs are shown |
|
1782 TName text; |
|
1783 CAknSearchField* findbox = FindBox(); |
|
1784 if( findbox ) |
|
1785 { |
|
1786 findbox->GetSearchText( text ); |
|
1787 delete iLastFindTxt; |
|
1788 iLastFindTxt = NULL; |
|
1789 iLastFindTxt = text.AllocL(); |
|
1790 DoFindL(); |
|
1791 HandleItemArrayChangeL(); |
|
1792 } |
|
1793 } |
|
1794 } |
|
1795 // End of File |