|
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 common container for the |
|
15 * Hitchcock platform. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <barsread.h> |
|
23 #include <stringloader.h> |
|
24 #include <akniconarray.h> |
|
25 #include <gulicon.h> |
|
26 #include <featmgr.h> |
|
27 #include <aknsfld.h> |
|
28 #include <aknutils.h> |
|
29 #include <aknlists.h> |
|
30 #include <aknconsts.h> |
|
31 #include <avkon.mbg> |
|
32 #include <eikclbd.h> |
|
33 #include <eikcmobs.h> |
|
34 #include <bautils.h> |
|
35 #include <glib/gstring.h> //for handling the Ustring memory leak |
|
36 #include <aknview.h> |
|
37 |
|
38 // Uiaccelerator Includes |
|
39 #include <alf/alfcontrolgroup.h> |
|
40 #include <alf/alfdisplay.h> |
|
41 #include <alf/alfenv.h> |
|
42 #include <alf/alfroster.h> |
|
43 #include <alf/alfwidgetcontrol.h> // To get CAlfControl from CAlfWidgetControl |
|
44 #include <alf/alfwidgetenvextension.h> |
|
45 |
|
46 #include <alf/ialfviewwidget.h> |
|
47 #include <alf/ialfcontainerwidget.h> |
|
48 #include <alf/ialfmap.h> |
|
49 #include <alf/ialfwidgetfactory.h> // Widget factory |
|
50 #include <osn/ustring.h> // ustring |
|
51 #include <osn/osnnew.h> |
|
52 #include <osn/alfptrvector.h> |
|
53 |
|
54 // MUL Includes |
|
55 #include <mul/imulwidget.h> // For Templates |
|
56 #include <mul/imullistwidget.h> // List widget |
|
57 #include <mul/imulmodel.h> // Data model |
|
58 #include <mul/mulvisualitem.h> // For Visual Item |
|
59 #include <mul/imulwidgetdef.h> |
|
60 |
|
61 #include <data_caging_path_literals.hrh> |
|
62 #include <mpxlog.h> |
|
63 #include <mpxuser.h> |
|
64 #include <mpxmedia.h> |
|
65 #include <mpxmediaarray.h> |
|
66 #include <mpxmediageneraldefs.h> |
|
67 #include <mpxmediamusicdefs.h> |
|
68 #include <mpxpodcastdefs.h> |
|
69 #include <mpxcommonuihelper.h> |
|
70 |
|
71 #include <mpxcommoncontainer.rsg> |
|
72 |
|
73 #include "mpxcommonlistboxarraybase.h" |
|
74 #include "mpxcommoncontainermediahelper.h" |
|
75 #include "mpxcommoncontainertexturemanager.h" |
|
76 #include "mpxcommoncontainerhitchcockimp.h" |
|
77 #include "mpxcommoncontainerfilteredlist.h" |
|
78 #include "mpxcommoncontainer.hrh" |
|
79 |
|
80 #include <thumbnaildata.h> |
|
81 #include <thumbnailobjectsource.h> |
|
82 |
|
83 using namespace Alf; |
|
84 //using namespace mulvisualitem; |
|
85 |
|
86 // CONSTANTS |
|
87 //const TInt KMPXFindboxTextLimit = 40; |
|
88 const TInt KMPXListSelectionCount = 5; |
|
89 const TInt KListControlGroupIdMusic = 270531711; // Need to be unique. Using music collection dll UID. |
|
90 const TInt KListControlGroupIdPodcast = 270531738; // Need to be unique. Using podcast collection dll UID. |
|
91 |
|
92 const TInt KMPXMinSecSeparatorIndex = 2; |
|
93 const TInt KOneHourInSeconds = 3600; |
|
94 const TInt KMPXTimeIndicatorLength = 16; |
|
95 _LIT( KMPXDash, " - " ); |
|
96 _LIT( KMPXZeroDurationMark, "--"); |
|
97 _LIT( KMPXAlbumMimeType, "image/jpeg" ); |
|
98 |
|
99 // AK - Temporary Begin - These need to be localized |
|
100 _LIT( KUnknown, "Unknown" ); |
|
101 _LIT( KSong, " song" ); |
|
102 _LIT( KSongs, " songs" ); |
|
103 _LIT( KEpisode, " episode" ); |
|
104 _LIT( KEpisodes, " episodes" ); |
|
105 _LIT( KAlbum, " album" ); |
|
106 _LIT( KAlbums, " albums" ); |
|
107 _LIT( KSongDash, " song - " ); |
|
108 _LIT( KSongsDash, " songs - " ); |
|
109 // AK - Temporary End |
|
110 |
|
111 // ======== MEMBER FUNCTIONS ======== |
|
112 |
|
113 // --------------------------------------------------------------------------- |
|
114 // C++ constructor can NOT contain any code that might leave. |
|
115 // --------------------------------------------------------------------------- |
|
116 // |
|
117 CMPXCommonContainerHitchcockImp::CMPXCommonContainerHitchcockImp() : |
|
118 iContext( EContextUnknown ), |
|
119 iIsFindEnabled( EFalse ), |
|
120 iIsMarkingEnabled( ETrue ), |
|
121 iTopIndex( KErrNotFound ), |
|
122 iBottomIndex( KErrNotFound ), |
|
123 iAlfEnvCreated( EFalse ), |
|
124 iContainerActive( EFalse ) |
|
125 { |
|
126 } |
|
127 |
|
128 // --------------------------------------------------------------------------- |
|
129 // Destructor |
|
130 // --------------------------------------------------------------------------- |
|
131 // |
|
132 CMPXCommonContainerHitchcockImp::~CMPXCommonContainerHitchcockImp() |
|
133 { |
|
134 MPX_FUNC( "CMPXCommonContainerHitchcockImp::~CMPXCommonContainerHitchcockImp" ); |
|
135 |
|
136 FeatureManager::UnInitializeLib(); |
|
137 |
|
138 if ( iResourceOffset ) |
|
139 { |
|
140 iEikonEnv->DeleteResourceFile( iResourceOffset ); |
|
141 } |
|
142 |
|
143 if ( iListWidget ) |
|
144 { |
|
145 iListWidget->RemoveEventHandler(*this); |
|
146 } |
|
147 // delete iEnv; |
|
148 |
|
149 delete iListSelections; |
|
150 delete iListBoxArray; |
|
151 delete iIconArray; |
|
152 |
|
153 if ( iTextureManager ) |
|
154 { |
|
155 iTextureManager->ClearCache(); |
|
156 } |
|
157 delete iTextureManager; |
|
158 delete iCommonUiHelper; |
|
159 |
|
160 delete iThumbnailManager; |
|
161 iThumbnailReqArray.Close(); |
|
162 |
|
163 delete iFilteredList; |
|
164 delete iSearchFieldWrapper; |
|
165 } |
|
166 |
|
167 // --------------------------------------------------------------------------- |
|
168 // Return Coe Control |
|
169 // --------------------------------------------------------------------------- |
|
170 // |
|
171 CCoeControl* CMPXCommonContainerHitchcockImp::CoeControl() |
|
172 { |
|
173 MPX_FUNC( "CMPXCommonContainerHitchcockImp::CoeControl" ); |
|
174 return this; |
|
175 } |
|
176 |
|
177 // --------------------------------------------------------------------------- |
|
178 // Set View Container |
|
179 // --------------------------------------------------------------------------- |
|
180 // |
|
181 void CMPXCommonContainerHitchcockImp::SetViewContainer( |
|
182 MMPXViewContainer* aViewContainer ) |
|
183 { |
|
184 MPX_FUNC( "CMPXCommonContainerHitchcockImp::SetViewContainer" ); |
|
185 iViewContainer = aViewContainer; |
|
186 } |
|
187 |
|
188 // --------------------------------------------------------------------------- |
|
189 // Set command observer for the container |
|
190 // --------------------------------------------------------------------------- |
|
191 // |
|
192 void CMPXCommonContainerHitchcockImp::SetCommandObserver( |
|
193 MEikCommandObserver* aCommandObserver ) |
|
194 { |
|
195 MPX_FUNC( "CMPXCommonContainerHitchcockImp::SetCommandObserver" ); |
|
196 iView = aCommandObserver; |
|
197 } |
|
198 |
|
199 // --------------------------------------------------------------------------- |
|
200 // C++ constructor can NOT contain any code that might leave. |
|
201 // --------------------------------------------------------------------------- |
|
202 // |
|
203 void CMPXCommonContainerHitchcockImp::SetListBoxObserver( |
|
204 MEikListBoxObserver* aListBoxObserver ) |
|
205 { |
|
206 MPX_FUNC( "CMPXCommonContainerHitchcockImp::SetListBoxObserver" ); |
|
207 iListBoxObserver = aListBoxObserver; |
|
208 } |
|
209 |
|
210 // --------------------------------------------------------------------------- |
|
211 // Set layout for all elements and set sizes for icons. |
|
212 // --------------------------------------------------------------------------- |
|
213 // |
|
214 void CMPXCommonContainerHitchcockImp::UpdateLayout() |
|
215 { |
|
216 MPX_FUNC( "CMPXCommonContainerHitchcockImp::UpdateLayout" ); |
|
217 } |
|
218 |
|
219 // ----------------------------------------------------------------------------- |
|
220 // Returns a pointer to the listboxarray |
|
221 // ----------------------------------------------------------------------------- |
|
222 // |
|
223 CMPXCommonListBoxArrayBase* CMPXCommonContainerHitchcockImp::ListBoxArray() const |
|
224 { |
|
225 return iListBoxArray; |
|
226 } |
|
227 |
|
228 // ----------------------------------------------------------------------------- |
|
229 // Sets listbox array |
|
230 // ----------------------------------------------------------------------------- |
|
231 // |
|
232 void CMPXCommonContainerHitchcockImp::SetListBoxArrayL( |
|
233 CMPXCommonListBoxArrayBase* aListBoxArray ) |
|
234 { |
|
235 iListBoxArray = aListBoxArray; |
|
236 } |
|
237 |
|
238 // ----------------------------------------------------------------------------- |
|
239 // Return number of listbox items shown in the current listbox. |
|
240 // ----------------------------------------------------------------------------- |
|
241 // |
|
242 TInt CMPXCommonContainerHitchcockImp::CurrentListItemCount() const |
|
243 { |
|
244 MPX_FUNC( "CMPXCommonContainerHitchcockImp::CurrentListItemCount" ); |
|
245 TInt count = 0; |
|
246 if ( iWidgetModel ) |
|
247 { |
|
248 count = iWidgetModel->Count(); |
|
249 } |
|
250 return count; |
|
251 } |
|
252 |
|
253 // ----------------------------------------------------------------------------- |
|
254 // Return total number of listbox items in the listbox. |
|
255 // ----------------------------------------------------------------------------- |
|
256 // |
|
257 TInt CMPXCommonContainerHitchcockImp::TotalListItemCount() const |
|
258 { |
|
259 MPX_FUNC( "CMPXCommonContainerHitchcockImp::TotalListItemCount" ); |
|
260 TInt count = 0; |
|
261 if ( iWidgetModel ) |
|
262 { |
|
263 count = iWidgetModel->Count(); |
|
264 } |
|
265 return count; |
|
266 } |
|
267 |
|
268 // ----------------------------------------------------------------------------- |
|
269 // Gets top listbox item index (relative to the original listbox). |
|
270 // ----------------------------------------------------------------------------- |
|
271 // |
|
272 TInt CMPXCommonContainerHitchcockImp::TopLbxItemIndex() const |
|
273 { |
|
274 MPX_FUNC( "CMPXCommonContainerHitchcockImp::TopLbxItemIndex" ); |
|
275 return iTopIndex; |
|
276 } |
|
277 |
|
278 // ----------------------------------------------------------------------------- |
|
279 // Gets bottom listbox item index (relative to the original listbox). |
|
280 // ----------------------------------------------------------------------------- |
|
281 // |
|
282 TInt CMPXCommonContainerHitchcockImp::BottomLbxItemIndex() const |
|
283 { |
|
284 MPX_FUNC( "CMPXCommonContainerHitchcockImp::BottomLbxItemIndex" ); |
|
285 return iBottomIndex; |
|
286 } |
|
287 |
|
288 // ----------------------------------------------------------------------------- |
|
289 // Gets current listbox item index (relative to the original listbox). |
|
290 // ----------------------------------------------------------------------------- |
|
291 // |
|
292 TInt CMPXCommonContainerHitchcockImp::CurrentLbxItemIndex() const |
|
293 { |
|
294 MPX_FUNC( "CMPXCommonContainerHitchcockImp::CurrentLbxItemIndex" ); |
|
295 const TInt count = CurrentListItemCount(); |
|
296 TInt index( KErrNotFound ); |
|
297 if( count > 0 ) |
|
298 { |
|
299 index = iWidgetModel->Highlight(); |
|
300 if ( iFilteredList ) |
|
301 { |
|
302 index = iFilteredList->FilteredIndexToRealIndex(index); |
|
303 } |
|
304 } |
|
305 return index; |
|
306 } |
|
307 |
|
308 // ----------------------------------------------------------------------------- |
|
309 // Get current selected listbox items indices (relative to the original listbox) |
|
310 // ----------------------------------------------------------------------------- |
|
311 // |
|
312 const CArrayFix<TInt>* CMPXCommonContainerHitchcockImp:: |
|
313 CurrentSelectionIndicesL() const |
|
314 { |
|
315 MPX_FUNC( "CMPXCommonContainerHitchcockImp::CurrentSelectionIndicesL" ); |
|
316 iListSelections->Reset(); |
|
317 if ( iWidgetModel ) |
|
318 { |
|
319 std::vector<int> itemsSelected = iWidgetModel->MarkedIndices(); |
|
320 int count = itemsSelected.size(); |
|
321 if ( iFilteredList ) |
|
322 { |
|
323 for( int i = 0; i < count; i++ ) |
|
324 { |
|
325 TInt index = iFilteredList->FilteredIndexToRealIndex( static_cast<TInt>( itemsSelected[i] ) ); |
|
326 iListSelections->AppendL( index ); |
|
327 } |
|
328 } |
|
329 else |
|
330 { |
|
331 for( int i = 0; i < count; i++ ) |
|
332 { |
|
333 iListSelections->AppendL( static_cast<TInt>( itemsSelected[i] ) ); |
|
334 } |
|
335 } |
|
336 } |
|
337 return iListSelections; |
|
338 } |
|
339 |
|
340 // ----------------------------------------------------------------------------- |
|
341 // Get current selected listbox items indices (relative to the original listbox) |
|
342 // ----------------------------------------------------------------------------- |
|
343 // |
|
344 void CMPXCommonContainerHitchcockImp::SetCurrentSelectionIndicesL( |
|
345 CArrayFix<TInt>* aIndices ) const |
|
346 { |
|
347 MPX_FUNC( "CMPXCommonContainerHitchcockImp::SetCurrentSelectionIndicesL" ); |
|
348 TInt count = aIndices->Count(); |
|
349 if ( count > 0 && iWidgetModel ) |
|
350 { |
|
351 std::vector<int> itemsToSelect; |
|
352 for( TInt i = 0; i < count; i++ ) |
|
353 { |
|
354 itemsToSelect.push_back( (*aIndices)[i] ); |
|
355 } |
|
356 iWidgetModel->SetMarkedIndices(MulWidgetDef::EMulMark, itemsToSelect); |
|
357 } |
|
358 } |
|
359 |
|
360 // ----------------------------------------------------------------------------- |
|
361 // Set top listbox item index. |
|
362 // ----------------------------------------------------------------------------- |
|
363 // |
|
364 void CMPXCommonContainerHitchcockImp::SetLbxTopItemIndex( TInt /*aIndex*/ ) |
|
365 { |
|
366 MPX_FUNC( "CMPXCommonContainerHitchcockImp::SetLbxTopItemIndex" ); |
|
367 // Not required for Hitchcock |
|
368 } |
|
369 |
|
370 // ----------------------------------------------------------------------------- |
|
371 // Set current listbox item index. |
|
372 // ----------------------------------------------------------------------------- |
|
373 // |
|
374 void CMPXCommonContainerHitchcockImp::SetLbxCurrentItemIndex( TInt aIndex ) |
|
375 { |
|
376 MPX_FUNC( "CMPXCommonContainerHitchcockImp::SetLbxCurrentItemIndex" ); |
|
377 if ( iWidgetModel ) |
|
378 { |
|
379 iWidgetModel->SetHighlight( aIndex ); |
|
380 } |
|
381 } |
|
382 |
|
383 // ----------------------------------------------------------------------------- |
|
384 // Set current listbox item index and highlight it. |
|
385 // ----------------------------------------------------------------------------- |
|
386 // |
|
387 void CMPXCommonContainerHitchcockImp::SetLbxCurrentItemIndexAndDraw( |
|
388 TInt aIndex ) |
|
389 { |
|
390 MPX_FUNC( "CMPXCommonContainerHitchcockImp::SetLbxCurrentItemIndexAndDraw" ); |
|
391 if ( iWidgetModel ) |
|
392 { |
|
393 if ( (aIndex >= 0) && (aIndex < iWidgetModel->Count()) ) |
|
394 { |
|
395 iWidgetModel->SetHighlight( aIndex ); |
|
396 } |
|
397 } |
|
398 } |
|
399 |
|
400 // ----------------------------------------------------------------------------- |
|
401 // Clear listbox selection. |
|
402 // ----------------------------------------------------------------------------- |
|
403 // |
|
404 void CMPXCommonContainerHitchcockImp::ClearLbxSelection() |
|
405 { |
|
406 MPX_FUNC( "CMPXCommonContainerHitchcockImp::ClearLbxSelection" ); |
|
407 if ( iWidgetModel ) |
|
408 { |
|
409 iWidgetModel->SetMarkedIndices(MulWidgetDef::EMulUnmarkAll); |
|
410 } |
|
411 } |
|
412 |
|
413 // ----------------------------------------------------------------------------- |
|
414 // Sets the text for an empty list box |
|
415 // ----------------------------------------------------------------------------- |
|
416 // |
|
417 void CMPXCommonContainerHitchcockImp::SetLbxEmptyTextL( const TDesC& aText ) |
|
418 { |
|
419 if ( aText == KNullDesC ) |
|
420 { |
|
421 return; |
|
422 } |
|
423 if ( iListWidget ) |
|
424 { |
|
425 HBufC8* buf = MPXUser::Alloc8ZL( aText ); |
|
426 TPtr8 ptr( buf->Des() ); |
|
427 UString emptyText( (char*)ptr.PtrZ() ); |
|
428 CleanupStack::PushL( buf ); |
|
429 iListWidget->SetEmptyText( emptyText ); |
|
430 CleanupStack::PopAndDestroy( buf ); |
|
431 } |
|
432 } |
|
433 |
|
434 // ----------------------------------------------------------------------------- |
|
435 // Draws a list box item |
|
436 // ----------------------------------------------------------------------------- |
|
437 // |
|
438 void CMPXCommonContainerHitchcockImp::DrawLbxItem( TInt aIndex ) |
|
439 { |
|
440 MPX_DEBUG2( "CMPXCommonContainerHitchcockImp::DrawLbxItem (aIndex=%d)", aIndex ); |
|
441 |
|
442 // Just inform the model about the update. Model will request for data if necessary. |
|
443 // Ignore if find box is activated |
|
444 if ( iWidgetModel && !FindBoxVisibility() ) |
|
445 { |
|
446 TInt count = iWidgetModel->Count(); |
|
447 if ( aIndex >= 0 && aIndex < count ) |
|
448 { |
|
449 iWidgetModel->Update(aIndex, 1); |
|
450 } |
|
451 } |
|
452 } |
|
453 |
|
454 // ----------------------------------------------------------------------------- |
|
455 // Set Find box's focus. |
|
456 // ----------------------------------------------------------------------------- |
|
457 // |
|
458 void CMPXCommonContainerHitchcockImp::SetFindBoxFocus( TBool /*aFocus*/ ) |
|
459 { |
|
460 MPX_FUNC( "CMPXCommonContainerHitchcockImp::SetFindBoxFocus" ); |
|
461 // Not used |
|
462 } |
|
463 |
|
464 // ----------------------------------------------------------------------------- |
|
465 // Handle listbox item addition. |
|
466 // ----------------------------------------------------------------------------- |
|
467 // |
|
468 void CMPXCommonContainerHitchcockImp::HandleLbxItemAdditionL() |
|
469 { |
|
470 MPX_FUNC( "CMPXCommonContainerHitchcockImp::HandleLbxItemAdditionL" ); |
|
471 const char* KLoadNameModel("mulmodel"); |
|
472 HandleLbxItemRemovalL(); |
|
473 IAlfWidgetFactory& widgetFactory = AlfWidgetEnvExtension::widgetFactory(*iEnv); |
|
474 iWidgetModel = widgetFactory.createModel<IMulModel>( KLoadNameModel ); |
|
475 iWidgetModel->SetDataProvider(*this); |
|
476 SetCollectionContextL(); |
|
477 |
|
478 TInt count = 0; |
|
479 if ( iFilteredList ) |
|
480 { |
|
481 iFilteredList->ReplaceMediaListL( iListBoxArray->MediaArray() ); |
|
482 count = iFilteredList->FilteredCount(); |
|
483 } |
|
484 else |
|
485 { |
|
486 count = iListBoxArray->MediaArray().Count(); |
|
487 } |
|
488 if ( count > 0 ) |
|
489 { |
|
490 iWidgetModel->Insert(0, count); |
|
491 } |
|
492 if ( iListWidget ) |
|
493 { |
|
494 iListWidget->SetModel( iWidgetModel->Accessor() ); |
|
495 } |
|
496 else |
|
497 { |
|
498 // Create list widget. CAlfEnv owns widget |
|
499 MPX_DEBUG1("CMPXCommonContainerHitchcockImp - Create List widget."); |
|
500 const char* KLoadNameList("mullistwidget"); |
|
501 const char* KListWidgetName("mpxmullistwidget"); |
|
502 const char* KListWidgetNamePod("mpxmullistwidgetpod"); |
|
503 |
|
504 // Create view widget. CAlfEnv owns widget |
|
505 if ( iCollectionType == MMPXCommonContainer::EMPXCommonContainerMusic ) |
|
506 { |
|
507 iListWidget = widgetFactory.createWidget<IMulListWidget>(KLoadNameList, KListWidgetName, *iViewWidget, NULL ); |
|
508 } |
|
509 else if ( iCollectionType == MMPXCommonContainer::EMPXCommonContainerPodcast ) |
|
510 { |
|
511 iListWidget = widgetFactory.createWidget<IMulListWidget>(KLoadNameList, KListWidgetNamePod, *iViewWidget, NULL ); |
|
512 } |
|
513 |
|
514 iListWidget->AddEventHandler(*this); |
|
515 iListWidget->SetModel( iWidgetModel->Accessor() ); |
|
516 |
|
517 // This will set icon area background to transparent |
|
518 iListWidget->SetVisualColor(IMulWidget::EThumbnailBackgroundBrush, TRgb(0xFFFFFFFF, 255)); |
|
519 |
|
520 // Enable multiselect and cyclic scrolling |
|
521 iListWidget->SetFlags( IMulMultiItemWidget::EMulWidgetFlagCyclic | |
|
522 IMulMultiItemWidget::EMulWidgetFlagFastScroll | IMulMultiItemWidget::EMulWidgetFlagNaviScroll | |
|
523 IMulMultiItemWidget::EMulWidgetMarkingMode | |
|
524 IMulMultiItemWidget::EMulWidgetTitleMarqueeOn ); |
|
525 |
|
526 // Fetch icon and indicator sizes |
|
527 iListWidget->GetIconSize( mulwidget::KTemplate3, mulvisualitem::KMulIcon1, iIconHeight, iIconWidth ); |
|
528 iListWidget->GetIconSize( mulwidget::KTemplate3, mulvisualitem::KMulIndicator1, iIndicatorHeight, iIndicatorWidth ); |
|
529 iThumbnailManager->SetThumbnailSizeL( TSize(iIconHeight, iIconWidth) ); |
|
530 } |
|
531 } |
|
532 |
|
533 // ----------------------------------------------------------------------------- |
|
534 // Handle listbox item addition, preserving the current display index |
|
535 // ----------------------------------------------------------------------------- |
|
536 // |
|
537 void CMPXCommonContainerHitchcockImp::HandleLbxItemAdditionPreserveIndexL() |
|
538 { |
|
539 MPX_FUNC( "CMPXCommonContainerHitchcockImp::HandleLbxItemAdditionPreserveIndexL" ); |
|
540 HandleLbxItemAdditionL(); |
|
541 } |
|
542 |
|
543 // ----------------------------------------------------------------------------- |
|
544 // Handle listbox item removal. |
|
545 // ----------------------------------------------------------------------------- |
|
546 // |
|
547 void CMPXCommonContainerHitchcockImp::HandleLbxItemRemovalL() |
|
548 { |
|
549 MPX_FUNC( "CMPXCommonContainerHitchcockImp::HandleLbxItemRemovalL" ); |
|
550 iTopIndex = iBottomIndex = KErrNotFound; |
|
551 if ( iTextureManager ) |
|
552 { |
|
553 // Enabling the following will free up the memory, but not clearing the cache |
|
554 // will improve performance when we come back to the list again. |
|
555 // iTextureManager->ClearCache(CMPXCommonContainerTextureManager::EMPXTextureImage); |
|
556 } |
|
557 iThumbnailReqArray.Reset(); |
|
558 } |
|
559 |
|
560 // ----------------------------------------------------------------------------- |
|
561 // Show/hide find box. |
|
562 // ----------------------------------------------------------------------------- |
|
563 // |
|
564 void CMPXCommonContainerHitchcockImp::SetFindBoxVisibilityL( TBool aIsVisible ) |
|
565 { |
|
566 MPX_FUNC( "CMPXCommonContainerHitchcockImp::SetFindBoxVisibilityL" ); |
|
567 if ( aIsVisible ) |
|
568 { |
|
569 if ( !FindBoxVisibility() ) |
|
570 { |
|
571 iSearchFieldWrapper = CMPXCommonContainerSearchFieldWrapper::NewL(this); |
|
572 iFilteredList = CMPXCommonContainerFilteredList::NewL(); |
|
573 iFilteredList->ReplaceMediaListL( iListBoxArray->MediaArray() ); |
|
574 } |
|
575 ActivateSearchFieldL(); |
|
576 } |
|
577 else |
|
578 { |
|
579 if ( FindBoxVisibility() ) |
|
580 { |
|
581 TInt index = iWidgetModel->Highlight(); |
|
582 if ( index != KErrNotFound ) |
|
583 { |
|
584 index = iFilteredList->FilteredIndexToRealIndex(index); |
|
585 } |
|
586 |
|
587 DeactivateSearchField(); |
|
588 |
|
589 delete iFilteredList; |
|
590 iFilteredList = NULL; |
|
591 delete iSearchFieldWrapper; |
|
592 iSearchFieldWrapper = NULL; |
|
593 |
|
594 // Restore original list |
|
595 TInt count = iListBoxArray->MediaArray().Count(); |
|
596 |
|
597 if( count > 0) |
|
598 { |
|
599 iWidgetModel->Refresh( count ); |
|
600 if ( index != KErrNotFound ) |
|
601 { |
|
602 iWidgetModel->SetHighlight( index ); |
|
603 } |
|
604 } |
|
605 iThumbnailReqArray.Reset(); |
|
606 } |
|
607 } |
|
608 } |
|
609 |
|
610 // ----------------------------------------------------------------------------- |
|
611 // Determine find box visibility |
|
612 // ----------------------------------------------------------------------------- |
|
613 // |
|
614 TBool CMPXCommonContainerHitchcockImp::FindBoxVisibility() |
|
615 { |
|
616 MPX_FUNC( "CMPXCommonContainerHitchcockImp::FindBoxVisibility" ); |
|
617 TBool visible = EFalse; |
|
618 if ( iSearchFieldWrapper ) |
|
619 { |
|
620 visible = iSearchFieldWrapper->IsSearchFieldActive(); |
|
621 } |
|
622 return visible; |
|
623 } |
|
624 |
|
625 // ----------------------------------------------------------------------------- |
|
626 // Restore the PopupCBA of find box |
|
627 // ----------------------------------------------------------------------------- |
|
628 // |
|
629 void CMPXCommonContainerHitchcockImp::RestoreFindBoxPopupCBA() |
|
630 { |
|
631 MPX_FUNC( "CMPXCommonContainerAvkonImp::RestoreFindBoxPopupCBA" ); |
|
632 // Not required for Hitchcock |
|
633 } |
|
634 |
|
635 // ----------------------------------------------------------------------------- |
|
636 // Calculate the top index of the visible items |
|
637 // ----------------------------------------------------------------------------- |
|
638 // |
|
639 TInt CMPXCommonContainerHitchcockImp::CalculateTopIndex( TInt /*aBottomIndex*/ ) |
|
640 { |
|
641 MPX_FUNC( "CMPXCommonContainerHitchcockImp::CalculateTopIndex" ); |
|
642 // Not required for Hitchcock |
|
643 return 0; |
|
644 } |
|
645 |
|
646 // --------------------------------------------------------------------------- |
|
647 // Symbian 2nd phase constructor can leave. |
|
648 // --------------------------------------------------------------------------- |
|
649 // |
|
650 void CMPXCommonContainerHitchcockImp::ConstructContainerL( TMPXCommonContainerCollectionType aCollectionType ) |
|
651 { |
|
652 MPX_FUNC( "CMPXCommonContainerHitchcockImp::ConstructContainerL" ); |
|
653 |
|
654 /* |
|
655 CCoeEnv* coeEnv( iEikonEnv ); |
|
656 TParse parse; |
|
657 parse.Set( KMPXCollectionRscPath, &KDC_APP_RESOURCE_DIR, NULL ); |
|
658 TFileName resourceFile( parse.FullName() ); |
|
659 User::LeaveIfError( MPXUser::CompleteWithDllPath( resourceFile ) ); |
|
660 BaflUtils::NearestLanguageFile( coeEnv->FsSession(), resourceFile ); |
|
661 iResourceOffset = coeEnv->AddResourceFileL( resourceFile ); |
|
662 */ |
|
663 |
|
664 iCollectionType = aCollectionType; |
|
665 CreateWindowL(); |
|
666 CreateListBoxL(); |
|
667 FeatureManager::InitializeLibL(); |
|
668 ConstructFindBoxL( ETrue ); |
|
669 |
|
670 // Common methods used for 2-line list support |
|
671 iCommonUiHelper = CMPXCommonUiHelper::NewL(); |
|
672 iListSelections = new (ELeave) CArrayFixFlat<TInt>( KMPXListSelectionCount ); |
|
673 iTextureManager = new (ELeave) CMPXCommonContainerTextureManager( iEnv->TextureManager() ); |
|
674 |
|
675 iThumbnailManager = CThumbnailManager::NewL( *this ); |
|
676 iThumbnailManager->SetFlagsL( CThumbnailManager::EDefaultFlags ); |
|
677 iThumbnailManager->SetQualityPreferenceL( CThumbnailManager::EOptimizeForQuality ); |
|
678 //iThumbnailManager->SetThumbnailSizeL( TSize(iIconHeight, iIconWidth) ); |
|
679 } |
|
680 |
|
681 // --------------------------------------------------------------------------- |
|
682 // Enable/disable find box |
|
683 // --------------------------------------------------------------------------- |
|
684 // |
|
685 void CMPXCommonContainerHitchcockImp::EnableFindBox( TBool aEnable ) |
|
686 { |
|
687 MPX_FUNC( "CMPXCommonContainerHitchcockImp::EnableFindBox" ); |
|
688 iIsFindEnabled = aEnable; |
|
689 } |
|
690 |
|
691 // --------------------------------------------------------------------------- |
|
692 // Enable/disable marking |
|
693 // --------------------------------------------------------------------------- |
|
694 // |
|
695 void CMPXCommonContainerHitchcockImp::EnableMarking( TBool aEnable ) |
|
696 { |
|
697 MPX_FUNC( "CMPXCommonContainerHitchcockImp::EnableMarking" ); |
|
698 iIsMarkingEnabled = aEnable; |
|
699 if( iListWidget ) |
|
700 { |
|
701 if( iIsMarkingEnabled ) |
|
702 { |
|
703 iListWidget->SetFlags( IMulMultiItemWidget::EMulWidgetMarkingMode ); |
|
704 } |
|
705 else |
|
706 { |
|
707 iListWidget->ClearFlags( IMulMultiItemWidget::EMulWidgetMarkingMode ); |
|
708 } |
|
709 } |
|
710 } |
|
711 |
|
712 // --------------------------------------------------------------------------- |
|
713 // Custom handling of commands for markable lists. |
|
714 // --------------------------------------------------------------------------- |
|
715 // |
|
716 void CMPXCommonContainerHitchcockImp::HandleMarkableListProcessCommandL( |
|
717 TInt aCommand ) |
|
718 { |
|
719 MPX_FUNC( "CMPXCommonContainerHitchcockImp::HandleMarkableListProcessCommandL" ); |
|
720 |
|
721 if ( iWidgetModel ) |
|
722 { |
|
723 switch ( aCommand ) |
|
724 { |
|
725 case EAknCmdMark: |
|
726 { |
|
727 std::vector<int> itemIndex; |
|
728 int highlight = iWidgetModel->Highlight(); |
|
729 itemIndex.push_back( highlight); |
|
730 iWidgetModel->SetMarkedIndices(MulWidgetDef::EMulMark, itemIndex); |
|
731 } |
|
732 break; |
|
733 case EAknCmdUnmark: |
|
734 { |
|
735 std::vector<int> itemIndex; |
|
736 int highlight = iWidgetModel->Highlight(); |
|
737 itemIndex.push_back(highlight); |
|
738 //mark the selected item |
|
739 iWidgetModel->SetMarkedIndices(MulWidgetDef::EMulUnmark, itemIndex); |
|
740 } |
|
741 break; |
|
742 case EAknMarkAll: |
|
743 iWidgetModel->SetMarkedIndices(MulWidgetDef::EMulMarkAll); |
|
744 break; |
|
745 case EAknUnmarkAll: |
|
746 iWidgetModel->SetMarkedIndices(MulWidgetDef::EMulUnmarkAll); |
|
747 break; |
|
748 } |
|
749 } |
|
750 } |
|
751 |
|
752 // --------------------------------------------------------------------------- |
|
753 // Custom handling of menu pane for markable lists |
|
754 // --------------------------------------------------------------------------- |
|
755 // |
|
756 void CMPXCommonContainerHitchcockImp::HandleMarkableListDynInitMenuPane( |
|
757 TInt aResourceId, |
|
758 CEikMenuPane* aMenuPane ) |
|
759 { |
|
760 MPX_FUNC( "CMPXCommonContainerHitchcockImp::HandleMarkableListDynInitMenuPane" ); |
|
761 |
|
762 if ( aResourceId == R_AVKON_MENUPANE_MARKABLE_LIST ) |
|
763 { |
|
764 TInt currentItem = CurrentLbxItemIndex(); |
|
765 if ( currentItem == KErrNotFound ) |
|
766 { |
|
767 aMenuPane->SetItemDimmed( EAknCmdEditListMenu, ETrue ); |
|
768 } |
|
769 else |
|
770 { |
|
771 aMenuPane->SetItemDimmed( EAknCmdEditListMenu, EFalse ); |
|
772 } |
|
773 } |
|
774 else if ( aResourceId == R_AVKON_MENUPANE_MARKABLE_LIST_IMPLEMENTATION ) |
|
775 { |
|
776 TInt currentItem = CurrentLbxItemIndex(); |
|
777 if ( currentItem != KErrNotFound ) |
|
778 { |
|
779 TBool currentItemMarked = EFalse; |
|
780 std::vector<int> itemsSelected = iWidgetModel->MarkedIndices(); |
|
781 int markedCount = itemsSelected.size(); |
|
782 for( int i = 0; i < markedCount; i++ ) |
|
783 { |
|
784 if ( currentItem == itemsSelected[i] ) |
|
785 { |
|
786 currentItemMarked = ETrue; |
|
787 break; |
|
788 } |
|
789 } |
|
790 TInt totalCount = iWidgetModel->Count(); |
|
791 aMenuPane->SetItemDimmed( EAknCmdMark, currentItemMarked ); |
|
792 aMenuPane->SetItemDimmed( EAknCmdUnmark, !currentItemMarked ); |
|
793 aMenuPane->SetItemDimmed( EAknMarkAll, markedCount == totalCount ); |
|
794 aMenuPane->SetItemDimmed( EAknUnmarkAll, markedCount == 0 ); |
|
795 } |
|
796 } |
|
797 } |
|
798 |
|
799 // --------------------------------------------------------------------------- |
|
800 // Handles key events. |
|
801 // --------------------------------------------------------------------------- |
|
802 // |
|
803 TKeyResponse CMPXCommonContainerHitchcockImp::HandleKeyEventL( |
|
804 const TKeyEvent& aKeyEvent, |
|
805 TEventCode aType ) |
|
806 { |
|
807 MPX_DEBUG5( "CMPXCommonContainerHitchcockImp::HandleKeyEventL(iCode=%d, iScanCode=%d, iModifiers=0x%x, aType=%d)", |
|
808 aKeyEvent.iCode, aKeyEvent.iScanCode, aKeyEvent.iModifiers, aType ); |
|
809 |
|
810 if ( iSearchFieldWrapper && aType == EEventKeyUp ) |
|
811 { |
|
812 #ifdef __ENABLE_MSK |
|
813 // Update the middle softkey for marking commands |
|
814 iView->ProcessCommandL( EMPXCmdCommonUpdateMiddleSoftKey ); |
|
815 #endif // __ENABLE_MSK |
|
816 } |
|
817 if ( iSearchFieldWrapper && aType == EEventKey ) |
|
818 { |
|
819 if ( iSearchFieldWrapper->IsSearchFieldActive() ) |
|
820 { |
|
821 if ( iSearchFieldWrapper->OfferKeyEventL( aKeyEvent, aType ) == EKeyWasConsumed ) |
|
822 { |
|
823 return EKeyWasConsumed; |
|
824 } |
|
825 } |
|
826 } |
|
827 // TODO: Temporary test code, what key codes should start find? |
|
828 else if ( ( aKeyEvent.iScanCode >= 48 && aKeyEvent.iScanCode <= 57 ) || |
|
829 ( aKeyEvent.iScanCode >= 65 && aKeyEvent.iScanCode <= 90 ) || |
|
830 ( aKeyEvent.iScanCode >= 121 && aKeyEvent.iScanCode <= 127 ) || |
|
831 ( aKeyEvent.iScanCode == 5 ) || ( aKeyEvent.iScanCode == 125 ) || |
|
832 ( aKeyEvent.iScanCode == 127 ) || ( aKeyEvent.iScanCode == 130 ) || |
|
833 ( aKeyEvent.iScanCode == 133 ) || ( aKeyEvent.iScanCode == 135 ) ) |
|
834 { |
|
835 if ( iContext != EContextGroupCollection ) |
|
836 { |
|
837 iView->ProcessCommandL( EMPXCmdCommonFind ); |
|
838 return EKeyWasConsumed; |
|
839 } |
|
840 } |
|
841 |
|
842 TKeyResponse response( EKeyWasNotConsumed ); |
|
843 if ( aKeyEvent.iCode == EKeyOK ) |
|
844 { |
|
845 // Handle enter key pressed |
|
846 iView->ProcessCommandL( EMPXCmdCommonEnterKey ); |
|
847 } |
|
848 |
|
849 if ( response == EKeyWasNotConsumed && |
|
850 aType == EEventKey && |
|
851 aKeyEvent.iCode == EKeyBackspace && iView ) |
|
852 { |
|
853 iView->ProcessCommandL( EMPXCmdCommonDelete ); |
|
854 response = EKeyWasConsumed; |
|
855 } |
|
856 |
|
857 return response; |
|
858 } |
|
859 |
|
860 // --------------------------------------------------------------------------- |
|
861 // Activate container |
|
862 // --------------------------------------------------------------------------- |
|
863 // |
|
864 void CMPXCommonContainerHitchcockImp::ActivateContainerL() |
|
865 { |
|
866 TRect clientRect = ((CAknView*)iView)->ClientRect(); |
|
867 iViewWidget->setRect( clientRect ); |
|
868 iViewWidget->show(true); |
|
869 iContainerActive = ETrue; |
|
870 if( iListWidget ) |
|
871 { |
|
872 iListWidget->ShowWidget(true); |
|
873 } |
|
874 } |
|
875 |
|
876 // --------------------------------------------------------------------------- |
|
877 // Deactivate container |
|
878 // --------------------------------------------------------------------------- |
|
879 // |
|
880 void CMPXCommonContainerHitchcockImp::DeactivateContainerL() |
|
881 { |
|
882 iViewWidget->show(false); |
|
883 if ( iListWidget ) |
|
884 { |
|
885 iListWidget->SetModel(NULL); |
|
886 iWidgetModel = NULL; |
|
887 iListWidget->ShowWidget(false); |
|
888 } |
|
889 iContainerActive = EFalse; |
|
890 } |
|
891 |
|
892 // --------------------------------------------------------------------------- |
|
893 // Return container state |
|
894 // --------------------------------------------------------------------------- |
|
895 // |
|
896 TBool CMPXCommonContainerHitchcockImp::IsContainerActive() |
|
897 { |
|
898 return iContainerActive; |
|
899 } |
|
900 |
|
901 // --------------------------------------------------------------------------- |
|
902 // From MMPXCommonListBoxArrayObserver |
|
903 // Handle listbox array events. |
|
904 // --------------------------------------------------------------------------- |
|
905 // |
|
906 void CMPXCommonContainerHitchcockImp::HandleListBoxArrayEventL( |
|
907 MMPXCommonListBoxArrayObserver::TMPXCommonListBoxArrayEvents aEvent ) |
|
908 { |
|
909 MPX_FUNC( "CMPXCommonContainerHitchcockImp::HandleListBoxArrayEventL" ); |
|
910 if ( aEvent == MMPXCommonListBoxArrayObserver::EMPXCommonListBoxArrayEventIconArrayChange ) |
|
911 { |
|
912 delete iIconArray; |
|
913 iIconArray = NULL; |
|
914 CreateIconArrayL(); |
|
915 } |
|
916 } |
|
917 |
|
918 // --------------------------------------------------------------------------- |
|
919 // From CCoeControl |
|
920 // Handles key events. |
|
921 // --------------------------------------------------------------------------- |
|
922 // |
|
923 TKeyResponse CMPXCommonContainerHitchcockImp::OfferKeyEventL( |
|
924 const TKeyEvent& aKeyEvent, |
|
925 TEventCode aType ) |
|
926 { |
|
927 MPX_DEBUG5( "CMPXCommonContainerHitchcockImp::OfferKeyEventL(iCode=%d, iScanCode=%d, iModifiers=0x%x, aType=%d)", |
|
928 aKeyEvent.iCode, aKeyEvent.iScanCode, aKeyEvent.iModifiers, aType ); |
|
929 MPX_DEBUG3("CMPXCommonContainerHitchcockImp::OfferKeyEventL, iType=%d, iActive=%d", iCollectionType, iContainerActive); |
|
930 if ( iWidgetModel ) |
|
931 { |
|
932 TAlfEvent event( iEnv->PrimaryDisplay(), aKeyEvent, aType ); |
|
933 if ( iListWidget->control()->processEvent( event ) == EEventHandled ) |
|
934 { |
|
935 return EKeyWasConsumed; |
|
936 } |
|
937 else |
|
938 { |
|
939 // Let the view container handle the key event. |
|
940 return iViewContainer->HandleKeyEventL( aKeyEvent, aType ); |
|
941 } |
|
942 } |
|
943 return EKeyWasNotConsumed; |
|
944 } |
|
945 |
|
946 // --------------------------------------------------------------------------- |
|
947 // Gets the control's help context. |
|
948 // --------------------------------------------------------------------------- |
|
949 // |
|
950 void CMPXCommonContainerHitchcockImp::GetHelpContext( |
|
951 TCoeHelpContext& aContext ) const |
|
952 { |
|
953 MPX_FUNC( "CMPXCommonContainerHitchcockImp::GetHelpContext" ); |
|
954 // Let the view container handle the help context retrieval |
|
955 if ( iViewContainer ) |
|
956 { |
|
957 iViewContainer->HandleHelpContext( aContext ); |
|
958 } |
|
959 } |
|
960 |
|
961 // --------------------------------------------------------------------------- |
|
962 // From CCoeControl |
|
963 // Handles a change to the control's resources. |
|
964 // --------------------------------------------------------------------------- |
|
965 // |
|
966 void CMPXCommonContainerHitchcockImp::HandleResourceChange( TInt aType ) |
|
967 { |
|
968 MPX_FUNC( "CMPXCommonContainerHitchcockImp::HandleResourceChange" ); |
|
969 CCoeControl::HandleResourceChange( aType ); |
|
970 |
|
971 if ( aType == KAknsMessageSkinChange ) |
|
972 { |
|
973 delete iIconArray; |
|
974 iIconArray = NULL; |
|
975 TRAP_IGNORE(CreateIconArrayL()); |
|
976 } |
|
977 else if ( aType == KEikDynamicLayoutVariantSwitch ) |
|
978 { |
|
979 TRect clientRect = ((CAknView*)iView)->ClientRect(); |
|
980 if ( FindBoxVisibility() ) |
|
981 { |
|
982 TRect clientRect = ((CAknView*)iView)->ClientRect(); |
|
983 iViewWidget->setRect( |
|
984 iSearchFieldWrapper->GetListRect( ETrue, clientRect ) ); |
|
985 iSearchFieldWrapper->SetRect( |
|
986 iSearchFieldWrapper->GetSearchFieldRect( ETrue, clientRect ) ); |
|
987 } |
|
988 else |
|
989 { |
|
990 iViewWidget->setRect( clientRect ); |
|
991 } |
|
992 } |
|
993 } |
|
994 |
|
995 // --------------------------------------------------------------------------- |
|
996 // Draw this application's view to the screen |
|
997 // --------------------------------------------------------------------------- |
|
998 // |
|
999 void CMPXCommonContainerHitchcockImp::Draw(const TRect& /*aRect*/) const |
|
1000 { |
|
1001 // Do nothing so that list model will be drawn by Hitchcock framework |
|
1002 } |
|
1003 |
|
1004 // --------------------------------------------------------------------------- |
|
1005 // From MCoeControlObserver |
|
1006 // Handle control event |
|
1007 // --------------------------------------------------------------------------- |
|
1008 // |
|
1009 void CMPXCommonContainerHitchcockImp::HandleControlEventL( |
|
1010 CCoeControl* /*aControl*/, |
|
1011 TCoeEvent /*aEventType*/ ) |
|
1012 { |
|
1013 // Not used |
|
1014 } |
|
1015 |
|
1016 // --------------------------------------------------------------------------- |
|
1017 // From IAlfWidgetEventHandler |
|
1018 // Indicates whether event is accepted |
|
1019 // --------------------------------------------------------------------------- |
|
1020 // |
|
1021 bool CMPXCommonContainerHitchcockImp::accept( |
|
1022 CAlfWidgetControl& /*aControl*/, |
|
1023 const TAlfEvent& /*aEvent*/ ) const |
|
1024 { |
|
1025 return true; |
|
1026 } |
|
1027 |
|
1028 // --------------------------------------------------------------------------- |
|
1029 // From IAlfWidgetEventHandler |
|
1030 // Sets the active states of the event handler |
|
1031 // --------------------------------------------------------------------------- |
|
1032 // |
|
1033 void CMPXCommonContainerHitchcockImp::setActiveStates( unsigned int /*aStates*/ ) |
|
1034 { |
|
1035 } |
|
1036 |
|
1037 // --------------------------------------------------------------------------- |
|
1038 // From IAlfWidgetEventHandler |
|
1039 // Performs the appropriate action for the ALF event |
|
1040 // --------------------------------------------------------------------------- |
|
1041 // |
|
1042 AlfEventStatus CMPXCommonContainerHitchcockImp::offerEvent( |
|
1043 CAlfWidgetControl& /*aControl*/, |
|
1044 const TAlfEvent& aEvent ) |
|
1045 { |
|
1046 MPX_FUNC( "CMPXCommonContainerHitchcockImp::offerEvent" ); |
|
1047 |
|
1048 AlfEventStatus status = EEventNotHandled; |
|
1049 |
|
1050 if( aEvent.IsCustomEvent() ) |
|
1051 { |
|
1052 uint eventID = aEvent.CustomParameter(); |
|
1053 |
|
1054 switch( eventID ) |
|
1055 { |
|
1056 case ETypeMark: |
|
1057 { |
|
1058 switch( aEvent.CustomEventData() ) |
|
1059 { |
|
1060 case EMarkStart: |
|
1061 case EMarkStop : |
|
1062 { |
|
1063 status = EEventConsumed; |
|
1064 } |
|
1065 break; |
|
1066 default: |
|
1067 break; |
|
1068 } |
|
1069 break; |
|
1070 } |
|
1071 case ETypeHighlight: |
|
1072 { |
|
1073 if( iWidgetModel && ( iWidgetModel->Count() > 0 ) ) |
|
1074 { |
|
1075 status = EEventConsumed; |
|
1076 } |
|
1077 break; |
|
1078 } |
|
1079 case ETypeSelect: |
|
1080 { |
|
1081 //Handling for this needs to be done, once it is implemented in widget |
|
1082 if( iWidgetModel && ( iWidgetModel->Count() > 0 ) ) |
|
1083 { |
|
1084 // Handle enter key pressed |
|
1085 iView->ProcessCommandL( EMPXCmdCommonEnterKey ); |
|
1086 status = EEventConsumed; |
|
1087 } |
|
1088 break; |
|
1089 } |
|
1090 default: |
|
1091 status = EEventNotHandled; |
|
1092 break; |
|
1093 } |
|
1094 } |
|
1095 |
|
1096 return status; |
|
1097 } |
|
1098 |
|
1099 // --------------------------------------------------------------------------- |
|
1100 // From IAlfWidgetEventHandler |
|
1101 // Make event handler interface using the specified type |
|
1102 // --------------------------------------------------------------------------- |
|
1103 // |
|
1104 IAlfInterfaceBase* CMPXCommonContainerHitchcockImp::makeInterface( |
|
1105 const IfId& /*aType*/ ) |
|
1106 { |
|
1107 return NULL; |
|
1108 } |
|
1109 |
|
1110 // --------------------------------------------------------------------------- |
|
1111 // From IAlfWidgetEventHandler |
|
1112 // Sets the event handler data |
|
1113 // --------------------------------------------------------------------------- |
|
1114 // |
|
1115 void CMPXCommonContainerHitchcockImp::setEventHandlerData( |
|
1116 const AlfWidgetEventHandlerInitData& /*aData*/ ) |
|
1117 { |
|
1118 } |
|
1119 |
|
1120 // --------------------------------------------------------------------------- |
|
1121 // From IAlfWidgetEventHandler |
|
1122 // Returns pointer to the event handler data |
|
1123 // --------------------------------------------------------------------------- |
|
1124 // |
|
1125 AlfWidgetEventHandlerInitData* |
|
1126 CMPXCommonContainerHitchcockImp::eventHandlerData() |
|
1127 { |
|
1128 return NULL; |
|
1129 } |
|
1130 |
|
1131 // --------------------------------------------------------------------------- |
|
1132 // From IAlfWidgetEventHandler |
|
1133 // Sets the event handler data |
|
1134 // --------------------------------------------------------------------------- |
|
1135 // |
|
1136 IAlfWidgetEventHandler::AlfEventHandlerType CMPXCommonContainerHitchcockImp::eventHandlerType() |
|
1137 { |
|
1138 return IAlfWidgetEventHandler::EPresentationEventHandler; |
|
1139 } |
|
1140 |
|
1141 // --------------------------------------------------------------------------- |
|
1142 // From IAlfWidgetEventHandler |
|
1143 // Sets the event handler data |
|
1144 // --------------------------------------------------------------------------- |
|
1145 // |
|
1146 IAlfWidgetEventHandler::AlfEventHandlerExecutionPhase CMPXCommonContainerHitchcockImp::eventExecutionPhase() |
|
1147 { |
|
1148 return EBubblingPhaseEventHandler; |
|
1149 } |
|
1150 |
|
1151 // ----------------------------------------------------------------------------- |
|
1152 // Provides the data to the model |
|
1153 // ----------------------------------------------------------------------------- |
|
1154 // |
|
1155 void CMPXCommonContainerHitchcockImp::ProvideData( |
|
1156 int aStartIndex, |
|
1157 int aCount, |
|
1158 MulDataPath /*aPath*/ ) |
|
1159 { |
|
1160 TInt numOfItems = 0; |
|
1161 if ( iFilteredList ) |
|
1162 { |
|
1163 numOfItems = iFilteredList->FilteredCount(); |
|
1164 } |
|
1165 else |
|
1166 { |
|
1167 numOfItems = iListBoxArray->MediaArray().Count(); |
|
1168 } |
|
1169 |
|
1170 for ( int i = 0; i < aCount ; ++i ) |
|
1171 { |
|
1172 int index = aStartIndex+i; |
|
1173 if ( index >= 0 && index < numOfItems ) |
|
1174 { |
|
1175 MulVisualItem* tempItem = CreateDisplayedItemL(index ); |
|
1176 if ( tempItem ) |
|
1177 { |
|
1178 auto_ptr<MulVisualItem> dataItem ( new (EMM) MulVisualItem(*tempItem)); |
|
1179 iWidgetModel->SetData(index, dataItem); |
|
1180 delete tempItem; |
|
1181 } |
|
1182 } |
|
1183 } |
|
1184 iTopIndex = aStartIndex; |
|
1185 iBottomIndex = aStartIndex + aCount - 1; |
|
1186 } |
|
1187 |
|
1188 // ----------------------------------------------------------------------------- |
|
1189 // Preview thumbnail generation or loading is complete. |
|
1190 // ----------------------------------------------------------------------------- |
|
1191 // |
|
1192 void CMPXCommonContainerHitchcockImp::ThumbnailPreviewReady( MThumbnailData& /*aThumbnail*/, TThumbnailRequestId /*aId*/ ) |
|
1193 { |
|
1194 // Not used |
|
1195 } |
|
1196 |
|
1197 // ----------------------------------------------------------------------------- |
|
1198 // Final thumbnail bitmap generation or loading is complete. |
|
1199 // ----------------------------------------------------------------------------- |
|
1200 // |
|
1201 void CMPXCommonContainerHitchcockImp::ThumbnailReady( TInt aError, MThumbnailData& aThumbnail, TThumbnailRequestId aId ) |
|
1202 { |
|
1203 if ( aError == KErrNone && iContainerActive ) |
|
1204 { |
|
1205 // Find the index |
|
1206 TInt index = KErrNotFound; |
|
1207 TInt count = iThumbnailReqArray.Count(); |
|
1208 for ( TInt i = 0; i < count; i++ ) |
|
1209 { |
|
1210 TThumnailReq req = iThumbnailReqArray[i]; |
|
1211 if ( req.iReqId == aId ) |
|
1212 { |
|
1213 index = req.iIndex; |
|
1214 break; |
|
1215 } |
|
1216 } |
|
1217 |
|
1218 if ( index != KErrNotFound ) |
|
1219 { |
|
1220 const CMPXMediaArray& mediaArray = iListBoxArray->MediaArray(); |
|
1221 TInt realIndex = index; |
|
1222 if ( iFilteredList ) |
|
1223 { |
|
1224 realIndex = iFilteredList->FilteredIndexToRealIndex(index); |
|
1225 } |
|
1226 CMPXMedia* currentMedia( mediaArray.AtL( realIndex ) ); |
|
1227 if ( currentMedia->IsSupported( KMPXMediaGeneralId ) ) |
|
1228 { |
|
1229 TMPXItemId currentId( currentMedia->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) ); |
|
1230 CFbsBitmap* bitmap = aThumbnail.DetachBitmap(); |
|
1231 |
|
1232 // Create the texture. The texture id will be |
|
1233 // set synchronously when the texture manager is notified |
|
1234 CAlfTexture& texture = iTextureManager->CreateTextureL( |
|
1235 realIndex, currentId, bitmap, NULL ); |
|
1236 TInt textureId = texture.Id(); |
|
1237 //iWidgetModel->Update(index, 1); |
|
1238 MulVisualItem* visualItem = new (EMM) MulVisualItem(); |
|
1239 visualItem->SetAttribute( mulvisualitem::KMulIcon1, textureId, 0 ); |
|
1240 iWidgetModel->SetData(index, auto_ptr<MulVisualItem>(visualItem) ); |
|
1241 } |
|
1242 } |
|
1243 } |
|
1244 } |
|
1245 // --------------------------------------------------------------------------- |
|
1246 // Create list box |
|
1247 // --------------------------------------------------------------------------- |
|
1248 // |
|
1249 void CMPXCommonContainerHitchcockImp::NewFilteringWordL( const TDesC& aWord ) |
|
1250 { |
|
1251 MPX_FUNC( "CMPXCommonContainerHitchcockImp::NewFilteringWordL" ); |
|
1252 if ( iFilteredList->HasMediaList() ) |
|
1253 { |
|
1254 iFilteredList->SetFilteringWordL( aWord ); |
|
1255 TInt filteredCount = iFilteredList->FilteredCount(); |
|
1256 if ( filteredCount > 0 ) |
|
1257 { |
|
1258 TInt index = iWidgetModel->Highlight(); |
|
1259 if ( index >= filteredCount ) |
|
1260 { |
|
1261 iWidgetModel->SetHighlight( 0 ); |
|
1262 } |
|
1263 iWidgetModel->Refresh( filteredCount ); |
|
1264 } |
|
1265 else |
|
1266 { |
|
1267 TInt widgetCount = iWidgetModel->Count(); |
|
1268 if ( widgetCount > 0 ) |
|
1269 { |
|
1270 iWidgetModel->Remove( 0, widgetCount ); |
|
1271 } |
|
1272 } |
|
1273 iThumbnailReqArray.Reset(); |
|
1274 } |
|
1275 } |
|
1276 |
|
1277 // --------------------------------------------------------------------------- |
|
1278 // Create list box |
|
1279 // --------------------------------------------------------------------------- |
|
1280 // |
|
1281 void CMPXCommonContainerHitchcockImp::CreateListBoxL() |
|
1282 { |
|
1283 MPX_FUNC( "CMPXCommonContainerHitchcockImp::CreateListBox" ); |
|
1284 const char* KLoadNameList("mullistwidget"); |
|
1285 const char* KLoadNameModel("mulmodel"); |
|
1286 const char* KListViewNameMusic("mpxmullistviewmusic"); |
|
1287 const char* KListViewNamePodcast("mpxmullistviewpodcast"); |
|
1288 |
|
1289 if ( iAlfEnvCreated ) |
|
1290 { |
|
1291 return; |
|
1292 } |
|
1293 iAlfEnvCreated = ETrue; |
|
1294 |
|
1295 TRect clientRect = ((CAknView*)iView)->ClientRect(); |
|
1296 |
|
1297 // Creating the Alf Environment |
|
1298 // Should be the first thing to be done before widgets can be created |
|
1299 iEnv = CAlfEnv::Static(); |
|
1300 |
|
1301 // This api will force glib to use the normal malloc for |
|
1302 // memory allocation,preventing ustring memory leak. |
|
1303 g_setenv("G_SLICE","always-malloc",1); |
|
1304 |
|
1305 // Creating the Alf Display |
|
1306 // Display is needed to show anything related to Alf |
|
1307 // Avkon perceives the Alf Display as one CoeControl. |
|
1308 // It can't see widgets inside the Display |
|
1309 CAlfDisplay& disp = iEnv->NewDisplayL( clientRect, CAlfEnv::ENewDisplayAsCoeControl ); |
|
1310 disp.SetClearBackgroundL( CAlfDisplay::EClearWithSkinBackground ); |
|
1311 |
|
1312 try |
|
1313 { |
|
1314 // Get widget factory from CAlfEnv |
|
1315 // Factory is then used to create the individual widgets & data model |
|
1316 IAlfWidgetFactory& widgetFactory = AlfWidgetEnvExtension::widgetFactory(*iEnv); |
|
1317 |
|
1318 // Create view widget. CAlfEnv owns widget |
|
1319 if ( !iViewWidget && iCollectionType == MMPXCommonContainer::EMPXCommonContainerMusic ) |
|
1320 { |
|
1321 iViewWidget = widgetFactory.createViewWidget(KListViewNameMusic, KListControlGroupIdMusic); |
|
1322 } |
|
1323 else if ( !iViewWidget && iCollectionType == MMPXCommonContainer::EMPXCommonContainerPodcast ) |
|
1324 { |
|
1325 iViewWidget = widgetFactory.createViewWidget(KListViewNamePodcast, KListControlGroupIdPodcast); |
|
1326 } |
|
1327 else |
|
1328 { |
|
1329 User::Leave(KErrArgument); |
|
1330 } |
|
1331 } |
|
1332 catch (...) |
|
1333 { |
|
1334 User::Leave(KErrGeneral); |
|
1335 } |
|
1336 SizeChanged(); |
|
1337 } |
|
1338 |
|
1339 // ----------------------------------------------------------------------------- |
|
1340 // Constructs Find box. |
|
1341 // ----------------------------------------------------------------------------- |
|
1342 // |
|
1343 void CMPXCommonContainerHitchcockImp::ConstructFindBoxL( TBool /*aIsFindPopup*/ ) |
|
1344 { |
|
1345 MPX_FUNC( "CMPXCommonContainerHitchcockImp::ConstructFindBoxL" ); |
|
1346 // Not used |
|
1347 } |
|
1348 |
|
1349 // ----------------------------------------------------------------------------- |
|
1350 // Creates icon array, populates iIconArray to be used by listbox |
|
1351 // ----------------------------------------------------------------------------- |
|
1352 // |
|
1353 void CMPXCommonContainerHitchcockImp::CreateIconArrayL() |
|
1354 { |
|
1355 if ( iListBoxArray ) |
|
1356 { |
|
1357 iIconArray = iListBoxArray->CreateIconArrayL(); |
|
1358 } |
|
1359 } |
|
1360 |
|
1361 // ----------------------------------------------------------------------------- |
|
1362 // Creates the display item from the media |
|
1363 // ----------------------------------------------------------------------------- |
|
1364 // |
|
1365 MulVisualItem* CMPXCommonContainerHitchcockImp::CreateDisplayedItemL( |
|
1366 TInt aIndex ) |
|
1367 { |
|
1368 MPX_FUNC( "CMPXCommonContainerHitchcockImp::CreateDisplayedItemL" ); |
|
1369 |
|
1370 MulVisualItem* visualItem = new (EMM) MulVisualItem(); |
|
1371 |
|
1372 const CMPXMediaArray& mediaArray = iListBoxArray->MediaArray(); |
|
1373 CMPXMedia* currentMedia = NULL; |
|
1374 if ( iFilteredList ) |
|
1375 { |
|
1376 TInt realIndex = iFilteredList->FilteredIndexToRealIndex(aIndex); |
|
1377 currentMedia = mediaArray.AtL( realIndex ); |
|
1378 } |
|
1379 else |
|
1380 { |
|
1381 currentMedia = mediaArray.AtL( aIndex ); |
|
1382 } |
|
1383 |
|
1384 SetTitleL( visualItem, currentMedia ); |
|
1385 // Add detailed text to the list item, if available |
|
1386 AddDetailToDisplayedItemL( visualItem, currentMedia, aIndex ); |
|
1387 |
|
1388 return visualItem; |
|
1389 } |
|
1390 |
|
1391 // ----------------------------------------------------------------------------- |
|
1392 // Adds detail to the list item at the specified index |
|
1393 // ----------------------------------------------------------------------------- |
|
1394 // |
|
1395 void CMPXCommonContainerHitchcockImp::AddDetailToDisplayedItemL( |
|
1396 MulVisualItem* aVisualItem, |
|
1397 CMPXMedia* aMedia, |
|
1398 TInt aIndex ) |
|
1399 { |
|
1400 MPX_FUNC( "CMPXCommonContainerHitchcockImp::AddDetailToDisplayedItemL" ); |
|
1401 |
|
1402 switch ( iContext ) |
|
1403 { |
|
1404 case EContextGroupCollection: |
|
1405 SetDetailIconL(aVisualItem, aIndex); |
|
1406 break; |
|
1407 case EContextGroupArtist: |
|
1408 SetDetailCountL(aVisualItem, aMedia); |
|
1409 break; |
|
1410 case EContextGroupAlbum: |
|
1411 SetDetailArtistL(aVisualItem, aMedia); |
|
1412 SetDetailThumbnailL(aVisualItem, aMedia, aIndex); |
|
1413 break; |
|
1414 case EContextGroupPlaylist: |
|
1415 SetDetailDurationL(aVisualItem, aMedia); |
|
1416 SetDetailIndicatorL(aVisualItem, aIndex); |
|
1417 break; |
|
1418 case EContextGroupSong: |
|
1419 case EContextItemAlbum: |
|
1420 case EContextItemPlaylist: |
|
1421 case EContextItemGenre: |
|
1422 case EContextItemComposer: |
|
1423 SetDetailArtistL(aVisualItem, aMedia); |
|
1424 SetDetailIndicatorL(aVisualItem, aIndex); |
|
1425 SetDetailThumbnailL(aVisualItem, aMedia, aIndex); |
|
1426 break; |
|
1427 case EContextGroupPodcast: |
|
1428 SetDetailCountL(aVisualItem, aMedia); |
|
1429 break; |
|
1430 case EContextGroupGenre: |
|
1431 SetDetailCountL(aVisualItem, aMedia); |
|
1432 break; |
|
1433 case EContextGroupComposer: |
|
1434 SetDetailCountL(aVisualItem, aMedia); |
|
1435 break; |
|
1436 case EContextItemArtist: |
|
1437 SetDetailCountL(aVisualItem, aMedia); |
|
1438 SetDetailThumbnailL(aVisualItem, aMedia, aIndex); |
|
1439 break; |
|
1440 case EContextItemSong: |
|
1441 SetDetailAlbumL(aVisualItem, aMedia); |
|
1442 SetDetailIndicatorL(aVisualItem, aIndex); |
|
1443 SetDetailThumbnailL(aVisualItem, aMedia, aIndex); |
|
1444 break; |
|
1445 case EContextItemPodcast: |
|
1446 SetDetailDurationL(aVisualItem, aMedia); |
|
1447 SetDetailIndicatorL(aVisualItem, aIndex); |
|
1448 SetDetailThumbnailL(aVisualItem, aMedia, aIndex); |
|
1449 break; |
|
1450 } |
|
1451 } |
|
1452 |
|
1453 // ----------------------------------------------------------------------------- |
|
1454 // Set title to the visual item |
|
1455 // ----------------------------------------------------------------------------- |
|
1456 // |
|
1457 void CMPXCommonContainerHitchcockImp::SetTitleL( |
|
1458 MulVisualItem* aVisualItem, |
|
1459 CMPXMedia* aMedia ) |
|
1460 { |
|
1461 if ( aMedia->IsSupported( KMPXMediaGeneralTitle ) ) |
|
1462 { |
|
1463 // AK - Needs to be localized |
|
1464 TFileName titleText( KUnknown ); |
|
1465 const TDesC& title = aMedia->ValueText( KMPXMediaGeneralTitle ); |
|
1466 if ( title.Compare( KNullDesC ) != 0 ) |
|
1467 { |
|
1468 titleText.Copy(title.Left(titleText.MaxLength())); |
|
1469 } |
|
1470 aVisualItem->SetAttribute( mulvisualitem::KMulTitle, titleText, 0); |
|
1471 } |
|
1472 } |
|
1473 |
|
1474 // ----------------------------------------------------------------------------- |
|
1475 // Set Detail - Count to the visual item |
|
1476 // ----------------------------------------------------------------------------- |
|
1477 // |
|
1478 void CMPXCommonContainerHitchcockImp::SetDetailCountL( |
|
1479 MulVisualItem* aVisualItem, |
|
1480 CMPXMedia* aMedia ) |
|
1481 { |
|
1482 if ( aMedia->IsSupported( KMPXMediaGeneralCount ) ) |
|
1483 { |
|
1484 // AK - Needs to be localized |
|
1485 TFileName detailText; |
|
1486 TInt count( aMedia->ValueTObjectL<TInt>( KMPXMediaGeneralCount ) ); |
|
1487 TBuf<10> temp; |
|
1488 temp.AppendNum( count ); |
|
1489 AknTextUtils::LanguageSpecificNumberConversion( temp ); |
|
1490 detailText.Append( temp ); |
|
1491 |
|
1492 if ( iContext == EContextGroupPodcast ) |
|
1493 { |
|
1494 detailText.Append( (count > 1 ) ? KEpisodes() : KEpisode() ); |
|
1495 } |
|
1496 else if ( iContext == EContextGroupArtist ) |
|
1497 { |
|
1498 detailText.Append( (count > 1 ) ? KAlbums() : KAlbum() ); |
|
1499 } |
|
1500 else |
|
1501 { |
|
1502 detailText.Append( (count > 1 ) ? KSongs() : KSong() ); |
|
1503 } |
|
1504 aVisualItem->SetAttribute( mulvisualitem::KMulDetail, detailText, 0); |
|
1505 } |
|
1506 } |
|
1507 |
|
1508 // ----------------------------------------------------------------------------- |
|
1509 // Set Detail - Artist to the visual item |
|
1510 // ----------------------------------------------------------------------------- |
|
1511 // |
|
1512 void CMPXCommonContainerHitchcockImp::SetDetailArtistL( |
|
1513 MulVisualItem* aVisualItem, |
|
1514 CMPXMedia* aMedia ) |
|
1515 { |
|
1516 if ( aMedia->IsSupported( KMPXMediaMusicArtist ) ) |
|
1517 { |
|
1518 // AK - Needs to be localized |
|
1519 TFileName detailText; |
|
1520 const TDesC& artist = aMedia->ValueText( KMPXMediaMusicArtist ); |
|
1521 if ( artist.Compare( KNullDesC ) != 0 ) |
|
1522 { |
|
1523 detailText.Copy(artist.Left(detailText.MaxLength())); |
|
1524 aVisualItem->SetAttribute( mulvisualitem::KMulDetail, detailText, 0); |
|
1525 } |
|
1526 } |
|
1527 } |
|
1528 |
|
1529 // ----------------------------------------------------------------------------- |
|
1530 // Set Detail - Album to the visual item |
|
1531 // ----------------------------------------------------------------------------- |
|
1532 // |
|
1533 void CMPXCommonContainerHitchcockImp::SetDetailAlbumL( |
|
1534 MulVisualItem* aVisualItem, |
|
1535 CMPXMedia* aMedia ) |
|
1536 { |
|
1537 if ( aMedia->IsSupported( KMPXMediaMusicAlbum ) ) |
|
1538 { |
|
1539 // AK - Needs to be localized |
|
1540 TFileName detailText; |
|
1541 const TDesC& album = aMedia->ValueText( KMPXMediaMusicAlbum ); |
|
1542 if ( album.Compare( KNullDesC ) != 0 ) |
|
1543 { |
|
1544 detailText.Copy(album.Left(detailText.MaxLength())); |
|
1545 aVisualItem->SetAttribute( mulvisualitem::KMulDetail, detailText, 0); |
|
1546 } |
|
1547 } |
|
1548 } |
|
1549 |
|
1550 // ----------------------------------------------------------------------------- |
|
1551 // Set Detail - Count + Duration to the visual item |
|
1552 // ----------------------------------------------------------------------------- |
|
1553 // |
|
1554 void CMPXCommonContainerHitchcockImp::SetDetailDurationL( |
|
1555 MulVisualItem* aVisualItem, |
|
1556 CMPXMedia* aMedia ) |
|
1557 { |
|
1558 if ( iContext == EContextGroupPlaylist && |
|
1559 aMedia->IsSupported( KMPXMediaGeneralDuration ) && |
|
1560 aMedia->IsSupported( KMPXMediaGeneralCount ) ) |
|
1561 { |
|
1562 // AK - Needs to be localized |
|
1563 TBuf<85> detailText; |
|
1564 TInt count( aMedia->ValueTObjectL<TInt>( KMPXMediaGeneralCount ) ); |
|
1565 TBuf<10> temp; |
|
1566 temp.AppendNum( count ); |
|
1567 AknTextUtils::LanguageSpecificNumberConversion( temp ); |
|
1568 detailText.Append( temp ); |
|
1569 detailText.Append( (count > 1 ) ? KSongsDash() : KSongDash() ); |
|
1570 |
|
1571 TInt duration = aMedia->ValueTObjectL<TInt>( KMPXMediaGeneralDuration ); |
|
1572 UpdateTimeIndicatorsL(detailText, duration); |
|
1573 aVisualItem->SetAttribute( mulvisualitem::KMulDetail, detailText, 0); |
|
1574 } |
|
1575 else if ( iContext == EContextItemPodcast && |
|
1576 aMedia->IsSupported( KMPXMediaGeneralDuration ) && |
|
1577 aMedia->IsSupported( KMPXMediaGeneralSize ) ) |
|
1578 { |
|
1579 TBuf<85> detailText; |
|
1580 TInt duration = aMedia->ValueTObjectL<TInt>( KMPXMediaGeneralDuration ); |
|
1581 UpdateTimeIndicatorsL(detailText, duration); |
|
1582 detailText.Append( KMPXDash() ); |
|
1583 |
|
1584 TInt size( aMedia->ValueTObjectL<TInt>( KMPXMediaGeneralSize ) ); |
|
1585 HBufC* sizeBuf = iCommonUiHelper->UnitConversionL( size ); |
|
1586 TPtr sizePtr( sizeBuf->Des() ); |
|
1587 detailText.Append( sizePtr ); |
|
1588 delete sizeBuf; |
|
1589 |
|
1590 aVisualItem->SetAttribute( mulvisualitem::KMulDetail, detailText, 0); |
|
1591 } |
|
1592 } |
|
1593 |
|
1594 // ----------------------------------------------------------------------------- |
|
1595 // Format the duration to the visual item |
|
1596 // ----------------------------------------------------------------------------- |
|
1597 // |
|
1598 void CMPXCommonContainerHitchcockImp::UpdateTimeIndicatorsL( |
|
1599 TDes& aBuf, |
|
1600 TInt aDuration ) |
|
1601 { |
|
1602 TInt durationInSeconds = aDuration; |
|
1603 if ( durationInSeconds > 0 ) |
|
1604 { |
|
1605 durationInSeconds /= 1000; // MilliSeconds to second conversion |
|
1606 } |
|
1607 else if ( durationInSeconds < 0 ) |
|
1608 { |
|
1609 durationInSeconds = 0; |
|
1610 } |
|
1611 if ( durationInSeconds == 0 ) |
|
1612 { |
|
1613 TLocale locale; |
|
1614 TBuf<KMPXTimeIndicatorLength> pos; |
|
1615 TChar separator = locale.TimeSeparator( KMPXMinSecSeparatorIndex ); |
|
1616 aBuf.Append(KMPXZeroDurationMark); |
|
1617 aBuf.Append( separator ); |
|
1618 aBuf.Append(KMPXZeroDurationMark); |
|
1619 } |
|
1620 else |
|
1621 { |
|
1622 CMPXCommonUiHelper::TMPXDuratDisplayMode durationMode = CMPXCommonUiHelper::EMPXDuratAuto; |
|
1623 if ( durationInSeconds > KOneHourInSeconds ) |
|
1624 { |
|
1625 durationMode = CMPXCommonUiHelper::EMPXDuratHMS; |
|
1626 } |
|
1627 // Convert ellapsed time to texts |
|
1628 HBufC* position = iCommonUiHelper->DisplayableDurationL( durationInSeconds, durationMode ); |
|
1629 aBuf.Append(position->Des()); |
|
1630 delete position; |
|
1631 } |
|
1632 } |
|
1633 |
|
1634 // ----------------------------------------------------------------------------- |
|
1635 // Set Detail - Indicator to the visual item |
|
1636 // ----------------------------------------------------------------------------- |
|
1637 // |
|
1638 void CMPXCommonContainerHitchcockImp::SetDetailIndicatorL( |
|
1639 MulVisualItem* aVisualItem, |
|
1640 TInt aIndex ) |
|
1641 { |
|
1642 // Reset the indicators |
|
1643 aVisualItem->SetAttribute( mulvisualitem::KMulIndicator1, -1, 0 ); |
|
1644 aVisualItem->SetAttribute( mulvisualitem::KMulIndicator2, -1, 0 ); |
|
1645 |
|
1646 // Get icon indices |
|
1647 TInt realIndex = aIndex; |
|
1648 if ( iFilteredList ) |
|
1649 { |
|
1650 realIndex = iFilteredList->FilteredIndexToRealIndex(aIndex); |
|
1651 } |
|
1652 RArray<TInt> iconIndices = iViewContainer->IndicatorsL( realIndex ); |
|
1653 CleanupClosePushL( iconIndices ); |
|
1654 |
|
1655 TInt iconCount = iconIndices.Count(); |
|
1656 if ( iconCount > 2 ) |
|
1657 { |
|
1658 // Restrict max number of icons to 2 |
|
1659 iconCount = 2; |
|
1660 } |
|
1661 if ( iconCount > 0 ) |
|
1662 { |
|
1663 for ( TInt iconIndex = 0; iconIndex < iconCount; iconIndex++ ) |
|
1664 { |
|
1665 TInt index = iconIndices[iconIndex]; |
|
1666 TInt textureIndex = index; |
|
1667 if ( iContext == EContextGroupPodcast || iContext == EContextItemPodcast ) |
|
1668 { |
|
1669 // Shift the range for podcast icons to avoid textureId |
|
1670 // clash with collection icons |
|
1671 textureIndex += 100; |
|
1672 } |
|
1673 |
|
1674 // Check if texture already exists for the icon |
|
1675 TInt textureId( iTextureManager->IconTextureId( textureIndex ) ); |
|
1676 if ( textureId == KErrNotFound ) |
|
1677 { |
|
1678 CGulIcon* icon = (*iIconArray)[index]; |
|
1679 CFbsBitmap* bitmap = icon->Bitmap(); |
|
1680 CFbsBitmap* mask = icon->Mask(); |
|
1681 |
|
1682 if( bitmap && mask ) |
|
1683 { |
|
1684 // Need to set the size of the bitmap used in CGulIcon to enable display |
|
1685 AknIconUtils::SetSize( bitmap, TSize(iIndicatorHeight, iIndicatorWidth) ); |
|
1686 AknIconUtils::SetSize( mask, TSize(iIndicatorHeight, iIndicatorWidth) ); |
|
1687 |
|
1688 // Bitmap ownership is transferred to the texture manager. |
|
1689 CFbsBitmap* bitmapTemp = new (ELeave) CFbsBitmap(); |
|
1690 CFbsBitmap* maskTemp = new (ELeave) CFbsBitmap(); |
|
1691 bitmapTemp->Duplicate( bitmap->Handle() ); |
|
1692 maskTemp->Duplicate( mask->Handle() ); |
|
1693 |
|
1694 // Create the texture. The texture id will be |
|
1695 // set synchronously when the texture manager is notified |
|
1696 CAlfTexture& texture = iTextureManager->CreateIconTextureL( |
|
1697 textureIndex, bitmapTemp, maskTemp ); |
|
1698 textureId = texture.Id(); |
|
1699 } |
|
1700 } |
|
1701 |
|
1702 // Set the texture id |
|
1703 switch ( iconIndex ) |
|
1704 { |
|
1705 case 0: |
|
1706 aVisualItem->SetAttribute( mulvisualitem::KMulIndicator1, textureId, 0 ); |
|
1707 break; |
|
1708 case 1: |
|
1709 aVisualItem->SetAttribute( mulvisualitem::KMulIndicator2, textureId, 0 ); |
|
1710 break; |
|
1711 } |
|
1712 } |
|
1713 } |
|
1714 CleanupStack::PopAndDestroy(); |
|
1715 } |
|
1716 |
|
1717 // ----------------------------------------------------------------------------- |
|
1718 // Set Detail - Icon to the visual item |
|
1719 // ----------------------------------------------------------------------------- |
|
1720 // |
|
1721 void CMPXCommonContainerHitchcockImp::SetDetailIconL( |
|
1722 MulVisualItem* aVisualItem, |
|
1723 TInt aIndex ) |
|
1724 { |
|
1725 // Get icon indices |
|
1726 TInt iconIndex = aIndex; |
|
1727 switch ( aIndex ) |
|
1728 { |
|
1729 case 0: |
|
1730 iconIndex = EMPXClvIconArtist; |
|
1731 break; |
|
1732 case 1: |
|
1733 iconIndex = EMPXClvIconAlbum; |
|
1734 break; |
|
1735 case 2: |
|
1736 iconIndex = EMPXClvIconPlaylist; |
|
1737 break; |
|
1738 case 3: |
|
1739 iconIndex = EMPXClvIconSongs; |
|
1740 break; |
|
1741 #ifdef __ENABLE_PODCAST_IN_MUSIC_MENU |
|
1742 case 4: |
|
1743 iconIndex = EMPXClvIconPodcasts; |
|
1744 break; |
|
1745 #endif |
|
1746 case 5: |
|
1747 iconIndex = EMPXClvIconGenre; |
|
1748 break; |
|
1749 case 6: |
|
1750 iconIndex = EMPXClvIconComposer; |
|
1751 break; |
|
1752 } |
|
1753 |
|
1754 // Check if texture already exists for the icon |
|
1755 TInt textureId( iTextureManager->IconTextureId( iconIndex ) ); |
|
1756 if ( textureId == KErrNotFound ) |
|
1757 { |
|
1758 CGulIcon* icon = (*iIconArray)[iconIndex]; |
|
1759 CFbsBitmap* bitmap = icon->Bitmap(); |
|
1760 CFbsBitmap* mask = icon->Mask(); |
|
1761 |
|
1762 if( bitmap && mask ) |
|
1763 { |
|
1764 // Need to set the size of the bitmap used in CGulIcon to enable display |
|
1765 AknIconUtils::SetSize( bitmap, TSize(iIconHeight, iIconWidth) ); |
|
1766 AknIconUtils::SetSize( mask, TSize(iIconHeight, iIconWidth) ); |
|
1767 |
|
1768 // Bitmap ownership is transferred to the texture manager. |
|
1769 CFbsBitmap* bitmapTemp = new (ELeave) CFbsBitmap(); |
|
1770 CFbsBitmap* maskTemp = new (ELeave) CFbsBitmap(); |
|
1771 bitmapTemp->Duplicate( bitmap->Handle() ); |
|
1772 maskTemp->Duplicate( mask->Handle() ); |
|
1773 |
|
1774 // Create the texture. The texture id will be |
|
1775 // set synchronously when the texture manager is notified |
|
1776 CAlfTexture& texture = iTextureManager->CreateIconTextureL( |
|
1777 iconIndex, bitmapTemp, maskTemp ); |
|
1778 textureId = texture.Id(); |
|
1779 } |
|
1780 } |
|
1781 |
|
1782 // Set the texture id |
|
1783 aVisualItem->SetAttribute( mulvisualitem::KMulIcon1, textureId, 0 ); |
|
1784 } |
|
1785 |
|
1786 // ----------------------------------------------------------------------------- |
|
1787 // Set Detail - Thumbnail to the visual item |
|
1788 // ----------------------------------------------------------------------------- |
|
1789 // |
|
1790 void CMPXCommonContainerHitchcockImp::SetDetailThumbnailL( |
|
1791 MulVisualItem* aVisualItem, |
|
1792 CMPXMedia* aMedia, |
|
1793 TInt aIndex ) |
|
1794 { |
|
1795 TMPXItemId currentId( aMedia->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) ); |
|
1796 // Check if texture already exists for the thumbnail |
|
1797 TInt textureId( iTextureManager->TextureId( currentId ) ); |
|
1798 if ( textureId != KErrNotFound ) |
|
1799 { |
|
1800 // Set the texture id |
|
1801 aVisualItem->SetAttribute( mulvisualitem::KMulIcon1, textureId, 0 ); |
|
1802 } |
|
1803 else |
|
1804 { |
|
1805 if ( aMedia->IsSupported( KMPXMediaMusicAlbumArtFileName ) ) |
|
1806 { |
|
1807 const TDesC& album = aMedia->ValueText( KMPXMediaMusicAlbumArtFileName ); |
|
1808 if ( album.Compare( KNullDesC ) != 0 ) |
|
1809 { |
|
1810 CThumbnailObjectSource* source = CThumbnailObjectSource::NewLC( album, KMPXAlbumMimeType ); |
|
1811 TInt ret = NULL; |
|
1812 TThumnailReq req; |
|
1813 req.iIndex = aIndex; |
|
1814 // Set priority based on the index so that the smaller indexes are loaded first |
|
1815 req.iReqId = iThumbnailManager->GetThumbnailL( *source, (TAny*)ret, -aIndex ); |
|
1816 iThumbnailReqArray.AppendL(req); |
|
1817 CleanupStack::PopAndDestroy( source ); |
|
1818 } |
|
1819 } |
|
1820 } |
|
1821 } |
|
1822 |
|
1823 // ----------------------------------------------------------------------------- |
|
1824 // Sets the current category. |
|
1825 // ----------------------------------------------------------------------------- |
|
1826 // |
|
1827 void CMPXCommonContainerHitchcockImp::SetCollectionContextL() |
|
1828 { |
|
1829 MPX_FUNC( "CMPXCommonContainerHitchcockImp::SetCollectionContextL" ); |
|
1830 |
|
1831 const CMPXMedia& media = iListBoxArray->ContainerMedia(); |
|
1832 |
|
1833 TMPXGeneralType containerType( EMPXNoType ); |
|
1834 if ( media.IsSupported( KMPXMediaGeneralType ) ) |
|
1835 { |
|
1836 containerType = media.ValueTObjectL<TMPXGeneralType>( KMPXMediaGeneralType ); |
|
1837 } |
|
1838 |
|
1839 TMPXGeneralCategory containerCategory( EMPXNoCategory ); |
|
1840 if( media.IsSupported( KMPXMediaGeneralCategory ) ) |
|
1841 { |
|
1842 containerCategory = media.ValueTObjectL<TMPXGeneralCategory>( KMPXMediaGeneralCategory ); |
|
1843 } |
|
1844 MPX_DEBUG3( "CMPXCommonContainerHitchcockImp::SetCollectionContextL container type = %d, category = %d", |
|
1845 containerType, containerCategory ); |
|
1846 |
|
1847 TBool isPodcast = EFalse; |
|
1848 TMPXPodcastCategory podcastCategory( EMPXUnknown ); |
|
1849 if ( media.IsSupported( KMPXMediaPodcastType ) ) |
|
1850 { |
|
1851 isPodcast = ETrue; |
|
1852 if( media.IsSupported( KMPXMediaPodcastCategoryGroup ) ) |
|
1853 { |
|
1854 podcastCategory = media.ValueTObjectL<TMPXPodcastCategory>( KMPXMediaPodcastCategoryGroup ); |
|
1855 } |
|
1856 } |
|
1857 MPX_DEBUG3( "CMPXCommonContainerHitchcockImp::SetCollectionContextL container podcast = %d, category = %d", |
|
1858 isPodcast, podcastCategory ); |
|
1859 |
|
1860 if ( !isPodcast ) |
|
1861 { |
|
1862 if ( containerType == EMPXGroup ) |
|
1863 { |
|
1864 switch (containerCategory) |
|
1865 { |
|
1866 case EMPXCollection: |
|
1867 iContext = EContextGroupCollection; |
|
1868 iWidgetModel->SetTemplate( mulwidget::KTemplate3 ); |
|
1869 break; |
|
1870 case EMPXArtist: |
|
1871 iContext = EContextGroupArtist; |
|
1872 iWidgetModel->SetTemplate( mulwidget::KTemplate2 ); |
|
1873 break; |
|
1874 case EMPXAlbum: |
|
1875 iContext = EContextGroupAlbum; |
|
1876 iWidgetModel->SetTemplate( mulwidget::KTemplate6 ); |
|
1877 break; |
|
1878 case EMPXPlaylist: |
|
1879 iContext = EContextGroupPlaylist; |
|
1880 iWidgetModel->SetTemplate( mulwidget::KTemplate2 ); |
|
1881 break; |
|
1882 case EMPXSong: |
|
1883 iContext = EContextGroupSong; |
|
1884 iWidgetModel->SetTemplate( mulwidget::KTemplate3 ); |
|
1885 break; |
|
1886 case EMPXGenre: |
|
1887 iContext = EContextGroupGenre; |
|
1888 iWidgetModel->SetTemplate( mulwidget::KTemplate2 ); |
|
1889 break; |
|
1890 case EMPXComposer: |
|
1891 iContext = EContextGroupComposer; |
|
1892 iWidgetModel->SetTemplate( mulwidget::KTemplate2 ); |
|
1893 break; |
|
1894 default: |
|
1895 User::Leave(KErrNotSupported); |
|
1896 break; |
|
1897 } |
|
1898 } |
|
1899 else if ( containerType == EMPXItem ) |
|
1900 { |
|
1901 switch (containerCategory) |
|
1902 { |
|
1903 case EMPXArtist: |
|
1904 iContext = EContextItemArtist; |
|
1905 iWidgetModel->SetTemplate( mulwidget::KTemplate6 ); |
|
1906 break; |
|
1907 case EMPXAlbum: |
|
1908 iContext = EContextItemAlbum; |
|
1909 iWidgetModel->SetTemplate( mulwidget::KTemplate3 ); |
|
1910 break; |
|
1911 case EMPXPlaylist: |
|
1912 iContext = EContextItemPlaylist; |
|
1913 iWidgetModel->SetTemplate( mulwidget::KTemplate3 ); |
|
1914 break; |
|
1915 case EMPXSong: |
|
1916 iContext = EContextItemSong; |
|
1917 iWidgetModel->SetTemplate( mulwidget::KTemplate3 ); |
|
1918 break; |
|
1919 case EMPXGenre: |
|
1920 iContext = EContextItemGenre; |
|
1921 iWidgetModel->SetTemplate( mulwidget::KTemplate3 ); |
|
1922 break; |
|
1923 case EMPXComposer: |
|
1924 iContext = EContextItemComposer; |
|
1925 iWidgetModel->SetTemplate( mulwidget::KTemplate3 ); |
|
1926 break; |
|
1927 default: |
|
1928 User::Leave(KErrNotSupported); |
|
1929 break; |
|
1930 } |
|
1931 } |
|
1932 } |
|
1933 else |
|
1934 { |
|
1935 if ( (containerType == EMPXGroup) && (podcastCategory == EMPXTitle) ) |
|
1936 { |
|
1937 iContext = EContextGroupPodcast; |
|
1938 iWidgetModel->SetTemplate( mulwidget::KTemplate2 ); |
|
1939 } |
|
1940 else if ( (containerType == EMPXItem) && (podcastCategory == EMPXEpisode) ) |
|
1941 { |
|
1942 iContext = EContextItemPodcast; |
|
1943 iWidgetModel->SetTemplate( mulwidget::KTemplate3 ); |
|
1944 } |
|
1945 else |
|
1946 { |
|
1947 User::Leave(KErrNotSupported); |
|
1948 } |
|
1949 } |
|
1950 } |
|
1951 |
|
1952 // ----------------------------------------------------------------------------- |
|
1953 // |
|
1954 // ----------------------------------------------------------------------------- |
|
1955 // |
|
1956 void CMPXCommonContainerHitchcockImp::ActivateSearchFieldL() |
|
1957 { |
|
1958 if ( ! iSearchFieldWrapper->IsSearchFieldActive() ) |
|
1959 { |
|
1960 TRect clientRect = ((CAknView*)iView)->ClientRect(); |
|
1961 iSearchFieldWrapper->ActivateSearchFieldL(); |
|
1962 |
|
1963 iViewWidget->setRect( |
|
1964 iSearchFieldWrapper->GetListRect( ETrue, clientRect ) ); |
|
1965 iSearchFieldWrapper->SetRect( |
|
1966 iSearchFieldWrapper->GetSearchFieldRect( ETrue, clientRect ) ); |
|
1967 } |
|
1968 } |
|
1969 |
|
1970 // ----------------------------------------------------------------------------- |
|
1971 // |
|
1972 // ----------------------------------------------------------------------------- |
|
1973 // |
|
1974 void CMPXCommonContainerHitchcockImp::DeactivateSearchField() |
|
1975 { |
|
1976 TRect clientRect = ((CAknView*)iView)->ClientRect(); |
|
1977 iViewWidget->setRect( |
|
1978 iSearchFieldWrapper->GetListRect( EFalse, clientRect ) ); |
|
1979 } |
|
1980 |
|
1981 // End of File |