author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 14 Sep 2010 21:19:17 +0300 | |
branch | RCL_3 |
changeset 27 | 34937ec34dac |
parent 26 | 5b3385a43d68 |
permissions | -rw-r--r-- |
26 | 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 details data provider |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
||
20 |
||
21 |
#include "glxdetailsmulmodelproviderimpl.h" // This is the implementation class of details data provider |
|
22 |
#include "glxattributerequirement.h" // This class will set the required attribute to the medialist |
|
23 |
#include "glxbindingset.h" // This basically holds the bindings required to populate the visual item |
|
24 |
#include "glxbinding.h" // This class holds the bindings required to populate the visual item |
|
25 |
#include "glxmulbindingsetfactory.h" // CreateBindingSetL creates instance of Binding set |
|
26 |
#include <mglxmedialist.h> // Interface for reading lists of media items |
|
27 |
#include <glxlog.h> // Logging |
|
28 |
#include <glxtracer.h> |
|
29 |
#include <eikmenup.h> // A helper class for extending CEikMenuPaneItem without breaking binary |
|
30 |
#include <glxuistd.h> // attribute/thumbnail fetch context priority definitions |
|
31 |
#include "glxdetailsboundcommand.h" // Handles user commands |
|
32 |
#include "glxerrormanager.h" // for handling the error attribute that may be attached to items |
|
33 |
#include "glxthumbnailattributeinfo.h" |
|
34 |
#include "glxdetailsboundcommand.hrh" |
|
35 |
/** Error Id EMPY-7MKDHP **/ |
|
36 |
#include "mglxmetadatadialogobserver.h" //for call back to dailog |
|
37 |
#include <glxcommandhandlers.hrh> |
|
38 |
using namespace Alf; |
|
39 |
||
40 |
// ---------------------------------------------------------------------------- |
|
41 |
// NewL |
|
42 |
// ---------------------------------------------------------------------------- |
|
43 |
// |
|
44 |
CGlxDetailsMulModelProviderImpl* CGlxDetailsMulModelProviderImpl::NewL( |
|
45 |
CAlfEnv& aEnv, |
|
46 |
Alf::IMulWidget& aWidget, |
|
47 |
MGlxMediaList& aMediaList, |
|
48 |
Alf::mulwidget::TLogicalTemplate aDefaultTemplate, |
|
49 |
TInt aDataWindowSize ) |
|
50 |
{ |
|
51 |
TRACER("CGlxDetailsMulModelProviderImpl::NewL"); |
|
52 |
CGlxDetailsMulModelProviderImpl* self = new ( ELeave )CGlxDetailsMulModelProviderImpl( aWidget, aMediaList, aDefaultTemplate, aDataWindowSize); |
|
53 |
CleanupStack::PushL( self ); |
|
54 |
self->ConstructL( aEnv, aDefaultTemplate, aDataWindowSize ); |
|
55 |
CleanupStack::Pop( self ); |
|
56 |
return self; |
|
57 |
} |
|
58 |
||
59 |
// ---------------------------------------------------------------------------- |
|
60 |
// ConstructL |
|
61 |
// ---------------------------------------------------------------------------- |
|
62 |
// |
|
63 |
void CGlxDetailsMulModelProviderImpl::ConstructL( |
|
64 |
CAlfEnv& aEnv, |
|
65 |
Alf::mulwidget::TLogicalTemplate aDefaultTemplate, |
|
66 |
TInt aDataWindowSize ) |
|
67 |
{ |
|
68 |
TRACER("CGlxDetailsMulModelProviderImpl::ConstructL"); |
|
69 |
BaseConstructL( aEnv, aDefaultTemplate, aDataWindowSize ); |
|
70 |
iMediaList.AddMediaListObserverL(this); |
|
71 |
iAttributeRequirements = CGlxAttributeRequirements::NewL( iMediaList ); |
|
72 |
AddWidgetEventHandler(); |
|
73 |
} |
|
74 |
// ---------------------------------------------------------------------------- |
|
75 |
// Destructor |
|
76 |
// ---------------------------------------------------------------------------- |
|
77 |
// |
|
78 |
CGlxDetailsMulModelProviderImpl::~CGlxDetailsMulModelProviderImpl() |
|
79 |
{ |
|
80 |
TRACER("CGlxDetailsMulModelProviderImpl::~CGlxDetailsMulModelProviderImpl"); |
|
81 |
iEntries.ResetAndDestroy(); |
|
82 |
iEntries.Close(); |
|
83 |
iMediaList.RemoveMediaListObserver( this ); |
|
84 |
delete iAttributeRequirements; |
|
85 |
} |
|
86 |
||
87 |
// ---------------------------------------------------------------------------- |
|
88 |
// AddEntryL |
|
89 |
// ---------------------------------------------------------------------------- |
|
90 |
// |
|
91 |
void CGlxDetailsMulModelProviderImpl::AddEntryL( const TGlxMulBindingSetFactory& aFactory ) |
|
92 |
{ |
|
93 |
TRACER("CGlxDetailsMulModelProviderImpl::AddEntryL"); |
|
94 |
CGlxBindingSet* bindingSet = aFactory.CreateBindingSetL( *this ); |
|
95 |
CleanupStack::PushL( bindingSet); |
|
96 |
iEntries.AppendL( bindingSet ); |
|
97 |
CleanupStack::Pop( bindingSet ); |
|
98 |
TSize Size; |
|
99 |
bindingSet->AddRequirementsL(*iAttributeRequirements,Size); |
|
100 |
InsertItemsL( iEntries.Count() - 1, 1 ); |
|
101 |
} |
|
102 |
||
103 |
// ---------------------------------------------------------------------------- |
|
104 |
// OfferCommandL |
|
105 |
// ---------------------------------------------------------------------------- |
|
106 |
// |
|
107 |
TBool CGlxDetailsMulModelProviderImpl::OfferCommandL( TInt aCommandId ) |
|
108 |
{ |
|
109 |
TRACER("CGlxDetailsMulModelProviderImpl::OfferCommandL"); |
|
110 |
MGlxBoundCommand* command = BoundCommand( FocusIndex() ); |
|
111 |
if ( command ) |
|
112 |
{ |
|
113 |
return command->OfferCommandL( aCommandId , iMediaList ); |
|
114 |
} |
|
115 |
return EFalse; |
|
116 |
} |
|
117 |
||
118 |
// ---------------------------------------------------------------------------- |
|
119 |
// HasCommandL |
|
120 |
// ---------------------------------------------------------------------------- |
|
121 |
// |
|
122 |
TBool CGlxDetailsMulModelProviderImpl::HasCommandL( CEikMenuPane& aMenuPane, const TInt aCommandId ) |
|
123 |
{ |
|
124 |
TRACER("CGlxDetailsMulModelProviderImpl::HasCommandL"); |
|
125 |
TInt count = aMenuPane.NumberOfItemsInPane(); |
|
126 |
TInt i = -1; |
|
127 |
while ( ++i < count ) |
|
128 |
{ |
|
129 |
if ( aCommandId == aMenuPane.ItemDataByIndexL( i ).iCommandId ) |
|
130 |
{ |
|
131 |
return ETrue; |
|
132 |
} |
|
133 |
} |
|
134 |
return EFalse; |
|
135 |
} |
|
136 |
// ---------------------------------------------------------------------------- |
|
137 |
// InitMenuL |
|
138 |
// ---------------------------------------------------------------------------- |
|
139 |
// |
|
140 |
void CGlxDetailsMulModelProviderImpl::InitMenuL( CEikMenuPane& aMenu ) |
|
141 |
{ |
|
142 |
TRACER("CGlxDetailsMulModelProviderImpl::InitMenuL"); |
|
143 |
//CEikMenuPane::SetItemDimmed will panic if the menu item does not exist |
|
144 |
if ( HasCommandL( aMenu, KGlxEditBoundMenuCommandId ) ) |
|
145 |
{ |
|
146 |
// Disable by default, bound command will enable if needed |
|
147 |
aMenu.SetItemDimmed( KGlxEditBoundMenuCommandId, ETrue ); |
|
148 |
const MGlxBoundCommand* command = BoundCommand( FocusIndex() ); |
|
149 |
if ( command ) |
|
150 |
{ |
|
151 |
command->InitMenuL( aMenu ); |
|
152 |
} |
|
153 |
} |
|
154 |
else |
|
155 |
{ |
|
156 |
// no implementation |
|
157 |
} |
|
158 |
||
159 |
||
160 |
if ( HasCommandL( aMenu, KGlxDeleteBoundMenuCommandId ) ) |
|
161 |
{ |
|
162 |
// Disable by default, bound command will enable if needed |
|
163 |
aMenu.SetItemDimmed( KGlxDeleteBoundMenuCommandId, ETrue ); |
|
164 |
const MGlxBoundCommand* command = BoundCommand( FocusIndex() ); |
|
165 |
if ( command ) |
|
166 |
{ |
|
167 |
command->InitMenuL( aMenu ); |
|
168 |
} |
|
169 |
} |
|
170 |
else |
|
171 |
{ |
|
172 |
// no implementation |
|
173 |
} |
|
174 |
||
175 |
if ( HasCommandL( aMenu, KGlxViewBoundMenuCommandId ) ) |
|
176 |
{ |
|
177 |
// Disable by default, bound command will enable if needed |
|
178 |
aMenu.SetItemDimmed( KGlxViewBoundMenuCommandId, ETrue ); |
|
179 |
const MGlxBoundCommand* command = BoundCommand( FocusIndex() ); |
|
180 |
if ( command ) |
|
181 |
{ |
|
182 |
command->InitMenuL( aMenu ); |
|
183 |
} |
|
184 |
} |
|
185 |
else |
|
186 |
{ |
|
187 |
// no implementation |
|
188 |
} |
|
189 |
if ( HasCommandL( aMenu, EGlxCmdAiwShowMap ) ) |
|
190 |
{ |
|
191 |
// Disable by default, bound command will enable if needed |
|
192 |
aMenu.SetItemDimmed( EGlxCmdAiwShowMap, ETrue ); |
|
193 |
const MGlxBoundCommand* command = BoundCommand( FocusIndex() ); |
|
194 |
if ( command ) |
|
195 |
{ |
|
196 |
command->InitMenuL( aMenu ); |
|
197 |
} |
|
198 |
} |
|
199 |
else |
|
200 |
{ |
|
201 |
// no implementation |
|
202 |
} |
|
203 |
} |
|
204 |
||
205 |
// ---------------------------------------------------------------------------- |
|
206 |
// CGlxDetailsMulModelProviderImpl |
|
207 |
// ---------------------------------------------------------------------------- |
|
208 |
// |
|
209 |
CGlxDetailsMulModelProviderImpl::CGlxDetailsMulModelProviderImpl( |
|
210 |
Alf::IMulWidget& aWidget, |
|
211 |
MGlxMediaList& aMediaList, |
|
212 |
Alf::mulwidget::TLogicalTemplate /*aDefaultTemplate*/, |
|
213 |
TInt /*aDataWindowSize*/ ): |
|
214 |
CGlxMulModelProviderBase(aWidget), iMediaList( aMediaList ) |
|
215 |
{ |
|
216 |
} |
|
217 |
||
218 |
// ---------------------------------------------------------------------------- |
|
219 |
// HandleBindingChanged |
|
220 |
// ---------------------------------------------------------------------------- |
|
221 |
// |
|
222 |
void CGlxDetailsMulModelProviderImpl::HandleBindingChanged( const CGlxBinding& /*aBinding*/ ) |
|
223 |
{ |
|
224 |
for(TInt i = 0; i < iEntries.Count(); i++) |
|
225 |
{ |
|
226 |
UpdateItems( i, 1 ); |
|
227 |
} |
|
228 |
} |
|
229 |
||
230 |
// ---------------------------------------------------------------------------- |
|
231 |
// HandleFocusChanged |
|
232 |
// ---------------------------------------------------------------------------- |
|
233 |
// |
|
234 |
void CGlxDetailsMulModelProviderImpl::HandleFocusChanged( TInt aNewFocus, TInt aPreviousFocus ) |
|
235 |
{ |
|
236 |
TRACER("CGlxDetailsMulModelProviderImpl::HandleFocusChanged"); |
|
237 |
if ( aPreviousFocus != -1 ) |
|
238 |
{ |
|
239 |
if ( CGlxBinding::EUpdateRequested == |
|
240 |
iEntries[ aPreviousFocus ]->HandleFocusChanged( EFalse ) ) |
|
241 |
{ |
|
242 |
UpdateItems( aPreviousFocus, 1 ); |
|
243 |
} |
|
244 |
} |
|
245 |
||
246 |
if ( aNewFocus != -1 ) |
|
247 |
{ |
|
248 |
if ( CGlxBinding::EUpdateRequested == |
|
249 |
iEntries[ aNewFocus ]->HandleFocusChanged( ETrue ) ) |
|
250 |
{ |
|
251 |
UpdateItems( aNewFocus, 1 ); |
|
252 |
} |
|
253 |
} |
|
254 |
} |
|
255 |
||
256 |
// ---------------------------------------------------------------------------- |
|
257 |
// HandleAttributesAvailableL |
|
258 |
// ---------------------------------------------------------------------------- |
|
259 |
// |
|
260 |
void CGlxDetailsMulModelProviderImpl::HandleAttributesAvailableL( TInt aIndex, |
|
261 |
const RArray<TMPXAttribute>& aAttributes, MGlxMediaList* aList ) |
|
262 |
{ |
|
263 |
TRACER("CGlxDetailsMulModelProviderImpl::HandleAttributesAvailableL"); |
|
264 |
if ( aList->FocusIndex() == aIndex ) |
|
265 |
{ |
|
266 |
for(TInt i = 0; i < iEntries.Count(); i++) |
|
267 |
{ |
|
268 |
if(iEntries[i]->HasRelevantAttributes(aAttributes) ) |
|
269 |
{ |
|
270 |
UpdateItems( i, 1 ); |
|
271 |
} |
|
272 |
} |
|
273 |
} |
|
274 |
} |
|
275 |
||
276 |
// ---------------------------------------------------------------------------- |
|
277 |
// ProvideData |
|
278 |
// ---------------------------------------------------------------------------- |
|
279 |
// |
|
280 |
void CGlxDetailsMulModelProviderImpl::ProvideData (int aIndex, int aCount, |
|
281 |
MulDataPath /*aPath*/) |
|
282 |
{ |
|
283 |
TRACER("CGlxDetailsMulModelProviderImpl::ProvideData"); |
|
284 |
for( int i = aIndex;i < aIndex + aCount ; i++) |
|
285 |
{ |
|
286 |
if( KErrNotFound != iMediaList.FocusIndex()) |
|
287 |
{ |
|
27
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
288 |
SetDataT( *iEntries[ i ], iMediaList.Item(iMediaList.FocusIndex()), i, iMediaList); |
26 | 289 |
} |
290 |
} |
|
291 |
} |
|
292 |
||
293 |
// ---------------------------------------------------------------------------- |
|
294 |
// HandleItemAddedL |
|
295 |
// ---------------------------------------------------------------------------- |
|
296 |
// |
|
297 |
void CGlxDetailsMulModelProviderImpl::HandleItemAddedL(TInt /*aStartIndex*/, TInt /*aEndIndex*/, |
|
298 |
MGlxMediaList* /*aList*/ ) |
|
299 |
{ |
|
300 |
TRACER("CGlxDetailsMulModelProviderImpl::HandleItemAddedL"); |
|
301 |
TInt count = iEntries.Count(); |
|
302 |
for(int i = 0; i < count; i++) |
|
303 |
{ |
|
304 |
UpdateItems( i , 1 ); |
|
305 |
} |
|
306 |
} |
|
307 |
// ---------------------------------------------------------------------------- |
|
308 |
// HandleError |
|
309 |
// ---------------------------------------------------------------------------- |
|
310 |
// |
|
311 |
void CGlxDetailsMulModelProviderImpl::HandleError( TInt aError ) |
|
312 |
{ |
|
313 |
TRACER("CGlxDetailsMulModelProviderImpl::HandleError"); |
|
314 |
TRAP_IGNORE( DoHandleErrorL( aError ) ); |
|
315 |
} |
|
316 |
||
317 |
// ---------------------------------------------------------------------------- |
|
318 |
// HandleError |
|
319 |
// ---------------------------------------------------------------------------- |
|
320 |
// |
|
321 |
void CGlxDetailsMulModelProviderImpl::DoHandleErrorL( TInt /*aError*/ ) |
|
322 |
{ |
|
323 |
TRACER("CGlxDetailsMulModelProviderImpl::DoHandleErrorL"); |
|
324 |
// Check for items for which fetching a thumbnail has failed, and replace |
|
325 |
// the default icon with broken icon |
|
326 |
TInt count = iMediaList.Count(); |
|
327 |
for ( TInt i = 0; i < count; i++ ) |
|
328 |
{ |
|
329 |
const TGlxMedia& item = iMediaList.Item( i ); |
|
330 |
TInt thumbnailError = GlxErrorManager::HasAttributeErrorL( |
|
331 |
item.Properties(), KGlxMediaIdThumbnail ); |
|
332 |
if( thumbnailError ) |
|
333 |
{ |
|
334 |
UpdateItems( i , 1 ); |
|
335 |
} |
|
336 |
} |
|
337 |
} |
|
338 |
// ---------------------------------------------------------------------------- |
|
339 |
// HideLocationMenuItem |
|
340 |
// ---------------------------------------------------------------------------- |
|
341 |
// |
|
342 |
void CGlxDetailsMulModelProviderImpl::HideLocationMenuItem( CEikMenuPane& aMenu ) |
|
343 |
{ |
|
344 |
if ( HasCommandL( aMenu, EGlxCmdAiwBase ) ) |
|
345 |
{ |
|
346 |
const MGlxBoundCommand* command = BoundCommand( FocusIndex() ); |
|
347 |
if ( command ) |
|
348 |
{ |
|
349 |
command->HideLocationMenuItem( aMenu ); |
|
350 |
} |
|
351 |
} |
|
352 |
} |
|
353 |
||
354 |
// ---------------------------------------------------------------------------- |
|
355 |
// EnableMskL |
|
356 |
// ---------------------------------------------------------------------------- |
|
357 |
// |
|
358 |
void CGlxDetailsMulModelProviderImpl::EnableMskL() |
|
359 |
{ |
|
360 |
TRACER("CGlxDetailsMulModelProviderImpl::EnableMskL"); |
|
361 |
MGlxBoundCommand* command = BoundCommand( FocusIndex() ); |
|
362 |
if ( command ) |
|
363 |
{ |
|
364 |
command->ChangeMskL(); |
|
365 |
} |
|
366 |
} |
|
367 |
||
368 |
// ---------------------------------------------------------------------------- |
|
369 |
// SetDetailsDailogObserver |
|
370 |
// ---------------------------------------------------------------------------- |
|
371 |
// |
|
372 |
void CGlxDetailsMulModelProviderImpl::SetDetailsDailogObserver( MGlxMetadataDialogObserver& aObserver ) |
|
373 |
{ |
|
374 |
TRACER("CGlxDetailsMulModelProviderImpl::SetDetailsDailogObserver"); |
|
375 |
/** Error Id EMPY-7MKDHP **/ |
|
376 |
MGlxBoundCommand* command = BoundCommand( FocusIndex() ); |
|
377 |
if ( command ) |
|
378 |
{ |
|
379 |
command->SetDetailsDailogObserver( aObserver ) ; |
|
380 |
} |
|
381 |
} |
|
382 |
||
383 |
||
384 |
// ---------------------------------------------------------------------------- |
|
385 |
// HandleCommandCompleteL |
|
386 |
// ---------------------------------------------------------------------------- |
|
387 |
// |
|
388 |
void CGlxDetailsMulModelProviderImpl::HandleCommandCompleteL(TAny* /*aSessionId*/, |
|
389 |
CMPXCommand* /*aCommandResult*/, TInt aError, MGlxMediaList* /*aList*/) |
|
390 |
{ |
|
391 |
TRACER("CGlxDetailsMulModelProviderImpl::HandleCommandCompleteL"); |
|
392 |
TGlxMedia media = iMediaList.Item(iMediaList.FocusIndex()) ; |
|
393 |
media.DeleteLocationAttribute(); |
|
394 |
if ( aError == KErrNone ) |
|
395 |
{ |
|
396 |
UpdateItems( FocusIndex(), 1 ); |
|
397 |
} |
|
398 |
} |