|
1 /* |
|
2 * Copyright (c) 2008-2009 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 class for Medialist Access for Data |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include "glxmedialistmulmodelproviderimpl.h" // The actual implemntation for providign the data to the clients is done here |
|
22 #include "glxbindingset.h" // This basically holds the bindings required to populate the visual item |
|
23 #include <mglxmedialist.h> // Interface for reading lists of media items |
|
24 #include "glxthumbnailinfo.h" |
|
25 #include "glxattributerequirement.h" // This class will set the required attribute to the medialist |
|
26 #include "glxerrormanager.h" // for handling the error attribute that may be attached to items |
|
27 #include "glxthumbnailattributeinfo.h" |
|
28 #include "glxmulbindingsetfactory.h" // CreateBindingSetL creates instance of Binding set |
|
29 #include <mul/imulcoverflowwidget.h> // An interface for Multimedia coverflow Widget |
|
30 #include <glxresolutionutility.h> // Singleton containing resolution utility methods |
|
31 #include <glxtracer.h> |
|
32 #include <glxlog.h> // Logging |
|
33 #include <glxuiutility.h> // Alf utils lib glxalfutils.lib |
|
34 #include "glxtexturemanager.h" |
|
35 |
|
36 |
|
37 static const char* const KListWidget = "ListWidget"; |
|
38 static const char* const KCoverFlowWidget = "CoverflowWidget"; |
|
39 |
|
40 using namespace Alf; |
|
41 |
|
42 // ---------------------------------------------------------------------------- |
|
43 // NewL |
|
44 // ---------------------------------------------------------------------------- |
|
45 // |
|
46 CGlxMediaListMulModelProviderImpl* CGlxMediaListMulModelProviderImpl::NewL( |
|
47 CAlfEnv& aEnv, |
|
48 IMulWidget& aWidget, |
|
49 MGlxMediaList& aMediaList, |
|
50 const TGlxMulBindingSetFactory& aFactory, |
|
51 Alf::mulwidget::TLogicalTemplate aDefaultTemplate, |
|
52 TInt aDataWindowSize ) |
|
53 { |
|
54 TRACER("CGlxMediaListMulModelProviderImpl::NewL"); |
|
55 CGlxMediaListMulModelProviderImpl* self = |
|
56 new ( ELeave) CGlxMediaListMulModelProviderImpl( aWidget, aMediaList ); |
|
57 CleanupStack::PushL( self ); |
|
58 self->ConstructL( aEnv, aFactory, aDefaultTemplate, aDataWindowSize ); |
|
59 CleanupStack::Pop( self ); |
|
60 return self; |
|
61 } |
|
62 |
|
63 // ---------------------------------------------------------------------------- |
|
64 // Constructor |
|
65 // ---------------------------------------------------------------------------- |
|
66 // |
|
67 CGlxMediaListMulModelProviderImpl::CGlxMediaListMulModelProviderImpl( |
|
68 IMulWidget& aWidget, MGlxMediaList& aMediaList ) |
|
69 : CGlxMulModelProviderBase( aWidget ), iMediaList( aMediaList ),iWidget(aWidget) |
|
70 { |
|
71 } |
|
72 |
|
73 // ---------------------------------------------------------------------------- |
|
74 // ConstructL |
|
75 // ---------------------------------------------------------------------------- |
|
76 // |
|
77 void CGlxMediaListMulModelProviderImpl::ConstructL( CAlfEnv& aEnv, |
|
78 const TGlxMulBindingSetFactory& aFactory, |
|
79 Alf::mulwidget::TLogicalTemplate aDefaultTemplate, TInt aDataWindowSize ) |
|
80 { |
|
81 TRACER("CGlxMediaListMulModelProviderImpl::ConstructL"); |
|
82 BaseConstructL( aEnv, aDefaultTemplate, aDataWindowSize ); |
|
83 iMediaList.AddMediaListObserverL(this); |
|
84 iUiUtility = CGlxUiUtility::UtilityL(); |
|
85 iAttributeRequirements = CGlxAttributeRequirements::NewL( iMediaList); |
|
86 iBindingSet = aFactory.CreateBindingSetL( *this ); |
|
87 |
|
88 TInt height; |
|
89 TInt width; |
|
90 iWidget.GetIconSize(aDefaultTemplate,Alf::mulvisualitem::KMulIcon1,height,width); |
|
91 TSize thumbnailSize(width,height); |
|
92 |
|
93 iBindingSet->AddRequirementsL( *iAttributeRequirements ,thumbnailSize ); |
|
94 if( iMediaList.Count() > 0 ) |
|
95 { |
|
96 HandleItemAddedL( 0, iMediaList.Count() - 1, &iMediaList ); |
|
97 if(!iUiUtility->IsPenSupported()) |
|
98 { |
|
99 CMPXCollectionPath* path = iMediaList.PathLC( NGlxListDefs::EPathFocusOrSelection ); |
|
100 iBindingSet->HandleItemChangedL( *path ); |
|
101 CleanupStack::PopAndDestroy( path ); |
|
102 } |
|
103 } |
|
104 |
|
105 if(UString( KListWidget ) == UString(iWidget.widgetName() ) || UString( KCoverFlowWidget ) == UString(iWidget.widgetName() ) ) |
|
106 { |
|
107 AddWidgetEventHandler(); |
|
108 } |
|
109 } |
|
110 |
|
111 // ---------------------------------------------------------------------------- |
|
112 // Destructor |
|
113 // ---------------------------------------------------------------------------- |
|
114 // |
|
115 CGlxMediaListMulModelProviderImpl::~CGlxMediaListMulModelProviderImpl() |
|
116 { |
|
117 TRACER("CGlxMediaListMulModelProviderImpl::~CGlxMediaListMulModelProviderImpl"); |
|
118 delete iBindingSet; |
|
119 delete iAttributeRequirements; |
|
120 iMediaList.RemoveMediaListObserver( this ); |
|
121 if (iUiUtility) |
|
122 { |
|
123 iUiUtility->Close(); |
|
124 } |
|
125 |
|
126 } |
|
127 |
|
128 // ---------------------------------------------------------------------------- |
|
129 // HandleBindingChanged |
|
130 // ---------------------------------------------------------------------------- |
|
131 // |
|
132 void CGlxMediaListMulModelProviderImpl::HandleBindingChanged( |
|
133 const CGlxBinding& aBinding ) |
|
134 { |
|
135 TRACER("CGlxMediaListMulModelProviderImpl::HandleBindingChanged"); |
|
136 SetDataT( aBinding, iMediaList.Item(iMediaList.FocusIndex()), |
|
137 iMediaList.FocusIndex() ); |
|
138 |
|
139 } |
|
140 |
|
141 // ---------------------------------------------------------------------------- |
|
142 // HandleFocusChanged |
|
143 // ---------------------------------------------------------------------------- |
|
144 // |
|
145 void CGlxMediaListMulModelProviderImpl::HandleFocusChanged( TInt |
|
146 /*aNewFocusIndex*/, TInt /*aPreviousFocusIndex*/ ) |
|
147 { |
|
148 TRACER("CGlxMediaListMulModelProviderImpl::HandleFocusChanged"); |
|
149 if (CGlxBinding::EUpdateRequested == iBindingSet->HandleFocusChanged( ETrue ) ) |
|
150 { |
|
151 UpdateItems( iMediaList.FocusIndex(), 1 ); |
|
152 } |
|
153 } |
|
154 |
|
155 // ---------------------------------------------------------------------------- |
|
156 // HandleFocusChangedL |
|
157 // ---------------------------------------------------------------------------- |
|
158 // |
|
159 void CGlxMediaListMulModelProviderImpl::HandleFocusChangedL( NGlxListDefs::TFocusChangeType /*aType*/, |
|
160 TInt aNewIndex, TInt aOldIndex, MGlxMediaList* aList ) |
|
161 { |
|
162 TRACER("CGlxMediaListMulModelProviderImpl::HandleFocusChangedL"); |
|
163 CMPXCollectionPath* path = iMediaList.PathLC( NGlxListDefs::EPathFocusOrSelection ); |
|
164 if ( aNewIndex != FocusIndex() ) |
|
165 { |
|
166 // focus was changed not by the widget, but by some other reason (e.g., item insertion) |
|
167 //Aki changes - todo |
|
168 SetFocusIndex( aNewIndex ); |
|
169 } |
|
170 iBindingSet->HandleItemChangedL( *path ); // Item changed is handled first before Updating the List - see line 168 moved from here |
|
171 if( aList->FocusIndex() >=0 && aOldIndex <= aList->Count() -1 && aOldIndex!=-1 ) |
|
172 { |
|
173 UpdateItems( aOldIndex, 1 ); |
|
174 UpdateItems( aNewIndex, 1 ); |
|
175 } |
|
176 |
|
177 CleanupStack::PopAndDestroy( path ); |
|
178 } |
|
179 |
|
180 // ---------------------------------------------------------------------------- |
|
181 // HandleItemAddedL |
|
182 // ---------------------------------------------------------------------------- |
|
183 // |
|
184 void CGlxMediaListMulModelProviderImpl::HandleItemAddedL( TInt aStartIndex, |
|
185 TInt aEndIndex, MGlxMediaList* aList ) |
|
186 { |
|
187 TRACER("CGlxMediaListMulModelProviderImpl::HandleItemAddedL"); |
|
188 GLX_LOG_INFO1("HandleItemAddedL::aStartIndex %d", aStartIndex); |
|
189 GLX_LOG_INFO1("HandleItemAddedL::aEndIndex %d", aEndIndex); |
|
190 |
|
191 InsertItemsL( aStartIndex, aEndIndex - aStartIndex + 1, aList->FocusIndex() ); |
|
192 } |
|
193 |
|
194 // ---------------------------------------------------------------------------- |
|
195 // HandleItemRemoved |
|
196 // ---------------------------------------------------------------------------- |
|
197 // |
|
198 void CGlxMediaListMulModelProviderImpl::HandleItemRemovedL( TInt aStartIndex, |
|
199 TInt aEndIndex, MGlxMediaList* /*aList*/ ) |
|
200 { |
|
201 TRACER("CGlxMediaListMulModelProviderImpl::HandleItemRemovedL"); |
|
202 // hack of making the flag iIsReleventAttribute to Etrue will be removed |
|
203 // once the bug ESPK-7G6GJX |
|
204 //iIsReleventAttribute = ETrue; |
|
205 RemoveItems( aStartIndex, aEndIndex - aStartIndex + 1 ); |
|
206 } |
|
207 |
|
208 // ---------------------------------------------------------------------------- |
|
209 // HandleAttributesAvailableL |
|
210 // ---------------------------------------------------------------------------- |
|
211 // |
|
212 void CGlxMediaListMulModelProviderImpl::HandleAttributesAvailableL( TInt aIndex, |
|
213 const RArray<TMPXAttribute>& aAttributes, MGlxMediaList* /*aList*/ ) |
|
214 { |
|
215 TRACER("CGlxMediaListMulModelProviderImpl::HandleAttributesAvailableL"); |
|
216 GLX_LOG_INFO1("HandleAttributesAvailableL::Index %d", aIndex); |
|
217 |
|
218 if(iBindingSet->HasRelevantAttributes( aAttributes ) ) |
|
219 { |
|
220 UpdateItems( aIndex, 1 ); |
|
221 } |
|
222 } |
|
223 |
|
224 // ---------------------------------------------------------------------------- |
|
225 // HandleError |
|
226 // ---------------------------------------------------------------------------- |
|
227 // |
|
228 void CGlxMediaListMulModelProviderImpl::HandleError( TInt aError ) |
|
229 { |
|
230 TRACER("CGlxMediaListMulModelProviderImpl::HandleError"); |
|
231 TRAP_IGNORE( DoHandleErrorL( aError ) ); |
|
232 } |
|
233 |
|
234 // ---------------------------------------------------------------------------- |
|
235 // HandleError |
|
236 // ---------------------------------------------------------------------------- |
|
237 // |
|
238 void CGlxMediaListMulModelProviderImpl::DoHandleErrorL( TInt /*aError*/ ) |
|
239 { |
|
240 TRACER("CGlxMediaListMulModelProviderImpl::DoHandleErrorL"); |
|
241 // Check for items for which fetching a thumbnail has failed, and replace |
|
242 // the default icon with broken icon |
|
243 TInt count = iMediaList.Count(); |
|
244 for ( TInt i = 0; i < count; i++ ) |
|
245 { |
|
246 const TGlxMedia& item = iMediaList.Item( i ); |
|
247 TInt thumbnailError = GlxErrorManager::HasAttributeErrorL( |
|
248 item.Properties(), KGlxMediaIdThumbnail ); |
|
249 if( thumbnailError ) |
|
250 { |
|
251 UpdateItems( i , 1 ); |
|
252 } |
|
253 } |
|
254 } |
|
255 |
|
256 // ---------------------------------------------------------------------------- |
|
257 // ProvideData |
|
258 // ---------------------------------------------------------------------------- |
|
259 // |
|
260 void CGlxMediaListMulModelProviderImpl::ProvideData (int aIndex, int aCount, |
|
261 MulDataPath /*aPath*/) |
|
262 { |
|
263 TRACER("CGlxMediaListMulModelProviderImpl::ProvideData"); |
|
264 GLX_LOG_INFO1("ProvideData::aCount %d", aCount); |
|
265 |
|
266 if( KErrNotFound != iMediaList.FocusIndex() ) |
|
267 { |
|
268 for(int i = aIndex; i < aIndex + aCount ; i++) |
|
269 { |
|
270 SetDataT( *iBindingSet, iMediaList.Item(i), i ); |
|
271 } |
|
272 } |
|
273 else |
|
274 return; |
|
275 |
|
276 } |
|
277 |
|
278 void CGlxMediaListMulModelProviderImpl::HandleOrientationChanged() |
|
279 { |
|
280 TRACER("CGlxMediaListMulModelProviderImpl::HandleOrientationChanged"); |
|
281 //Fix for ESLM-7VGCS8 |
|
282 //Since iBindingSet->AddRequirementsL() will change the iFsThumbnailContext's |
|
283 //thumbnail size due to which thumbnail fetched for old context is getting |
|
284 //deleted in clean-up. But actually S60 TNM provides same thumbnail for both |
|
285 //the configurations requests,So it is unneccesary to delete the existing |
|
286 //thumbnail and request for the same. To avoid this ,iBindingSet->AddRequirementsL() |
|
287 //and UpdateItems() is removed so that the context will not be changed |
|
288 //and the thumbnail deletion will not happen. |
|
289 } |
|
290 |
|
291 // ---------------------------------------------------------------------------- |
|
292 // HandleItemModifiedL |
|
293 // ---------------------------------------------------------------------------- |
|
294 // |
|
295 void CGlxMediaListMulModelProviderImpl::HandleItemModifiedL( const RArray<TInt>& aItemIndexes, |
|
296 MGlxMediaList* aList ) |
|
297 { |
|
298 //Bug fix for PKAA-7NRBYZ |
|
299 //First remove all the textures from the list in the texture manager |
|
300 //otherwise it would not create a new texture for the modified image. |
|
301 for(TInt index = 0;index<aItemIndexes.Count();index++) |
|
302 { |
|
303 TGlxMedia media = aList->Item(aItemIndexes[index]); |
|
304 |
|
305 iUiUtility->GlxTextureManager().RemoveTexture(media.Id(),ETrue); |
|
306 } |
|
307 //Now update the items, this would create the new textures and update the view. |
|
308 for(TInt index = 0;index<aItemIndexes.Count();index++) |
|
309 UpdateItems(aItemIndexes[index],1); |
|
310 } |