photosgallery/viewframework/views/listview/inc/glxpreviewthumbnailbinding.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 19 Feb 2010 22:51:01 +0200
branchRCL_3
changeset 9 6b87b143d312
parent 2 7d9067c6fcb1
child 13 71da52165949
permissions -rw-r--r--
Revision: 201003 Kit: 201007

/*
* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). 
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
*  Description : Class header for preview thumbnail in list view
*
*/


#ifndef _GLXPREVIEWTHUMBNAILBINDING_H_
#define _GLXPREVIEWTHUMBNAILBINDING_H_


#include "glxbinding.h"              // The binding is created by the binding set factory.
#include "glxmedialistiterator.h"    // Interface for going through items in the list in a  non-sequential order
#include "mglxmedialistobserver.h"   // Observes for changes in media list
#include <memory>                    
#include <bitmaptransforms.h>

class GlxThumbnailVariantType;
class CGlxThumbnailContext;          // Fetch context to retrieve thumbnails

/**
 * Observer interface
 */
class MPreviewTNObserver 
    {
public:
    virtual void PreviewTNReadyL(CFbsBitmap* aBitmap, CFbsBitmap* aMask, TInt aIndex) = 0;
    };
    
// CLASS DECLARATION
/**
 * Implementation of preview thumbnail binding for the 
 * list view. 
 * 
 */ 
    
 NONSHARABLE_CLASS(CGlxPreviewThumbnailBinding) : public CBase,
                                                  public MGlxMediaListObserver
 	{
 public:
 
	/**
	  * Two phase construction
	  * @param aMulTag Mul field that the binding corresponds to
	  */
	static CGlxPreviewThumbnailBinding* NewL (MPreviewTNObserver& aObserver);
	
	/**
	 * Two phase construction
	 */
	static CGlxPreviewThumbnailBinding* NewLC(MPreviewTNObserver& aObserver ); // takes ownership

	
	/**
	 * Destructor
	 */
	~CGlxPreviewThumbnailBinding();
	
private:

	 /**
	 * Constructor
	 */
	CGlxPreviewThumbnailBinding(MPreviewTNObserver& aObserver);
	
	/**
	 * Two phase construction
	 */
	void ConstructL();
	
	/**
     * Scale the source bitmap to list size
     * aSrcBitmap - Source bitmap
     * aDestBitmap - Scaled destination bitmap
     */
      void ScaleBitmapToListSizeL(CFbsBitmap* aSrcBitmap, CFbsBitmap* aDestBitmap);

public:	
      void HandleItemChangedL(const CMPXCollectionPath& aPath,
              TBool aPopulateListTNs, TBool aBackwardNavigation);
      void StartTimer(TBool aPopulateListTNs);
      void StopTimer();
      
      // From MGlxMediaListObserver
      void HandleItemAddedL( TInt aStartIndex, TInt aEndIndex, MGlxMediaList* aList );
      void HandleItemRemovedL( TInt aStartIndex, TInt aEndIndex, MGlxMediaList* aList );
      void HandleAttributesAvailableL( TInt aItemIndex, 
          const RArray<TMPXAttribute>& aAttributes, MGlxMediaList* aList );    
      void HandleFocusChangedL( NGlxListDefs::TFocusChangeType aType, 
      TInt aNewIndex, TInt aOldIndex, MGlxMediaList* aList );
      void HandleItemSelectedL(TInt aIndex, TBool aSelected, MGlxMediaList* aList );
      void HandleMessageL( const CMPXMessage& aMessage, MGlxMediaList* aList );
      void HandleError( TInt aError );
      void HandleCommandCompleteL( CMPXCommand* aCommandResult, TInt aError, 
          MGlxMediaList* aList );
      void HandleMediaL( TInt aListIndex, MGlxMediaList* aList );
      void HandleItemModifiedL( const RArray<TInt>& aItemIndexes, MGlxMediaList* aList );
      void HandlePopulatedL( MGlxMediaList* aList );
     
private:
	/**
	 * IsTimeL
	 */
	static TInt IsTimeL( TAny* aSelf );
	
	/**
	 * TimerTickedL
	 */
	void TimerTickedL();
	
private:
	MPreviewTNObserver& iObserver;	
	
	// Timer that checks for the time expiration
	CPeriodic* iTimer;
	
	//Medialist that holds the thumbnail information
	MGlxMediaList* iMediaList;
	
	// Thumbnail Attrib context
    CGlxAttributeContext* iThumbnailContext;	
	
	// for thumbnail context
	TGlxSequentialIterator iThumbnailIterator;
	
	// Preview thumbnail index
	TInt iProgressIndex;
	
	// flag that says whether timer has expired
	TBool iTimerTicked;
	
	//flag will be true, when initially the first thumbnails for all the 
	//items in the list are populated.
	TBool iPopulateListTNs;

    //it holds the initial number of thumbnail to be displayed
    RArray<TInt> iPreviewItemCount;
    
    TSize iGridIconSize;
    
    // Holds the numbers of trials count,after which PreviewTNReady callback
    // has to be called
    TInt iTrialCount;
    
    TInt iTrial;
        
    TBool iBackwardNavigation;
    
    CMPXFilter* iPreviewFilter;
    
    CBitmapScaler* iBitmapScaler;
};

 // ----------------------------------------------------------------------------
 // CWaitScheduler - Active object to scale the bitmap to the desired size.
 // ----------------------------------------------------------------------------
 class CGlxWaitScheduler : public CActive
     {
 public:
     static CGlxWaitScheduler* NewL();  
     void WaitForRequest();

 private:
     CGlxWaitScheduler();
     void ConstructL();
     virtual ~CGlxWaitScheduler();  
     void RunL();
     void DoCancel();

 private:
     CActiveSchedulerWait iScheduler;  
     };

#endif //_GLXPREVIEWTHUMBNAILBINDING_H_