emailuis/emailui/src/FreestyleEmailUiFolderListVisualiser.cpp
changeset 1 12c456ceeff2
parent 0 8466d47a6819
child 2 5253a20d2a1e
equal deleted inserted replaced
0:8466d47a6819 1:12c456ceeff2
     1 /*
     1 /*
     2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
     2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:  FreestyleEmailUi folder list view implementation
    14 * Description:  FreestyleEmailUi folder list view implementation
    15 *
    15 *
    16 */
    16 */
    17 
       
    18 
    17 
    19 // SYSTEM INCLUDES
    18 // SYSTEM INCLUDES
    20 #include "emailtrace.h"
    19 #include "emailtrace.h"
    21 #include <AknUtils.h>
    20 #include <AknUtils.h>
    22 #include <StringLoader.h>
    21 #include <StringLoader.h>
    30 #include <eikcolib.h>
    29 #include <eikcolib.h>
    31 #include <alf/alfdecklayout.h>
    30 #include <alf/alfdecklayout.h>
    32 #include <alf/alftextvisual.h>
    31 #include <alf/alftextvisual.h>
    33 #include <alf/alfcontrolgroup.h>
    32 #include <alf/alfcontrolgroup.h>
    34 #include <alf/alfbrusharray.h>
    33 #include <alf/alfbrusharray.h>
       
    34 #include <alf/alfshadowborderbrush.h>
    35 #include <alf/alfevent.h>
    35 #include <alf/alfevent.h>
    36 #include <alf/alfframebrush.h>
    36 #include <alf/alfframebrush.h>
    37 #include <alf/alfstatic.h>
    37 #include <alf/alfstatic.h>
    38 
    38 
    39 // GENERIC LIST COMPONENT INCLUDES
    39 // GENERIC LIST COMPONENT INCLUDES
    73 #include "FreestyleEmailUiLayoutData.h"
    73 #include "FreestyleEmailUiLayoutData.h"
    74 #include "FreestyleEmailUiShortcutBinding.h"
    74 #include "FreestyleEmailUiShortcutBinding.h"
    75 #include "ESMailSettingsPlugin.h"
    75 #include "ESMailSettingsPlugin.h"
    76 #include "FreestyleEmailUiStatusIndicator.h"
    76 #include "FreestyleEmailUiStatusIndicator.h"
    77 
    77 
    78 // REMOVE WHEN DONE TESTING:
       
    79 //#include "CSimpleAOTest.h"
       
    80 
       
    81 // Defines the order of the folders in UI
    78 // Defines the order of the folders in UI
    82 enum TFSEmailUiFolderListPriorities
    79 enum TFSEmailUiFolderListPriorities
    83 	{
    80 	{
    84     EFolderListPriorityInbox = 1,
    81     EFolderListPriorityInbox = 1,
    85     EFolderListPriorityDrafts,
    82     EFolderListPriorityDrafts,
   101     EFolderListIconServerFolders,
    98     EFolderListIconServerFolders,
   102 	EFolderListIconMoreFolders,
    99 	EFolderListIconMoreFolders,
   103     EFolderListIconEmailAccount
   100     EFolderListIconEmailAccount
   104 	};
   101 	};
   105 
   102 
       
   103 // Defines the order of the sort list icons in the sort icon array
       
   104 enum TFsEmailUiSortListIcons
       
   105 	{
       
   106 	ESortListAttachmentAscIcon = 0,
       
   107 	ESortListAttachmentDescIcon,
       
   108 	ESortListDateAscIcon,
       
   109 	ESortListDateDescIcon,
       
   110 	ESortListFollowAscIcon,
       
   111 	ESortListFollowDescIcon,
       
   112 	ESortListPriorityAscIcon,
       
   113 	ESortListPriorityDescIcon,
       
   114 	ESortListSenderAscIcon,
       
   115 	ESortListSenderDescIcon,
       
   116 	ESortListSubjectAscIcon,
       
   117 	ESortListSubjectDescIcon,
       
   118 	ESortListUnreadAscIcon,
       
   119 	ESortListUnreadDescIcon
       
   120 	};
       
   121 
   106 // List level for the root folders
   122 // List level for the root folders
   107 static const TInt KListRootLevel( 1 );
   123 static const TInt KListRootLevel( 1 );
   108 // List supports three levels, so basically root folder + two levels of subfolders
   124 // List supports three levels, so basically root folder + two levels of subfolders
   109 static const TInt KListLastBasicLevel( KListRootLevel + 2 );
   125 static const TInt KListLastBasicLevel( KListRootLevel + 2 );
       
   126 
       
   127 const TInt KDefaultShadowBorderWidth( 15 );
       
   128 const TReal KShadowBorderOpacity( 0.08 );
   110 
   129 
   111 // Constants for drawing header text
   130 // Constants for drawing header text
   112 const TReal KFSHeaderTextBackgroundOpacity = 0.3f;
   131 const TReal KFSHeaderTextBackgroundOpacity = 0.3f;
   113 const TAlfTimedValue KFSVisible( 1 );
   132 const TAlfTimedValue KFSVisible( 1 );
   114 const TAlfTimedValue KFSInvisible( 0 );
   133 const TAlfTimedValue KFSInvisible( 0 );
   147 
   166 
   148 // ---------------------------------------------------------------------------
   167 // ---------------------------------------------------------------------------
   149 // Constructor
   168 // Constructor
   150 // ---------------------------------------------------------------------------
   169 // ---------------------------------------------------------------------------
   151 //
   170 //
   152 CFSEmailUiFolderListVisualiser::CFSEmailUiFolderListVisualiser( CAlfEnv& aEnv, 
   171 CFSEmailUiFolderListVisualiser::CFSEmailUiFolderListVisualiser( CAlfEnv& aEnv,
   153                                                                 CFreestyleEmailUiAppUi& aAppUi, 
   172                                                                 CFreestyleEmailUiAppUi& aAppUi,
   154                                                                 CAlfControlGroup& aControlGroup )
   173                                                                 CAlfControlGroup& aControlGroup )
   155     : CFsEmailUiViewBase( aControlGroup, aAppUi ),
   174     : CFsEmailUiViewBase( aControlGroup, aAppUi ),
   156       iEnv( aEnv ),
   175       iEnv( aEnv ),
   157       iFullScreen( ETrue ),
   176       iFullScreen( ETrue ),
   158       iPreviousListLevel( KListRootLevel ),
   177       iPreviousListLevel( KListRootLevel ),
   160       iWaitingToGoOnline(EFalse),
   179       iWaitingToGoOnline(EFalse),
   161       iNoConnectNeeded(ETrue)
   180       iNoConnectNeeded(ETrue)
   162 	{
   181 	{
   163     FUNC_LOG;
   182     FUNC_LOG;
   164 	}
   183 	}
   165 	
   184 
   166 // ---------------------------------------------------------------------------
   185 // ---------------------------------------------------------------------------
   167 // Destructor
   186 // Destructor
   168 // ---------------------------------------------------------------------------
   187 // ---------------------------------------------------------------------------
   169 //
   188 //
   170 CFSEmailUiFolderListVisualiser::~CFSEmailUiFolderListVisualiser()
   189 CFSEmailUiFolderListVisualiser::~CFSEmailUiFolderListVisualiser()
   174 	iModel = NULL;
   193 	iModel = NULL;
   175 
   194 
   176 	delete iBackgroundBrush;
   195 	delete iBackgroundBrush;
   177 	iBackgroundBrush = NULL;
   196 	iBackgroundBrush = NULL;
   178 
   197 
       
   198 	delete iShadowBrush;
       
   199 	
   179 	// No need for ResetAndDestroy because list items are owned by generic list
   200 	// No need for ResetAndDestroy because list items are owned by generic list
   180 	iListItemVisulizers.Close();
   201 	iListItemVisulizers.Close();
   181 	
   202 
   182     //delete iNotifierTest;
   203     //delete iNotifierTest;
   183     
   204 
   184     delete iTreeList;
   205     delete iTreeList;
   185     iTreeList = NULL;
   206     iTreeList = NULL;
   186     
   207 
   187     iIconArray.Close();
   208     iIconArray.Close();
       
   209     iSortIconArray.Close();
   188     
   210     
   189     if ( iAsyncCallback )
   211     if ( iAsyncCallback )
   190         {
   212         {
   191         iAsyncCallback->Cancel();
   213         iAsyncCallback->Cancel();
   192         delete iAsyncCallback;
   214         delete iAsyncCallback;
   216 void CFSEmailUiFolderListVisualiser::DoFirstStartL()
   238 void CFSEmailUiFolderListVisualiser::DoFirstStartL()
   217     {
   239     {
   218     FUNC_LOG;
   240     FUNC_LOG;
   219     iControl = CFSEmailUiFolderListControl::NewL( iEnv, *this );
   241     iControl = CFSEmailUiFolderListControl::NewL( iEnv, *this );
   220     iModel = new (ELeave) CFSEmailUiFolderListModel();
   242     iModel = new (ELeave) CFSEmailUiFolderListModel();
   221      
   243 
   222     UpdateListSizeAttributes();
   244     UpdateListSizeAttributes();
   223     //LoadIconsL();
   245     //LoadIconsL();
   224    
   246 
   225     TRect mainPaneRect;
   247     TRect mainPaneRect;
   226     AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
   248     AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
   227     iFaderLayout = CAlfDeckLayout::AddNewL( *iControl );
   249     iFaderLayout = CAlfDeckLayout::AddNewL( *iControl );
   228     iFaderLayout->SetRect( mainPaneRect );
   250     iFaderLayout->SetRect( mainPaneRect );
   229     
   251 
   230     iParentLayout = CAlfAnchorLayout::AddNewL( *iControl );
   252     iParentLayout = CAlfAnchorLayout::AddNewL( *iControl );
   231     iParentLayout->SetRect( iScreenRect );
   253     iParentLayout->SetRect( iScreenRect );
   232     iParentLayout->SetFlags( EAlfVisualFlagManualLayout );
   254     iParentLayout->SetFlags( EAlfVisualFlagManualLayout );
   233     
   255 
   234     iParentLayout->EnableBrushesL();
   256     iParentLayout->EnableBrushesL();
   235     SetAnchors();
   257     SetAnchors();
   236 
   258 
   237     iFaderVisual = CAlfImageVisual::AddNewL( *iControl, iParentLayout );
   259     iFaderVisual = CAlfImageVisual::AddNewL( *iControl, iParentLayout );
   238 
   260 
   239     iHeaderLayout = CAlfDeckLayout::AddNewL( *iControl, iParentLayout );
   261     iHeaderLayout = CAlfDeckLayout::AddNewL( *iControl, iParentLayout );
   240     iHeaderLayout->SetFlags( EAlfVisualFlagAutomaticLocaleMirroringEnabled );
   262     iHeaderLayout->SetFlags( EAlfVisualFlagAutomaticLocaleMirroringEnabled );
   241      
   263 
   242     iHeaderTextVisual = CAlfTextVisual::AddNewL( *iControl, iHeaderLayout );
   264     iHeaderTextVisual = CAlfTextVisual::AddNewL( *iControl, iHeaderLayout );
   243     iHeaderTextVisual->SetWrapping( CAlfTextVisual::ELineWrapTruncate );
   265     iHeaderTextVisual->SetWrapping( CAlfTextVisual::ELineWrapTruncate );
   244     iHeaderTextVisual->SetTextL( KNullDesC );
   266     iHeaderTextVisual->SetTextL( KNullDesC );
   245      
   267 
   246     TRgb headerTextColor( KRgbBlack );
   268     TRgb headerTextColor( KRgbBlack );
   247     AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), 
   269     AknsUtils::GetCachedColor( AknsUtils::SkinInstance(),
   248                                headerTextColor, KAknsIIDFsTextColors, EAknsCIFsTextColorsCG10 );
   270                                headerTextColor, KAknsIIDFsTextColors, EAknsCIFsTextColorsCG10 );
   249     iHeaderTextVisual->SetColor( headerTextColor );
   271     iHeaderTextVisual->SetColor( headerTextColor );
   250     iHeaderTextVisual->SetTextStyle( iAppUi.LayoutHandler()->
   272     iHeaderTextVisual->SetTextStyle( iAppUi.LayoutHandler()->
   251         FSTextStyleFromLayoutL( AknLayoutScalable_Apps::main_sp_fs_ctrlbar_pane_t1( 0 ) ).Id() );
   273         FSTextStyleFromLayoutL( AknLayoutScalable_Apps::main_sp_fs_ctrlbar_pane_t1( 0 ) ).Id() );
   252 
   274 
   259         iHeaderTextVisual->SetAlign( EAlfAlignHLeft, EAlfAlignVCenter );
   281         iHeaderTextVisual->SetAlign( EAlfAlignHLeft, EAlfAlignVCenter );
   260         }
   282         }
   261 
   283 
   262 	iHeaderTextVisual->SetOpacity( KFSInvisible );
   284 	iHeaderTextVisual->SetOpacity( KFSInvisible );
   263 	iHeaderLayout->SetOpacity( KFSInvisible );
   285 	iHeaderLayout->SetOpacity( KFSInvisible );
   264 	
   286 
   265     iListLayout = CAlfDeckLayout::AddNewL( *iControl, iParentLayout );
   287     iListLayout = CAlfDeckLayout::AddNewL( *iControl, iParentLayout );
   266     iListLayout->SetFlags(EAlfVisualFlagLayoutUpdateNotification|EAlfVisualFlagAutomaticLocaleMirroringEnabled);
   288     iListLayout->SetFlags(EAlfVisualFlagLayoutUpdateNotification|EAlfVisualFlagAutomaticLocaleMirroringEnabled);
   267 
   289 
   268     iTreeVisualizer = CFsTreeVisualizerBase::NewL(iControl, *iListLayout);
   290     iTreeVisualizer = CFsTreeVisualizerBase::NewL(iControl, *iListLayout);
   269     iTreeVisualizer->SetItemExpansionDelay( iAppUi.LayoutHandler()->ListItemExpansionDelay() );
   291     iTreeVisualizer->SetItemExpansionDelay( iAppUi.LayoutHandler()->ListItemExpansionDelay() );
   270     iTreeVisualizer->SetScrollTime( iAppUi.LayoutHandler()->ListScrollingTime() );
   292     iTreeVisualizer->SetScrollTime( iAppUi.LayoutHandler()->ListScrollingTime() );
   271     iTreeVisualizer->SetFadeInEffectTime( iAppUi.LayoutHandler()->CtrlBarListFadeEffectTime() );
   293     iTreeVisualizer->SetFadeInEffectTime( iAppUi.LayoutHandler()->CtrlBarListFadeEffectTime() );
   272     iTreeVisualizer->SetFadeOutEffectTime( iAppUi.LayoutHandler()->CtrlBarListFadeEffectTime() );
   294     iTreeVisualizer->SetFadeOutEffectTime( iAppUi.LayoutHandler()->CtrlBarListFadeEffectTime() );
   273     iTreeVisualizer->SetItemSeparatorSize( TSize(0, 0) );
   295     iTreeVisualizer->SetItemSeparatorSize( TSize(0, 0) );
   274     iTreeVisualizer->SetExpandCollapseAllOnLongTap( EFalse );
   296     iTreeVisualizer->SetExpandCollapseAllOnLongTap( EFalse );
   275      
   297 
   276     iTreeList = CFsTreeList::NewL( *iTreeVisualizer, iEnv );
   298     iTreeList = CFsTreeList::NewL( *iTreeVisualizer, iEnv );
   277     
   299 
   278     // Compared to S60 3.2.3 in S60 5.0 Alf offers the key events in
   300     // Compared to S60 3.2.3 in S60 5.0 Alf offers the key events in
   279     // opposite order.
   301     // opposite order.
   280     ControlGroup().AppendL( iControl );
   302     ControlGroup().AppendL( iControl );
   281     ControlGroup().AppendL( iTreeList->TreeControl() ); 
   303     ControlGroup().AppendL( iTreeList->TreeControl() );
   282     
   304 
   283     iTreeList->AddObserverL(*this);
   305     iTreeList->AddObserverL(*this);
   284 
   306 
   285     iTreeList->SetLoopingType( EFsTreeListLoopingJumpToFirstLast );
   307     iTreeList->SetLoopingType( EFsTreeListLoopingJumpToFirstLast );
   286     iTreeList->SetScrollbarVisibilityL( EFsScrollbarAuto );
   308     iTreeList->SetScrollbarVisibilityL( EFsScrollbarAuto );
   287     iAppUi.LayoutHandler()->SetListMarqueeBehaviour( iTreeList );
   309     iAppUi.LayoutHandler()->SetListMarqueeBehaviour( iTreeList );
   294             iAppUi.LayoutHandler()->FolderListIndentation(iScreenRect) );
   316             iAppUi.LayoutHandler()->FolderListIndentation(iScreenRect) );
   295 
   317 
   296     iTreeVisualizer->SetSelectorPropertiesL(
   318     iTreeVisualizer->SetSelectorPropertiesL(
   297             iAppUi.FsTextureManager()->NewListSelectorBrushL(), 1.0,
   319             iAppUi.FsTextureManager()->NewListSelectorBrushL(), 1.0,
   298             CFsTreeVisualizerBase::EFsSelectorMoveSmoothly );
   320             CFsTreeVisualizerBase::EFsSelectorMoveSmoothly );
   299     
   321 
   300     iAsyncCallback = new (ELeave) CAsyncCallBack( CActive::EPriorityStandard );
   322     iAsyncCallback = new (ELeave) CAsyncCallBack( CActive::EPriorityStandard );
   301     
   323 
   302     //iNotifierTest = CSimpleAOTest::NewL();
   324     //iNotifierTest = CSimpleAOTest::NewL();
   303     iFirstStartCompleted = ETrue;
   325     iFirstStartCompleted = ETrue;
   304     }
   326     }
   305 
   327 
   306 
   328 
   310 //
   332 //
   311 TUid CFSEmailUiFolderListVisualiser::Id() const
   333 TUid CFSEmailUiFolderListVisualiser::Id() const
   312 	{
   334 	{
   313     FUNC_LOG;
   335     FUNC_LOG;
   314 	return FolderListId;
   336 	return FolderListId;
   315 	}			   
   337 	}
   316 
   338 
   317 // ---------------------------------------------------------------------------
   339 // ---------------------------------------------------------------------------
   318 // CFSEmailUiFolderListVisualiser::PrepareFolderListL
   340 // CFSEmailUiFolderListVisualiser::PrepareFolderListL
   319 // ---------------------------------------------------------------------------
   341 // ---------------------------------------------------------------------------
   320 //
   342 //
   333     SetAnchors();
   355     SetAnchors();
   334     ResizeListIcons();
   356     ResizeListIcons();
   335 
   357 
   336     // Show empty screen when offline
   358     // Show empty screen when offline
   337     CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current();
   359     CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current();
   338             
   360 
   339     if( iModel->Count() == 0 )
   361     if( iModel->Count() == 0 )
   340         {
   362         {
   341         cba->SetCommandSetL( R_FREESTYLE_EMAUIL_UI_SK_OPTIONS_BACK );
   363         cba->SetCommandSetL( R_FREESTYLE_EMAUIL_UI_SK_OPTIONS_BACK );
   342         }
   364         }
   343         
   365 
   344     if( iMoveOrCopyInitiated )
   366     if( iMoveOrCopyInitiated )
   345         {
   367         {
   346         iTreeVisualizer->SetEmptyListTextL( KNullDesC );    
   368         iTreeVisualizer->SetEmptyListTextL( KNullDesC );
   347         iTreeVisualizer->RefreshListViewL();    
   369         iTreeVisualizer->RefreshListViewL();
   348         }
   370         }
   349 	}
   371 	}
   350 
   372 
   351 // ---------------------------------------------------------------------------
   373 // ---------------------------------------------------------------------------
   352 // CFSEmailUiFolderListVisualiser::PopulateFolderListL
   374 // CFSEmailUiFolderListVisualiser::PopulateFolderListL
   375         }
   397         }
   376 
   398 
   377   	iParentLayout->SetRect(iScreenRect);
   399   	iParentLayout->SetRect(iScreenRect);
   378 
   400 
   379     CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current();
   401     CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current();
   380     
   402 
   381   	if( iModel->Count() > 0 )
   403   	if( iModel->Count() > 0 )
   382   	    {
   404   	    {
   383         cba->SetCommandSetL( R_FREESTYLE_EMAUIL_UI_SK_OPTIONS_BACK__SELECT );
   405         cba->SetCommandSetL( R_FREESTYLE_EMAUIL_UI_SK_OPTIONS_BACK__SELECT );
   384   	    }
   406   	    }
   385   	    
   407 
   386     if( iMoveOrCopyInitiated )
   408     if( iMoveOrCopyInitiated )
   387         {
   409         {
   388         HBufC* emptyListText = StringLoader::LoadLC( 
   410         HBufC* emptyListText = StringLoader::LoadLC(
   389                R_FREESTYLE_EMAIL_UI_FOLDER_LIST_NO_FOLDERS_AVAILABLE );
   411                R_FREESTYLE_EMAIL_UI_FOLDER_LIST_NO_FOLDERS_AVAILABLE );
   390         iTreeVisualizer->SetEmptyListTextL( *emptyListText );
   412         iTreeVisualizer->SetEmptyListTextL( *emptyListText );
   391         CleanupStack::PopAndDestroy( emptyListText );
   413         CleanupStack::PopAndDestroy( emptyListText );
   392     
   414 
   393         iTreeVisualizer->RefreshListViewL();
   415         iTreeVisualizer->RefreshListViewL();
   394         }
   416         }
   395 	}
   417 	}
   396 
   418 
   397 // ---------------------------------------------------------------------------
   419 // ---------------------------------------------------------------------------
   416 TInt CFSEmailUiFolderListVisualiser::DoPopulateFolderList( TAny* aSelfPtr )
   438 TInt CFSEmailUiFolderListVisualiser::DoPopulateFolderList( TAny* aSelfPtr )
   417     {
   439     {
   418     FUNC_LOG;
   440     FUNC_LOG;
   419     CFSEmailUiFolderListVisualiser* self =
   441     CFSEmailUiFolderListVisualiser* self =
   420         static_cast< CFSEmailUiFolderListVisualiser* >( aSelfPtr );
   442         static_cast< CFSEmailUiFolderListVisualiser* >( aSelfPtr );
   421     TRAPD( err, 
   443     TRAPD( err,
   422         self->PopulateFolderListL();
   444         self->PopulateFolderListL();
   423         if ( self->iCustomMessageId == KFolderListMoveMessage ||
   445         if ( self->iCustomMessageId == KFolderListMoveMessage ||
   424              self->iCustomMessageId == KFolderListMoveMessages ||
   446              self->iCustomMessageId == KFolderListMoveMessages ||
   425              self->iCustomMessageId == KFolderListCopyMessage ||
   447              self->iCustomMessageId == KFolderListCopyMessage ||
   426              self->iCustomMessageId == KFolderListCopyMessages )
   448              self->iCustomMessageId == KFolderListCopyMessages )
   446 // ---------------------------------------------------------------------------
   468 // ---------------------------------------------------------------------------
   447 //
   469 //
   448 void CFSEmailUiFolderListVisualiser::HidePopupL()
   470 void CFSEmailUiFolderListVisualiser::HidePopupL()
   449 	{
   471 	{
   450     FUNC_LOG;
   472     FUNC_LOG;
   451     
   473 
   452     iParentLayout->SetRect( iCtrlButtonRect, iAppUi.LayoutHandler()->CtrlBarListFadeEffectTime() );
   474     iParentLayout->SetRect( iCtrlButtonRect, iAppUi.LayoutHandler()->CtrlBarListFadeEffectTime() );
   453 
   475 
   454     TAlfTimedValue bgOpacity;
   476     TAlfTimedValue bgOpacity;
   455 
   477 
   456 	// Hiding delay was removed to get rid of flickering if changing between
   478 	// Hiding delay was removed to get rid of flickering if changing between
   509 
   531 
   510 // ---------------------------------------------------------------------------
   532 // ---------------------------------------------------------------------------
   511 // CFSEmailUiFolderListVisualiser::DoShowInPopupL
   533 // CFSEmailUiFolderListVisualiser::DoShowInPopupL
   512 // ---------------------------------------------------------------------------
   534 // ---------------------------------------------------------------------------
   513 //
   535 //
   514 /*void CFSEmailUiFolderListVisualiser::DoShowInPopupL()*/
       
   515 void CFSEmailUiFolderListVisualiser::DoShowInPopupL(
   536 void CFSEmailUiFolderListVisualiser::DoShowInPopupL(
   516         MFsControlButtonInterface* aButton,
   537         MFsControlButtonInterface* aButton,
   517         MFSEmailUiFolderListCallback* aFolderCallback,
   538         MFSEmailUiFolderListCallback* aFolderCallback,
   518         MFSEmailUiSortListCallback* aSortCallback )
   539         MFSEmailUiSortListCallback* aSortCallback )
   519 	{
   540 	{
   520     FUNC_LOG;
   541     FUNC_LOG;
   521         
   542 
   522     if ( ( aFolderCallback == NULL && aSortCallback == NULL ) ||
   543     if ( ( aFolderCallback == NULL && aSortCallback == NULL ) ||
   523             aButton == NULL )
   544             aButton == NULL )
   524         {
   545         {
   525         return;
   546         return;
   526         }
   547         }
   527     
   548 
   528     // In case of popup we are not moving or copying messages,
   549     // In case of popup we are not moving or copying messages,
   529     // so there's no need to connect the mailbox
   550     // so there's no need to connect the mailbox
   530     iNoConnectNeeded = ETrue;
   551     iNoConnectNeeded = ETrue;
   531     
   552 
   532     iCallback = aFolderCallback;
   553     iCallback = aFolderCallback;
   533     iSortListCallback = aSortCallback;
   554     iSortListCallback = aSortCallback;
   534     const TPoint buttonPos( aButton->Pos().Target() );
   555     const TPoint buttonPos( aButton->Pos().Target() );
   535     const TSize buttonSize( aButton->Size().Target().AsSize() );
   556     const TSize buttonSize( aButton->Size().Target().AsSize() );
   536 
   557 
   537     // TRect from where to start the transformation effect
   558     // TRect from where to start the transformation effect
   538     iCtrlButtonRect.SetRect( buttonPos, buttonSize );
   559     TRect cbr = iAppUi.LayoutHandler()->GetControlBarRect();
       
   560     iCtrlButtonRect.SetRect( buttonPos + cbr.iTl, buttonSize );
   539 
   561 
   540     iFullScreen = EFalse;
   562     iFullScreen = EFalse;
   541 
   563 
   542     LoadIconsL();
   564     LoadIconsL();
   543     
   565 
   544     if ( !iFirstStartCompleted )
   566     if ( !iFirstStartCompleted )
   545         {
   567         {
   546         DoFirstStartL();
   568         DoFirstStartL();
   547         }
   569         }
   548 
   570 
   559 		}
   581 		}
   560 
   582 
   561 	PrepareFolderListL();
   583 	PrepareFolderListL();
   562     PopulateFolderListL();
   584     PopulateFolderListL();
   563 
   585 
   564     const TInt paddingValue( 
   586     const TInt paddingValue(
   565             iAppUi.LayoutHandler()->DropDownMenuListPadding() );
   587             iAppUi.LayoutHandler()->DropDownMenuListPadding() );
   566     const TAlfMetric paddingMetric( paddingValue );
   588     const TAlfMetric paddingMetric( paddingValue );
   567     iParentLayout->SetPadding( paddingMetric );
   589     iParentLayout->SetPadding( paddingMetric );
   568 
   590 
   569 	// Set list background
   591 	// Set list background
   574         TRect outerRect( iScreenRect );
   596         TRect outerRect( iScreenRect );
   575         outerRect.Shrink( paddingValue, paddingValue );
   597         outerRect.Shrink( paddingValue, paddingValue );
   576         iBackgroundBrush->SetFrameRectsL( outerRect, iScreenRect );
   598         iBackgroundBrush->SetFrameRectsL( outerRect, iScreenRect );
   577 		}
   599 		}
   578 
   600 
   579 	// Append brush if it's not yet appended. Currently this is our only
   601 	   // Append brush if it's not yet appended. Currently this is our only
   580 	// brush so if brush count is more than zero, this brush is already
   602 	    // brush so if brush count is more than zero, this brush is already
   581 	// appended. If other brush(es) are added later, this implementation
   603 	    // appended. If other brush(es) are added later, this implementation
   582 	// need to be changed.
   604 	    // need to be changed.
   583     if ( iParentLayout->Brushes()->Count() == 0 )
   605 	    if ( iParentLayout->Brushes()->Count() == 0 )
   584         {
   606 	        {
   585     	// Keep the ownership of the brush to avoid unneeded object
   607 	        // Keep the ownership of the brush to avoid unneeded object
   586     	// deletion / reconstruction
   608 	        // deletion / reconstruction
   587     	iParentLayout->Brushes()->AppendL( iBackgroundBrush, EAlfDoesNotHaveOwnership );
   609 	        iParentLayout->Brushes()->AppendL( iBackgroundBrush, EAlfDoesNotHaveOwnership );
   588         }
   610 	        }
   589 	
   611 	
       
   612 	if( !iShadowBrush )
       
   613 	    {
       
   614         iShadowBrush = CAlfShadowBorderBrush::NewL( 
       
   615             iEnv, TAlfMetric( KDefaultShadowBorderWidth ) );
       
   616         iShadowBrush->SetOpacity( KShadowBorderOpacity );
       
   617         iShadowBrush->SetLayer( EAlfBrushLayerBackground );
       
   618         iParentLayout->Brushes()->AppendL( iShadowBrush,
       
   619                                            EAlfDoesNotHaveOwnership );
       
   620 	    }
       
   621 
   590 	SetPopupSoftkeysL();
   622 	SetPopupSoftkeysL();
   591 	// SetRect need to be called also here, otherwise the list layout might
   623 	// SetRect need to be called also here, otherwise the list layout might
   592 	// be wrong in mirrored layout
   624 	// be wrong in mirrored layout
   593     //iParentLayout->SetRect( iScreenRect );
       
   594     iParentLayout->SetRect( iCtrlButtonRect );
   625     iParentLayout->SetRect( iCtrlButtonRect );
   595     
   626 
   596     opacity.SetValueNow( 1 );
   627     opacity.SetValueNow( 1 );
   597     //opacity.SetTarget( 1, iAppUi.LayoutHandler()->CtrlBarListFadeEffectTime() );
   628     //opacity.SetTarget( 1, iAppUi.LayoutHandler()->CtrlBarListFadeEffectTime() );
   598     iParentLayout->SetOpacity( opacity );
   629     iParentLayout->SetOpacity( opacity );
   599     iParentLayout->SetRect( iScreenRect, iAppUi.LayoutHandler()->CtrlBarListFadeEffectTime() );
   630     iParentLayout->SetRect( iScreenRect, iAppUi.LayoutHandler()->CtrlBarListFadeEffectTime() );
   600     iParentLayout->UpdateChildrenLayout();
   631     iParentLayout->UpdateChildrenLayout();
   601     iTreeList->DisableKineticScrolling( ETrue );
   632     iTreeList->DisableKineticScrolling( ETrue );
   602     iTreeList->ShowListL( ETrue );
   633     iTreeList->ShowListL( ETrue );
   603     iTreeList->SetFocusedL( ETrue );
   634     iTreeList->SetFocusedL( ETrue );
       
   635     iFocusVisible = iAppUi.IsFocusShown();
       
   636     iTreeVisualizer->SetFocusVisibility( iFocusVisible );
   604     iPopupListShown = ETrue;
   637     iPopupListShown = ETrue;
   605 	}
   638 	}
   606 
   639 
   607 // ---------------------------------------------------------------------------
   640 // ---------------------------------------------------------------------------
   608 // CFSEmailUiFolderListVisualiser::ShowInPopupL
   641 // CFSEmailUiFolderListVisualiser::ShowInPopupL
   622 // ---------------------------------------------------------------------------
   655 // ---------------------------------------------------------------------------
   623 // CFSEmailUiFolderListVisualiser::ShowSortListPopupL
   656 // CFSEmailUiFolderListVisualiser::ShowSortListPopupL
   624 // ---------------------------------------------------------------------------
   657 // ---------------------------------------------------------------------------
   625 //
   658 //
   626 void CFSEmailUiFolderListVisualiser::ShowSortListPopupL(
   659 void CFSEmailUiFolderListVisualiser::ShowSortListPopupL(
   627     const TFSMailSortField aCurrentSortOrder,
   660     const TFSMailSortCriteria aCurrentSortCriteria,
   628 	const TFSFolderType aFolderType,
   661 	const TFSFolderType aFolderType,
   629 	MFSEmailUiSortListCallback* aCallback,
   662 	MFSEmailUiSortListCallback* aCallback,
   630 	MFsControlButtonInterface* aButton )
   663 	MFsControlButtonInterface* aButton )
   631 	{
   664 	{
   632     FUNC_LOG;
   665     FUNC_LOG;
   633     iCurrentSortOrder = aCurrentSortOrder;
   666     iCurrentSortCriteria = aCurrentSortCriteria;
   634     iCurrentFolderType = aFolderType;
   667     iCurrentFolderType = aFolderType;
   635     DoShowInPopupL( aButton, NULL, aCallback );
   668     DoShowInPopupL( aButton, NULL, aCallback );
   636 	}
   669 	}
   637 
   670 
   638 // ---------------------------------------------------------------------------
   671 // ---------------------------------------------------------------------------
   645 	{
   678 	{
   646     FUNC_LOG;
   679     FUNC_LOG;
   647     iFullScreen = ETrue;
   680     iFullScreen = ETrue;
   648 
   681 
   649     LoadIconsL();
   682     LoadIconsL();
   650     
   683 
   651     if ( !iFirstStartCompleted )
   684     if ( !iFirstStartCompleted )
   652 	    {
   685 	    {
   653 	    DoFirstStartL();
   686 	    DoFirstStartL();
   654 	    }
   687 	    }
   655 
   688 
   656 	// Set title pane text
   689 	// Set title pane text
   657 	iAppUi.SetActiveMailboxNameToStatusPaneL();
   690 	iAppUi.SetActiveMailboxNameToStatusPaneL();
   658     
   691 
   659     // Different effect is used when opening folder selection list
   692     // Different effect is used when opening folder selection list
   660     iAnimateNextActivation = ( aCustomMessageId == KFolderListSelectFolder );
   693     iAnimateNextActivation = ( aCustomMessageId == KFolderListSelectFolder );
   661 
   694 
   662     // Create header image visual if not yet created
   695     // Create header image visual if not yet created
   663     if( !iHeaderImageVisual )
   696     if( !iHeaderImageVisual )
   734             {
   767             {
   735             // Hide text visual
   768             // Hide text visual
   736             iTitleCaptionVisible = EFalse;
   769             iTitleCaptionVisible = EFalse;
   737             iHeaderTextVisual->SetOpacity( KFSInvisible );
   770             iHeaderTextVisual->SetOpacity( KFSInvisible );
   738             }
   771             }
   739     
   772 
   740         // Set flag for moving or copying
   773         // Set flag for moving or copying
   741         iMoveOrCopyInitiated = (aCustomMessageId == KFolderListMoveMessage ||
   774         iMoveOrCopyInitiated = (aCustomMessageId == KFolderListMoveMessage ||
   742                                 aCustomMessageId == KFolderListMoveMessages ||
   775                                 aCustomMessageId == KFolderListMoveMessages ||
   743                                 aCustomMessageId == KFolderListCopyMessage ||
   776                                 aCustomMessageId == KFolderListCopyMessage ||
   744                                 aCustomMessageId == KFolderListCopyMessages);
   777                                 aCustomMessageId == KFolderListCopyMessages);
   747         TFolderListActivationData subView;
   780         TFolderListActivationData subView;
   748         TPckgBuf<TFolderListActivationData> viewData( subView );
   781         TPckgBuf<TFolderListActivationData> viewData( subView );
   749         viewData.Copy( aCustomMessage );
   782         viewData.Copy( aCustomMessage );
   750         iCallback = viewData().iCallback;
   783         iCallback = viewData().iCallback;
   751         iCurrentFolderType = viewData().iSourceFolderType;
   784         iCurrentFolderType = viewData().iSourceFolderType;
   752     
   785 
   753        	iTreeList->HideListL();
   786        	iTreeList->HideListL();
   754     
   787 
   755     	// Clear padding when shown in full screen
   788     	// Clear padding when shown in full screen
   756        	const TAlfMetric padding( 0 );
   789        	const TAlfMetric padding( 0 );
   757     	iParentLayout->SetPadding( padding );
   790     	iParentLayout->SetPadding( padding );
   758     	iListLayout->SetPadding( padding );
   791     	iListLayout->SetPadding( padding );
   759     
   792 
   760         PrepareFolderListL();
   793         PrepareFolderListL();
   761     
   794 
   762         // Remove need to be called for all brushes before Reset, otherwise the
   795         // Remove need to be called for all brushes before Reset, otherwise the
   763         // brush resources are not completely freed from server side -> brushes
   796         // brush resources are not completely freed from server side -> brushes
   764         // keep "hanging" there and make future drawing slower.
   797         // keep "hanging" there and make future drawing slower.
   765         while( iParentLayout->Brushes()->Count() > 0 )
   798         while( iParentLayout->Brushes()->Count() > 0 )
   766             {
   799             {
   767             iParentLayout->Brushes()->Remove( 0 );
   800             iParentLayout->Brushes()->Remove( 0 );
   768             }
   801             }
   769     	iParentLayout->Brushes()->Reset();
   802     	iParentLayout->Brushes()->Reset();
   770     	
   803 
   771     	TAlfTimedValue layoutOpacity = iHeaderLayout->Opacity();
   804     	TAlfTimedValue layoutOpacity = iHeaderLayout->Opacity();
   772     	layoutOpacity.SetTarget( 1, iAppUi.LayoutHandler()->CtrlBarListFadeEffectTime()/2 );
   805     	layoutOpacity.SetTarget( 1, iAppUi.LayoutHandler()->CtrlBarListFadeEffectTime()/2 );
   773     	iHeaderLayout->SetOpacity( layoutOpacity );
   806     	iHeaderLayout->SetOpacity( layoutOpacity );
   774     	
   807 
   775     	TAlfTimedValue bgImageOpacity = iListBgImageVisual->Opacity();
   808     	TAlfTimedValue bgImageOpacity = iListBgImageVisual->Opacity();
   776     	bgImageOpacity.SetTarget( 1, iAppUi.LayoutHandler()->CtrlBarListFadeEffectTime()/2 );
   809     	bgImageOpacity.SetTarget( 1, iAppUi.LayoutHandler()->CtrlBarListFadeEffectTime()/2 );
   777     	iListBgImageVisual->SetOpacity( bgImageOpacity );
   810     	iListBgImageVisual->SetOpacity( bgImageOpacity );
   778     
   811 
   779     	// Reset the variables used in horizontal scrolling
   812     	// Reset the variables used in horizontal scrolling
   780     	iPreviousListRect = iListLayout->DisplayRectTarget();
   813     	iPreviousListRect = iListLayout->DisplayRectTarget();
   781         iPreviousListLevel = KListRootLevel;
   814         iPreviousListLevel = KListRootLevel;
   782     
   815 
   783         iParentLayout->SetRect( iScreenRect );
   816         iParentLayout->SetRect( iScreenRect );
   784         iTreeList->ShowListL();
   817         iTreeList->ShowListL();
   785 
   818 
   786         TAlfTimedValue opacity;
   819         TAlfTimedValue opacity;
   787         opacity.SetValueNow( 1 );
   820         opacity.SetValueNow( 1 );
   790 
   823 
   791     // See if we are already connected
   824     // See if we are already connected
   792     CFSMailBox* mb = iAppUi.GetActiveMailbox();
   825     CFSMailBox* mb = iAppUi.GetActiveMailbox();
   793     // Just in case, shouldn't happen
   826     // Just in case, shouldn't happen
   794     User::LeaveIfNull( mb );
   827     User::LeaveIfNull( mb );
   795     
   828 
   796     TFSMailBoxStatus onlineStatus = mb->GetMailBoxStatus();
   829     TFSMailBoxStatus onlineStatus = mb->GetMailBoxStatus();
   797 
   830 
   798     // If we are not moving or copying messages, there's no need to connect
   831     // If we are not moving or copying messages, there's no need to connect
   799     // the mailbox. In case of move/copy we need to check the mailbox
   832     // the mailbox. In case of move/copy we need to check the mailbox
   800     // capability to see if we need to connect the mailbox before showing the
   833     // capability to see if we need to connect the mailbox before showing the
   823         {
   856         {
   824         // If we come here it means that the mailbox is offline but connection
   857         // If we come here it means that the mailbox is offline but connection
   825         // is needed for this operation, so we need to connect first
   858         // is needed for this operation, so we need to connect first
   826         ConnectToMailboxL();
   859         ConnectToMailboxL();
   827         }
   860         }
       
   861     FocusVisibilityChange( iAppUi.IsFocusShown() );
   828 	}
   862 	}
   829 
   863 
   830 // ---------------------------------------------------------------------------
   864 // ---------------------------------------------------------------------------
   831 // CFSEmailUiFolderListVisualiser::OfferToolbarEventL
   865 // CFSEmailUiFolderListVisualiser::OfferToolbarEventL
   832 // ---------------------------------------------------------------------------
   866 // ---------------------------------------------------------------------------
   856 //
   890 //
   857 TInt CFSEmailUiFolderListVisualiser::ToolbarResourceId() const
   891 TInt CFSEmailUiFolderListVisualiser::ToolbarResourceId() const
   858     {
   892     {
   859     return R_FREESTYLE_EMAIL_UI_TOOLBAR_FOLDER_LIST;
   893     return R_FREESTYLE_EMAIL_UI_TOOLBAR_FOLDER_LIST;
   860     }
   894     }
   861 	
   895 
   862 // ---------------------------------------------------------------------------
   896 // ---------------------------------------------------------------------------
   863 // Deactivate this view
   897 // Deactivate this view
   864 // ---------------------------------------------------------------------------
   898 // ---------------------------------------------------------------------------
   865 //
   899 //
   866 void CFSEmailUiFolderListVisualiser::ChildDoDeactivate()
   900 void CFSEmailUiFolderListVisualiser::ChildDoDeactivate()
   881 void CFSEmailUiFolderListVisualiser::SetFocusToCurrentSortItemL()
   915 void CFSEmailUiFolderListVisualiser::SetFocusToCurrentSortItemL()
   882     {
   916     {
   883     FUNC_LOG;
   917     FUNC_LOG;
   884     if ( iFirstStartCompleted ) // Safety
   918     if ( iFirstStartCompleted ) // Safety
   885         {
   919         {
   886         for ( TInt i=0; i < iModel->Count() ; i++ )
   920         for ( TInt i = 0; i < iModel->Count(); i++ )
   887             {
   921         	{
   888             CFSEmailUiFolderListItem* modelItem = iModel->ItemByIndex( i );
   922         	CFSEmailUiFolderListItem* modelItem = iModel->ItemByIndex( i );
   889             if ( modelItem && ( modelItem->iSortField == iCurrentSortOrder ) )
   923         	if ( modelItem && ( modelItem->iSortField == iCurrentSortCriteria.iField ) )
   890                 {
   924         		{
   891                 iTreeVisualizer->SetFocusedItemL( modelItem->iListId, EFalse );
   925         		iTreeVisualizer->SetFocusedItemL( modelItem->iListId, EFalse );
   892                 break;          
   926         		break;
   893                 }
   927         		}
   894             }
   928         	}
       
   929 	
       
   930 		// Bold the focused item's text
       
   931 		TInt arraySize = iListItemVisulizers.Count();
       
   932 		for( TInt i = 0; i < arraySize; i++ )
       
   933 			{
       
   934 			TFsTreeItemId id = iTreeList->FocusedItem();
       
   935 			if ( iListItemVisulizers[ i ] == &( iTreeList->ItemVisualizer( id ) ) )
       
   936 				{
       
   937 				iListItemVisulizers[i]->SetTextBold( ETrue );
       
   938 				break;
       
   939 				}
       
   940 			}
   895         }
   941         }
   896     }
   942     }
   897 
   943 
   898 // ---------------------------------------------------------------------------
   944 // ---------------------------------------------------------------------------
   899 // In case of folder list popup, this function sets focus to current folder,
   945 // In case of folder list popup, this function sets focus to current folder,
   911             {
   957             {
   912             CFSEmailUiFolderListItem* modelItem = iModel->ItemByIndex( i );
   958             CFSEmailUiFolderListItem* modelItem = iModel->ItemByIndex( i );
   913             if ( modelItem && ( modelItem->iFolderId == iCurrentFolderId ) )
   959             if ( modelItem && ( modelItem->iFolderId == iCurrentFolderId ) )
   914                 {
   960                 {
   915                 itemToFocus = modelItem->iListId;
   961                 itemToFocus = modelItem->iListId;
   916                 break;          
   962                 break;
   917                 }
   963                 }
   918             }
   964             }
   919         iTreeVisualizer->SetFocusedItemL( itemToFocus, EFalse );
   965         iTreeVisualizer->SetFocusedItemL( itemToFocus, EFalse );
   920         }
   966         }
   921     }
   967     }
   937 	              !modelItem->iFolderId.IsNullId() && // Filter mailbox and sort items
   983 	              !modelItem->iFolderId.IsNullId() && // Filter mailbox and sort items
   938 	              modelItem->iFolderId == iLatestSelectedMoveFolderId )
   984 	              modelItem->iFolderId == iLatestSelectedMoveFolderId )
   939 	             {
   985 	             {
   940 	             match = ETrue;
   986 	             match = ETrue;
   941 	             iTreeVisualizer->SetFocusedItemL( modelItem->iListId );
   987 	             iTreeVisualizer->SetFocusedItemL( modelItem->iListId );
   942 	             break;          
   988 	             break;
   943 	             }
   989 	             }
   944 	         }
   990 	         }
   945 
   991 
   946 	     if ( match )
   992 	     if ( match )
   947 	         {
   993 	         {
   961 // ---------------------------------------------------------------------------
  1007 // ---------------------------------------------------------------------------
   962 //
  1008 //
   963 TBool CFSEmailUiFolderListVisualiser::OfferEventL(const TAlfEvent& aEvent)
  1009 TBool CFSEmailUiFolderListVisualiser::OfferEventL(const TAlfEvent& aEvent)
   964     {
  1010     {
   965     FUNC_LOG;
  1011     FUNC_LOG;
   966     TBool result( EFalse ); 
  1012     TBool result( EFalse );
   967     if ( aEvent.IsKeyEvent() && aEvent.Code() == EEventKey )
  1013     if ( aEvent.IsKeyEvent() && aEvent.Code() == EEventKey )
   968         {
  1014         {
   969         // Swap left and right with mirrored layout
  1015         // Swap left and right with mirrored layout
   970         TInt scanCode = aEvent.KeyEvent().iScanCode;
  1016         TInt scanCode( aEvent.KeyEvent().iScanCode );
   971         if ( AknLayoutUtils::LayoutMirrored() )
  1017         if ( AknLayoutUtils::LayoutMirrored() )
   972             {
  1018             {
   973             if ( scanCode == EStdKeyLeftArrow ) scanCode = EStdKeyRightArrow;
  1019             if( scanCode == EStdKeyLeftArrow )
   974             else if ( scanCode == EStdKeyRightArrow ) scanCode = EStdKeyLeftArrow;
  1020                 {
   975             }
  1021                 scanCode = EStdKeyRightArrow;
   976         
  1022                 }
       
  1023             else if( scanCode == EStdKeyRightArrow )
       
  1024                 {
       
  1025                 scanCode = EStdKeyLeftArrow;
       
  1026                 }
       
  1027             }
       
  1028 
       
  1029         // Handle possible focus visibility change
       
  1030         if( ( scanCode == EStdKeyRightArrow ) ||
       
  1031             ( scanCode == EStdKeyLeftArrow ) ||
       
  1032             ( scanCode == EStdKeyUpArrow ) ||
       
  1033             ( scanCode == EStdKeyDownArrow ) ||
       
  1034             ( scanCode == EStdKeyEnter ) ||
       
  1035             ( scanCode == EStdKeyDeviceA ) ||
       
  1036             ( scanCode == EStdKeyDevice3 ) )
       
  1037             {
       
  1038             // If the focus was not active already, ignore the key press
       
  1039             if( !iAppUi.SetFocusVisibility( ETrue ) )
       
  1040                 {
       
  1041                 return ETrue;
       
  1042                 }
       
  1043             }
       
  1044 
   977         switch ( scanCode )
  1045         switch ( scanCode )
   978             {
  1046             {
   979             case EStdKeyDevice3:	// CENTER CLICK
  1047             case EStdKeyDevice3:	// CENTER CLICK
   980             case EStdKeyEnter:		// ENTER
  1048             case EStdKeyEnter:		// ENTER
   981             	{
  1049             	{
   995             	// Check is the sort list open
  1063             	// Check is the sort list open
   996             	else if( !iFullScreen && iSortListCallback )
  1064             	else if( !iFullScreen && iSortListCallback )
   997             		{
  1065             		{
   998             		HandleSelectionL( EFSEmailUiCtrlBarResponseSwitchList );
  1066             		HandleSelectionL( EFSEmailUiCtrlBarResponseSwitchList );
   999             		}
  1067             		}
  1000  	           	}            
  1068  	           	}
  1001                 break;
  1069                 break;
  1002 
  1070 
  1003 	        case EStdKeyRightArrow:
  1071 	        case EStdKeyRightArrow:
  1004             	{
  1072             	{
  1005             	// Check is the folder list open
  1073             	// Check is the folder list open
  1015             	}
  1083             	}
  1016 				break;
  1084 				break;
  1017 
  1085 
  1018              default:
  1086              default:
  1019 	       	    // Check keyboard shortcuts.
  1087 	       	    // Check keyboard shortcuts.
  1020 	       	    TInt shortcutCommand = 
  1088 	       	    TInt shortcutCommand =
  1021 	       	        iAppUi.ShortcutBinding().CommandForShortcutKey( aEvent.KeyEvent(),
  1089 	       	        iAppUi.ShortcutBinding().CommandForShortcutKey( aEvent.KeyEvent(),
  1022 	       	                                                         CFSEmailUiShortcutBinding::EContextFolderList );
  1090 	       	                                                         CFSEmailUiShortcutBinding::EContextFolderList );
  1023 	       	    if ( shortcutCommand != KErrNotFound )
  1091 	       	    if ( shortcutCommand != KErrNotFound )
  1024 	       	        {
  1092 	       	        {
  1025        	            HandleCommandL( shortcutCommand );
  1093        	            HandleCommandL( shortcutCommand );
  1026 	       	        result = ETrue;
  1094 	       	        result = ETrue;
  1027 	       	        }
  1095 	       	        }
  1028                 break;
  1096                 break;
  1029             }
  1097             }
  1030         }      
  1098         }
  1031     return result;
  1099     return result;
  1032     }
  1100     }
  1033 
  1101 
  1034 // ---------------------------------------------------------------------------
  1102 // ---------------------------------------------------------------------------
  1035 // CFSEmailUiFolderListVisualiser::HandlePointerEventL
  1103 // CFSEmailUiFolderListVisualiser::HandlePointerEventL
  1036 // ---------------------------------------------------------------------------
  1104 // ---------------------------------------------------------------------------
  1037 //      
  1105 //
  1038 TBool CFSEmailUiFolderListVisualiser::HandlePointerEventL(const TAlfEvent& aEvent)
  1106 TBool CFSEmailUiFolderListVisualiser::HandlePointerEventL(const TAlfEvent& aEvent)
  1039     {
  1107     {
  1040     // Handle pointer events to fadervisual. If the list is shown in popup, then
  1108     TBool eventHandled( EFalse );
  1041     // the popup will be closed.
  1109 
  1042     if ((aEvent.Visual() == iFaderVisual || aEvent.Visual() == iFaderLayout) && aEvent.PointerEvent().iType == TPointerEvent::EButton1Down && iPopupListShown)
  1110     if( ( aEvent.Visual() == iFaderVisual || aEvent.Visual() == iFaderLayout ) &&
  1043         {
  1111         ( aEvent.PointerEvent().iType == TPointerEvent::EButton1Down  ) &&
       
  1112         ( iPopupListShown ) )
       
  1113         {
       
  1114         iAppUi.SetFocusVisibility( EFalse );
  1044         HandleSelectionL( EFSEmailUiCtrlBarResponseCancel );
  1115         HandleSelectionL( EFSEmailUiCtrlBarResponseCancel );
       
  1116         eventHandled = ETrue;
  1045         }
  1117         }
  1046     else
  1118     else
  1047         {
  1119         {
  1048         return iTreeList->TreeControl()->OfferEventL(aEvent);
  1120         // Handle pointer events to fadervisual. If the list is shown in popup,
  1049         }
  1121         // then the popup will be closed.
  1050     return ETrue;     
  1122         if( ( aEvent.IsPointerEvent() ) &&
       
  1123             ( aEvent.PointerEvent().iType == TPointerEvent::EButton1Up ) )
       
  1124             {
       
  1125             eventHandled = iTreeList->TreeControl()->OfferEventL(aEvent);
       
  1126             // Hide focus visibility always after pointer up event.
       
  1127             iAppUi.SetFocusVisibility( EFalse );
       
  1128             }
       
  1129         else 
       
  1130         	{
       
  1131         	eventHandled = iTreeList->TreeControl()->OfferEventL(aEvent);
       
  1132         	}
       
  1133         }
       
  1134     return eventHandled;
  1051     }
  1135     }
  1052 
  1136 
  1053 // ---------------------------------------------------------------------------
  1137 // ---------------------------------------------------------------------------
  1054 // CFSEmailUiFolderListVisualiser::DynInitMenuPaneL
  1138 // CFSEmailUiFolderListVisualiser::DynInitMenuPaneL
  1055 // ---------------------------------------------------------------------------
  1139 // ---------------------------------------------------------------------------
  1063         if ( aResourceId == R_FSEMAILUI_FOLDERLIST_MENUPANE )
  1147         if ( aResourceId == R_FSEMAILUI_FOLDERLIST_MENUPANE )
  1064             {
  1148             {
  1065             if ( FeatureManager::FeatureSupported( KFeatureIdFfCmailIntegration ) )
  1149             if ( FeatureManager::FeatureSupported( KFeatureIdFfCmailIntegration ) )
  1066         	   {
  1150         	   {
  1067         	   // remove help support in pf5250
  1151         	   // remove help support in pf5250
  1068         	   aMenuPane->SetItemDimmed( EFsEmailUiCmdHelp, ETrue);      
  1152         	   aMenuPane->SetItemDimmed( EFsEmailUiCmdHelp, ETrue);
  1069         	   }
  1153         	   }
  1070             
  1154 
  1071             // OFFLINE/ONLINE MENU SELECTION
  1155             // OFFLINE/ONLINE MENU SELECTION
  1072             if( iMoveOrCopyInitiated )
  1156             if( iMoveOrCopyInitiated )
  1073                 {
  1157                 {
  1074                 TFSMailBoxStatus onlineStatus = iAppUi.GetActiveMailbox()->GetMailBoxStatus();
  1158                 TFSMailBoxStatus onlineStatus = iAppUi.GetActiveMailbox()->GetMailBoxStatus();
  1075                 aMenuPane->SetItemDimmed( EFsEmailUiCmdGoOnline, onlineStatus == EFSMailBoxOnline );                            
  1159                 aMenuPane->SetItemDimmed( EFsEmailUiCmdGoOnline, onlineStatus == EFSMailBoxOnline );
  1076                 aMenuPane->SetItemDimmed( EFsEmailUiCmdGoOffline, onlineStatus == EFSMailBoxOffline );      
  1160                 aMenuPane->SetItemDimmed( EFsEmailUiCmdGoOffline, onlineStatus == EFSMailBoxOffline );
  1077                 }
  1161                 }
  1078             else
  1162             else
  1079                 {
  1163                 {
  1080                 aMenuPane->SetItemDimmed( EFsEmailUiCmdGoOnline, ETrue );                            
  1164                 aMenuPane->SetItemDimmed( EFsEmailUiCmdGoOnline, ETrue );
  1081                 aMenuPane->SetItemDimmed( EFsEmailUiCmdGoOffline, ETrue );      
  1165                 aMenuPane->SetItemDimmed( EFsEmailUiCmdGoOffline, ETrue );
  1082                 }
  1166                 }
  1083 
  1167 
  1084             // select option
  1168             // select option
  1085             aMenuPane->SetItemDimmed( EFsEmailUiCmdSelect, iModel->Count() == 0 );
  1169             aMenuPane->SetItemDimmed( EFsEmailUiCmdSelect, iModel->Count() == 0 );
  1086 
  1170 
  1087             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsCollapseAll, AllNodesCollapsed() );
  1171             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsCollapseAll, AllNodesCollapsed() );
  1088             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsExpandAll, AllNodesExpanded() );
  1172             aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsExpandAll, AllNodesExpanded() );
  1089             }
  1173             }
  1090          
  1174 
  1091         // Add shortcut hints
  1175         // Add shortcut hints
  1092         iAppUi.ShortcutBinding().AppendShortcutHintsL( *aMenuPane, 
  1176         iAppUi.ShortcutBinding().AppendShortcutHintsL( *aMenuPane,
  1093                                     CFSEmailUiShortcutBinding::EContextFolderList );
  1177                                     CFSEmailUiShortcutBinding::EContextFolderList );
  1094         }
  1178         }
  1095 	}
  1179 	}
  1096 
  1180 
  1097 
  1181 
  1098 // ---------------------------------------------------------------------------
  1182 // ---------------------------------------------------------------------------
  1099 // 
  1183 //
  1100 // ---------------------------------------------------------------------------
  1184 // ---------------------------------------------------------------------------
  1101 //
  1185 //
  1102 void CFSEmailUiFolderListVisualiser::HandleSelectionL( TFSEmailUiCtrlBarResponse aSelection )
  1186 void CFSEmailUiFolderListVisualiser::HandleSelectionL( TFSEmailUiCtrlBarResponse aSelection )
  1103     {
  1187     {
  1104     FUNC_LOG;
  1188     FUNC_LOG;
  1105     // If popup is not open or the view is not active, then do nothing
  1189     // If popup is not open or the view is not active, then do nothing
  1106     if ( !(iPopupListShown || IsViewActive()) )
  1190     if ( !(iPopupListShown || IsViewActive()) )
  1107         {
  1191         {
  1108         return;
  1192         return;
  1109         }
  1193         }
  1110     
  1194 
  1111     TBool popupHiddenAlready(EFalse);
  1195     TBool popupHiddenAlready(EFalse);
  1112     switch( aSelection )
  1196     switch( aSelection )
  1113         {
  1197         {
  1114         case EFSEmailUiCtrlBarResponseSelect:
  1198         case EFSEmailUiCtrlBarResponseSelect:
  1115             {
  1199             {
  1142                     HidePopupL();
  1226                     HidePopupL();
  1143                     }
  1227                     }
  1144 
  1228 
  1145                 iAppUi.FolderPopupClosed();
  1229                 iAppUi.FolderPopupClosed();
  1146                 }
  1230                 }
  1147                 
  1231 
  1148             if ( !iFullScreen && iSortListCallback )
  1232             if ( !iFullScreen && iSortListCallback )
  1149                 {
  1233                 {
  1150                 iSortListCallback->SortOrderChangedL( EFSMailDontCare, aSelection );
  1234                 iSortListCallback->SortOrderChangedL( EFSMailDontCare, aSelection );
  1151                 iSortListCallback = NULL;
  1235                 iSortListCallback = NULL;
  1152                 }
  1236                 }
  1182 		return GetRootParent( parentId );
  1266 		return GetRootParent( parentId );
  1183 		}
  1267 		}
  1184 	}
  1268 	}
  1185 
  1269 
  1186 // ---------------------------------------------------------------------------
  1270 // ---------------------------------------------------------------------------
  1187 // Override the default transition effect in case full screen mode is launched 
  1271 // Override the default transition effect in case full screen mode is launched
  1188 // from popup mode.
  1272 // from popup mode.
  1189 // ---------------------------------------------------------------------------
  1273 // ---------------------------------------------------------------------------
  1190 //
  1274 //
  1191 void CFSEmailUiFolderListVisualiser::DoTransitionEffect( TBool aDirectionOut )
  1275 void CFSEmailUiFolderListVisualiser::DoTransitionEffect( TBool aDirectionOut )
  1192     {
  1276     {
  1193     FUNC_LOG;
  1277     FUNC_LOG;
  1194     if ( !aDirectionOut && IsFullScreen() && iAnimateNextActivation )
  1278     if ( !aDirectionOut && IsFullScreen() && iAnimateNextActivation )
  1195         {
  1279         {
  1196         TInt rectTransitionTime = iAppUi.LayoutHandler()->CtrlBarListFadeEffectTime();
  1280         TInt rectTransitionTime = iAppUi.LayoutHandler()->CtrlBarListFadeEffectTime();
  1197         TInt opacityTransitionTime = iAppUi.LayoutHandler()->CtrlBarListFadeEffectTime() / 2;
  1281         TInt opacityTransitionTime = iAppUi.LayoutHandler()->CtrlBarListFadeEffectTime() / 2;
  1198         
  1282 
  1199         TAlfTimedValue opacity;
  1283         TAlfTimedValue opacity;
  1200         opacity.SetValueNow( 0 );
  1284         opacity.SetValueNow( 0 );
  1201         opacity.SetTarget( 1, opacityTransitionTime );
  1285         opacity.SetTarget( 1, opacityTransitionTime );
  1202         iParentLayout->SetOpacity( opacity );
  1286         iParentLayout->SetOpacity( opacity );
  1203         
  1287 
  1204         // Do animated enlargening from popup window rect to full screen rect
  1288         // Do animated enlargening from popup window rect to full screen rect
  1205         iParentLayout->SetRect( FolderListRectInThisResolution() );
  1289         iParentLayout->SetRect( FolderListRectInThisResolution() );
  1206         iParentLayout->SetRect( iScreenRect, rectTransitionTime );
  1290         iParentLayout->SetRect( iScreenRect, rectTransitionTime );
  1207         }
  1291         }
  1208     else
  1292     else
  1234          {
  1318          {
  1235          switch(aCommand)
  1319          switch(aCommand)
  1236               {
  1320               {
  1237               // Key presses
  1321               // Key presses
  1238               case EAknSoftkeySelect:
  1322               case EAknSoftkeySelect:
       
  1323                   {
       
  1324                   // If focus is not visible, make it visible
       
  1325                   // otherwise fall through ( call HandleSelectionL )
       
  1326                   if( !iFocusVisible )
       
  1327                       {
       
  1328                       iAppUi.SetFocusVisibility( ETrue );
       
  1329                       break;
       
  1330                       }
       
  1331                   }
  1239               case EAknSoftkeyOpen:
  1332               case EAknSoftkeyOpen:
  1240               case EFsEmailUiCmdOpen:
  1333               case EFsEmailUiCmdOpen:
  1241               case EFsEmailUiCmdSelect:
  1334               case EFsEmailUiCmdSelect:
  1242                   {
  1335                   {
  1243                   HandleSelectionL( EFSEmailUiCtrlBarResponseSelect );
  1336                   HandleSelectionL( EFSEmailUiCtrlBarResponseSelect );
  1244                   }
  1337                   }
  1245                   break;
  1338                   break;
  1246                   
  1339 
  1247               case EAknSoftkeyBack:
  1340               case EAknSoftkeyBack:
  1248               case EEikBidCancel:
  1341               case EEikBidCancel:
  1249                   {
  1342                   {
  1250                   HandleSelectionL( EFSEmailUiCtrlBarResponseCancel );
  1343                   HandleSelectionL( EFSEmailUiCtrlBarResponseCancel );
  1251                   }
  1344                   }
  1280                   }
  1373                   }
  1281                   break;
  1374                   break;
  1282 
  1375 
  1283               case EFsEmailUiCmdActionsExpandAll:
  1376               case EFsEmailUiCmdActionsExpandAll:
  1284                   {
  1377                   {
  1285                   TFsTreeItemId prevId = iTreeList->FocusedItem();    
  1378                   TFsTreeItemId prevId = iTreeList->FocusedItem();
  1286                   iTreeVisualizer->ExpandAllL();
  1379                   iTreeVisualizer->ExpandAllL();
  1287                   if ( prevId != KFsTreeRootID && prevId != KFsTreeNoneID )
  1380                   if ( prevId != KFsTreeRootID && prevId != KFsTreeNoneID )
  1288                       {
  1381                       {
  1289                       iTreeVisualizer->SetFocusedItemL( prevId );
  1382                       iTreeVisualizer->SetFocusedItemL( prevId );
  1290                       }
  1383                       }
  1295                   {
  1388                   {
  1296                   CESMailSettingsPlugin::TSubViewActivationData activationData;
  1389                   CESMailSettingsPlugin::TSubViewActivationData activationData;
  1297                   activationData.iAccount = iAppUi.GetActiveMailbox()->GetId();
  1390                   activationData.iAccount = iAppUi.GetActiveMailbox()->GetId();
  1298                   activationData.iSubviewId = 1;
  1391                   activationData.iSubviewId = 1;
  1299                   activationData.iLaunchFolderSettings = ETrue;
  1392                   activationData.iLaunchFolderSettings = ETrue;
  1300                   
  1393 
  1301                   TUid pluginUid = iAppUi.GetActiveMailbox()->GetSettingsUid();
  1394                   TUid pluginUid = iAppUi.GetActiveMailbox()->GetSettingsUid();
  1302                   // register plugin view if not exists so that activation can be made
  1395                   // register plugin view if not exists so that activation can be made
  1303                   if ( !iAppUi.View( pluginUid ) )
  1396                   if ( !iAppUi.View( pluginUid ) )
  1304                       {
  1397                       {
  1305                       CESMailSettingsPlugin* plugin = CESMailSettingsPlugin::NewL( pluginUid );
  1398                       CESMailSettingsPlugin* plugin = CESMailSettingsPlugin::NewL( pluginUid );
  1306                       CleanupStack::PushL( plugin );
  1399                       CleanupStack::PushL( plugin );
  1307                       iAppUi.AddViewL( plugin );
  1400                       iAppUi.AddViewL( plugin );
  1308                       CleanupStack::Pop( plugin );        
  1401                       CleanupStack::Pop( plugin );
  1309                       }
  1402                       }
  1310                   TUid messageId = TUid::Uid( CESMailSettingsPlugin::EActivateMailSettingsSubview );
  1403                   TUid messageId = TUid::Uid( CESMailSettingsPlugin::EActivateMailSettingsSubview );
  1311                   const TPckgBuf<CESMailSettingsPlugin::TSubViewActivationData> pluginMessagePkg( activationData );
  1404                   const TPckgBuf<CESMailSettingsPlugin::TSubViewActivationData> pluginMessagePkg( activationData );
  1312                   iAppUi.EnterPluginSettingsViewL( pluginUid, messageId, pluginMessagePkg );
  1405                   iAppUi.EnterPluginSettingsViewL( pluginUid, messageId, pluginMessagePkg );
  1313                   
  1406 
  1314                   // Hide list to avoid it flashing when returning back
  1407                   // Hide list to avoid it flashing when returning back
  1315                   iTreeList->HideListL();
  1408                   iTreeList->HideListL();
  1316                   }
  1409                   }
  1317                   break;
  1410                   break;
  1318 
  1411 
  1322                   }
  1415                   }
  1323                   break;
  1416                   break;
  1324 
  1417 
  1325               case EFsEmailUiCmdExit:
  1418               case EFsEmailUiCmdExit:
  1326                   {
  1419                   {
  1327                   iAppUi.Exit();      
  1420                   iAppUi.Exit();
  1328                   }
  1421                   }
  1329                   break;
  1422                   break;
  1330 
  1423 
  1331               case EFsEmailUiCmdGoToTop:
  1424               case EFsEmailUiCmdGoToTop:
  1332                   {
  1425                   {
  1333                   GoToTopL();
  1426                   GoToTopL();
  1334                   }
  1427                   }
  1335                   break;
  1428                   break;
  1336                   
  1429 
  1337               case EFsEmailUiCmdGoToBottom:
  1430               case EFsEmailUiCmdGoToBottom:
  1338                   {
  1431                   {
  1339                   GoToBottomL();
  1432                   GoToBottomL();
  1340                   }
  1433                   }
  1341                   break;
  1434                   break;
  1342               
  1435 
  1343               case EFsEmailUiCmdPageUp:
  1436               case EFsEmailUiCmdPageUp:
  1344                   {
  1437                   {
  1345                   TKeyEvent simEvent = { EKeyPageUp, EStdKeyPageUp, 0, 0 };
  1438                   TKeyEvent simEvent = { EKeyPageUp, EStdKeyPageUp, 0, 0 };
  1346                   iCoeEnv->SimulateKeyEventL( simEvent, EEventKey );
  1439                   iCoeEnv->SimulateKeyEventL( simEvent, EEventKey );
  1347                   }
  1440                   }
  1348                   break;
  1441                   break;
  1349                   
  1442 
  1350               case EFsEmailUiCmdPageDown:
  1443               case EFsEmailUiCmdPageDown:
  1351                   {
  1444                   {
  1352                   TKeyEvent simEvent = { EKeyPageDown, EStdKeyPageDown, 0, 0 };
  1445                   TKeyEvent simEvent = { EKeyPageDown, EStdKeyPageDown, 0, 0 };
  1353                   iCoeEnv->SimulateKeyEventL( simEvent, EEventKey );
  1446                   iCoeEnv->SimulateKeyEventL( simEvent, EEventKey );
  1354                   }
  1447                   }
  1359                   if ( !AllNodesCollapsed() )
  1452                   if ( !AllNodesCollapsed() )
  1360                       {
  1453                       {
  1361                       HandleCommandL( EFsEmailUiCmdActionsCollapseAll );
  1454                       HandleCommandL( EFsEmailUiCmdActionsCollapseAll );
  1362                       }
  1455                       }
  1363                   else
  1456                   else
  1364                       {       
  1457                       {
  1365                       HandleCommandL( EFsEmailUiCmdActionsExpandAll );
  1458                       HandleCommandL( EFsEmailUiCmdActionsExpandAll );
  1366                       }
  1459                       }
  1367                   }
  1460                   }
  1368                   break;
  1461                   break;
  1369                   
  1462 
  1370               default:
  1463               default:
  1371                   break;
  1464                   break;
  1372               }        
  1465               }
  1373          }
  1466          }
  1374     }
  1467     }
  1375 
  1468 
  1376 // ---------------------------------------------------------------------------
  1469 // ---------------------------------------------------------------------------
  1377 // Handle call to callback function
  1470 // Handle call to callback function
  1384 
  1477 
  1385     if( focusedItem == KFsTreeNoneID )
  1478     if( focusedItem == KFsTreeNoneID )
  1386     	{
  1479     	{
  1387     	return ETrue;
  1480     	return ETrue;
  1388     	}
  1481     	}
  1389     
  1482 
  1390     if( focusedItem == iMoreFoldersItemId )
  1483     if( focusedItem == iMoreFoldersItemId )
  1391     	{
  1484     	{
  1392         //HidePopupL();
  1485         //HidePopupL();
  1393         iFullScreen = ETrue;
  1486         iFullScreen = ETrue;
  1394 
  1487 
  1395 		TFolderListActivationData tmp;	
  1488 		TFolderListActivationData tmp;
  1396 	    tmp.iCallback = iCallback;
  1489 	    tmp.iCallback = iCallback;
  1397 		const TPckgBuf<TFolderListActivationData> pkgOut( tmp );
  1490 		const TPckgBuf<TFolderListActivationData> pkgOut( tmp );
  1398 
  1491 
  1399 		iAppUi.EnterFsEmailViewL( FolderListId, KFolderListSelectFolder, pkgOut );
  1492 		iAppUi.EnterFsEmailViewL( FolderListId, KFolderListSelectFolder, pkgOut );
  1400 		
  1493 
  1401         return EFalse;
  1494         return EFalse;
  1402     	}
  1495     	}
  1403 
  1496 
  1404     CFSEmailUiFolderListItem* modelItem = iModel->ItemByListId( focusedItem );
  1497     CFSEmailUiFolderListItem* modelItem = iModel->ItemByListId( focusedItem );
  1405 	if( !modelItem ) // Safety check, shouldn't be possible
  1498 	if( !modelItem ) // Safety check, shouldn't be possible
  1406 		{
  1499 		{
  1407 		return EFalse;
  1500 		return EFalse;
  1408 		}
  1501 		}
  1409 		
  1502 
  1410 	if( iCallback )
  1503 	if( iCallback )
  1411 		{
  1504 		{
  1412 		const TFSMailMsgId& selectedFolderId = modelItem->iFolderId;
  1505 		const TFSMailMsgId& selectedFolderId = modelItem->iFolderId;
  1413 		const TFSMailMsgId& selectedMailboxId = modelItem->iMailboxId;
  1506 		const TFSMailMsgId& selectedMailboxId = modelItem->iMailboxId;
  1414         if( !selectedFolderId.IsNullId() )
  1507         if( !selectedFolderId.IsNullId() )
  1415         	{
  1508         	{
  1416     		if ( iCustomMessageId == KFolderListMoveMessage || 
  1509     		if ( iCustomMessageId == KFolderListMoveMessage ||
  1417     			 iCustomMessageId == KFolderListMoveMessages ||
  1510     			 iCustomMessageId == KFolderListMoveMessages ||
  1418     		     iCustomMessageId == KFolderListCopyMessage ||
  1511     		     iCustomMessageId == KFolderListCopyMessage ||
  1419     		     iCustomMessageId == KFolderListCopyMessages )
  1512     		     iCustomMessageId == KFolderListCopyMessages )
  1420     			{
  1513     			{
  1421     			iLatestSelectedMoveFolderId = selectedFolderId;
  1514     			iLatestSelectedMoveFolderId = selectedFolderId;
  1422     			}		        	
  1515     			}
  1423   	       	iCallback->FolderSelectedL( selectedFolderId, EFSEmailUiCtrlBarResponseSelect );
  1516   	       	iCallback->FolderSelectedL( selectedFolderId, EFSEmailUiCtrlBarResponseSelect );
  1424         	}
  1517         	}
  1425         else if( !selectedMailboxId.IsNullId() )
  1518         else if( !selectedMailboxId.IsNullId() )
  1426         	{
  1519         	{
  1427         	iCallback->MailboxSelectedL( selectedMailboxId );
  1520         	iCallback->MailboxSelectedL( selectedMailboxId );
  1435         iSortListCallback->SortOrderChangedL( modelItem->iSortField, EFSEmailUiCtrlBarResponseSelect );
  1528         iSortListCallback->SortOrderChangedL( modelItem->iSortField, EFSEmailUiCtrlBarResponseSelect );
  1436         // Set callback to NULL after callback is called so that the
  1529         // Set callback to NULL after callback is called so that the
  1437         // same callback is not reused unintentionally.
  1530         // same callback is not reused unintentionally.
  1438         iSortListCallback = NULL;
  1531         iSortListCallback = NULL;
  1439 		}
  1532 		}
  1440 		
  1533 
  1441     return ETrue;
  1534     return ETrue;
  1442 	}
  1535 	}
  1443 
  1536 
  1444 
  1537 
  1445 // ---------------------------------------------------------------------------
  1538 // ---------------------------------------------------------------------------
  1446 // Append node to list by getting the item data from resource
  1539 // Append node to list by getting the item data from resource
  1447 // ---------------------------------------------------------------------------
  1540 // ---------------------------------------------------------------------------
  1448 //
  1541 //
  1449 void CFSEmailUiFolderListVisualiser::SetHeaderTextByResourceIdL( 
  1542 void CFSEmailUiFolderListVisualiser::SetHeaderTextByResourceIdL(
  1450         TInt aResourceId )
  1543         TInt aResourceId )
  1451 	{
  1544 	{
  1452     FUNC_LOG;
  1545     FUNC_LOG;
  1453     if ( iFirstStartCompleted ) // Safety
  1546     if ( iFirstStartCompleted ) // Safety
  1454         {	
  1547         {
  1455         HBufC* headingText = StringLoader::LoadLC( aResourceId );
  1548         HBufC* headingText = StringLoader::LoadLC( aResourceId );
  1456         SetHeaderTextAttributesL();
  1549         SetHeaderTextAttributesL();
  1457         iHeaderTextVisual->SetTextL( *headingText );
  1550         iHeaderTextVisual->SetTextL( *headingText );
  1458         CleanupStack::PopAndDestroy( headingText );
  1551         CleanupStack::PopAndDestroy( headingText );
  1459         }
  1552         }
  1467 // ---------------------------------------------------------------------------
  1560 // ---------------------------------------------------------------------------
  1468 //
  1561 //
  1469 void CFSEmailUiFolderListVisualiser::SetHeaderTextAttributesL()
  1562 void CFSEmailUiFolderListVisualiser::SetHeaderTextAttributesL()
  1470     {
  1563     {
  1471     iHeaderTextVisual->SetOpacity( KFSVisible );
  1564     iHeaderTextVisual->SetOpacity( KFSVisible );
  1472     CAlfTextStyle* textStyle = iAppUi.LayoutHandler()->FSTextStyleFromIdL( 
  1565     CAlfTextStyle* textStyle = iAppUi.LayoutHandler()->FSTextStyleFromIdL(
  1473             EFSFontTypeNormalBold );
  1566             EFSFontTypeNormalBold );
  1474     iHeaderTextVisual->SetTextStyle ( textStyle->Id() );
  1567     iHeaderTextVisual->SetTextStyle ( textStyle->Id() );
  1475     iHeaderTextVisual->SetColor( iAppUi.LayoutHandler()->
  1568     iHeaderTextVisual->SetColor( iAppUi.LayoutHandler()->
  1476             ListNormalStateTextSkinColor() );
  1569             ListNormalStateTextSkinColor() );
  1477     iHeaderTextVisual->SetPadding( 
  1570     iHeaderTextVisual->SetPadding(
  1478             iAppUi.LayoutHandler()->TitleCaptionPadding() );
  1571             iAppUi.LayoutHandler()->TitleCaptionPadding() );
  1479 
  1572 
  1480     if( iHeaderTextVisual->Brushes() )
  1573     if( iHeaderTextVisual->Brushes() )
  1481         {
  1574         {
  1482         iHeaderTextVisual->Brushes()->Reset();
  1575         iHeaderTextVisual->Brushes()->Reset();
  1494 // CFSEmailUiFolderListVisualiser::ConnectMailbox
  1587 // CFSEmailUiFolderListVisualiser::ConnectMailbox
  1495 // ---------------------------------------------------------------------------
  1588 // ---------------------------------------------------------------------------
  1496 //
  1589 //
  1497 void CFSEmailUiFolderListVisualiser::ConnectToMailboxL()
  1590 void CFSEmailUiFolderListVisualiser::ConnectToMailboxL()
  1498     {
  1591     {
  1499 	CFSMailBox* mb = iAppUi.GetActiveMailbox();	
  1592 	CFSMailBox* mb = iAppUi.GetActiveMailbox();
  1500 	TDesC* mbName = &mb->GetName();
       
  1501     
       
  1502     iWaitingToGoOnline = ETrue;
  1593     iWaitingToGoOnline = ETrue;
  1503 		
       
  1504     mb->GoOnlineL();
  1594     mb->GoOnlineL();
  1505     }
  1595     }
  1506 
  1596 
  1507 
  1597 
  1508 // ---------------------------------------------------------------------------
  1598 // ---------------------------------------------------------------------------
  1510 // ---------------------------------------------------------------------------
  1600 // ---------------------------------------------------------------------------
  1511 //
  1601 //
  1512 void CFSEmailUiFolderListVisualiser::DisconnectFromMailboxL()
  1602 void CFSEmailUiFolderListVisualiser::DisconnectFromMailboxL()
  1513     {
  1603     {
  1514     iAppUi.GetActiveMailbox()->GoOfflineL();
  1604     iAppUi.GetActiveMailbox()->GoOfflineL();
  1515     
       
  1516     iWaitingToGoOnline = EFalse;
  1605     iWaitingToGoOnline = EFalse;
  1517     }
  1606     }
  1518 
  1607 
  1519 
  1608 
  1520 // ---------------------------------------------------------------------------
  1609 // ---------------------------------------------------------------------------
  1531 		// </cmail>
  1620 		// </cmail>
  1532         if( iFullScreen )
  1621         if( iFullScreen )
  1533             {
  1622             {
  1534             // Append lines to the model
  1623             // Append lines to the model
  1535             AppendActiveMailboxFoldersL();
  1624             AppendActiveMailboxFoldersL();
  1536             
  1625 
  1537             // Update toolbar button statuses.
  1626             // Update toolbar button statuses.
  1538             UpdateToolbarButtons();
  1627             UpdateToolbarButtons();
  1539             }
  1628             }
  1540         else
  1629         else
  1541             {    
  1630             {
  1542             //Mailboxes needed to be at the top followed by seperator
  1631             //Mailboxes needed to be at the top followed by seperator
  1543             AppendMailboxesL();   
  1632             AppendMailboxesL();
  1544             
  1633 
  1545             // Append lines to the model followed by seperator
  1634             // Append lines to the model followed by seperator
  1546             AppendActiveMailboxFoldersL();
  1635             AppendActiveMailboxFoldersL();
  1547             AppendSeparatorLineL();
  1636             AppendSeparatorLineL();
  1548             
  1637 
  1549             // Append the folder list view selector            
  1638             // Append the folder list view selector
  1550             AppendMoreFoldersL();            
  1639             AppendMoreFoldersL();
  1551             }	        
  1640             }
  1552         }
  1641         }
  1553   	}
  1642   	}
  1554 
  1643 
  1555 // ---------------------------------------------------------------------------
  1644 // ---------------------------------------------------------------------------
  1556 // Construct sort list data
  1645 // Construct sort list data
  1565         iTreeList->RemoveAllL();
  1654         iTreeList->RemoveAllL();
  1566         iListItemVisulizers.Reset();
  1655         iListItemVisulizers.Reset();
  1567         iModel->RemoveAll();
  1656         iModel->RemoveAll();
  1568         iMoreFoldersItemId = KFsTreeNoneID;
  1657         iMoreFoldersItemId = KFsTreeNoneID;
  1569         // Append lines to the model
  1658         // Append lines to the model
  1570         AppendSortListItemsL();	        
  1659         AppendSortListItemsL();
  1571         }
  1660         }
  1572 	}
  1661 	}
  1573 
  1662 
  1574 // ---------------------------------------------------------------------------
  1663 // ---------------------------------------------------------------------------
  1575 // Append active mailbox's folders
  1664 // Append active mailbox's folders
  1582         {
  1671         {
  1583         iActiveMailbox = iAppUi.GetActiveMailbox();
  1672         iActiveMailbox = iAppUi.GetActiveMailbox();
  1584         if( iActiveMailbox )
  1673         if( iActiveMailbox )
  1585             {
  1674             {
  1586             AppendSubfoldersL( TFSMailMsgId(), KFsTreeRootID, ETrue );
  1675             AppendSubfoldersL( TFSMailMsgId(), KFsTreeRootID, ETrue );
  1587             }     
  1676             }
  1588         }
  1677         }
  1589 	}
  1678 	}
  1590 
  1679 
  1591 // ---------------------------------------------------------------------------
  1680 // ---------------------------------------------------------------------------
  1592 // Compare two mail folders, used in sorting done with TLinearOrder
  1681 // Compare two mail folders, used in sorting done with TLinearOrder
  1606 		}
  1695 		}
  1607 	else
  1696 	else
  1608 		{
  1697 		{
  1609 		TDesC& nameOfFirst = aFirst.GetFolderName();
  1698 		TDesC& nameOfFirst = aFirst.GetFolderName();
  1610 		TDesC& nameOfSecond = aSecond.GetFolderName();
  1699 		TDesC& nameOfSecond = aSecond.GetFolderName();
  1611 		
  1700 
  1612 		return nameOfFirst.CompareC( nameOfSecond );
  1701 		return nameOfFirst.CompareC( nameOfSecond );
  1613 		}
  1702 		}
  1614 	}
  1703 	}
  1615 
  1704 
  1616 // ---------------------------------------------------------------------------
  1705 // ---------------------------------------------------------------------------
  1644 	}
  1733 	}
  1645 
  1734 
  1646 void CFSEmailUiFolderListVisualiser::AppendSortListItemsL()
  1735 void CFSEmailUiFolderListVisualiser::AppendSortListItemsL()
  1647 	{
  1736 	{
  1648     FUNC_LOG;
  1737     FUNC_LOG;
  1649 	TFsTreeItemId itemId = AppendItemToListFromResourceL( R_FREESTYLE_EMAIL_UI_SORT_BY_DATE, KFsTreeRootID, NULL, EFalse );
  1738 
       
  1739     // Select correct icon depending on the selected sort criteria
       
  1740     CAlfTexture* icon( NULL );
       
  1741     icon = iCurrentSortCriteria.iField == EFSMailSortByDate ? 
       
  1742     	   iCurrentSortCriteria.iOrder == EFSMailAscending ? 
       
  1743 		   iSortIconArray[ ESortListDateDescIcon ] : 
       
  1744 		   iSortIconArray[ ESortListDateAscIcon ] : 
       
  1745 		   iSortIconArray[ ESortListDateDescIcon ];
       
  1746 		   
       
  1747 	TFsTreeItemId itemId = AppendItemToListFromResourceL( R_FREESTYLE_EMAIL_UI_SORT_BY_DATE, KFsTreeRootID, icon, EFalse );
  1650 	iModel->AppendL( itemId, EFSMailSortByDate );
  1748 	iModel->AppendL( itemId, EFSMailSortByDate );
  1651 	
  1749 
  1652 	switch( iCurrentFolderType )
  1750 	switch( iCurrentFolderType )
  1653 		{
  1751 		{
  1654 		case EFSSentFolder:
  1752 		case EFSSentFolder:
  1655 		case EFSDraftsFolder:
  1753 		case EFSDraftsFolder:
  1656 		case EFSOutbox:
  1754 		case EFSOutbox:
  1657 			{
  1755 			{
  1658 			itemId = AppendItemToListFromResourceL( R_FREESTYLE_EMAIL_UI_SORT_BY_RECIPIENT, KFsTreeRootID, NULL, EFalse );
  1756 		    icon = iCurrentSortCriteria.iField == EFSMailSortByRecipient ? 
       
  1757 		    	   iCurrentSortCriteria.iOrder == EFSMailAscending ? 
       
  1758 				   iSortIconArray[ ESortListSenderDescIcon ] : 
       
  1759 				   iSortIconArray[ ESortListSenderAscIcon ] : 
       
  1760 				   iSortIconArray[ ESortListSenderDescIcon ];
       
  1761 			itemId = AppendItemToListFromResourceL( R_FREESTYLE_EMAIL_UI_SORT_BY_RECIPIENT, KFsTreeRootID, icon, EFalse );
  1659 			iModel->AppendL( itemId, EFSMailSortByRecipient );
  1762 			iModel->AppendL( itemId, EFSMailSortByRecipient );
  1660 			}
  1763 			}
  1661 			break;
  1764 			break;
  1662 			
  1765 
  1663 		default:
  1766 		default:
  1664 			{
  1767 			{
  1665 			itemId = AppendItemToListFromResourceL( R_FREESTYLE_EMAIL_UI_SORT_BY_SENDER, KFsTreeRootID, NULL, EFalse );
  1768 		    icon = iCurrentSortCriteria.iField == EFSMailSortBySender ? 
       
  1769 		    	   iCurrentSortCriteria.iOrder == EFSMailAscending ? 
       
  1770 				   iSortIconArray[ ESortListSenderDescIcon ] : 
       
  1771 				   iSortIconArray[ ESortListSenderAscIcon ] : 
       
  1772 				   iSortIconArray[ ESortListSenderDescIcon ];
       
  1773 			itemId = AppendItemToListFromResourceL( R_FREESTYLE_EMAIL_UI_SORT_BY_SENDER, KFsTreeRootID, icon, EFalse );
  1666 			iModel->AppendL( itemId, EFSMailSortBySender );
  1774 			iModel->AppendL( itemId, EFSMailSortBySender );
  1667 			}
  1775 			}
  1668 			break;
  1776 			break;
  1669 		}
  1777 		}
  1670 
  1778 
  1671 	itemId = AppendItemToListFromResourceL( R_FREESTYLE_EMAIL_UI_SORT_BY_SUBJECT, KFsTreeRootID, NULL, EFalse );
  1779 	icon = iCurrentSortCriteria.iField == EFSMailSortBySubject ? 
       
  1780 		   iCurrentSortCriteria.iOrder == EFSMailAscending ? 
       
  1781 		   iSortIconArray[ ESortListSubjectDescIcon ] : 
       
  1782 		   iSortIconArray[ ESortListSubjectAscIcon ] : 
       
  1783 		   iSortIconArray[ ESortListSubjectDescIcon ];
       
  1784 	
       
  1785 	itemId = AppendItemToListFromResourceL( R_FREESTYLE_EMAIL_UI_SORT_BY_SUBJECT, KFsTreeRootID, icon, EFalse );
  1672 	iModel->AppendL( itemId, EFSMailSortBySubject );
  1786 	iModel->AppendL( itemId, EFSMailSortBySubject );
  1673 
  1787 
  1674 	if ( TFsEmailUiUtility::IsFollowUpSupported( *iAppUi.GetActiveMailbox() ) )
  1788 	if ( TFsEmailUiUtility::IsFollowUpSupported( *iAppUi.GetActiveMailbox() ) )
  1675 		{
  1789 		{
  1676 		itemId = AppendItemToListFromResourceL( R_FREESTYLE_EMAIL_UI_SORT_BY_FLAG, KFsTreeRootID, NULL, EFalse );
  1790 		icon = iCurrentSortCriteria.iField == EFSMailSortByFlagStatus ? 
       
  1791 			   iCurrentSortCriteria.iOrder == EFSMailAscending ? 
       
  1792 			   iSortIconArray[ ESortListFollowDescIcon ] : 
       
  1793 			   iSortIconArray[ ESortListFollowAscIcon ] : 
       
  1794 			   iSortIconArray[ ESortListFollowDescIcon ];
       
  1795 			   
       
  1796 		itemId = AppendItemToListFromResourceL( R_FREESTYLE_EMAIL_UI_SORT_BY_FLAG, KFsTreeRootID, icon, EFalse );
  1677 		iModel->AppendL( itemId, EFSMailSortByFlagStatus );
  1797 		iModel->AppendL( itemId, EFSMailSortByFlagStatus );
  1678 		}
  1798 		}
  1679 
  1799 
  1680 	itemId = AppendItemToListFromResourceL( R_FREESTYLE_EMAIL_UI_SORT_BY_PRIORITY, KFsTreeRootID, NULL, EFalse );
  1800 	icon = iCurrentSortCriteria.iField == EFSMailSortByPriority ? 
       
  1801 		   iCurrentSortCriteria.iOrder == EFSMailAscending ? 
       
  1802 		   iSortIconArray[ ESortListPriorityDescIcon ] : 
       
  1803 		   iSortIconArray[ ESortListPriorityAscIcon ] : 
       
  1804 		   iSortIconArray[ ESortListPriorityDescIcon ];
       
  1805 	
       
  1806 	itemId = AppendItemToListFromResourceL( R_FREESTYLE_EMAIL_UI_SORT_BY_PRIORITY, KFsTreeRootID, icon, EFalse );
  1681 	iModel->AppendL( itemId, EFSMailSortByPriority );
  1807 	iModel->AppendL( itemId, EFSMailSortByPriority );
  1682 
  1808 
  1683 	if ( iCurrentFolderType != EFSSentFolder &&
  1809 	if ( iCurrentFolderType != EFSSentFolder &&
  1684 		 iCurrentFolderType != EFSDraftsFolder &&
  1810 		 iCurrentFolderType != EFSDraftsFolder &&
  1685 		 iCurrentFolderType != EFSOutbox )
  1811 		 iCurrentFolderType != EFSOutbox )
  1686 		{
  1812 		{
  1687 		itemId = AppendItemToListFromResourceL( R_FREESTYLE_EMAIL_UI_SORT_BY_UNREAD, KFsTreeRootID, NULL, EFalse );
  1813 		icon = iCurrentSortCriteria.iField == EFSMailSortByUnread ? 
       
  1814 			   iCurrentSortCriteria.iOrder == EFSMailAscending ? 
       
  1815 			   iSortIconArray[ ESortListUnreadDescIcon ] : 
       
  1816 			   iSortIconArray[ ESortListUnreadAscIcon ] : 
       
  1817 			   iSortIconArray[ ESortListUnreadDescIcon ];
       
  1818 		
       
  1819 		itemId = AppendItemToListFromResourceL( R_FREESTYLE_EMAIL_UI_SORT_BY_UNREAD, KFsTreeRootID, icon, EFalse );
  1688 		iModel->AppendL( itemId, EFSMailSortByUnread );
  1820 		iModel->AppendL( itemId, EFSMailSortByUnread );
  1689 		}
  1821 		}
  1690 
  1822 
  1691 	// Allow scroll bar refresh only for the last item
  1823 	// Allow scroll bar refresh only for the last item
  1692 	itemId = AppendItemToListFromResourceL( R_FREESTYLE_EMAIL_UI_SORT_BY_ATTACHMENT, KFsTreeRootID, NULL, ETrue );
  1824 	icon = iCurrentSortCriteria.iField == EFSMailSortByAttachment ? 
       
  1825 		   iCurrentSortCriteria.iOrder == EFSMailAscending ? 
       
  1826 		   iSortIconArray[ ESortListAttachmentDescIcon ] : 
       
  1827 		   iSortIconArray[ ESortListAttachmentAscIcon ] : 
       
  1828 		   iSortIconArray[ ESortListAttachmentDescIcon ];
       
  1829 		   
       
  1830 	itemId = AppendItemToListFromResourceL( R_FREESTYLE_EMAIL_UI_SORT_BY_ATTACHMENT, KFsTreeRootID, icon, ETrue );
  1693 	iModel->AppendL( itemId, EFSMailSortByAttachment );
  1831 	iModel->AppendL( itemId, EFSMailSortByAttachment );
  1694 	}
  1832 	}
  1695 
  1833 
  1696 // ---------------------------------------------------------------------------
  1834 // ---------------------------------------------------------------------------
  1697 // Recursive function to get the folder's subfolder data
  1835 // Recursive function to get the folder's subfolder data
  1703     FUNC_LOG;
  1841     FUNC_LOG;
  1704 	RPointerArray<CFSMailFolder> folders;
  1842 	RPointerArray<CFSMailFolder> folders;
  1705     CleanupResetAndDestroyClosePushL( folders );
  1843     CleanupResetAndDestroyClosePushL( folders );
  1706 
  1844 
  1707 	iActiveMailbox->ListFolders( aFolder, folders );
  1845 	iActiveMailbox->ListFolders( aFolder, folders );
  1708 	
  1846 
  1709 	TLinearOrder<CFSMailFolder> order(
  1847 	TLinearOrder<CFSMailFolder> order(
  1710 		CFSEmailUiFolderListVisualiser::CompareFolders );
  1848 		CFSEmailUiFolderListVisualiser::CompareFolders );
  1711 	folders.Sort( order );
  1849 	folders.Sort( order );
  1712 
  1850 
  1713 	// First check which folders are not shown, and remove those from the list.
  1851 	// First check which folders are not shown, and remove those from the list.
  1721             // Skip this folder
  1859             // Skip this folder
  1722             delete folders[i];
  1860             delete folders[i];
  1723             folders.Remove(i);
  1861             folders.Remove(i);
  1724             }
  1862             }
  1725 	    }
  1863 	    }
  1726 	
  1864 
  1727 	TBool allowItemRefresh = EFalse;
  1865 	TBool allowItemRefresh = EFalse;
  1728 	while( folders.Count() > 0 )
  1866 	while( folders.Count() > 0 )
  1729 		{
  1867 		{
  1730 		// If last item of this level is to be refreshed, and we are in the
  1868 		// If last item of this level is to be refreshed, and we are in the
  1731 		// last item, allow the refresh. If this last item is leaf folder,
  1869 		// last item, allow the refresh. If this last item is leaf folder,
  1794 			aResourceId = R_FREESTYLE_EMAIL_UI_FOLDER_LIST_INBOX;
  1932 			aResourceId = R_FREESTYLE_EMAIL_UI_FOLDER_LIST_INBOX;
  1795 			aIcon = iIconArray[EFolderListIconInbox];
  1933 			aIcon = iIconArray[EFolderListIconInbox];
  1796 			}
  1934 			}
  1797 		else
  1935 		else
  1798 			{
  1936 			{
  1799 			aResourceId = R_FREESTYLE_EMAIL_UI_DROPDOWN_LIST_INBOX;								
  1937 			aResourceId = R_FREESTYLE_EMAIL_UI_DROPDOWN_LIST_INBOX;
  1800 			// Get branded mailbox icon
  1938 			// Get branded mailbox icon
  1801 			aIcon = &iAppUi.FsTextureManager()->TextureByMailboxIdL( iActiveMailbox->GetId().PluginId(),
  1939 			aIcon = &iAppUi.FsTextureManager()->TextureByMailboxIdL( iActiveMailbox->GetId().PluginId(),
  1802 																	 iActiveMailbox->GetId().Id(),
  1940 																	 iActiveMailbox->GetId().Id(),
  1803 																     iListIconSize);	
  1941 																     iListIconSize);
  1804 			}		
  1942 			}
  1805 		found = ETrue;
  1943 		found = ETrue;
  1806 		}
  1944 		}
  1807 	else if( aFolderType == EFSOutbox )
  1945 	else if( aFolderType == EFSOutbox )
  1808 		{
  1946 		{
  1809 		if( iFullScreen )
  1947 		if( iFullScreen )
  1812 			aIcon = iIconArray[EFolderListIconOutbox];
  1950 			aIcon = iIconArray[EFolderListIconOutbox];
  1813 			}
  1951 			}
  1814 		else
  1952 		else
  1815 			{
  1953 			{
  1816 			aResourceId = R_FREESTYLE_EMAIL_UI_DROPDOWN_LIST_OUTBOX;
  1954 			aResourceId = R_FREESTYLE_EMAIL_UI_DROPDOWN_LIST_OUTBOX;
  1817 			}		
  1955 			}
  1818 		found = ETrue;
  1956 		found = ETrue;
  1819 		}
  1957 		}
  1820 	else if( aFolderType == EFSDraftsFolder )
  1958 	else if( aFolderType == EFSDraftsFolder )
  1821 		{
  1959 		{
  1822 		if( iFullScreen )
  1960 		if( iFullScreen )
  1825 			aIcon = iIconArray[EFolderListIconDrafts];
  1963 			aIcon = iIconArray[EFolderListIconDrafts];
  1826 			}
  1964 			}
  1827 		else
  1965 		else
  1828 			{
  1966 			{
  1829 			aResourceId = R_FREESTYLE_EMAIL_UI_DROPDOWN_LIST_DRAFTS;
  1967 			aResourceId = R_FREESTYLE_EMAIL_UI_DROPDOWN_LIST_DRAFTS;
  1830 			}		
  1968 			}
  1831 		found = ETrue;
  1969 		found = ETrue;
  1832 		}
  1970 		}
  1833 	else if( aFolderType == EFSSentFolder )
  1971 	else if( aFolderType == EFSSentFolder )
  1834 		{
  1972 		{
  1835 		if( iFullScreen )
  1973 		if( iFullScreen )
  1851 			aIcon = iIconArray[EFolderListIconDeleted];
  1989 			aIcon = iIconArray[EFolderListIconDeleted];
  1852 			}
  1990 			}
  1853 		else
  1991 		else
  1854 			{
  1992 			{
  1855 			aResourceId = R_FREESTYLE_EMAIL_UI_DROPDOWN_LIST_DELETED;
  1993 			aResourceId = R_FREESTYLE_EMAIL_UI_DROPDOWN_LIST_DELETED;
  1856 			}		
  1994 			}
  1857 		found = ETrue;
  1995 		found = ETrue;
  1858 		}
  1996 		}
  1859 	return found;
  1997 	return found;
  1860 	}
  1998 	}
  1861 
  1999 
  1865 //
  2003 //
  1866 TBool CFSEmailUiFolderListVisualiser::ShowThisTypeOfFolderL(
  2004 TBool CFSEmailUiFolderListVisualiser::ShowThisTypeOfFolderL(
  1867 	CFSMailFolder* aFolder ) const
  2005 	CFSMailFolder* aFolder ) const
  1868 	{
  2006 	{
  1869     FUNC_LOG;
  2007     FUNC_LOG;
  1870 	if( iCustomMessageId == KFolderListMoveMessage || 
  2008 	if( iCustomMessageId == KFolderListMoveMessage ||
  1871     	iCustomMessageId == KFolderListMoveMessages )
  2009     	iCustomMessageId == KFolderListMoveMessages )
  1872 		{
  2010 		{
  1873 		// When moving or copying message(s), hide Outbox from list
  2011 		// When moving or copying message(s), hide Outbox from list
  1874 		if( aFolder->GetFolderType() == EFSOutbox )
  2012 		if( aFolder->GetFolderType() == EFSOutbox )
  1875 			{
  2013 			{
  1924 		{
  2062 		{
  1925 		// Append non-standard folders only if in Fullscreen
  2063 		// Append non-standard folders only if in Fullscreen
  1926 		if( iFullScreen )
  2064 		if( iFullScreen )
  1927 			{
  2065 			{
  1928 			// For other folders get the name from the folder object
  2066 			// For other folders get the name from the folder object
  1929 			
  2067 
  1930 			nodeId = AppendNodeToListL(
  2068 			nodeId = AppendNodeToListL(
  1931 			        &aFolder->GetFolderName(),
  2069 			        &aFolder->GetFolderName(),
  1932 			        aParentNode,
  2070 			        aParentNode,
  1933 			        iIconArray[EFolderListIconInboxSubfolders],
  2071 			        iIconArray[EFolderListIconInboxSubfolders],
  1934 			        aFolder->GetUnreadCount());
  2072 			        aFolder->GetUnreadCount());
  1981     FUNC_LOG;
  2119     FUNC_LOG;
  1982 	RPointerArray<CFSMailBox> mailboxes;
  2120 	RPointerArray<CFSMailBox> mailboxes;
  1983     CleanupResetAndDestroyClosePushL( mailboxes );
  2121     CleanupResetAndDestroyClosePushL( mailboxes );
  1984 	TFSMailMsgId id;
  2122 	TFSMailMsgId id;
  1985     iAppUi.GetMailClient()->ListMailBoxes( id, mailboxes );
  2123     iAppUi.GetMailClient()->ListMailBoxes( id, mailboxes );
  1986     
  2124 
  1987     TInt count = mailboxes.Count();
  2125     TInt count = mailboxes.Count();
  1988 
  2126 
  1989 	while( mailboxes.Count() > 0 )
  2127 	while( mailboxes.Count() > 0 )
  1990 		{		
  2128 		{
  1991 		if( !( mailboxes[0]->GetId() == iAppUi.GetActiveMailboxId() ) )
  2129 		if( !( mailboxes[0]->GetId() == iAppUi.GetActiveMailboxId() ) )
  1992 			{
  2130 			{
  1993 			MFSMailBrandManager& brandManager = iAppUi.GetMailClient()->GetBrandManagerL();
  2131 			MFSMailBrandManager& brandManager = iAppUi.GetMailClient()->GetBrandManagerL();
  1994 			
  2132 
  1995 			CAlfTexture* mailBoxTexture;
  2133 			CAlfTexture* mailBoxTexture;
  1996 			CGulIcon* mailboxIcon( NULL );
  2134 			CGulIcon* mailboxIcon( NULL );
  1997 			TRAPD( err, mailboxIcon = brandManager.GetGraphicL( EFSMailboxIcon, mailboxes[0]->GetId() ) ); 
  2135 			TRAPD( err, mailboxIcon = brandManager.GetGraphicL( EFSMailboxIcon, mailboxes[0]->GetId() ) );
  1998 			if ( err == KErrNone && mailboxIcon )
  2136 			if ( err == KErrNone && mailboxIcon )
  1999 				{
  2137 				{
  2000 				CleanupStack::PushL( mailboxIcon );
  2138 				CleanupStack::PushL( mailboxIcon );
  2001 				AknIconUtils::SetSize(mailboxIcon->Bitmap(), iListIconSize);
  2139 				AknIconUtils::SetSize(mailboxIcon->Bitmap(), iListIconSize);
  2002 			    AknIconUtils::SetSize(mailboxIcon->Mask(), iListIconSize);				
  2140 			    AknIconUtils::SetSize(mailboxIcon->Mask(), iListIconSize);
  2003 			    
  2141 
  2004 			    // Create texture into TextureManager, If not already existing			    
  2142 			    // Create texture into TextureManager, If not already existing
  2005 			    iAppUi.FsTextureManager()->CreateBrandedMailboxTexture( mailboxIcon,
  2143 			    iAppUi.FsTextureManager()->CreateBrandedMailboxTexture( mailboxIcon,
  2006 			    		                                                mailboxes[0]->GetId().PluginId(),
  2144 			    		                                                mailboxes[0]->GetId().PluginId(),
  2007 			    		                                                mailboxes[0]->GetId().Id(),
  2145 			    		                                                mailboxes[0]->GetId().Id(),
  2008 			    		                                                iListIconSize);
  2146 			    		                                                iListIconSize);
  2009 			    // Get branded mailbox icon
  2147 			    // Get branded mailbox icon
  2010 			    mailBoxTexture = &iAppUi.FsTextureManager()->TextureByMailboxIdL( mailboxes[0]->GetId().PluginId(),
  2148 			    mailBoxTexture = &iAppUi.FsTextureManager()->TextureByMailboxIdL( mailboxes[0]->GetId().PluginId(),
  2011 			    		                                                          mailboxes[0]->GetId().Id(),
  2149 			    		                                                          mailboxes[0]->GetId().Id(),
  2012 			    		                                                          iListIconSize);	
  2150 			    		                                                          iListIconSize);
  2013 			    
  2151 
  2014 				CleanupStack::PopAndDestroy( mailboxIcon );
  2152 				CleanupStack::PopAndDestroy( mailboxIcon );
  2015 				}
  2153 				}
  2016 			else
  2154 			else
  2017 				{
  2155 				{
  2018 				mailBoxTexture = iIconArray[EFolderListIconEmailAccount];
  2156 				mailBoxTexture = iIconArray[EFolderListIconEmailAccount];
  2035                 {
  2173                 {
  2036                 // Note that ownership of the mailbox object is NOT transferred
  2174                 // Note that ownership of the mailbox object is NOT transferred
  2037                 // to model anymore, so we need to delete it here in all cases
  2175                 // to model anymore, so we need to delete it here in all cases
  2038                 iModel->AppendL( itemId, mailboxes[0] );
  2176                 iModel->AppendL( itemId, mailboxes[0] );
  2039                 }
  2177                 }
  2040 				
  2178 
  2041 			}
  2179 			}
  2042 		
  2180 
  2043 		delete mailboxes[0];
  2181 		delete mailboxes[0];
  2044         mailboxes.Remove(0);
  2182         mailboxes.Remove(0);
  2045 		}
  2183 		}
  2046 	//There is more then 1 mailbox so we add the seperator at the end
  2184 	//There is more then 1 mailbox so we add the seperator at the end
  2047 	if( count > 1 )
  2185 	if( count > 1 )
  2048 		{
  2186 		{
  2049 		AppendSeparatorLineL();
  2187 		AppendSeparatorLineL();
  2050 		}		
  2188 		}
  2051 	
  2189 
  2052     CleanupStack::PopAndDestroy( &mailboxes );
  2190     CleanupStack::PopAndDestroy( &mailboxes );
  2053 	}
  2191 	}
  2054 
  2192 
  2055 
  2193 
  2056 // ---------------------------------------------------------------------------
  2194 // ---------------------------------------------------------------------------
  2062     FUNC_LOG;
  2200     FUNC_LOG;
  2063 	CFsSeparatorData* data = CFsSeparatorData::NewL();
  2201 	CFsSeparatorData* data = CFsSeparatorData::NewL();
  2064 
  2202 
  2065 	CFsSeparatorVisualizer* visualizer( NULL );
  2203 	CFsSeparatorVisualizer* visualizer( NULL );
  2066     visualizer = CFsSeparatorVisualizer::NewL(*iTreeList->TreeControl());
  2204     visualizer = CFsSeparatorVisualizer::NewL(*iTreeList->TreeControl());
  2067     
  2205 
  2068     // We use the default size of the separator, but we need to save it
  2206     // We use the default size of the separator, but we need to save it
  2069     // here to have it available later when calculating the list height
  2207     // here to have it available later when calculating the list height
  2070     iListSeparatorHeight = visualizer->Size().iHeight;
  2208     iListSeparatorHeight = visualizer->Size().iHeight;
  2071     
  2209 
  2072     // This should never be the last item in the list, so disable the refresh
  2210     // This should never be the last item in the list, so disable the refresh
  2073     iTreeList->InsertItemL( *data, *visualizer, KFsTreeRootID, KErrNotFound, EFalse);
  2211     iTreeList->InsertItemL( *data, *visualizer, KFsTreeRootID, KErrNotFound, EFalse);
  2074     
  2212 
  2075     iModel->IncreaseSeparatorCount();
  2213     iModel->IncreaseSeparatorCount();
  2076 	}
  2214 	}
  2077 
  2215 
  2078 // ---------------------------------------------------------------------------
  2216 // ---------------------------------------------------------------------------
  2079 // Append separator between active mailbox's folders and other mailboxes
  2217 // Append separator between active mailbox's folders and other mailboxes
  2112 TFsTreeItemId CFSEmailUiFolderListVisualiser::AppendNodeToListL( TDesC* aItemData, TFsTreeItemId aParentNode, CAlfTexture* aIcon, TUint aUnreadCnt )
  2250 TFsTreeItemId CFSEmailUiFolderListVisualiser::AppendNodeToListL( TDesC* aItemData, TFsTreeItemId aParentNode, CAlfTexture* aIcon, TUint aUnreadCnt )
  2113 	{
  2251 	{
  2114     FUNC_LOG;
  2252     FUNC_LOG;
  2115     CFsTreePlainOneLineNodeData* plainItemData;
  2253     CFsTreePlainOneLineNodeData* plainItemData;
  2116     CFsTreePlainOneLineNodeVisualizer* plainNodeVisualizer;
  2254     CFsTreePlainOneLineNodeVisualizer* plainNodeVisualizer;
  2117     
  2255 
  2118     HBufC* itemDispName = HBufC::NewLC(aItemData->Length() + KFmtUnRdCntMaxLength);
  2256     HBufC* itemDispName = HBufC::NewLC(aItemData->Length() + KFmtUnRdCntMaxLength);
  2119     itemDispName->Des().Copy(*aItemData);
  2257     itemDispName->Des().Copy(*aItemData);
  2120     if( aUnreadCnt > 0 )
  2258     if( aUnreadCnt > 0 )
  2121         {
  2259         {
  2122         itemDispName->Des().AppendFormat(KFormatUnreadCnt, aUnreadCnt);
  2260         itemDispName->Des().AppendFormat(KFormatUnreadCnt, aUnreadCnt);
  2123         }
  2261         }
  2124 	CreatePlainNodeLC2( itemDispName, plainItemData, plainNodeVisualizer, aIcon );
  2262 	CreatePlainNodeLC2( itemDispName, plainItemData, plainNodeVisualizer, aIcon );
  2125 	
  2263 
  2126 	// We assume that node can never be the last item to be drawn, there will
  2264 	// We assume that node can never be the last item to be drawn, there will
  2127 	// always be leaf folder under it. So we can always deny scroll bar update.
  2265 	// always be leaf folder under it. So we can always deny scroll bar update.
  2128     TFsTreeItemId nodeId = iTreeList->InsertNodeL( *plainItemData, *plainNodeVisualizer, aParentNode, KErrNotFound, EFalse);
  2266     TFsTreeItemId nodeId = iTreeList->InsertNodeL( *plainItemData, *plainNodeVisualizer, aParentNode, KErrNotFound, EFalse);
  2129     CleanupStack::Pop( 2 ); // plainItemData & plainNodeVisualizer
  2267     CleanupStack::Pop( 2 ); // plainItemData & plainNodeVisualizer
  2130 	CleanupStack::PopAndDestroy( itemDispName );
  2268 	CleanupStack::PopAndDestroy( itemDispName );
  2139 
  2277 
  2140 // ---------------------------------------------------------------------------
  2278 // ---------------------------------------------------------------------------
  2141 // Append leaf to list by getting the item data from resource
  2279 // Append leaf to list by getting the item data from resource
  2142 // ---------------------------------------------------------------------------
  2280 // ---------------------------------------------------------------------------
  2143 //
  2281 //
  2144 TFsTreeItemId CFSEmailUiFolderListVisualiser::AppendItemToListFromResourceL( TInt aResourceId, 
  2282 TFsTreeItemId CFSEmailUiFolderListVisualiser::AppendItemToListFromResourceL( TInt aResourceId,
  2145 																			 TFsTreeItemId aParentNode,
  2283 																			 TFsTreeItemId aParentNode,
  2146 																			 CAlfTexture* aIcon,
  2284 																			 CAlfTexture* aIcon,
  2147 																			 TBool aAllowRefresh,
  2285 																			 TBool aAllowRefresh,
  2148 																			 TUint aUnreadCnt)
  2286 																			 TUint aUnreadCnt)
  2149 	{
  2287 	{
  2150     FUNC_LOG;
  2288     FUNC_LOG;
  2151  	HBufC* headingText = StringLoader::LoadLC( aResourceId );
  2289  	HBufC* headingText = StringLoader::LoadLC( aResourceId );
  2152 
  2290  	
  2153 	TFsTreeItemId itemId = AppendItemToListL( headingText, aParentNode, aIcon, aAllowRefresh,  aUnreadCnt);
  2291 	TFsTreeItemId itemId = AppendItemToListL( headingText, aParentNode, aIcon, aAllowRefresh,  aUnreadCnt);
  2154 
  2292 
  2155    	CleanupStack::PopAndDestroy( headingText );
  2293    	CleanupStack::PopAndDestroy( headingText );
  2156 
  2294 
  2157    	return itemId;
  2295    	return itemId;
  2159 
  2297 
  2160 // ---------------------------------------------------------------------------
  2298 // ---------------------------------------------------------------------------
  2161 // Append leaf to list
  2299 // Append leaf to list
  2162 // ---------------------------------------------------------------------------
  2300 // ---------------------------------------------------------------------------
  2163 //
  2301 //
  2164 TFsTreeItemId CFSEmailUiFolderListVisualiser::AppendItemToListL( TDesC* aItemData, 
  2302 TFsTreeItemId CFSEmailUiFolderListVisualiser::AppendItemToListL( TDesC* aItemData,
  2165 																 TFsTreeItemId aParentNode,
  2303 																 TFsTreeItemId aParentNode,
  2166 																 CAlfTexture* aIcon,
  2304 																 CAlfTexture* aIcon,
  2167                                                                  TBool aAllowRefresh,
  2305                                                                  TBool aAllowRefresh,
  2168                                                                  TUint aUnreadCnt)
  2306                                                                  TUint aUnreadCnt)
  2169 	{
  2307 	{
  2170     FUNC_LOG;
  2308     FUNC_LOG;
  2171     CFsTreePlainOneLineItemData* plainItemData;
  2309     CFsTreePlainOneLineItemData* plainItemData;
  2172     CFsTreePlainOneLineItemVisualizer* plainItemVisualizer;
  2310     CFsTreePlainOneLineItemVisualizer* plainItemVisualizer;
  2173     
  2311 
  2174     HBufC* itemDispName = HBufC::NewLC(aItemData->Length() + KFmtUnRdCntMaxLength);
  2312     HBufC* itemDispName = HBufC::NewLC(aItemData->Length() + KFmtUnRdCntMaxLength);
  2175     itemDispName->Des().Copy(*aItemData);
  2313     itemDispName->Des().Copy(*aItemData);
  2176     if( aUnreadCnt > 0 )
  2314     if( aUnreadCnt > 0 )
  2177         {
  2315         {
  2178         itemDispName->Des().AppendFormat(KFormatUnreadCnt, aUnreadCnt);
  2316         itemDispName->Des().AppendFormat(KFormatUnreadCnt, aUnreadCnt);
  2179         }
  2317         }
  2180     CreatePlainItemLC2( itemDispName, plainItemData, plainItemVisualizer, aIcon );
  2318     CreatePlainItemLC2( itemDispName, plainItemData, plainItemVisualizer, aIcon );
  2181     
  2319 
  2182     
  2320 
  2183     TFsTreeItemId itemId = iTreeList->InsertItemL( *plainItemData, *plainItemVisualizer, aParentNode, KErrNotFound, aAllowRefresh);
  2321     TFsTreeItemId itemId = iTreeList->InsertItemL( *plainItemData, *plainItemVisualizer, aParentNode, KErrNotFound, aAllowRefresh);
  2184     CleanupStack::Pop( 2 ); // plainItemData & plainItemVisualizer
  2322     CleanupStack::Pop( 2 ); // plainItemData & plainItemVisualizer
  2185 	CleanupStack::PopAndDestroy( itemDispName );
  2323 	CleanupStack::PopAndDestroy( itemDispName );
  2186 	if( itemId != KFsTreeNoneID )
  2324 	if( itemId != KFsTreeNoneID )
  2187 		{
  2325 		{
  2188 		iListItemVisulizers.Append( plainItemVisualizer );
  2326 		iListItemVisulizers.Append( plainItemVisualizer );
  2189 		}
  2327 		}
  2190     
  2328 
  2191 	return itemId;
  2329 	return itemId;
  2192 	}
  2330 	}
  2193 
  2331 
  2194 // ---------------------------------------------------------------------------
  2332 // ---------------------------------------------------------------------------
  2195 // Create plain leaf item
  2333 // Create plain leaf item
  2201                                                          CAlfTexture* aIcon )
  2339                                                          CAlfTexture* aIcon )
  2202 	{
  2340 	{
  2203     FUNC_LOG;
  2341     FUNC_LOG;
  2204     aItemData = CFsTreePlainOneLineItemData::NewL();
  2342     aItemData = CFsTreePlainOneLineItemData::NewL();
  2205     CleanupStack::PushL( aItemData );
  2343     CleanupStack::PushL( aItemData );
  2206     
  2344 
  2207     aItemData->SetDataL( *aItemDataBuff );
  2345     aItemData->SetDataL( *aItemDataBuff );
  2208     if( aIcon )
  2346     if( aIcon )
  2209     	{
  2347     	{
  2210 		aItemData->SetIcon( *aIcon );
  2348 		aItemData->SetIcon( *aIcon );
  2211     	}
  2349     	}
  2218         {
  2356         {
  2219         aItemVisualizer->SetLayoutHints( CFsTreeItemVisualizerBase::EFolderLayout );
  2357         aItemVisualizer->SetLayoutHints( CFsTreeItemVisualizerBase::EFolderLayout );
  2220         }
  2358         }
  2221     else
  2359     else
  2222         {
  2360         {
  2223         aItemVisualizer->SetLayoutHints( CFsTreeItemVisualizerBase::EPopupLayout );        
  2361         aItemVisualizer->SetLayoutHints( CFsTreeItemVisualizerBase::EPopupLayout );
  2224         }
  2362         }
       
  2363 
  2225     SetItemVisualizerPropertiesL( aItemVisualizer );
  2364     SetItemVisualizerPropertiesL( aItemVisualizer );
  2226 	}
  2365 	}
  2227 
  2366 
  2228 // ---------------------------------------------------------------------------
  2367 // ---------------------------------------------------------------------------
  2229 // Create plain node itme
  2368 // Create plain node itme
  2235                                                          CAlfTexture* aIcon )
  2374                                                          CAlfTexture* aIcon )
  2236 	{
  2375 	{
  2237     FUNC_LOG;
  2376     FUNC_LOG;
  2238     aItemData = CFsTreePlainOneLineNodeData::NewL();
  2377     aItemData = CFsTreePlainOneLineNodeData::NewL();
  2239     CleanupStack::PushL( aItemData );
  2378     CleanupStack::PushL( aItemData );
  2240     
  2379 
  2241     aItemData->SetDataL( *aItemDataBuff );
  2380     aItemData->SetDataL( *aItemDataBuff );
  2242     if( aIcon )
  2381     if( aIcon )
  2243     	{
  2382     	{
  2244 		aItemData->SetIconExpanded( *aIcon );
  2383 		aItemData->SetIconExpanded( *aIcon );
  2245 		aItemData->SetIconCollapsed( *aIcon );
  2384 		aItemData->SetIconCollapsed( *aIcon );
  2246     	}
  2385     	}
  2247 	
  2386 
  2248     aNodeVisualizer = CFsTreePlainOneLineNodeVisualizer::NewL( *iTreeList->TreeControl() );
  2387     aNodeVisualizer = CFsTreePlainOneLineNodeVisualizer::NewL( *iTreeList->TreeControl() );
  2249     CleanupStack::PushL( aNodeVisualizer );
  2388     CleanupStack::PushL( aNodeVisualizer );
  2250      
  2389 
  2251     // Set folder view specific layouts to be used
  2390     // Set folder view specific layouts to be used
  2252     if ( iFullScreen )
  2391     if ( iFullScreen )
  2253         {
  2392         {
  2254         aNodeVisualizer->SetLayoutHints( CFsTreeItemVisualizerBase::EFolderLayout );
  2393         aNodeVisualizer->SetLayoutHints( CFsTreeItemVisualizerBase::EFolderLayout );
  2255         }
  2394         }
  2256     else
  2395     else
  2257         {
  2396         {
  2258         aNodeVisualizer->SetLayoutHints( CFsTreeItemVisualizerBase::EPopupLayout );        
  2397         aNodeVisualizer->SetLayoutHints( CFsTreeItemVisualizerBase::EPopupLayout );
  2259         }
  2398         }
  2260     SetItemVisualizerPropertiesL( aNodeVisualizer );
  2399     SetItemVisualizerPropertiesL( aNodeVisualizer );
  2261 	}
  2400 	}
  2262     
  2401 
  2263 void CFSEmailUiFolderListVisualiser::SetItemVisualizerPropertiesL( MFsTreeItemVisualizer* aItemVisualizer )
  2402 void CFSEmailUiFolderListVisualiser::SetItemVisualizerPropertiesL( MFsTreeItemVisualizer* aItemVisualizer )
  2264 	{
  2403 	{
  2265     FUNC_LOG;
  2404     FUNC_LOG;
  2266 	aItemVisualizer->SetFlags(aItemVisualizer->Flags() & ~KFsTreeListItemManagedLayout);
  2405 	aItemVisualizer->SetFlags(aItemVisualizer->Flags() & ~KFsTreeListItemManagedLayout);
  2267 
  2406 
  2274 	    aItemVisualizer->SetSize(TSize(iScreenRect.Width(), iListItemHeight));
  2413 	    aItemVisualizer->SetSize(TSize(iScreenRect.Width(), iListItemHeight));
  2275         }
  2414         }
  2276 
  2415 
  2277     aItemVisualizer->SetExtendable( EFalse );
  2416     aItemVisualizer->SetExtendable( EFalse );
  2278 
  2417 
  2279   	// Set correct skin text colors for the list items  
  2418   	// Set correct skin text colors for the list items
  2280    	TRgb focusedColor = iAppUi.LayoutHandler()->ListFocusedStateTextSkinColor();
  2419    	TRgb focusedColor = iAppUi.LayoutHandler()->ListFocusedStateTextSkinColor();
  2281 	// If list is in full screen, it has general list background, so we use
  2420 	// If list is in full screen, it has general list background, so we use
  2282 	// general list text color. If it's not in full screen, we use dropdown
  2421 	// general list text color. If it's not in full screen, we use dropdown
  2283 	// menu specific text color.
  2422 	// menu specific text color.
  2284 	TRgb normalColor = KRgbBlack;
  2423 	TRgb normalColor = KRgbBlack;
  2288 		}
  2427 		}
  2289 	else
  2428 	else
  2290 		{
  2429 		{
  2291 		normalColor = iAppUi.LayoutHandler()->DropdownMenuTextColor();
  2430 		normalColor = iAppUi.LayoutHandler()->DropdownMenuTextColor();
  2292 		}
  2431 		}
  2293 	
  2432 
  2294     aItemVisualizer->SetFocusedStateTextColor( focusedColor );
  2433     aItemVisualizer->SetFocusedStateTextColor( focusedColor );
  2295     aItemVisualizer->SetNormalStateTextColor( normalColor );
  2434     aItemVisualizer->SetNormalStateTextColor( normalColor );
  2296 	
  2435 
  2297 	// Set font size
  2436 	// Set font size
  2298     aItemVisualizer->SetFontHeight( iAppUi.LayoutHandler()->ListItemFontHeightInTwips( !iFullScreen ) );
  2437     aItemVisualizer->SetFontHeight( iAppUi.LayoutHandler()->ListItemFontHeightInTwips( !iFullScreen ) );
  2299 	// Set node bolded
  2438 	// Set node bolded
  2300 	aItemVisualizer->SetTextBold( EFalse );
  2439 	aItemVisualizer->SetTextBold( EFalse );
  2301 	}
  2440 	}
  2321                 {
  2460                 {
  2322                 // get popup rect in local coordinates
  2461                 // get popup rect in local coordinates
  2323                 TRect popupRect( iScreenRect );
  2462                 TRect popupRect( iScreenRect );
  2324                 // translate to screen coorinates
  2463                 // translate to screen coorinates
  2325                 popupRect.Move( iEnv.PrimaryDisplay().VisibleArea().iTl );
  2464                 popupRect.Move( iEnv.PrimaryDisplay().VisibleArea().iTl );
  2326                 // check if the event happened outside of the popup   
  2465                 // check if the event happened outside of the popup
  2327                 if ( !popupRect.Contains( position ) )
  2466                 if ( !popupRect.Contains( position ) )
  2328                     {
  2467                     {
  2329                     HandleSelectionL( EFSEmailUiCtrlBarResponseCancel );
  2468                     HandleSelectionL( EFSEmailUiCtrlBarResponseCancel );
  2330                     iConsumeUntilNextUpEvent = eventHandled = ETrue;
  2469                     iConsumeUntilNextUpEvent = eventHandled = ETrue;
  2331                     }
  2470                     }
  2337                 {
  2476                 {
  2338                 iConsumeUntilNextUpEvent = EFalse;
  2477                 iConsumeUntilNextUpEvent = EFalse;
  2339                 }
  2478                 }
  2340             eventHandled = ETrue;
  2479             eventHandled = ETrue;
  2341             }
  2480             }
  2342         }    
  2481         }
  2343     return eventHandled;
  2482     return eventHandled;
  2344     }
  2483     }
  2345 
  2484 
  2346 // Handle foreground event (called by FreestyleEmailUiMailListVisualiser)
  2485 // Handle foreground event (called by FreestyleEmailUiMailListVisualiser)
  2347 void CFSEmailUiFolderListVisualiser::HandleForegroundEventL()
  2486 void CFSEmailUiFolderListVisualiser::HandleForegroundEventL()
  2455 	 	AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, iScreenRect );
  2594 	 	AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, iScreenRect );
  2456 	 	iScreenRect.SetRect( 0, 0, iScreenRect.Width(), iScreenRect.Height() );
  2595 	 	iScreenRect.SetRect( 0, 0, iScreenRect.Width(), iScreenRect.Height() );
  2457         }
  2596         }
  2458 	else
  2597 	else
  2459 		{
  2598 		{
       
  2599         TRect cbr = iAppUi.LayoutHandler()->GetControlBarRect();
  2460 		if( iCallback )
  2600 		if( iCallback )
  2461 			{
  2601 			{
  2462 			iCtrlButtonRect = iCallback->FolderButtonRect();
  2602 			iCtrlButtonRect = iCallback->FolderButtonRect();
       
  2603             iCtrlButtonRect.Move( cbr.iTl );
  2463 			iScreenRect = FolderListRectInThisResolution();
  2604 			iScreenRect = FolderListRectInThisResolution();
  2464 			}
  2605 			}
  2465 		else if ( iSortListCallback )
  2606 		else if ( iSortListCallback )
  2466 			{
  2607 			{
  2467             iCtrlButtonRect = iSortListCallback->SortButtonRect();
  2608             iCtrlButtonRect = iSortListCallback->SortButtonRect();
  2468 			iScreenRect = SortListRectInThisResolution();
  2609             iCtrlButtonRect.Move( cbr.iTl );
       
  2610             iScreenRect = SortListRectInThisResolution();
  2469 			}
  2611 			}
  2470 		else
  2612 		else
  2471 		    {
  2613 		    {
  2472 		    // Do nothing. This happens if HandleDynamicVariantSwitch() is called while the popup list is not visible. 
  2614 		    // Do nothing. This happens if HandleDynamicVariantSwitch() is called while the popup list is not visible.
  2473 		    }
  2615 		    }
  2474 		}
  2616 		}
  2475 	iListIconSize = iAppUi.LayoutHandler()->FolderListIconSize( !iFullScreen );
  2617 	iListIconSize = iAppUi.LayoutHandler()->FolderListIconSize( !iFullScreen );
  2476 	}
  2618 	}
  2477 
  2619 
  2509 void CFSEmailUiFolderListVisualiser::LoadIconsL()
  2651 void CFSEmailUiFolderListVisualiser::LoadIconsL()
  2510 	{
  2652 	{
  2511     FUNC_LOG;
  2653     FUNC_LOG;
  2512 	iIconArray.Reset();
  2654 	iIconArray.Reset();
  2513 	if ( iFullScreen )
  2655 	if ( iFullScreen )
  2514 	    {	
  2656 	    {
  2515         // NOTE: Must be appended same order as are in TFsEmailUiFolderListIcons!	
  2657         // NOTE: Must be appended same order as are in TFsEmailUiFolderListIcons!
  2516         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListInboxTexture ) );   			// EFolderListIconInbox
  2658         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListInboxTexture ) );   			// EFolderListIconInbox
  2517         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListInboxSubfoldersTexture ) );	// EFolderListIconInboxSubfolders
  2659         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListInboxSubfoldersTexture ) );	// EFolderListIconInboxSubfolders
  2518         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListOutboxTexture ) );  			// EFolderListIconOutbox
  2660         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListOutboxTexture ) );  			// EFolderListIconOutbox
  2519         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListDraftsTexture ) );  			// EFolderListIconDrafts
  2661         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListDraftsTexture ) );  			// EFolderListIconDrafts
  2520         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListSentTexture ) );    			// EFolderListIconSent
  2662         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListSentTexture ) );    			// EFolderListIconSent
  2523         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListMoreFoldersTexture ) ); 		// EFolderListIconMoreFolders
  2665         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListMoreFoldersTexture ) ); 		// EFolderListIconMoreFolders
  2524         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListEmailAccountTexture ) ); 	// EFolderListIconEmailAccount
  2666         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListEmailAccountTexture ) ); 	// EFolderListIconEmailAccount
  2525 	    }
  2667 	    }
  2526 	else
  2668 	else
  2527 	    {
  2669 	    {
  2528         // NOTE: Must be appended same order as are in TFsEmailUiFolderListIcons!   
  2670         // NOTE: Must be appended same order as are in TFsEmailUiFolderListIcons!
  2529         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListInboxTexturePopup ) );            // EFolderListIconInbox
  2671         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListInboxTexturePopup ) );            // EFolderListIconInbox
  2530         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListInboxSubfoldersTexturePopup ) );  // EFolderListIconInboxSubfolders
  2672         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListInboxSubfoldersTexturePopup ) );  // EFolderListIconInboxSubfolders
  2531         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListOutboxTexturePopup ) );           // EFolderListIconOutbox
  2673         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListOutboxTexturePopup ) );           // EFolderListIconOutbox
  2532         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListDraftsTexturePopup ) );           // EFolderListIconDrafts
  2674         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListDraftsTexturePopup ) );           // EFolderListIconDrafts
  2533         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListSentTexturePopup ) );             // EFolderListIconSent
  2675         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListSentTexturePopup ) );             // EFolderListIconSent
  2534         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListDeletedItemsTexturePopup ) );     // EFolderListIconDeleted
  2676         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListDeletedItemsTexturePopup ) );     // EFolderListIconDeleted
  2535         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListServerFoldersTexturePopup ) );    // EFolderListIconServerFolders
  2677         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListServerFoldersTexturePopup ) );    // EFolderListIconServerFolders
  2536         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListMoreFoldersTexturePopup ) );      // EFolderListIconMoreFolders
  2678         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListMoreFoldersTexturePopup ) );      // EFolderListIconMoreFolders
  2537         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListEmailAccountTexturePopup ) );     // EFolderListIconEmailAccount	    
  2679         iIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( EFolderListEmailAccountTexturePopup ) );     // EFolderListIconEmailAccount
       
  2680 	    
       
  2681 	    // NOTE: Must be appended same order as are in TFsEmailUiSortListIcons!
       
  2682         iSortIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( ESortListAttachmentAscTexture ) );       // ESortListAttachmentAscIcon
       
  2683         iSortIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( ESortListAttachmentDescTexture ) );      // ESortListAttachmentDescIcon
       
  2684         iSortIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( ESortListDateAscTexture ) );       		 // ESortListDateAscIcon
       
  2685         iSortIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( ESortListDateDescTexture ) );       	 // ESortListDateDescIcon
       
  2686         iSortIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( ESortListFollowAscTexture ) );       	 // ESortListFollowAscIcon
       
  2687         iSortIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( ESortListFollowDescTexture ) );        	 // ESortListFollowDescIcon
       
  2688         iSortIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( ESortListPriorityAscTexture ) );         // ESortListPriorityAscIcon
       
  2689         iSortIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( ESortListPriorityDescTexture ) );        // ESortListPriorityDescIcon
       
  2690         iSortIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( ESortListSenderAscTexture ) );       	 // ESortListSenderAscIcon
       
  2691         iSortIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( ESortListSenderDescTexture ) );       	 // ESortListSenderDescIcon
       
  2692         iSortIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( ESortListSubjectAscTexture ) );       	 // ESortListSubjectAscIcon
       
  2693         iSortIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( ESortListSubjectDescTexture ) );       	 // ESortListSubjectDescIcon
       
  2694         iSortIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( ESortListUnreadAscTexture ) );       	 // ESortListUnreadAscIcon
       
  2695         iSortIconArray.AppendL( &iAppUi.FsTextureManager()->TextureByIndex( ESortListUnreadDescTexture ) );       	 // ESortListUnreadDescIcon
  2538 	    }
  2696 	    }
  2539 	}
  2697 	}
  2540 
  2698 
  2541 void CFSEmailUiFolderListVisualiser::ResizeListIcons()
  2699 void CFSEmailUiFolderListVisualiser::ResizeListIcons()
  2542 	{
  2700 	{
  2559 		// Then resize used branded mailbox icons
  2717 		// Then resize used branded mailbox icons
  2560 		//       Branded mailbox icons are not stored anymore in our own
  2718 		//       Branded mailbox icons are not stored anymore in our own
  2561 		//       array, instead those are owned by texture manager. So
  2719 		//       array, instead those are owned by texture manager. So
  2562 		//       those should be resized by other means. But currently
  2720 		//       those should be resized by other means. But currently
  2563 		//       there is no way to do it (see above comment).
  2721 		//       there is no way to do it (see above comment).
       
  2722 		
       
  2723 		// Then resize sort list icons
       
  2724 		TInt arraySizeSort = iSortIconArray.Count();
       
  2725 		for( TInt i = 0; i < arraySizeSort; i++ )
       
  2726 			{
       
  2727 			iSortIconArray[i]->Size().SetSize( iListIconSize.iWidth, iListIconSize.iHeight );
       
  2728 			}
  2564 		}
  2729 		}
  2565 	}
  2730 	}
  2566 
  2731 
  2567 // ---------------------------------------------------------------------------
  2732 // ---------------------------------------------------------------------------
  2568 // Resizes the list items without recreating all items
  2733 // Resizes the list items without recreating all items
  2584 //
  2749 //
  2585 void CFSEmailUiFolderListVisualiser::AdaptScreenRectToListContent()
  2750 void CFSEmailUiFolderListVisualiser::AdaptScreenRectToListContent()
  2586 	{
  2751 	{
  2587     FUNC_LOG;
  2752     FUNC_LOG;
  2588     const TInt popupHeight( iScreenRect.Height() );
  2753     const TInt popupHeight( iScreenRect.Height() );
  2589     const TInt separatorHeight( iListSeparatorHeight * 
  2754     const TInt separatorHeight( iListSeparatorHeight *
  2590             iModel->SeparatorCount() );
  2755             iModel->SeparatorCount() );
  2591     const TInt itemCount( iTreeList->Count() - iModel->SeparatorCount() );    
  2756     const TInt itemCount( iTreeList->Count() - iModel->SeparatorCount() );
  2592     TInt visibleItemCount( ( popupHeight - separatorHeight ) / 
  2757     TInt visibleItemCount( ( popupHeight - separatorHeight ) /
  2593             iListItemHeight );    
  2758             iListItemHeight );
  2594     visibleItemCount = Min( visibleItemCount, itemCount );   
  2759     visibleItemCount = Min( visibleItemCount, itemCount );
  2595     iScreenRect.SetHeight( visibleItemCount * iListItemHeight + 
  2760     iScreenRect.SetHeight( visibleItemCount * iListItemHeight +
  2596             separatorHeight + 
  2761             separatorHeight +
  2597             iAppUi.LayoutHandler()->DropDownMenuListPadding() * 2 + 
  2762             iAppUi.LayoutHandler()->DropDownMenuListPadding() * 2 +
  2598             iAppUi.LayoutHandler()->ControlBarListPadding().iY );
  2763             iAppUi.LayoutHandler()->ControlBarListPadding().iY );
  2599 	AdjustWidthByContent( iScreenRect );
  2764 	AdjustWidthByContent( iScreenRect );
  2600 	}
  2765 	}
  2601 
  2766 
  2602 // ---------------------------------------------------------------------------
  2767 // ---------------------------------------------------------------------------
  2603 // Adjusts list width according to content.
  2768 // Adjusts list width according to content.
  2604 // ---------------------------------------------------------------------------
  2769 // ---------------------------------------------------------------------------
  2605 //
  2770 //
  2606 void CFSEmailUiFolderListVisualiser::AdjustWidthByContent( TRect& aRect ) const
  2771 void CFSEmailUiFolderListVisualiser::AdjustWidthByContent( TRect& aRect ) const
  2607     {
  2772     {
       
  2773     const TRect oldButtonRect( iScreenRect );
  2608     const TInt buttonWidth( iCtrlButtonRect.Width() );
  2774     const TInt buttonWidth( iCtrlButtonRect.Width() );
  2609     const TInt currentWidth( aRect.Width() );
  2775     const TInt currentWidth( aRect.Width() );
  2610 
  2776 
  2611     // only do adjusting if the buttonWidth is smaller than current popup width
  2777     // only do adjusting if the buttonWidth is smaller than current popup width
  2612     if ( buttonWidth < currentWidth )
  2778     if ( buttonWidth < currentWidth )
  2613         {
  2779         {
       
  2780         TBool landscape( Layout_Meta_Data::IsLandscapeOrientation() );
  2614         TAknLayoutRect scrollPane;
  2781         TAknLayoutRect scrollPane;
  2615         scrollPane.LayoutRect( aRect,
  2782         scrollPane.LayoutRect( aRect,
  2616                 AknLayoutScalable_Apps::sp_fs_scroll_pane_cp01( 6 ) );
  2783                 AknLayoutScalable_Apps::sp_fs_scroll_pane_cp01( 6 ) );
  2617         const TInt scrollPaneWidth( scrollPane.Rect().Width() );
  2784         const TInt scrollPaneWidth( scrollPane.Rect().Width() );
  2618         
  2785 
  2619         TAknLayoutText textLayout;
  2786         TAknLayoutText textLayout;
  2620         textLayout.LayoutText( aRect,
  2787         textLayout.LayoutText( aRect,
  2621                 AknLayoutScalable_Apps::list_single_dyc_row_text_pane_t1( 0 ) );
  2788                 AknLayoutScalable_Apps::list_single_dyc_row_text_pane_t1( 0 ) );
  2622         const CFont& font( *(textLayout.Font()) );
  2789         const CFont& font( *(textLayout.Font()) );
  2623         const TInt padding(
  2790         const TInt padding(
  2672                     else
  2839                     else
  2673                         {
  2840                         {
  2674                         aRect.Move( -aRect.iTl.iX + iCtrlButtonRect.iTl.iX, 0 );
  2841                         aRect.Move( -aRect.iTl.iX + iCtrlButtonRect.iTl.iX, 0 );
  2675                         }
  2842                         }
  2676                     }
  2843                     }
       
  2844                 
       
  2845                 // Keep the right edge position unchanged
       
  2846                 if( landscape )
       
  2847                     {
       
  2848                     aRect.Move( oldButtonRect.iBr.iX - aRect.iBr.iX, 0 );
       
  2849                     }
  2677                 }
  2850                 }
  2678             }
  2851             }
  2679         }
  2852         }
  2680     else
  2853     else
  2681         {
  2854         {
  2696         }
  2869         }
  2697     else
  2870     else
  2698         {
  2871         {
  2699         iListHeaderHeight = 0;
  2872         iListHeaderHeight = 0;
  2700         }
  2873         }
  2701     
  2874 
  2702     TSize mainPaneSize;
  2875     TSize mainPaneSize;
  2703     AknLayoutUtils::LayoutMetricsSize(AknLayoutUtils::EMainPane, mainPaneSize);
  2876     AknLayoutUtils::LayoutMetricsSize(AknLayoutUtils::EMainPane, mainPaneSize);
  2704     
  2877 
  2705     // Set anchor for background visual
  2878     // Set anchor for background visual
  2706     iParentLayout->SetAnchor(EAlfAnchorTopLeft,
  2879     iParentLayout->SetAnchor(EAlfAnchorTopLeft,
  2707                     0,
  2880                     0,
  2708                     EAlfAnchorOriginLeft,
  2881                     EAlfAnchorOriginLeft,
  2709                     EAlfAnchorOriginTop,
  2882                     EAlfAnchorOriginTop,
  2715                     EAlfAnchorOriginRight,
  2888                     EAlfAnchorOriginRight,
  2716                     EAlfAnchorOriginTop,
  2889                     EAlfAnchorOriginTop,
  2717                     EAlfAnchorMetricAbsolute,
  2890                     EAlfAnchorMetricAbsolute,
  2718                     EAlfAnchorMetricAbsolute,
  2891                     EAlfAnchorMetricAbsolute,
  2719                     TAlfTimedPoint(mainPaneSize.iWidth,mainPaneSize.iHeight));
  2892                     TAlfTimedPoint(mainPaneSize.iWidth,mainPaneSize.iHeight));
  2720     
  2893 
  2721 	// Set anchor for header text visual
  2894 	// Set anchor for header text visual
  2722 	iParentLayout->SetAnchor(EAlfAnchorTopLeft,
  2895 	iParentLayout->SetAnchor(EAlfAnchorTopLeft,
  2723 					1,
  2896 					1,
  2724 					EAlfAnchorOriginLeft,
  2897 					EAlfAnchorOriginLeft,
  2725 					EAlfAnchorOriginTop,
  2898 					EAlfAnchorOriginTop,
  2762     FUNC_LOG;
  2935     FUNC_LOG;
  2763     TInt topLevelCount = iTreeList->CountChildren( KFsTreeRootID );
  2936     TInt topLevelCount = iTreeList->CountChildren( KFsTreeRootID );
  2764     if ( topLevelCount )
  2937     if ( topLevelCount )
  2765         {
  2938         {
  2766         TFsTreeItemId topId = iTreeList->Child(KFsTreeRootID, 0);
  2939         TFsTreeItemId topId = iTreeList->Child(KFsTreeRootID, 0);
  2767         iTreeVisualizer->SetFocusedItemL( topId );            
  2940         iTreeVisualizer->SetFocusedItemL( topId );
  2768         }
  2941         }
  2769     }
  2942     }
  2770 
  2943 
  2771 // ---------------------------------------------------------------------------
  2944 // ---------------------------------------------------------------------------
  2772 // Moves the focus to the bottommost item
  2945 // Moves the focus to the bottommost item
  2776     {
  2949     {
  2777     FUNC_LOG;
  2950     FUNC_LOG;
  2778     // There may be arbitrary number of nested sub folders. Make sure we focus
  2951     // There may be arbitrary number of nested sub folders. Make sure we focus
  2779     // the bottommost visible subfolder.
  2952     // the bottommost visible subfolder.
  2780     TFsTreeItemId bottomId = KFsTreeRootID;
  2953     TFsTreeItemId bottomId = KFsTreeRootID;
  2781     
  2954 
  2782     while ( iTreeList->IsNode(bottomId) && 
  2955     while ( iTreeList->IsNode(bottomId) &&
  2783             iTreeList->IsExpanded(bottomId) &&
  2956             iTreeList->IsExpanded(bottomId) &&
  2784             iTreeList->CountChildren(bottomId) )
  2957             iTreeList->CountChildren(bottomId) )
  2785         {
  2958         {
  2786         bottomId = iTreeList->Child( bottomId, iTreeList->CountChildren(bottomId)-1 );
  2959         bottomId = iTreeList->Child( bottomId, iTreeList->CountChildren(bottomId)-1 );
  2787         }
  2960         }
  2788     
  2961 
  2789     if ( bottomId != KFsTreeRootID )
  2962     if ( bottomId != KFsTreeRootID )
  2790         {
  2963         {
  2791         iTreeVisualizer->SetFocusedItemL( bottomId );            
  2964         iTreeVisualizer->SetFocusedItemL( bottomId );
  2792         }
  2965         }
  2793     }
  2966     }
  2794 
  2967 
  2795 // ---------------------------------------------------------------------------
  2968 // ---------------------------------------------------------------------------
  2796 // Updates the toolbar buttons (sets the dimmed status of the collapse
  2969 // Updates the toolbar buttons (sets the dimmed status of the collapse
  2811 TBool CFSEmailUiFolderListVisualiser::AllNodesCollapsed() const
  2984 TBool CFSEmailUiFolderListVisualiser::AllNodesCollapsed() const
  2812     {
  2985     {
  2813     FUNC_LOG;
  2986     FUNC_LOG;
  2814     TFsTreeItemId itemId = KFsTreeNoneID;
  2987     TFsTreeItemId itemId = KFsTreeNoneID;
  2815     TInt count = iTreeList->CountChildren(KFsTreeRootID);
  2988     TInt count = iTreeList->CountChildren(KFsTreeRootID);
  2816 	
  2989 
  2817 	// If top level is collapsed, then everything is collapsed. There's no need
  2990 	// If top level is collapsed, then everything is collapsed. There's no need
  2818 	// to crawl any deeper in the tree hierarchy.
  2991 	// to crawl any deeper in the tree hierarchy.
  2819 	for ( TInt i=0 ; i<count ; ++i )
  2992 	for ( TInt i=0 ; i<count ; ++i )
  2820 	    {
  2993 	    {
  2821 	    itemId = iTreeList->Child( KFsTreeRootID, i );
  2994 	    itemId = iTreeList->Child( KFsTreeRootID, i );
  2823 	         iTreeList->IsExpanded(itemId) )
  2996 	         iTreeList->IsExpanded(itemId) )
  2824 	        {
  2997 	        {
  2825 	        return EFalse;
  2998 	        return EFalse;
  2826 	        }
  2999 	        }
  2827 	    }
  3000 	    }
  2828 	
  3001 
  2829 	return ETrue;
  3002 	return ETrue;
  2830     }
  3003     }
  2831 
  3004 
  2832 // ---------------------------------------------------------------------------
  3005 // ---------------------------------------------------------------------------
  2833 // Tells if all expandable nodes are expanded
  3006 // Tells if all expandable nodes are expanded
  2836 TBool CFSEmailUiFolderListVisualiser::AllNodesExpanded( TFsTreeItemId aParentNodeId ) const
  3009 TBool CFSEmailUiFolderListVisualiser::AllNodesExpanded( TFsTreeItemId aParentNodeId ) const
  2837     {
  3010     {
  2838     FUNC_LOG;
  3011     FUNC_LOG;
  2839     // We must crawl through the whole tree to see, if there are any collapsed nodes
  3012     // We must crawl through the whole tree to see, if there are any collapsed nodes
  2840     // at any level. We do this with recursive depth-first-search.
  3013     // at any level. We do this with recursive depth-first-search.
  2841     
  3014 
  2842     TFsTreeItemId itemId = KFsTreeNoneID;
  3015     TFsTreeItemId itemId = KFsTreeNoneID;
  2843     TInt count = iTreeList->CountChildren(aParentNodeId);
  3016     TInt count = iTreeList->CountChildren(aParentNodeId);
  2844     
  3017 
  2845     for ( TInt i=0 ; i<count ; ++i )
  3018     for ( TInt i=0 ; i<count ; ++i )
  2846         {
  3019         {
  2847         itemId = iTreeList->Child( aParentNodeId, i );
  3020         itemId = iTreeList->Child( aParentNodeId, i );
  2848         if ( iTreeList->IsNode(itemId) )
  3021         if ( iTreeList->IsNode(itemId) )
  2849             {
  3022             {
  2852                 {
  3025                 {
  2853                 return EFalse;
  3026                 return EFalse;
  2854                 }
  3027                 }
  2855             }
  3028             }
  2856         }
  3029         }
  2857 	
  3030 
  2858 	return ETrue;
  3031 	return ETrue;
  2859     }
  3032     }
  2860 
  3033 
  2861 // ---------------------------------------------------------------------------
  3034 // ---------------------------------------------------------------------------
  2862 // Does a horizontal scrolling for the list by resizing and moving the list
  3035 // Does a horizontal scrolling for the list by resizing and moving the list
  2873         TFsTreeItemId focusedId = iTreeList->FocusedItem();
  3046         TFsTreeItemId focusedId = iTreeList->FocusedItem();
  2874         if ( focusedId > KFsTreeRootID )
  3047         if ( focusedId > KFsTreeRootID )
  2875             {
  3048             {
  2876             // Get the list level
  3049             // Get the list level
  2877             TUint level = iTreeList->Level( focusedId );
  3050             TUint level = iTreeList->Level( focusedId );
  2878             
  3051 
  2879             // Little optimisation, handle all levels up to KListLastBasicLevel
  3052             // Little optimisation, handle all levels up to KListLastBasicLevel
  2880             // as root level because horizontal scroll amount is same for all
  3053             // as root level because horizontal scroll amount is same for all
  2881             if( level <= KListLastBasicLevel )
  3054             if( level <= KListLastBasicLevel )
  2882                 {
  3055                 {
  2883                 level = KListRootLevel;
  3056                 level = KListRootLevel;
  2884                 }
  3057                 }
  2885             
  3058 
  2886             // Recalculate the list rect only if level has changed or if
  3059             // Recalculate the list rect only if level has changed or if
  2887             // recalculation is forced by parameter (e.g. in case of
  3060             // recalculation is forced by parameter (e.g. in case of
  2888             // dynamic variant switch)
  3061             // dynamic variant switch)
  2889             if( ( level != iPreviousListLevel ) || aForceRecalculation )
  3062             if( ( level != iPreviousListLevel ) || aForceRecalculation )
  2890                 {
  3063                 {
  2891                 TRect listRect = iListLayout->DisplayRectTarget();
  3064                 TRect listRect = iListLayout->DisplayRectTarget();
  2892                 
  3065 
  2893                 // Calulate list rect by taking x-coordinates from iScreenRect
  3066                 // Calulate list rect by taking x-coordinates from iScreenRect
  2894                 // and y-coordinates from list layouts target rect (to take
  3067                 // and y-coordinates from list layouts target rect (to take
  2895                 // into account the list header)
  3068                 // into account the list header)
  2896                 listRect.SetRect( iScreenRect.iTl.iX, listRect.iTl.iY,
  3069                 listRect.SetRect( iScreenRect.iTl.iX, listRect.iTl.iY,
  2897                                   iScreenRect.iBr.iX, listRect.iBr.iY );
  3070                                   iScreenRect.iBr.iX, listRect.iBr.iY );
  2898                 
  3071 
  2899                 if( level > KListLastBasicLevel )
  3072                 if( level > KListLastBasicLevel )
  2900                     {
  3073                     {
  2901                     // Calculate rect according to current level
  3074                     // Calculate rect according to current level
  2902                     TInt rectChange = (level - KListLastBasicLevel) * iTreeList->Indentation();
  3075                     TInt rectChange = (level - KListLastBasicLevel) * iTreeList->Indentation();
  2903                     listRect.SetWidth( iScreenRect.Width() + rectChange );
  3076                     listRect.SetWidth( iScreenRect.Width() + rectChange );
  2904                     listRect.Move( -rectChange, 0 );
  3077                     listRect.Move( -rectChange, 0 );
  2905                     }
  3078                     }
  2906     
  3079 
  2907                 // Set the list rect only if it has changed from previous
  3080                 // Set the list rect only if it has changed from previous
  2908                 // (because list refresh causes a little twitch)
  3081                 // (because list refresh causes a little twitch)
  2909                 if( listRect != iPreviousListRect )
  3082                 if( listRect != iPreviousListRect )
  2910                     {
  3083                     {
  2911                     iListLayout->SetRect( listRect, iAppUi.LayoutHandler()->CtrlBarListFadeEffectTime() );
  3084                     iListLayout->SetRect( listRect, iAppUi.LayoutHandler()->CtrlBarListFadeEffectTime() );
  2912                     iTreeVisualizer->RefreshListViewL();
  3085                     iTreeVisualizer->RefreshListViewL();
  2913                     iPreviousListRect = listRect;
  3086                     iPreviousListRect = listRect;
  2914                     }
  3087                     }
  2915                 
  3088 
  2916                 iPreviousListLevel = level;
  3089                 iPreviousListLevel = level;
  2917                 }
  3090                 }
  2918             }
  3091             }
  2919         }
  3092         }
  2920     }
  3093     }
  2975             // enable collapsing.
  3148             // enable collapsing.
  2976             Toolbar()->SetItemDimmed( EFsEmailUiTbCmdCollapseAll, EFalse, ETrue );
  3149             Toolbar()->SetItemDimmed( EFsEmailUiTbCmdCollapseAll, EFalse, ETrue );
  2977             Toolbar()->SetItemDimmed( EFsEmailUiTbCmdExpandAll, ETrue, ETrue );
  3150             Toolbar()->SetItemDimmed( EFsEmailUiTbCmdExpandAll, ETrue, ETrue );
  2978             break;
  3151             break;
  2979             }
  3152             }
       
  3153         case EFsFocusVisibilityChange:
       
  3154             {
       
  3155             iAppUi.SetFocusVisibility( EFalse );
       
  3156             break;
       
  3157             }
       
  3158         default:
       
  3159             {
       
  3160             // No need to handle other events.
       
  3161             break;
       
  3162             }
  2980         }
  3163         }
  2981     }
  3164     }
  2982 
  3165 
  2983 // ---------------------------------------------------------------------------
  3166 // ---------------------------------------------------------------------------
  2984 // HandleMailBoxEventL
  3167 // HandleMailBoxEventL
  2987 //
  3170 //
  2988 void CFSEmailUiFolderListVisualiser::HandleMailBoxEventL( TFSMailEvent aEvent,
  3171 void CFSEmailUiFolderListVisualiser::HandleMailBoxEventL( TFSMailEvent aEvent,
  2989     TFSMailMsgId aMailboxId, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
  3172     TFSMailMsgId aMailboxId, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
  2990     {
  3173     {
  2991     FUNC_LOG;
  3174     FUNC_LOG;
  2992     
  3175 
  2993     // Handle the event
  3176     // Handle the event
  2994     if ( iMoveOrCopyInitiated && 
  3177     if ( iMoveOrCopyInitiated &&
  2995          iFirstStartCompleted && 
  3178          iFirstStartCompleted &&
  2996          aMailboxId == iAppUi.GetActiveMailboxId() &&
  3179          aMailboxId == iAppUi.GetActiveMailboxId() &&
  2997          iAppUi.CurrentActiveView() == this ) 
  3180          iAppUi.CurrentActiveView() == this )
  2998         {
  3181         {
  2999 		if ( aEvent == TFSEventMailboxOnline ) 
  3182 		if ( aEvent == TFSEventMailboxOnline )
  3000 			{
  3183 			{
  3001             if( iWaitingToGoOnline )
  3184             if( iWaitingToGoOnline )
  3002                 {
  3185                 {
  3003                 PrepareFolderListL();
  3186                 PrepareFolderListL();
  3004                 PopulateFolderListL();
  3187                 PopulateFolderListL();
  3005                 
  3188 
  3006                 if ( iModel->Count() )
  3189                 if ( iModel->Count() )
  3007                     {
  3190                     {
  3008                     SetFocusToLatestMovedFolderL(); 
  3191                     SetFocusToLatestMovedFolderL();
  3009                     }
  3192                     }
       
  3193                 iTreeList->SetFocusedL( ETrue );
       
  3194                 iWaitingToGoOnline = EFalse;
  3010                 }
  3195                 }
  3011 			}
  3196 			}
  3012    		else if ( aEvent == TFSEventMailboxOffline )
  3197    		else if ( aEvent == TFSEventMailboxOffline )
  3013    			{
  3198    			{
  3014             // Empty the list when disconnected if connection is needed for
  3199             // Empty the list when disconnected if connection is needed for
  3020 			}
  3205 			}
  3021         }
  3206         }
  3022     }
  3207     }
  3023 
  3208 
  3024 // ---------------------------------------------------------------------------
  3209 // ---------------------------------------------------------------------------
       
  3210 //
       
  3211 // ---------------------------------------------------------------------------
       
  3212 //
       
  3213 void CFSEmailUiFolderListVisualiser::FocusVisibilityChange( TBool aVisible )
       
  3214     {
       
  3215     FUNC_LOG;
       
  3216     CFsEmailUiViewBase::FocusVisibilityChange( aVisible );
       
  3217     iTreeVisualizer->SetFocusVisibility( aVisible );
       
  3218     }
       
  3219 
       
  3220 // ---------------------------------------------------------------------------
  3025 // CbaButtonPressed
  3221 // CbaButtonPressed
  3026 // Check if aPosition is on CBA touch area
  3222 // Check if aPosition is on CBA touch area
  3027 // ---------------------------------------------------------------------------
  3223 // ---------------------------------------------------------------------------
  3028 //
  3224 //
  3029 TBool CFSEmailUiFolderListVisualiser::CbaButtonPressed( TPoint aPosition )
  3225 TBool CFSEmailUiFolderListVisualiser::CbaButtonPressed( TPoint aPosition )
  3030     {
  3226     {
  3031     TBool cbaPressed( EFalse );
  3227     TBool cbaPressed( EFalse );
  3032     
  3228 
  3033     TRect leftCbaRect = TRect();
  3229     TRect leftCbaRect = TRect();
  3034     TRect rightCbaRect = TRect();
  3230     TRect rightCbaRect = TRect();
  3035     GetCbaRects( leftCbaRect, rightCbaRect );
  3231     GetCbaRects( leftCbaRect, rightCbaRect );
  3036     if ( leftCbaRect.Contains( aPosition ) ||
  3232     if ( leftCbaRect.Contains( aPosition ) ||
  3037          rightCbaRect.Contains( aPosition ))
  3233          rightCbaRect.Contains( aPosition ))
  3047 // Resolve CBA touch areas from layouts
  3243 // Resolve CBA touch areas from layouts
  3048 // ---------------------------------------------------------------------------
  3244 // ---------------------------------------------------------------------------
  3049 //
  3245 //
  3050 void CFSEmailUiFolderListVisualiser::GetCbaRects( TRect& aLeftCbaRect, TRect& aRightCbaRect )
  3246 void CFSEmailUiFolderListVisualiser::GetCbaRects( TRect& aLeftCbaRect, TRect& aRightCbaRect )
  3051     {
  3247     {
  3052     TBool rightPaneActive( IsAreaSideRightPaneActive() );    
  3248     TBool rightPaneActive( IsAreaSideRightPaneActive() );
  3053     TBool bskLandscape( Layout_Meta_Data::IsLandscapeOrientation() &&
  3249     TBool bskLandscape( Layout_Meta_Data::IsLandscapeOrientation() &&
  3054                         !rightPaneActive );
  3250                         !rightPaneActive );
  3055     TRect screen;
  3251     TRect screen;
  3056     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screen );
  3252     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screen );
  3057     if ( rightPaneActive )
  3253     if ( rightPaneActive )
  3058         {
  3254         {
  3059         TAknWindowComponentLayout rightAreaLayout(
  3255         TAknWindowComponentLayout rightAreaLayout(
  3060             AknLayoutScalable_Avkon::area_side_right_pane( 0 ) );
  3256             AknLayoutScalable_Avkon::area_side_right_pane( 0 ) );
  3061             
  3257 
  3062         TAknLayoutRect layoutRect;
  3258         TAknLayoutRect layoutRect;
  3063         // Read right (top in landscape) softkey layout.      
  3259         // Read right (top in landscape) softkey layout.
  3064         layoutRect.LayoutRect(
  3260         layoutRect.LayoutRect(
  3065                 screen,
  3261                 screen,
  3066                 TAknWindowComponentLayout::Compose(
  3262                 TAknWindowComponentLayout::Compose(
  3067                 rightAreaLayout,
  3263                 rightAreaLayout,
  3068                 AknLayoutScalable_Avkon::sctrl_sk_bottom_pane() ).LayoutLine() );
  3264                 AknLayoutScalable_Avkon::sctrl_sk_bottom_pane() ).LayoutLine() );
  3069         TRect bottomSKRect( layoutRect.Rect() );
  3265         TRect bottomSKRect( layoutRect.Rect() );
  3070 
  3266 
  3071         // Read left (bottom in landscape) softkey layout.       
  3267         // Read left (bottom in landscape) softkey layout.
  3072         layoutRect.LayoutRect(
  3268         layoutRect.LayoutRect(
  3073                 screen,
  3269                 screen,
  3074                 TAknWindowComponentLayout::Compose(
  3270                 TAknWindowComponentLayout::Compose(
  3075                 rightAreaLayout,
  3271                 rightAreaLayout,
  3076                 AknLayoutScalable_Avkon::sctrl_sk_top_pane() ).LayoutLine() );
  3272                 AknLayoutScalable_Avkon::sctrl_sk_top_pane() ).LayoutLine() );
  3082         aLeftCbaRect = layoutRect.Rect();
  3278         aLeftCbaRect = layoutRect.Rect();
  3083 
  3279 
  3084         layoutRect.LayoutRect(
  3280         layoutRect.LayoutRect(
  3085             topSKRect,
  3281             topSKRect,
  3086             AknLayoutScalable_Avkon::aid_touch_sctrl_top().LayoutLine() );
  3282             AknLayoutScalable_Avkon::aid_touch_sctrl_top().LayoutLine() );
  3087         aRightCbaRect = layoutRect.Rect();        
  3283         aRightCbaRect = layoutRect.Rect();
  3088         }
  3284         }
  3089     else
  3285     else
  3090         {          
  3286         {
  3091         TAknWindowComponentLayout applicationWindow(
  3287         TAknWindowComponentLayout applicationWindow(
  3092             AknLayoutScalable_Avkon::application_window( 0 ) );
  3288             AknLayoutScalable_Avkon::application_window( 0 ) );
  3093         TAknLayoutRect cbarect;
  3289         TAknLayoutRect cbarect;
  3094         cbarect.LayoutRect(
  3290         cbarect.LayoutRect(
  3095             screen,
  3291             screen,
  3097                 applicationWindow,
  3293                 applicationWindow,
  3098                 TAknWindowComponentLayout::Compose(
  3294                 TAknWindowComponentLayout::Compose(
  3099                     AknLayoutScalable_Avkon::area_bottom_pane( bskLandscape ? 2 : 1 ),
  3295                     AknLayoutScalable_Avkon::area_bottom_pane( bskLandscape ? 2 : 1 ),
  3100                     AknLayoutScalable_Avkon::control_pane() ) ).LayoutLine() );
  3296                     AknLayoutScalable_Avkon::control_pane() ) ).LayoutLine() );
  3101         aLeftCbaRect = cbarect.Rect();
  3297         aLeftCbaRect = cbarect.Rect();
  3102         }    
  3298         }
  3103     }
  3299     }
  3104 
  3300 
  3105 // ---------------------------------------------------------------------------
  3301 // ---------------------------------------------------------------------------
  3106 // IsAreaSideRightPaneActive
  3302 // IsAreaSideRightPaneActive
  3107 // Checks if right side pane is active.
  3303 // Checks if right side pane is active.
  3110 TBool CFSEmailUiFolderListVisualiser::IsAreaSideRightPaneActive()
  3306 TBool CFSEmailUiFolderListVisualiser::IsAreaSideRightPaneActive()
  3111     {
  3307     {
  3112     // Currently the widescreen status pane layout is in use only
  3308     // Currently the widescreen status pane layout is in use only
  3113     // when pen input (touch) is enabled.
  3309     // when pen input (touch) is enabled.
  3114     TBool result = EFalse;
  3310     TBool result = EFalse;
  3115     
  3311 
  3116     if ( Layout_Meta_Data::IsLandscapeOrientation() && 
  3312     if ( Layout_Meta_Data::IsLandscapeOrientation() &&
  3117          Layout_Meta_Data::IsPenEnabled() )
  3313          Layout_Meta_Data::IsPenEnabled() )
  3118         {
  3314         {
  3119         if ( iAvkonEnv->StatusPaneResIdForCurrentLayout(
  3315         if ( iAvkonEnv->StatusPaneResIdForCurrentLayout(
  3120                  AknStatuspaneUtils::CurrentStatusPaneLayoutResId() ) ==
  3316                  AknStatuspaneUtils::CurrentStatusPaneLayoutResId() ) ==
  3121                      R_AVKON_WIDESCREEN_PANE_LAYOUT_IDLE_FLAT_NO_SOFTKEYS )
  3317                      R_AVKON_WIDESCREEN_PANE_LAYOUT_IDLE_FLAT_NO_SOFTKEYS )