|
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 #ifndef _GLXBINDING_H_ |
|
22 #define _GLXBINDING_H_ |
|
23 |
|
24 #include "glxattributerequirement.h" // class will set the required attribute to the medialist |
|
25 #include <glxattributecontext.h> // Fetch context to retrieve thumbnails |
|
26 #include <glxthumbnailcontext.h> // Fetch context to retrieve thumbnails |
|
27 #include <glxmedialistiterator.h> // Interface for going through items in the list |
|
28 #include <mpxattribute.h> // lib mpxcommon.lib |
|
29 #include <mglxmedialistobserver.h> // Observes for changes in media list |
|
30 #include <mglxfetchcontext.h> // which attributes should be fetched |
|
31 #include "glxuiutility.h" // lib glxalfutils.lib |
|
32 #include <mul/mulvisualitem.h> // Client need to use this class to add data in data model |
|
33 #include <mul/imulwidget.h> |
|
34 // Forward Declaration |
|
35 class CMPXCollectionPath; // Encapsulates a 'bookmark' to a specific collection entry |
|
36 class CGlxMulIconProvider; // Icon details |
|
37 class MGlxMediaList; // lib glxmedialists.lib |
|
38 class MGlxBindingObserver; // Notifies that binding has changed |
|
39 class MGlxBoundCommand; // Handles user commands |
|
40 class TGlxMedia; // media item in the item pool |
|
41 |
|
42 namespace Alf |
|
43 { |
|
44 class IAlfVariantType; // lib alfwidgetmodel.lib |
|
45 class MulVisualItem; // Client need to use this class to add data in data model |
|
46 } |
|
47 |
|
48 namespace osncore |
|
49 { |
|
50 class UString; // encapsulates utf-8 encoded string |
|
51 } |
|
52 |
|
53 /** |
|
54 * CGlxBinding |
|
55 * The binding is created by the binding set factory. |
|
56 * This class holds the bindings required to populate the visual item. |
|
57 */ |
|
58 NONSHARABLE_CLASS( CGlxBinding ) : public CBase |
|
59 { |
|
60 public: |
|
61 /** |
|
62 * Virtual Destructor |
|
63 */ |
|
64 virtual ~CGlxBinding(); |
|
65 |
|
66 /** |
|
67 * PopulateT populates the visual item with the data from the media item |
|
68 * @param aItem Visual item to be populated |
|
69 * @param aMedia Media item |
|
70 * @param aIsFocused the item is focused or not |
|
71 */ |
|
72 /// T for "throws" (instead of L for "leaves") |
|
73 virtual void PopulateT( Alf::MulVisualItem& aItem, const TGlxMedia& aMedia, |
|
74 TBool aIsFocused ) const = 0; |
|
75 |
|
76 /** |
|
77 * HasRelevantAttributes Checks whether the attribute is relevent to the context |
|
78 * @param aAttrbutes MPX attributes |
|
79 */ |
|
80 virtual TBool HasRelevantAttributes( const RArray< TMPXAttribute >& aAttributes ) const; |
|
81 |
|
82 enum TResponse |
|
83 { |
|
84 ENoUpdateNeeded , |
|
85 EUpdateRequested |
|
86 }; |
|
87 |
|
88 /** |
|
89 * HandleFocusChanged handles the focus change events |
|
90 * @param aIsGained |
|
91 * @param aPath |
|
92 */ |
|
93 virtual TResponse HandleFocusChanged( TBool aIsGained ); |
|
94 |
|
95 |
|
96 virtual void HandleItemChangedL(const CMPXCollectionPath& aPath ); |
|
97 |
|
98 |
|
99 |
|
100 /** |
|
101 * SetObserver setting the binding observer |
|
102 * @param aObserver Binding observer |
|
103 */ |
|
104 // only to be called by CGlxBindingSet |
|
105 void SetObserver( MGlxBindingObserver& aObserver ); |
|
106 |
|
107 /** |
|
108 * adding fetch context to medialist |
|
109 * @param aAttributeRequirement |
|
110 */ |
|
111 virtual void AddRequestL( CGlxAttributeRequirements& |
|
112 aAttributeRequirement,TSize aSize); |
|
113 |
|
114 protected: |
|
115 /** |
|
116 * Update informs the observer that binding has changed |
|
117 */ |
|
118 void Update(); |
|
119 |
|
120 private: |
|
121 /// From Binding observer |
|
122 MGlxBindingObserver* iObserver; |
|
123 }; |
|
124 |
|
125 /** |
|
126 * CGlxTemplateBinding |
|
127 * The binding is created by the binding set factory. |
|
128 * This class holds the template information when there is editable |
|
129 * template and changing the template when the focus moves away |
|
130 */ |
|
131 NONSHARABLE_CLASS( CGlxTemplateBinding ): public CGlxBinding |
|
132 { |
|
133 |
|
134 public: |
|
135 |
|
136 /** |
|
137 * Two phase constructor |
|
138 * @param aTemplate |
|
139 * @param aFocusedTemplate |
|
140 */ |
|
141 static CGlxTemplateBinding* NewL( |
|
142 Alf::mulwidget::TLogicalTemplate aTemplate, |
|
143 Alf::mulwidget::TLogicalTemplate aTemplateWhenFocused); |
|
144 |
|
145 /** |
|
146 * Two phase constructor |
|
147 * @param aTemplate |
|
148 * @param aFocusedTemplate |
|
149 */ |
|
150 static CGlxTemplateBinding* NewLC( |
|
151 Alf::mulwidget::TLogicalTemplate aTemplate, |
|
152 Alf::mulwidget::TLogicalTemplate aTemplateWhenFocused); |
|
153 |
|
154 /** |
|
155 * Destructor |
|
156 */ |
|
157 ~CGlxTemplateBinding(); |
|
158 |
|
159 private: |
|
160 |
|
161 // From CGlxBinding |
|
162 void PopulateT( Alf::MulVisualItem& aItem, const TGlxMedia& aMedia, |
|
163 TBool aIsFocused ) const; |
|
164 |
|
165 /** |
|
166 * @todo |
|
167 */ |
|
168 TResponse HandleFocusChanged( TBool aIsGained ); |
|
169 |
|
170 void HandleItemChangedL(const CMPXCollectionPath& aPath ); |
|
171 |
|
172 private: |
|
173 Alf::mulwidget::TLogicalTemplate iTemplate; |
|
174 Alf::mulwidget::TLogicalTemplate iFocusedTemplate; |
|
175 }; |
|
176 |
|
177 // ---------------------------------------------------------------------------- |
|
178 |
|
179 /** |
|
180 * CGlxSingleTagBinding |
|
181 * Base class for bindings that provide the value for a single mul tag |
|
182 */ |
|
183 NONSHARABLE_CLASS( CGlxSingleTagBinding ) : public CGlxBinding |
|
184 { |
|
185 public: |
|
186 /** |
|
187 * Constructor |
|
188 */ |
|
189 CGlxSingleTagBinding(); |
|
190 |
|
191 /** |
|
192 * Destructor |
|
193 */ |
|
194 ~CGlxSingleTagBinding(); |
|
195 |
|
196 protected: |
|
197 /** |
|
198 * Constructs single tag binding |
|
199 * @param aMulTag The mul field that MPX attribute is mapped to |
|
200 */ |
|
201 void BaseConstructL( const Alf::mulvisualitem::TVisualAttribute& aMulTag /*const char* const aMulTag*/ ); |
|
202 |
|
203 /** |
|
204 * Returns the MUL field |
|
205 */ |
|
206 //const osncore::UString& MulTag() const; |
|
207 Alf::mulvisualitem::TVisualAttribute MulTag() const; |
|
208 |
|
209 private: |
|
210 /// Stores the MUL field |
|
211 //osncore::UString* iMulTag; |
|
212 Alf::mulvisualitem::TVisualAttribute iMulTag; |
|
213 }; |
|
214 |
|
215 // ---------------------------------------------------------------------------- |
|
216 |
|
217 /** |
|
218 * CGlxStringBinding |
|
219 * This class holds all string bindings required to populate the visual item |
|
220 */ |
|
221 NONSHARABLE_CLASS( CGlxStringBinding ) : public CGlxSingleTagBinding |
|
222 { |
|
223 public: |
|
224 |
|
225 /** |
|
226 * Two phase Construction |
|
227 * @param aMulTag The mul field that MPX attribute is mapped to |
|
228 * @param aStringId The MPX attribute |
|
229 */ |
|
230 static CGlxStringBinding* NewL( const Alf::mulvisualitem::TVisualAttribute& aMulTag/*const char* const aMulTag*/, |
|
231 TInt aStringId ); |
|
232 /** |
|
233 * Two phase Construction |
|
234 * @param aMulTag The mul field that MPX attribute is mapped to |
|
235 * @param aStringId |
|
236 */ |
|
237 static CGlxStringBinding* NewLC( const Alf::mulvisualitem::TVisualAttribute& aMulTag /*const char* const aMulTag*/, |
|
238 TInt aStringId ); |
|
239 |
|
240 /** |
|
241 * Two phase Construction |
|
242 * @param aMulTag The mul field that MPX attribute is mapped to |
|
243 * @param aString |
|
244 */ |
|
245 static CGlxStringBinding* NewL( const Alf::mulvisualitem::TVisualAttribute& aMulTag/*const char* const aMulTag*/, |
|
246 const char* const aString ); |
|
247 |
|
248 /** |
|
249 * Two phase Construction |
|
250 * @param aMulTag The mul field that MPX attribute is mapped to |
|
251 * @param aString |
|
252 */ |
|
253 static CGlxStringBinding* NewLC( const Alf::mulvisualitem::TVisualAttribute& aMulTag/*const char* const aMulTag*/, |
|
254 const char* const aString ); |
|
255 |
|
256 /** |
|
257 * Destructor |
|
258 */ |
|
259 ~CGlxStringBinding(); |
|
260 |
|
261 /** |
|
262 * Destructor |
|
263 */ |
|
264 CGlxStringBinding(); |
|
265 |
|
266 protected: |
|
267 |
|
268 /** |
|
269 * Two phase Construction |
|
270 * Converts the symbian types to Ustring |
|
271 */ |
|
272 void ConstructL( const Alf::mulvisualitem::TVisualAttribute& aMulTag/*const char* const aMulTag*/, TInt aStringId ); |
|
273 |
|
274 /** |
|
275 * Two phase Construction |
|
276 */ |
|
277 void ConstructL( const Alf::mulvisualitem::TVisualAttribute& aMulTag/*const char* const aMulTag*/, const char* const aString ); |
|
278 |
|
279 private: |
|
280 /// From CGlxBinding |
|
281 void PopulateT( Alf::MulVisualItem& aItem, const TGlxMedia& aMedia, |
|
282 TBool aIsFocused ) const; |
|
283 |
|
284 private: |
|
285 /// Holds MPX data |
|
286 HBufC* iStringBuffer; |
|
287 }; |
|
288 |
|
289 // ---------------------------------------------------------------------------- |
|
290 |
|
291 NONSHARABLE_CLASS( CGlxMpxAttributeBinding ) : public CGlxSingleTagBinding |
|
292 { |
|
293 public: |
|
294 |
|
295 /** |
|
296 * Two phase Construction |
|
297 * @param aMulTag The mul field that MPX attribute is mapped to |
|
298 * @param aAttribute MPX attribute name |
|
299 */ |
|
300 static CGlxMpxAttributeBinding* NewL( const Alf::mulvisualitem::TVisualAttribute& aMulTag/*const char* const aMulTag*/, |
|
301 const TMPXAttribute& aAttribute, TInt aFormatStringId ); |
|
302 |
|
303 /** |
|
304 * Two phase Construction |
|
305 * @param aMulTag The mul field that MPX attribute is mapped to |
|
306 * @param aAttribute MPX attribute name |
|
307 */ |
|
308 static CGlxMpxAttributeBinding* NewLC( const Alf::mulvisualitem::TVisualAttribute& aMulTag/*const char* const aMulTag*/, |
|
309 const TMPXAttribute& aAttribute, TInt aFormatStringId ); |
|
310 |
|
311 // From CGlxBinding |
|
312 void AddRequestL( CGlxAttributeRequirements& aAttributeRequirement ,TSize aSize); |
|
313 |
|
314 protected: |
|
315 |
|
316 /** |
|
317 * Two phase Construction |
|
318 */ |
|
319 void ConstructL( const Alf::mulvisualitem::TVisualAttribute& aMulTag/*const char* const aMulTag*/ ); |
|
320 |
|
321 private: |
|
322 |
|
323 /** |
|
324 * Constructor |
|
325 * @param aAttribute MPX attribute name |
|
326 */ |
|
327 CGlxMpxAttributeBinding( const TMPXAttribute& aAttribute, TInt aFormatStringId ); |
|
328 // From CGlxBinding |
|
329 void PopulateT( Alf::MulVisualItem& aItem, const TGlxMedia& aMedia, |
|
330 TBool aIsFocused ) const; |
|
331 |
|
332 /** |
|
333 * HasRelevantAttributes |
|
334 * @param aAttribute MPX attribute name |
|
335 */ |
|
336 TBool HasRelevantAttributes( const RArray< TMPXAttribute >& aAttributes ) const; |
|
337 |
|
338 /** |
|
339 * HandleFocusChanged |
|
340 * @param aIsGained holds the focus change status |
|
341 * @param aPath source path to the collection |
|
342 */ |
|
343 TResponse HandleFocusChanged( TBool aIsGained ); |
|
344 |
|
345 void HandleItemChangedL(const CMPXCollectionPath& aPath ); |
|
346 |
|
347 private: |
|
348 /// stores the MPX attribute |
|
349 const TMPXAttribute iAttribute; |
|
350 TInt iFormatStringId; |
|
351 |
|
352 }; |
|
353 |
|
354 // ---------------------------------------------------------------------------- |
|
355 |
|
356 NONSHARABLE_CLASS( CGlxThumbnailBinding ) : public CGlxSingleTagBinding |
|
357 { |
|
358 public: |
|
359 |
|
360 /** |
|
361 * Two phase construction |
|
362 * @param aMulTag The mul field that MPX attribute is mapped to |
|
363 */ |
|
364 static CGlxThumbnailBinding* NewL( const Alf::mulvisualitem::TVisualAttribute& aMulTag /*const char* const aMulTag*/, |
|
365 const TSize& aSize ); |
|
366 |
|
367 /** |
|
368 * Two phase construction |
|
369 * @param aMulTag The mul field that MPX attribute is mapped to |
|
370 */ |
|
371 static CGlxThumbnailBinding* NewLC(const Alf::mulvisualitem::TVisualAttribute& aMulTag /*const char* const aMulTag*/, |
|
372 const TSize& aSize ); |
|
373 |
|
374 /** |
|
375 * Destructor |
|
376 */ |
|
377 ~CGlxThumbnailBinding(); |
|
378 |
|
379 /** |
|
380 * Constructor |
|
381 */ |
|
382 CGlxThumbnailBinding( const TSize& aSize ); |
|
383 |
|
384 // From CGlxBinding |
|
385 void AddRequestL(CGlxAttributeRequirements& aAttributeRequirement,TSize aSize); |
|
386 |
|
387 TResponse HandleFocusChanged( TBool aIsGained ); |
|
388 |
|
389 private: // From CGlxBinding |
|
390 void PopulateT( Alf::MulVisualItem& aItem, const TGlxMedia& aMedia, |
|
391 TBool aIsFocused ) const; |
|
392 |
|
393 /** |
|
394 * HasRelevantAttributes |
|
395 * @param aAttribute MPX attribute name |
|
396 */ |
|
397 TBool HasRelevantAttributes( const RArray< TMPXAttribute >& aAttributes ) const; |
|
398 |
|
399 private: |
|
400 TSize iThumbnailSize; |
|
401 }; |
|
402 |
|
403 // ---------------------------------------------------------------------------- |
|
404 |
|
405 NONSHARABLE_CLASS( CGlxFullScreenThumbnailBinding ) : public CGlxSingleTagBinding |
|
406 { |
|
407 public: |
|
408 |
|
409 /** |
|
410 * Two phase construction |
|
411 * @param aMulTag The mul field that MPX attribute is mapped to |
|
412 */ |
|
413 static CGlxFullScreenThumbnailBinding* NewL( const Alf::mulvisualitem::TVisualAttribute& aMulTag /*const char* const aMulTag*/); |
|
414 |
|
415 /** |
|
416 * Two phase construction |
|
417 * @param aMulTag The mul field that MPX attribute is mapped to |
|
418 */ |
|
419 static CGlxFullScreenThumbnailBinding* NewLC(const Alf::mulvisualitem::TVisualAttribute& aMulTag /*const char* const aMulTag*/ ); |
|
420 |
|
421 /** |
|
422 * Destructor |
|
423 */ |
|
424 ~CGlxFullScreenThumbnailBinding(); |
|
425 |
|
426 /** |
|
427 * Constructor |
|
428 */ |
|
429 CGlxFullScreenThumbnailBinding( ); |
|
430 |
|
431 // From CGlxBinding |
|
432 void AddRequestL(CGlxAttributeRequirements& aAttributeRequirement,TSize aSize); |
|
433 |
|
434 TResponse HandleFocusChanged( TBool aIsGained ); |
|
435 |
|
436 private: // From CGlxBinding |
|
437 void PopulateT( Alf::MulVisualItem& aItem, const TGlxMedia& aMedia, |
|
438 TBool aIsFocused ) const; |
|
439 |
|
440 /** |
|
441 * HasRelevantAttributes |
|
442 * @param aAttribute MPX attribute name |
|
443 */ |
|
444 TBool HasRelevantAttributes( const RArray< TMPXAttribute >& aAttributes ) const; |
|
445 |
|
446 private: |
|
447 // The size of the thumbnails in fullscreen |
|
448 TSize iFullScreenThumbnailSize; |
|
449 }; |
|
450 |
|
451 // ---------------------------------------------------------------------------- |
|
452 |
|
453 NONSHARABLE_CLASS( CGlxIconBinding ) : public CGlxSingleTagBinding |
|
454 { |
|
455 public: |
|
456 |
|
457 /** |
|
458 * Constructor |
|
459 * @param aAttribute MPX attribute name |
|
460 */ |
|
461 CGlxIconBinding( const CGlxMulIconProvider* aIconProvider , const TSize& aSize); |
|
462 |
|
463 /** |
|
464 * Two phase construction |
|
465 * @param aMulTag The mul field that icon from resource file is mapped to |
|
466 */ |
|
467 static CGlxIconBinding* NewL( const Alf::mulvisualitem::TVisualAttribute& aMulTag /*const char* const aMulTag*/, |
|
468 const CGlxMulIconProvider* aIconProvider, const TSize& aSize ); |
|
469 |
|
470 /** |
|
471 * Two phase construction |
|
472 * @param aMulTag The mul field that icon from resource file is mapped to |
|
473 */ |
|
474 static CGlxIconBinding* NewLC( const Alf::mulvisualitem::TVisualAttribute& aMulTag /*const char* const aMulTag*/, |
|
475 const CGlxMulIconProvider* aIconProvider, const TSize& aSize ); |
|
476 |
|
477 /** |
|
478 * Destructor |
|
479 */ |
|
480 ~CGlxIconBinding(); |
|
481 |
|
482 private: // From CGlxBinding |
|
483 void PopulateT( Alf::MulVisualItem& aItem, const TGlxMedia& aMedia, |
|
484 TBool aIsFocused ) const; |
|
485 |
|
486 private: |
|
487 const CGlxMulIconProvider* iIconProvider; |
|
488 |
|
489 TSize iIconSize; |
|
490 }; |
|
491 |
|
492 // ---------------------------------------------------------------------------- |
|
493 |
|
494 NONSHARABLE_CLASS( CGlxCommandBinding ) : public CGlxSingleTagBinding |
|
495 { |
|
496 public: |
|
497 |
|
498 /** |
|
499 * Two phase construction |
|
500 * @param aCommand MGlxBoundCommand is mapped to |
|
501 * aCommand must be topmost in cleanup stack. This function will pop it. |
|
502 */ |
|
503 static CGlxCommandBinding* NewL ( MGlxBoundCommand* aCommand ); |
|
504 |
|
505 /** |
|
506 * Two phase construction |
|
507 * @param aCommand MGlxBoundCommand is mapped to |
|
508 */ |
|
509 static CGlxCommandBinding* NewLC( MGlxBoundCommand* aCommand ); // takes ownership |
|
510 |
|
511 /** |
|
512 * Constructor |
|
513 */ |
|
514 CGlxCommandBinding(); |
|
515 |
|
516 /** |
|
517 * Destructor |
|
518 */ |
|
519 ~CGlxCommandBinding(); |
|
520 |
|
521 private: |
|
522 // From CGlxBinding |
|
523 void PopulateT( Alf::MulVisualItem& aItem, const TGlxMedia& aMedia, |
|
524 TBool aIsFocused ) const; |
|
525 |
|
526 private: |
|
527 MGlxBoundCommand* iCommand; |
|
528 }; |
|
529 #endif |
|
530 |