photosgallery/viewframework/medialists/inc/glxattributecontext.h
changeset 0 4e91876724a2
child 1 9ba538e329bd
equal deleted inserted replaced
-1:000000000000 0:4e91876724a2
       
     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:    Generic fetch context to retrieve attributes
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef C_GLXATTRIBUTECONTEXT_H
       
    22 #define C_GLXATTRIBUTECONTEXT_H
       
    23 
       
    24 #include <e32std.h>
       
    25 #include "mglxfetchcontext.h"
       
    26 #include "glxmedialistiterator.h"	// for TGlxSequentialIterator
       
    27 
       
    28 // Forward declarations
       
    29 class MGlxMediaList;
       
    30 class TMPXAttribute;
       
    31 class T_CGlxAttributeContext; // For E-unit only
       
    32 
       
    33 /**
       
    34  *  CGlxAttributeContext
       
    35  *
       
    36  *  Fetch context to retrieve thumbnails
       
    37  *
       
    38  *  @lib glxmedialists.lib
       
    39  */
       
    40 class CGlxAttributeContext : public CBase, public MGlxFetchContext
       
    41 	{
       
    42 public:
       
    43 	/**
       
    44 	 * Constructor
       
    45 	 * @param aIterator Iterator that determines the order of attribute 
       
    46 	 *  	  retrieval and for which items attributes are and are not retrieved
       
    47 	 */
       
    48 	IMPORT_C CGlxAttributeContext(MGlxMediaListIterator* aIterator);
       
    49 	IMPORT_C ~CGlxAttributeContext();
       
    50 
       
    51 	/**
       
    52 	 * Adds an attribute to be retrieved for all items
       
    53 	 * @param aAttribute The attribute to be retrieved
       
    54 	 */
       
    55 	IMPORT_C void AddAttributeL(const TMPXAttribute& aAttribute);
       
    56 
       
    57 	/**
       
    58 	 * Removes an attribute from the "retrieval instructions"
       
    59 	 * @param aAttribute The attribute to be removed 
       
    60 	 */
       
    61 	IMPORT_C void RemoveAttribute(const TMPXAttribute& aAttribute);
       
    62 
       
    63 	/**
       
    64 	 * Returns the count of the attributes to be retrieved
       
    65 	 * @return the count of the attribtues to be retrieved
       
    66 	 */
       
    67 	IMPORT_C TInt AttributeCount();
       
    68 	
       
    69 	/**
       
    70 	 * Sets granularity of the item index array returned from AttributeRequestL
       
    71 	 */
       
    72 	IMPORT_C void SetGranularity(TUint aGranularity);
       
    73 
       
    74 public: // From MGlxFetchContext
       
    75     /// See @ref MGlxFetchContext::AttributeRequestL
       
    76     TInt AttributeRequestL(const MGlxMediaList* aList, RArray<TInt>& aItemIndices, 
       
    77     	RArray<TMPXAttribute>& aAttributes, CMPXAttributeSpecs*& aDetailedSpecs) const;
       
    78 
       
    79     /// See @ref MGlxFetchContext::AllAttributesL
       
    80     void AllAttributesL(const MGlxMediaList* aList, TInt aListIndex, 
       
    81     	RArray<TMPXAttribute>& aAttributes) const;
       
    82 
       
    83     /// See @ref MGlxFetchContext::RequestCountL
       
    84     TInt RequestCountL(const MGlxMediaList* aList) const;
       
    85     	
       
    86 private:
       
    87 	/**
       
    88 	 * Determine attributes to request for an item
       
    89 	 * @param aIndexInList item index in media list
       
    90 	 * @param aList media list
       
    91 	 * @param aAttributes requested attributes
       
    92 	 * @return ETrue if attributes to be requested, otherwise EFalse
       
    93 	 */
       
    94 	TBool AddItemAttributesL(TInt aIndexInList, const MGlxMediaList* aList, RArray<TMPXAttribute>& aAttributes, 
       
    95 	                         TInt& aError, TBool aFirstItem) const;
       
    96 
       
    97 	/**
       
    98 	 * Append attribute to array, no duplicates
       
    99 	 * @param aAttributes requested attributes
       
   100 	 * @param aAttribute attribute to be added
       
   101 	 */
       
   102 	void AddItemAttributeL(RArray<TMPXAttribute>& aAttributes, const TMPXAttribute& aAttribute) const;
       
   103 	
       
   104 private:
       
   105 	/** Attributes to be requested for all items */
       
   106 	RArray<TMPXAttribute> iAttributes;
       
   107 	
       
   108 	/**
       
   109 	 * Iterator for traversing the list
       
   110 	 */
       
   111 	MGlxMediaListIterator* iIterator;	
       
   112 	
       
   113 	/** 
       
   114 	 * Granularity of the item index array returned from AttributeRequestL
       
   115 	 */
       
   116 	TUint iGranularity;
       
   117 
       
   118 	/** Tester class */
       
   119 	friend class T_CGlxAttributeContext;
       
   120 	};
       
   121 	
       
   122 /**
       
   123  *  CGlxDefaultAttributeContext
       
   124  *
       
   125  *  Fetch context to retrieve MPX attributes starting from focus outward
       
   126  *
       
   127  *  @lib glxmedialists.lib
       
   128  */
       
   129 class CGlxDefaultAttributeContext : public CGlxAttributeContext
       
   130 	{
       
   131 public:
       
   132 	IMPORT_C static CGlxDefaultAttributeContext* NewL();
       
   133 	IMPORT_C ~CGlxDefaultAttributeContext();
       
   134 
       
   135 	/**
       
   136 	 * Set the range offsets. These determine the outer limits
       
   137 	 * of attributes to be retrieved, compared to current focus in
       
   138 	 * the list
       
   139 	 * If ranges not defined, retrieves the attributes for focused item only
       
   140 	 */
       
   141     IMPORT_C void SetRangeOffsets(TInt aFrontOffset, TInt aRearOffset);
       
   142 
       
   143 private:
       
   144 	CGlxDefaultAttributeContext();
       
   145 
       
   146 private:
       
   147 	TGlxFromFocusOutwardIterator iFromFocusIterator;	
       
   148 	};
       
   149 	
       
   150 #endif // C_GLXATTRIBUTECONTEXT_H
       
   151