|
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: bindings required to populate the visual item |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include "glxbinding.h" // The binding is created by the binding set factory. |
|
22 #include "glxmuliconprovider.h" // Icon details |
|
23 #include <StringLoader.h> // Class provides methods to load and format resource strings |
|
24 #include <mul/mulvisualitem.h> // Client need to use this class to add data in data model |
|
25 #include <mul/imulwidget.h> |
|
26 #include <glxthumbnailattributeinfo.h> // Thumbnail attribute content ID |
|
27 #include <mpxcollectionpath.h> // Encapsulates a 'bookmark' to a specific collection entry |
|
28 #include <glxlog.h> // Logging |
|
29 #include <glxtracer.h> |
|
30 #include "glxcommandbindingutility.h" // collect binding handling here |
|
31 #include "glxmulthumbnailvarianttype.h" |
|
32 #include "mglxbindingobserver.h" // Notifies that binding has changed |
|
33 #include "glxustringconverter.h" // converts the symbian types to UString type |
|
34 #include "glxattributerequirement.h" // class will set the required attribute to the medialist |
|
35 #include "glxuiutility.h" |
|
36 #include "glxdetailsboundcommand.h" // Handles user commands |
|
37 |
|
38 using namespace Alf; |
|
39 |
|
40 // ---------------------------------------------------------------------------- |
|
41 // Sets the attribute to the visual item |
|
42 // ---------------------------------------------------------------------------- |
|
43 // |
|
44 static void SetAttributeT( Alf::MulVisualItem& aItem, const Alf::mulvisualitem::TVisualAttribute& aTag/*const UString& aTag*/, |
|
45 std::auto_ptr<MulVariantType> aValue ) |
|
46 { |
|
47 TRACER("SetAttributeT"); |
|
48 aItem.SetAttribute( aTag, aValue.get() ); |
|
49 aValue.release(); |
|
50 } |
|
51 |
|
52 // ---------------------------------------------------------------------------- |
|
53 // Destructor |
|
54 // ---------------------------------------------------------------------------- |
|
55 // |
|
56 CGlxBinding::~CGlxBinding() |
|
57 { |
|
58 |
|
59 } |
|
60 |
|
61 // ---------------------------------------------------------------------------- |
|
62 // Checks whether the attributes are relevant, returns EFalse always |
|
63 // ---------------------------------------------------------------------------- |
|
64 // |
|
65 TBool CGlxBinding::HasRelevantAttributes( |
|
66 const RArray< TMPXAttribute >& /*aAttributes*/ ) const |
|
67 { |
|
68 TRACER("CGlxBinding::HasRelevantAttributes"); |
|
69 return EFalse; |
|
70 } |
|
71 |
|
72 // ---------------------------------------------------------------------------- |
|
73 // Notification whether any updation is required for the focus changed |
|
74 // ---------------------------------------------------------------------------- |
|
75 // |
|
76 CGlxBinding::TResponse CGlxBinding::HandleFocusChanged( TBool /*aIsGained*/ ) |
|
77 { |
|
78 TRACER("CGlxBinding::HandleFocusChanged"); |
|
79 return ENoUpdateNeeded; |
|
80 } |
|
81 void CGlxBinding::HandleItemChangedL(const CMPXCollectionPath& /*aPath*/ ) |
|
82 { |
|
83 |
|
84 } |
|
85 |
|
86 // ---------------------------------------------------------------------------- |
|
87 // Set the binding observer |
|
88 // ---------------------------------------------------------------------------- |
|
89 // |
|
90 void CGlxBinding::SetObserver( MGlxBindingObserver& aObserver ) |
|
91 { |
|
92 TRACER("CGlxBinding::SetObserver"); |
|
93 iObserver = &aObserver; |
|
94 } |
|
95 |
|
96 // ---------------------------------------------------------------------------- |
|
97 // Initiates the update process when the binding changed |
|
98 // ---------------------------------------------------------------------------- |
|
99 // |
|
100 void CGlxBinding::Update() |
|
101 { |
|
102 TRACER("CGlxBinding::Update"); |
|
103 __ASSERT_DEBUG( iObserver, User::Invariant() ); |
|
104 iObserver->HandleBindingChanged( *this ); |
|
105 } |
|
106 |
|
107 // ---------------------------------------------------------------------------- |
|
108 // AddRequestL |
|
109 // ---------------------------------------------------------------------------- |
|
110 // |
|
111 void CGlxBinding::AddRequestL( CGlxAttributeRequirements& |
|
112 /*aAttributeRequirement*/, TSize /*aSize*/ ) |
|
113 { |
|
114 |
|
115 } |
|
116 |
|
117 // ---------------------------------------------------------------------------- |
|
118 // Template Binding |
|
119 //----------------------------------------------------------------------------- |
|
120 |
|
121 // ---------------------------------------------------------------------------- |
|
122 // Destructor |
|
123 // ---------------------------------------------------------------------------- |
|
124 // |
|
125 CGlxTemplateBinding::~CGlxTemplateBinding() |
|
126 { |
|
127 |
|
128 } |
|
129 |
|
130 // ---------------------------------------------------------------------------- |
|
131 // Two phase constructor |
|
132 // ---------------------------------------------------------------------------- |
|
133 // |
|
134 CGlxTemplateBinding* CGlxTemplateBinding::NewL( |
|
135 Alf::mulwidget::TLogicalTemplate aTemplate, |
|
136 Alf::mulwidget::TLogicalTemplate aTemplateWhenFocused) |
|
137 { |
|
138 TRACER("CGlxTemplateBinding::NewL"); |
|
139 CGlxTemplateBinding* self = CGlxTemplateBinding::NewLC( aTemplate, aTemplateWhenFocused ); |
|
140 CleanupStack::Pop( self ); |
|
141 return self; |
|
142 } |
|
143 |
|
144 |
|
145 // ---------------------------------------------------------------------------- |
|
146 // Two phase constructor |
|
147 // ---------------------------------------------------------------------------- |
|
148 // |
|
149 CGlxTemplateBinding* CGlxTemplateBinding::NewLC( |
|
150 Alf::mulwidget::TLogicalTemplate aTemplate, |
|
151 Alf::mulwidget::TLogicalTemplate aTemplateWhenFocused) |
|
152 { |
|
153 TRACER("CGlxTemplateBinding::NewLC"); |
|
154 CGlxTemplateBinding* self = new ( ELeave ) CGlxTemplateBinding(); |
|
155 CleanupStack::PushL( self ); |
|
156 self->iTemplate = aTemplate; |
|
157 self->iFocusedTemplate = aTemplateWhenFocused; |
|
158 return self; |
|
159 } |
|
160 |
|
161 // ---------------------------------------------------------------------------- |
|
162 // PopulateT |
|
163 // ---------------------------------------------------------------------------- |
|
164 // |
|
165 void CGlxTemplateBinding::PopulateT( Alf::MulVisualItem& aItem, |
|
166 const TGlxMedia& /*aMedia*/, TBool aIsFocused ) const |
|
167 { |
|
168 TRACER("CGlxTemplateBinding::PopulateT"); |
|
169 // need to get the MUL field for the editable template from Akash |
|
170 |
|
171 aItem.SetAttribute( Alf::mulvisualitem::KAttributeTemplate , |
|
172 ( aIsFocused && iFocusedTemplate ) ? iFocusedTemplate : iTemplate ); |
|
173 |
|
174 } |
|
175 |
|
176 // ---------------------------------------------------------------------------- |
|
177 // HandleFocusChanged |
|
178 // ---------------------------------------------------------------------------- |
|
179 // |
|
180 CGlxBinding::TResponse CGlxTemplateBinding::HandleFocusChanged( TBool /*aIsGained*/ ) |
|
181 { |
|
182 TRACER("CGlxTemplateBinding::HandleFocusChanged"); |
|
183 //Need further implementation |
|
184 return iFocusedTemplate ? EUpdateRequested: ENoUpdateNeeded; |
|
185 } |
|
186 |
|
187 void CGlxTemplateBinding::HandleItemChangedL(const CMPXCollectionPath& /*aPath*/ ) |
|
188 { |
|
189 |
|
190 } |
|
191 |
|
192 // ---------------------------------------------------------------------------- |
|
193 // Single Tag Binding |
|
194 //----------------------------------------------------------------------------- |
|
195 // ---------------------------------------------------------------------------- |
|
196 // Constructor |
|
197 // ---------------------------------------------------------------------------- |
|
198 // |
|
199 CGlxSingleTagBinding::CGlxSingleTagBinding() |
|
200 { |
|
201 |
|
202 } |
|
203 // ---------------------------------------------------------------------------- |
|
204 // Destructor |
|
205 // ---------------------------------------------------------------------------- |
|
206 // |
|
207 CGlxSingleTagBinding::~CGlxSingleTagBinding() |
|
208 { |
|
209 TRACER("CGlxSingleTagBinding::~CGlxSingleTagBinding"); |
|
210 //delete iMulTag; |
|
211 } |
|
212 |
|
213 // ---------------------------------------------------------------------------- |
|
214 // Two phase construction |
|
215 // ---------------------------------------------------------------------------- |
|
216 // |
|
217 void CGlxSingleTagBinding::BaseConstructL( const Alf::mulvisualitem::TVisualAttribute& aMulTag /*const char* const aMulTag*/ ) |
|
218 { |
|
219 TRACER("CGlxSingleTagBinding::BaseConstructL"); |
|
220 //iMulTag = new ( ELeave ) UString( aMulTag ); |
|
221 iMulTag = aMulTag ; |
|
222 } |
|
223 |
|
224 // ---------------------------------------------------------------------------- |
|
225 // Returns the MUL field |
|
226 // ---------------------------------------------------------------------------- |
|
227 // |
|
228 Alf::mulvisualitem::TVisualAttribute CGlxSingleTagBinding::MulTag() const |
|
229 { |
|
230 TRACER("CGlxSingleTagBinding::MulTag"); |
|
231 return iMulTag; |
|
232 } |
|
233 |
|
234 |
|
235 // ---------------------------------------------------------------------------- |
|
236 // String Binding |
|
237 //----------------------------------------------------------------------------- |
|
238 |
|
239 // ---------------------------------------------------------------------------- |
|
240 // Two phase construction |
|
241 // ---------------------------------------------------------------------------- |
|
242 // |
|
243 CGlxStringBinding* CGlxStringBinding::NewL( const Alf::mulvisualitem::TVisualAttribute& aMulTag /*const char* const aMulTag*/, |
|
244 TInt aStringId ) |
|
245 { |
|
246 TRACER("CGlxStringBinding::NewL"); |
|
247 CGlxStringBinding* self = CGlxStringBinding::NewLC( aMulTag, aStringId ); |
|
248 CleanupStack::Pop(self); |
|
249 return self; |
|
250 } |
|
251 |
|
252 // ---------------------------------------------------------------------------- |
|
253 // Two phase construction |
|
254 // ---------------------------------------------------------------------------- |
|
255 // |
|
256 CGlxStringBinding* CGlxStringBinding::NewLC( const Alf::mulvisualitem::TVisualAttribute& aMulTag /*const char* const aMulTag*/, |
|
257 TInt aStringId ) |
|
258 { |
|
259 TRACER("CGlxStringBinding::NewLC"); |
|
260 CGlxStringBinding* self = new ( ELeave ) CGlxStringBinding(); |
|
261 CleanupStack::PushL( self ); |
|
262 self->ConstructL( aMulTag, aStringId ); |
|
263 return self; |
|
264 } |
|
265 |
|
266 // ---------------------------------------------------------------------------- |
|
267 // Two phase construction |
|
268 // ---------------------------------------------------------------------------- |
|
269 // |
|
270 CGlxStringBinding* CGlxStringBinding::NewL( const Alf::mulvisualitem::TVisualAttribute& aMulTag /*const char* const aMulTag*/, |
|
271 const char* const aString ) |
|
272 { |
|
273 TRACER("CGlxStringBinding::NewL"); |
|
274 CGlxStringBinding* self = CGlxStringBinding::NewLC( aMulTag, aString ); |
|
275 CleanupStack::Pop( self ); |
|
276 return self; |
|
277 } |
|
278 // ---------------------------------------------------------------------------- |
|
279 // Two phase construction |
|
280 // ---------------------------------------------------------------------------- |
|
281 // |
|
282 CGlxStringBinding* CGlxStringBinding::NewLC( const Alf::mulvisualitem::TVisualAttribute& aMulTag /*const char* const aMulTag*/, |
|
283 const char* const aString ) |
|
284 { |
|
285 TRACER("CGlxStringBinding::NewLC"); |
|
286 CGlxStringBinding* self = new ( ELeave ) CGlxStringBinding(); |
|
287 CleanupStack::PushL( self ); |
|
288 self->ConstructL( aMulTag, aString ); |
|
289 return self; |
|
290 } |
|
291 |
|
292 // ---------------------------------------------------------------------------- |
|
293 // Constructor |
|
294 // ---------------------------------------------------------------------------- |
|
295 // |
|
296 CGlxStringBinding::CGlxStringBinding() |
|
297 { |
|
298 |
|
299 } |
|
300 |
|
301 // ---------------------------------------------------------------------------- |
|
302 // Destructor |
|
303 // ---------------------------------------------------------------------------- |
|
304 // |
|
305 CGlxStringBinding::~CGlxStringBinding() |
|
306 { |
|
307 TRACER("CGlxStringBinding::~CGlxStringBinding"); |
|
308 delete iStringBuffer; |
|
309 } |
|
310 |
|
311 // ---------------------------------------------------------------------------- |
|
312 // Two phase construction |
|
313 // ---------------------------------------------------------------------------- |
|
314 // |
|
315 void CGlxStringBinding::ConstructL( const Alf::mulvisualitem::TVisualAttribute& aMulTag /*const char* const aMulTag*/, |
|
316 TInt aStringId ) |
|
317 { |
|
318 TRACER("CGlxStringBinding::ConstructL"); |
|
319 BaseConstructL( aMulTag ); |
|
320 iStringBuffer = StringLoader::LoadL( aStringId ); |
|
321 } |
|
322 |
|
323 // ---------------------------------------------------------------------------- |
|
324 // Two phase construction |
|
325 // ---------------------------------------------------------------------------- |
|
326 // |
|
327 void CGlxStringBinding::ConstructL( const Alf::mulvisualitem::TVisualAttribute& aMulTag/*const char* const aMulTag*/, |
|
328 const char* const /*aString*/ ) |
|
329 { |
|
330 TRACER("CGlxStringBinding::ConstructL"); |
|
331 BaseConstructL( aMulTag ); |
|
332 //iString = new ( ELeave ) UString( aString ); |
|
333 } |
|
334 |
|
335 // ---------------------------------------------------------------------------- |
|
336 // populate visual item |
|
337 // ---------------------------------------------------------------------------- |
|
338 // |
|
339 void CGlxStringBinding::PopulateT( MulVisualItem& aItem, const TGlxMedia& /*aMedia*/, |
|
340 TBool /*aIsFocused*/ ) const |
|
341 { |
|
342 TRACER("CGlxStringBinding::PopulateT"); |
|
343 aItem.SetAttribute( MulTag(), *iStringBuffer ); |
|
344 } |
|
345 |
|
346 |
|
347 // ---------------------------------------------------------------------------- |
|
348 // MPX attribute Binding |
|
349 //----------------------------------------------------------------------------- |
|
350 |
|
351 // ---------------------------------------------------------------------------- |
|
352 // Two phase construction |
|
353 // ---------------------------------------------------------------------------- |
|
354 // |
|
355 CGlxMpxAttributeBinding* CGlxMpxAttributeBinding::NewL( const Alf::mulvisualitem::TVisualAttribute& aMulTag /*const char* const |
|
356 aMulTag*/, const TMPXAttribute& aAttribute, TInt aFormatStringId ) |
|
357 { |
|
358 TRACER("CGlxMpxAttributeBinding::NewL"); |
|
359 CGlxMpxAttributeBinding* self = CGlxMpxAttributeBinding::NewLC |
|
360 ( aMulTag, aAttribute, aFormatStringId ); |
|
361 CleanupStack::Pop( self ); |
|
362 return self; |
|
363 } |
|
364 |
|
365 // ---------------------------------------------------------------------------- |
|
366 // Two phase construction |
|
367 // ---------------------------------------------------------------------------- |
|
368 // |
|
369 CGlxMpxAttributeBinding* CGlxMpxAttributeBinding::NewLC( const Alf::mulvisualitem::TVisualAttribute& aMulTag /*const char* const aMulTag*/, |
|
370 const TMPXAttribute& aAttribute, TInt aFormatStringId ) |
|
371 { |
|
372 TRACER("CGlxMpxAttributeBinding::NewLC"); |
|
373 CGlxMpxAttributeBinding* self = new ( ELeave ) CGlxMpxAttributeBinding( |
|
374 aAttribute, aFormatStringId); |
|
375 CleanupStack::PushL( self ); |
|
376 self->ConstructL( aMulTag ); |
|
377 return self; |
|
378 } |
|
379 |
|
380 // ---------------------------------------------------------------------------- |
|
381 // Two phase construction |
|
382 // ---------------------------------------------------------------------------- |
|
383 // |
|
384 void CGlxMpxAttributeBinding::ConstructL(const Alf::mulvisualitem::TVisualAttribute& aMulTag /*const char* const aMulTag*/ ) |
|
385 { |
|
386 TRACER("CGlxMpxAttributeBinding::ConstructL"); |
|
387 BaseConstructL( aMulTag ); |
|
388 } |
|
389 |
|
390 // ---------------------------------------------------------------------------- |
|
391 // Constructor |
|
392 // ---------------------------------------------------------------------------- |
|
393 // |
|
394 CGlxMpxAttributeBinding::CGlxMpxAttributeBinding( const TMPXAttribute& |
|
395 aAttribute, TInt aFormatStringId ) : iAttribute( aAttribute ), |
|
396 iFormatStringId( aFormatStringId ) |
|
397 { |
|
398 } |
|
399 |
|
400 // ---------------------------------------------------------------------------- |
|
401 // populate visual item |
|
402 // ---------------------------------------------------------------------------- |
|
403 // |
|
404 void CGlxMpxAttributeBinding::PopulateT( MulVisualItem& aItem/**/, const |
|
405 TGlxMedia& aMedia, TBool /*aIsFocused*/ ) const |
|
406 { |
|
407 TRACER("CGlxMpxAttributeBinding::PopulateT"); |
|
408 //T is used for throws as per C++ standard.Hence used instead of "L" |
|
409 //Ignoring this for code scanner warnings - Leaving functions called in non-leaving functions. |
|
410 CGlxUStringConverter* stringConverter = CGlxUStringConverter::NewL(); |
|
411 CleanupStack::PushL(stringConverter ); |
|
412 HBufC* string = NULL; |
|
413 stringConverter->AsStringL( aMedia, iAttribute, iFormatStringId, string ); |
|
414 if ( string ) |
|
415 { |
|
416 aItem.SetAttribute( MulTag(), *string ); |
|
417 delete string; |
|
418 string = NULL; |
|
419 } |
|
420 CleanupStack::PopAndDestroy(stringConverter ); |
|
421 } |
|
422 |
|
423 // ---------------------------------------------------------------------------- |
|
424 // checks whether the attributes are relevant, returns EFalse always |
|
425 // ---------------------------------------------------------------------------- |
|
426 // |
|
427 TBool CGlxMpxAttributeBinding::HasRelevantAttributes( |
|
428 const RArray< TMPXAttribute >& aAttributes ) const |
|
429 { |
|
430 TRACER("CGlxMpxAttributeBinding::HasRelevantAttributes"); |
|
431 // only the member attribute is relevant; check if it is in the list |
|
432 TIdentityRelation< TMPXAttribute > match ( &TMPXAttribute::Match ); |
|
433 return ( KErrNotFound != aAttributes.Find( iAttribute, match ) ); |
|
434 } |
|
435 |
|
436 // ---------------------------------------------------------------------------- |
|
437 // checks whether the focus has changed, returns the response status |
|
438 // ---------------------------------------------------------------------------- |
|
439 // |
|
440 CGlxBinding::TResponse CGlxMpxAttributeBinding::HandleFocusChanged( |
|
441 TBool aIsGained ) |
|
442 { |
|
443 TRACER("CGlxMpxAttributeBinding::HandleFocusChanged"); |
|
444 //Need further implementation |
|
445 return aIsGained ? EUpdateRequested : ENoUpdateNeeded ; |
|
446 } |
|
447 |
|
448 void CGlxMpxAttributeBinding::HandleItemChangedL(const CMPXCollectionPath& /*aPath*/ ) |
|
449 { |
|
450 |
|
451 } |
|
452 // ---------------------------------------------------------------------------- |
|
453 // sends the attribute that is to be set to the medialist |
|
454 // ---------------------------------------------------------------------------- |
|
455 // |
|
456 void CGlxMpxAttributeBinding::AddRequestL( CGlxAttributeRequirements& |
|
457 aAttributeRequirement,TSize /*aSize*/ ) |
|
458 { |
|
459 TRACER("CGlxMpxAttributeBinding::AddRequestL"); |
|
460 aAttributeRequirement.AddAttributeL(iAttribute); |
|
461 } |
|
462 |
|
463 // ---------------------------------------------------------------------------- |
|
464 // Thumbnail Binding |
|
465 //----------------------------------------------------------------------------- |
|
466 |
|
467 // ---------------------------------------------------------------------------- |
|
468 // Two phase construction |
|
469 // ---------------------------------------------------------------------------- |
|
470 // |
|
471 CGlxThumbnailBinding* CGlxThumbnailBinding::NewL( const Alf::mulvisualitem::TVisualAttribute& aMulTag /*const char* const aMulTag*/, |
|
472 const TSize& aSize ) |
|
473 { |
|
474 TRACER("CGlxThumbnailBinding::NewL"); |
|
475 CGlxThumbnailBinding* self = CGlxThumbnailBinding::NewLC( aMulTag, aSize ); |
|
476 CleanupStack::Pop( self ); |
|
477 return self; |
|
478 } |
|
479 |
|
480 // ---------------------------------------------------------------------------- |
|
481 // Two phase construction |
|
482 // ---------------------------------------------------------------------------- |
|
483 // |
|
484 CGlxThumbnailBinding* CGlxThumbnailBinding::NewLC( const Alf::mulvisualitem::TVisualAttribute& aMulTag /*const char* const aMulTag*/, |
|
485 const TSize& aSize ) |
|
486 { |
|
487 TRACER("CGlxThumbnailBinding::NewLC"); |
|
488 CGlxThumbnailBinding* self = new ( ELeave ) CGlxThumbnailBinding( aSize ); |
|
489 CleanupStack::PushL( self ); |
|
490 self->BaseConstructL( aMulTag ); |
|
491 return self; |
|
492 } |
|
493 |
|
494 // ---------------------------------------------------------------------------- |
|
495 // Constructor |
|
496 // ---------------------------------------------------------------------------- |
|
497 // |
|
498 CGlxThumbnailBinding::CGlxThumbnailBinding( const TSize& aSize ) : |
|
499 iThumbnailSize( aSize ) |
|
500 { |
|
501 } |
|
502 |
|
503 // ---------------------------------------------------------------------------- |
|
504 // Destructor |
|
505 // ---------------------------------------------------------------------------- |
|
506 // |
|
507 CGlxThumbnailBinding::~CGlxThumbnailBinding() |
|
508 { |
|
509 } |
|
510 |
|
511 // ---------------------------------------------------------------------------- |
|
512 // populate visual item |
|
513 // ---------------------------------------------------------------------------- |
|
514 // |
|
515 void CGlxThumbnailBinding::PopulateT( MulVisualItem& aItem, const TGlxMedia& |
|
516 aMedia, TBool aIsFocused ) const |
|
517 { |
|
518 TRACER("CGlxThumbnailBinding::PopulateT"); |
|
519 //T is used for throws as per C++ standard.Hence used instead of "L" |
|
520 //Ignoring this for code scanner warnings - Leaving functions called in non-leaving functions. |
|
521 SetAttributeT( aItem, MulTag(), |
|
522 std::auto_ptr< GlxThumbnailVariantType >( |
|
523 GlxThumbnailVariantType::NewL( aMedia, iThumbnailSize, |
|
524 aIsFocused ) ) ); |
|
525 //@todo |
|
526 } |
|
527 |
|
528 // ---------------------------------------------------------------------------- |
|
529 // checks whether the attributes are relevant, returns EFalse always |
|
530 // ---------------------------------------------------------------------------- |
|
531 // |
|
532 TBool CGlxThumbnailBinding::HasRelevantAttributes( |
|
533 const RArray< TMPXAttribute >& aAttributes ) const |
|
534 { |
|
535 |
|
536 TRACER("CGlxThumbnailBinding::HasRelevantAttributes"); |
|
537 TMPXAttribute tnAttribQuality(KGlxMediaIdThumbnail, |
|
538 GlxFullThumbnailAttributeId( ETrue, iThumbnailSize.iWidth, |
|
539 iThumbnailSize.iHeight ) ); |
|
540 |
|
541 TIdentityRelation< TMPXAttribute > match ( &TMPXAttribute::Match ); |
|
542 if (KErrNotFound != aAttributes.Find( tnAttribQuality, match ) ) |
|
543 { |
|
544 GLX_DEBUG1("CGlxThumbnailBinding::HasRelevantAttributes (tnAttribQuality) - ETrue"); |
|
545 return ETrue; |
|
546 } |
|
547 else |
|
548 { |
|
549 TMPXAttribute tnAttribSpeed(KGlxMediaIdThumbnail, |
|
550 GlxFullThumbnailAttributeId( EFalse, iThumbnailSize.iWidth, |
|
551 iThumbnailSize.iHeight ) ); |
|
552 |
|
553 if ( KErrNotFound != aAttributes.Find( tnAttribSpeed, match ) ) |
|
554 { |
|
555 GLX_DEBUG1("CGlxThumbnailBinding::HasRelevantAttributes (tnAttribSpeed) - ETrue"); |
|
556 return ETrue; |
|
557 } |
|
558 } |
|
559 GLX_DEBUG1("CGlxThumbnailBinding::HasRelevantAttributes - EFalse"); |
|
560 return EFalse; |
|
561 } |
|
562 |
|
563 // ---------------------------------------------------------------------------- |
|
564 // invokes the necessary api that sets the thumbnail attribute to the medialist |
|
565 // ---------------------------------------------------------------------------- |
|
566 // |
|
567 void CGlxThumbnailBinding::AddRequestL( CGlxAttributeRequirements& |
|
568 aAttributeRequirement,TSize /*aSize*/ ) |
|
569 { |
|
570 TRACER("CGlxThumbnailBinding::AddRequestL"); |
|
571 aAttributeRequirement.AddThumbnailL( iThumbnailSize ); |
|
572 } |
|
573 |
|
574 |
|
575 // ---------------------------------------------------------------------------- |
|
576 // sends response whether update required or not depending on the focus gained |
|
577 // ---------------------------------------------------------------------------- |
|
578 // |
|
579 CGlxBinding::TResponse CGlxThumbnailBinding::HandleFocusChanged( TBool aIsGained ) |
|
580 { |
|
581 TRACER("CGlxThumbnailBinding::HandleFocusChanged"); |
|
582 if(aIsGained) |
|
583 { |
|
584 |
|
585 return EUpdateRequested; |
|
586 } |
|
587 |
|
588 return ENoUpdateNeeded; |
|
589 } |
|
590 // ---------------------------------------------------------------------------- |
|
591 // FullScreenThumbnail Binding |
|
592 //----------------------------------------------------------------------------- |
|
593 |
|
594 // ---------------------------------------------------------------------------- |
|
595 // Two phase construction |
|
596 // ---------------------------------------------------------------------------- |
|
597 // |
|
598 CGlxFullScreenThumbnailBinding* CGlxFullScreenThumbnailBinding::NewL( const Alf::mulvisualitem::TVisualAttribute& aMulTag /*const char* const aMulTag*/ ) |
|
599 { |
|
600 TRACER("CGlxFullScreenThumbnailBinding::NewL"); |
|
601 CGlxFullScreenThumbnailBinding* self = CGlxFullScreenThumbnailBinding::NewLC( aMulTag ); |
|
602 CleanupStack::Pop( self ); |
|
603 return self; |
|
604 } |
|
605 |
|
606 // ---------------------------------------------------------------------------- |
|
607 // Two phase construction |
|
608 // ---------------------------------------------------------------------------- |
|
609 // |
|
610 CGlxFullScreenThumbnailBinding* CGlxFullScreenThumbnailBinding::NewLC( const Alf::mulvisualitem::TVisualAttribute& aMulTag/*const char* const aMulTag*/ |
|
611 ) |
|
612 { |
|
613 TRACER("CGlxFullScreenThumbnailBinding::NewLC"); |
|
614 CGlxFullScreenThumbnailBinding* self = new ( ELeave ) CGlxFullScreenThumbnailBinding(); |
|
615 CleanupStack::PushL( self ); |
|
616 self->BaseConstructL( aMulTag ); |
|
617 return self; |
|
618 } |
|
619 |
|
620 // ---------------------------------------------------------------------------- |
|
621 // Constructor |
|
622 // ---------------------------------------------------------------------------- |
|
623 // |
|
624 CGlxFullScreenThumbnailBinding::CGlxFullScreenThumbnailBinding( ) |
|
625 { |
|
626 } |
|
627 |
|
628 // ---------------------------------------------------------------------------- |
|
629 // Destructor |
|
630 // ---------------------------------------------------------------------------- |
|
631 // |
|
632 CGlxFullScreenThumbnailBinding::~CGlxFullScreenThumbnailBinding() |
|
633 { |
|
634 } |
|
635 |
|
636 // ---------------------------------------------------------------------------- |
|
637 // populate visual item |
|
638 // ---------------------------------------------------------------------------- |
|
639 // |
|
640 void CGlxFullScreenThumbnailBinding::PopulateT( MulVisualItem& aItem, const TGlxMedia& |
|
641 aMedia, TBool aIsFocused ) const |
|
642 { |
|
643 TRACER("CGlxFullScreenThumbnailBinding::PopulateT"); |
|
644 //T is used for throws as per C++ standard.Hence used instead of "L" |
|
645 //Ignoring this for code scanner warnings - Leaving functions called in non-leaving functions. |
|
646 SetAttributeT( aItem, MulTag(), |
|
647 std::auto_ptr< GlxThumbnailVariantType >( |
|
648 GlxThumbnailVariantType::NewL( aMedia, iFullScreenThumbnailSize, |
|
649 aIsFocused ) ) ); |
|
650 |
|
651 } |
|
652 |
|
653 // ---------------------------------------------------------------------------- |
|
654 // checks whether the attributes are relevant, returns EFalse always |
|
655 // ---------------------------------------------------------------------------- |
|
656 // |
|
657 TBool CGlxFullScreenThumbnailBinding::HasRelevantAttributes( |
|
658 const RArray< TMPXAttribute >& aAttributes ) const |
|
659 { |
|
660 |
|
661 TRACER("CGlxFullScreenThumbnailBinding::HasRelevantAttributes"); |
|
662 TMPXAttribute tnAttribQuality(KGlxMediaIdThumbnail, |
|
663 GlxFullThumbnailAttributeId( ETrue, iFullScreenThumbnailSize.iWidth, |
|
664 iFullScreenThumbnailSize.iHeight ) ); |
|
665 |
|
666 TIdentityRelation< TMPXAttribute > match ( &TMPXAttribute::Match ); |
|
667 if ( KErrNotFound != aAttributes.Find( tnAttribQuality, match ) ) |
|
668 { |
|
669 GLX_DEBUG1("CGlxFullScreenThumbnailBinding::HasRelevantAttributes (tnAttribQuality) - ETrue"); |
|
670 return ETrue; |
|
671 } |
|
672 else |
|
673 { |
|
674 TMPXAttribute tnAttribSpeed(KGlxMediaIdThumbnail, |
|
675 GlxFullThumbnailAttributeId( EFalse, iFullScreenThumbnailSize.iWidth, |
|
676 iFullScreenThumbnailSize.iHeight ) ); |
|
677 if ( KErrNotFound != aAttributes.Find( tnAttribSpeed, match ) ) |
|
678 { |
|
679 GLX_DEBUG1("CGlxFullScreenThumbnailBinding::HasRelevantAttributes (tnAttribSpeed) - ETrue"); |
|
680 return ETrue; |
|
681 } |
|
682 } |
|
683 |
|
684 GLX_DEBUG1("CGlxFullScreenThumbnailBinding::HasRelevantAttributes - EFalse"); |
|
685 return EFalse; |
|
686 } |
|
687 |
|
688 // ---------------------------------------------------------------------------- |
|
689 // invokes the necessary api that sets the thumbnail attribute to the medialist |
|
690 // ---------------------------------------------------------------------------- |
|
691 // |
|
692 void CGlxFullScreenThumbnailBinding::AddRequestL( CGlxAttributeRequirements& aAttributeRequirement,TSize aSize) |
|
693 { |
|
694 TRACER("CGlxFullScreenThumbnailBinding::AddRequestL"); |
|
695 iFullScreenThumbnailSize = aSize; |
|
696 aAttributeRequirement.AddThumbnailL( iFullScreenThumbnailSize ); |
|
697 CGlxUiUtility* uiUtility = CGlxUiUtility::UtilityL(); |
|
698 CleanupStack::PushL( uiUtility ); |
|
699 aAttributeRequirement.AddThumbnailL( uiUtility->GetGridIconSize() ); |
|
700 uiUtility->Close(); |
|
701 CleanupStack::Pop( uiUtility ); |
|
702 } |
|
703 |
|
704 |
|
705 // ---------------------------------------------------------------------------- |
|
706 // sends response whether update required or not depending on the focus gained |
|
707 // ---------------------------------------------------------------------------- |
|
708 // |
|
709 CGlxBinding::TResponse CGlxFullScreenThumbnailBinding::HandleFocusChanged( TBool aIsGained ) |
|
710 { |
|
711 TRACER("CGlxFullScreenThumbnailBinding::HandleFocusChanged"); |
|
712 if(aIsGained) |
|
713 { |
|
714 |
|
715 return EUpdateRequested; |
|
716 } |
|
717 |
|
718 return ENoUpdateNeeded; |
|
719 } |
|
720 |
|
721 // ---------------------------------------------------------------------------- |
|
722 // Icon Binding |
|
723 //----------------------------------------------------------------------------- |
|
724 |
|
725 // ---------------------------------------------------------------------------- |
|
726 // Two phase construction |
|
727 // ---------------------------------------------------------------------------- |
|
728 // |
|
729 CGlxIconBinding* CGlxIconBinding::NewL( const Alf::mulvisualitem::TVisualAttribute& aMulTag /*const char* const aMulTag*/, |
|
730 const CGlxMulIconProvider* aMulIcon, const TSize& aSize) |
|
731 { |
|
732 TRACER("CGlxIconBinding::NewL"); |
|
733 CGlxIconBinding* self = CGlxIconBinding::NewLC( aMulTag, aMulIcon, aSize ); |
|
734 CleanupStack::Pop( self ); |
|
735 return self; |
|
736 } |
|
737 |
|
738 // ---------------------------------------------------------------------------- |
|
739 // Two phase construction |
|
740 // ---------------------------------------------------------------------------- |
|
741 // |
|
742 CGlxIconBinding* CGlxIconBinding::NewLC( const Alf::mulvisualitem::TVisualAttribute& aMulTag /*const char* const aMulTag*/, |
|
743 const CGlxMulIconProvider* aMulIcon, const TSize& aSize) |
|
744 { |
|
745 TRACER("CGlxIconBinding::NewLC"); |
|
746 CGlxIconBinding* self = new ( ELeave ) CGlxIconBinding( aMulIcon, aSize ); |
|
747 CleanupStack::PushL( self ); |
|
748 self->BaseConstructL( aMulTag ); |
|
749 return self; |
|
750 } |
|
751 |
|
752 // ---------------------------------------------------------------------------- |
|
753 // Destructor |
|
754 // ---------------------------------------------------------------------------- |
|
755 // |
|
756 CGlxIconBinding::~CGlxIconBinding() |
|
757 { |
|
758 delete iIconProvider; |
|
759 } |
|
760 |
|
761 // ---------------------------------------------------------------------------- |
|
762 // Constructor |
|
763 // ---------------------------------------------------------------------------- |
|
764 // |
|
765 CGlxIconBinding::CGlxIconBinding( const CGlxMulIconProvider* aIconProvider, |
|
766 const TSize& aSize ) : iIconProvider( aIconProvider ), iIconSize(aSize) |
|
767 { |
|
768 |
|
769 } |
|
770 |
|
771 // ---------------------------------------------------------------------------- |
|
772 // populate visual item |
|
773 // ---------------------------------------------------------------------------- |
|
774 // |
|
775 void CGlxIconBinding::PopulateT( MulVisualItem& aItem, |
|
776 const TGlxMedia& aMedia, TBool /*aIsFocused*/ ) const |
|
777 { |
|
778 |
|
779 TRACER("CGlxIconBinding::PopulateT"); |
|
780 if(iIconProvider) |
|
781 { |
|
782 SetAttributeT( aItem, MulTag(), |
|
783 std::auto_ptr< GlxIconVariantType >( |
|
784 GlxIconVariantType::NewL( iIconProvider->IconIdL(aMedia), |
|
785 iIconProvider->ResourceFileName(), iIconSize ) ) ); |
|
786 } |
|
787 |
|
788 } |
|
789 |
|
790 // ---------------------------------------------------------------------------- |
|
791 // Command Binding |
|
792 //----------------------------------------------------------------------------- |
|
793 |
|
794 // ---------------------------------------------------------------------------- |
|
795 // Two phase construction |
|
796 // ---------------------------------------------------------------------------- |
|
797 // |
|
798 CGlxCommandBinding* CGlxCommandBinding::NewL( MGlxBoundCommand* aCommand ) |
|
799 { |
|
800 TRACER("CGlxCommandBinding::NewL"); |
|
801 CGlxCommandBinding* self = CGlxCommandBinding::NewLC( aCommand ); |
|
802 CleanupStack::Pop( self ); |
|
803 return self; |
|
804 } |
|
805 |
|
806 // ---------------------------------------------------------------------------- |
|
807 // Two phase construction |
|
808 // ---------------------------------------------------------------------------- |
|
809 // |
|
810 CGlxCommandBinding* CGlxCommandBinding::NewLC( MGlxBoundCommand* aCommand ) |
|
811 { |
|
812 TRACER("CGlxCommandBinding::NewLC"); |
|
813 __ASSERT_DEBUG( aCommand ,User::Invariant()); |
|
814 CGlxCommandBinding* self = new ( ELeave ) CGlxCommandBinding(); |
|
815 self->iCommand = aCommand; |
|
816 // cannot pass aCommand since abstract MGlxCommand pointer is a few bytes off |
|
817 // from the concrete derived class pointer |
|
818 CleanupStack::PushL( self ); |
|
819 return self; |
|
820 } |
|
821 |
|
822 // ---------------------------------------------------------------------------- |
|
823 // Constructor |
|
824 // ---------------------------------------------------------------------------- |
|
825 // |
|
826 CGlxCommandBinding::CGlxCommandBinding() |
|
827 { |
|
828 } |
|
829 |
|
830 // ---------------------------------------------------------------------------- |
|
831 // Destructor |
|
832 // ---------------------------------------------------------------------------- |
|
833 // |
|
834 CGlxCommandBinding::~CGlxCommandBinding() |
|
835 { |
|
836 if(iCommand) |
|
837 { |
|
838 iCommand->Close(); |
|
839 } |
|
840 } |
|
841 |
|
842 // ---------------------------------------------------------------------------- |
|
843 // populate visual item |
|
844 // ---------------------------------------------------------------------------- |
|
845 // |
|
846 void CGlxCommandBinding::PopulateT( Alf::MulVisualItem& aItem, const TGlxMedia& /*aMedia*/, |
|
847 TBool /*aIsFocused*/ ) const |
|
848 { |
|
849 TRACER("CGlxCommandBinding::PopulateT"); |
|
850 GlxCommandBindingUtility::SetT( aItem, *iCommand ); |
|
851 } |
|
852 |