photosgallery/slideshow/engine/coresrc/shwthumbnailcontext.cpp
changeset 0 4e91876724a2
child 18 bcb43dc84c44
equal deleted inserted replaced
-1:000000000000 0:4e91876724a2
       
     1 /*
       
     2 * Copyright (c) 2007-2008 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:    Slideshow specific thumbnail context
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDES
       
    22 #include "shwthumbnailcontext.h"
       
    23 
       
    24 #include <glxthumbnailinfo.h>
       
    25 #include <glxthumbnailattributeinfo.h>
       
    26 #include <glxerrormanager.h>
       
    27 #include <mglxmedialist.h>
       
    28 
       
    29 #include <glxlog.h>
       
    30 #include <glxtracer.h>
       
    31 
       
    32 // DEPENDENCIES
       
    33 
       
    34 // -----------------------------------------------------------------------------
       
    35 // Constructor.
       
    36 // -----------------------------------------------------------------------------
       
    37 inline CShwThumbnailContext::CShwThumbnailContext( 
       
    38     TInt aIndex, TSize aSize ) : iSize(aSize), iCurrentIndex( aIndex )
       
    39     {
       
    40     }
       
    41 
       
    42 // -----------------------------------------------------------------------------
       
    43 // NewLC.
       
    44 // -----------------------------------------------------------------------------
       
    45 CShwThumbnailContext* CShwThumbnailContext::NewLC( TInt aIndex, TSize aSize )
       
    46     {
       
    47     TRACER("CShwThumbnailContext::NewLC");
       
    48     GLX_LOG_INFO1( "CShwThumbnailContext::NewL, aIndex=%d", aIndex );
       
    49     CShwThumbnailContext* self =
       
    50         new (ELeave) CShwThumbnailContext( aIndex, aSize );
       
    51     CleanupStack::PushL( self );
       
    52     self->ConstructL();
       
    53     return self;
       
    54     }
       
    55 
       
    56 // -----------------------------------------------------------------------------
       
    57 // ConstructL.
       
    58 // -----------------------------------------------------------------------------
       
    59 void CShwThumbnailContext::ConstructL()
       
    60     {
       
    61     TRACER("CShwThumbnailContext::ConstructL");
       
    62     GLX_LOG_INFO("CShwThumbnailContext::ConstructL");
       
    63     // Create the high quality / slower context
       
    64     iHighQualityContext = CGlxThumbnailContext::NewL( this );
       
    65     // Call both setdefault and add?
       
    66     iHighQualityContext->SetDefaultSpec( iSize.iWidth, iSize.iHeight );
       
    67     iHighQualityContext->AddSpecForItemL( iSize.iWidth, iSize.iHeight,
       
    68         iCurrentIndex );
       
    69     // we want to only load high quality with this context
       
    70     iHighQualityContext->SetHighQualityOnly( ETrue );
       
    71     }
       
    72 
       
    73 // -----------------------------------------------------------------------------
       
    74 // Destructor.
       
    75 // -----------------------------------------------------------------------------
       
    76 CShwThumbnailContext::~CShwThumbnailContext()
       
    77     {
       
    78     TRACER("CShwThumbnailContext::~CShwThumbnailContext");
       
    79     GLX_LOG_INFO( "CShwThumbnailContext::~CShwThumbnailContext" );
       
    80     delete iHighQualityContext;
       
    81     }
       
    82 
       
    83 // -----------------------------------------------------------------------------
       
    84 // SetToFirst.
       
    85 // -----------------------------------------------------------------------------
       
    86 void CShwThumbnailContext::SetToFirst( const MGlxMediaList* /*aList*/ )
       
    87     {
       
    88     TRACER("CShwThumbnailContext::SetToFirst");
       
    89     GLX_LOG_INFO( "CShwThumbnailContext::SetToFirst" );
       
    90     // reset iterator state
       
    91     iIterated = EFalse;
       
    92     }
       
    93 
       
    94 // -----------------------------------------------------------------------------
       
    95 // CShwThumbnailLoaderImpl::operator++.
       
    96 // -----------------------------------------------------------------------------
       
    97 TInt CShwThumbnailContext::operator++( TInt )
       
    98     {
       
    99     TRACER("CShwThumbnailContext::operator++");
       
   100     GLX_LOG_INFO( "CShwThumbnailContext::operator++" );
       
   101     // we want to load all the thumbnails our clients have requested 
       
   102     // notification on, nothing else
       
   103     // by default tell the thumbnail that we dont have any interesting indexes
       
   104     TInt wantedIndex = KErrNotFound;
       
   105     // check if we were asked already
       
   106     if( !iIterated )
       
   107         {
       
   108         // we want to load thumbnail for the specified index
       
   109         wantedIndex = iCurrentIndex;
       
   110         iIterated = ETrue;
       
   111         }
       
   112     // finally return the index that was wanted
       
   113     return wantedIndex;
       
   114     }
       
   115 
       
   116 // -----------------------------------------------------------------------------
       
   117 // InRange.
       
   118 // -----------------------------------------------------------------------------
       
   119 TBool CShwThumbnailContext::InRange( TInt aIndex ) const
       
   120     {
       
   121     TRACER("CShwThumbnailContext::InRange");
       
   122     GLX_LOG_INFO( "CShwThumbnailContext::InRange" );
       
   123     // if we got notifications
       
   124     if ( aIndex == iCurrentIndex )
       
   125         {
       
   126         // is in range so dont remove the item :)
       
   127         // cache removes thumbnails that are no longer in range
       
   128         return ETrue;
       
   129         }
       
   130     // not in our range
       
   131     return EFalse;
       
   132     }
       
   133 
       
   134 // -----------------------------------------------------------------------------
       
   135 // RequestCountL.
       
   136 // -----------------------------------------------------------------------------
       
   137 TInt CShwThumbnailContext::RequestCountL(const MGlxMediaList* aList) const
       
   138     {
       
   139     TRACER("CShwThumbnailContext::RequestCountL");
       
   140     GLX_LOG_INFO( "CShwThumbnailContext::RequestCountL" );
       
   141     return iHighQualityContext->RequestCountL( aList );
       
   142     }
       
   143 
       
   144 // -----------------------------------------------------------------------------
       
   145 // Index.
       
   146 // -----------------------------------------------------------------------------
       
   147 TInt CShwThumbnailContext::Index()
       
   148     {
       
   149     TRACER("CShwThumbnailContext::Index");
       
   150     GLX_LOG_INFO1( "CShwThumbnailContext::Index %d", iCurrentIndex );
       
   151     return iCurrentIndex;
       
   152     }
       
   153 
       
   154 // -----------------------------------------------------------------------------
       
   155 // Context.
       
   156 // -----------------------------------------------------------------------------
       
   157 MGlxFetchContext* CShwThumbnailContext::Context()
       
   158 	{
       
   159 	TRACER("CShwThumbnailContext::Context");
       
   160 	GLX_LOG_INFO( "CShwThumbnailContext::Context" );
       
   161 	return iHighQualityContext;
       
   162 	}