emailuis/emailui/src/FreestyleEmailUiSendAttachmentsListModel.cpp
changeset 0 8466d47a6819
child 2 5253a20d2a1e
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     1 /*
       
     2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Implements model for the attachment list view
       
    15 *
       
    16 */
       
    17 
       
    18 // SYSTEM INCLUDES
       
    19 //<cmail>
       
    20 #include "emailtrace.h"
       
    21 #include "fstreelist.h"
       
    22 #include <AknUtils.h>
       
    23 #include <StringLoader.h>
       
    24 #include <FreestyleEmailUi.rsg>
       
    25 #include "CFSMailClient.h"
       
    26 // <cmail> SF
       
    27 #include <alf/alfdecklayout.h>
       
    28 // </cmail>
       
    29 #include "fstreelist.h"
       
    30 #include "fstreevisualizerbase.h"
       
    31 #include "fstreeplainonelineitemdata.h"
       
    32 #include "fstreeplainonelineitemvisualizer.h"
       
    33 #include "fstreeplainonelinenodedata.h"
       
    34 #include "fstreeplainonelinenodevisualizer.h"
       
    35 #include "fstreeplaintwolineitemdata.h"
       
    36 #include "fstreeplaintwolineitemvisualizer.h"
       
    37 //</cmail>
       
    38 
       
    39 // <cmail> Use layout data instead of hard-coded values
       
    40 #include <aknlayoutscalable_apps.cdl.h>
       
    41 #include <layoutmetadata.cdl.h>
       
    42 // </cmail>
       
    43 
       
    44 
       
    45 // INTERNAL INCLUDES
       
    46 #include "FreestyleEmailUiAppui.h"
       
    47 #include "FreestyleEmailUi.hrh"
       
    48 #include "FreestyleEmailUiLayoutHandler.h"
       
    49 #include "FreestyleEmailUiTextureManager.h"
       
    50 #include "FreestyleEmailUiSendAttachmentsListModel.h"
       
    51 #include "FreestyleEmailUiSendAttachmentsListControl.h"
       
    52 #include "FreestyleEmailUiSendAttachmentsListVisualiser.h"
       
    53 #include "FreestyleEmailUiShortcutBinding.h"
       
    54 #include "FreestyleEmailUiUtilities.h"
       
    55 #include "ncscomposeview.h"
       
    56 #include "ncsconstants.h"
       
    57 
       
    58 // ---------------------------------------------------------------------------
       
    59 // Two-phased constructor.
       
    60 // ---------------------------------------------------------------------------
       
    61 //
       
    62 CFSEmailUiSendAttachmentsListModelItem* CFSEmailUiSendAttachmentsListModelItem::NewL( 
       
    63     const TDesC& aFileName, 
       
    64     TInt aFileSize,
       
    65     TFileType aFileType,
       
    66     TBool aRemote, 
       
    67     TBool aReadOnly )
       
    68     {
       
    69     FUNC_LOG;
       
    70     CFSEmailUiSendAttachmentsListModelItem* self = 
       
    71     	CFSEmailUiSendAttachmentsListModelItem::NewLC( 
       
    72     		aFileName, 
       
    73     		aFileSize,
       
    74     		aFileType,
       
    75     		aRemote,
       
    76     		aReadOnly );
       
    77     CleanupStack::Pop( self );
       
    78     return self;
       
    79     }
       
    80 
       
    81 // ---------------------------------------------------------------------------
       
    82 // Two-phased constructor.
       
    83 // ---------------------------------------------------------------------------
       
    84 //
       
    85 CFSEmailUiSendAttachmentsListModelItem* CFSEmailUiSendAttachmentsListModelItem::NewLC( 
       
    86     const TDesC& aFileName, 
       
    87     TInt aFileSize,
       
    88     TFileType aFileType,
       
    89     TBool aRemote, 
       
    90     TBool aReadOnly )
       
    91 	{
       
    92     FUNC_LOG;
       
    93     CFSEmailUiSendAttachmentsListModelItem* self = 
       
    94     	new (ELeave) CFSEmailUiSendAttachmentsListModelItem( 
       
    95     		aFileName, 
       
    96 			aFileSize,
       
    97 			aFileType,
       
    98 			aRemote, 
       
    99 			aReadOnly );
       
   100     CleanupStack::PushL( self );
       
   101     return self;
       
   102 	}
       
   103 
       
   104 // ---------------------------------------------------------------------------
       
   105 // c++ constructor.
       
   106 // ---------------------------------------------------------------------------
       
   107 //
       
   108 CFSEmailUiSendAttachmentsListModelItem::CFSEmailUiSendAttachmentsListModelItem( 
       
   109     const TDesC& aFileName, 
       
   110     TInt aFileSize,
       
   111     TFileType aFileType,
       
   112     TBool aRemote, 
       
   113     TBool aReadOnly )
       
   114    	:iFileName( aFileName ), 
       
   115      iFileSize( aFileSize ),
       
   116      iRemote( aRemote ),
       
   117      iReadOnly( aReadOnly ),
       
   118      iFileType( aFileType )
       
   119     {
       
   120     FUNC_LOG;
       
   121     }
       
   122 
       
   123 // ---------------------------------------------------------------------------
       
   124 // c++ destructor.
       
   125 // ---------------------------------------------------------------------------
       
   126 //
       
   127 CFSEmailUiSendAttachmentsListModelItem::~CFSEmailUiSendAttachmentsListModelItem() 
       
   128     {
       
   129     FUNC_LOG;
       
   130     }
       
   131 
       
   132 // ---------------------------------------------------------------------------
       
   133 // FileName
       
   134 // ---------------------------------------------------------------------------
       
   135 //
       
   136 const TDesC& CFSEmailUiSendAttachmentsListModelItem::FileName() const
       
   137     {
       
   138     FUNC_LOG;
       
   139     return iFileName;
       
   140     }
       
   141 
       
   142 // ---------------------------------------------------------------------------
       
   143 // FileExtension
       
   144 // ---------------------------------------------------------------------------
       
   145 //
       
   146 TPtrC CFSEmailUiSendAttachmentsListModelItem::FileExtension() const
       
   147     {
       
   148     FUNC_LOG;
       
   149     return TParsePtrC( iFileName ).Ext(); 
       
   150     }
       
   151 
       
   152 
       
   153 // ---------------------------------------------------------------------------
       
   154 // MailMsgPartId
       
   155 // ---------------------------------------------------------------------------
       
   156 //
       
   157 TFSMailMsgId CFSEmailUiSendAttachmentsListModelItem::MailMsgPartId() const
       
   158     {
       
   159     FUNC_LOG;
       
   160     return iMailMsgPartId;
       
   161     }
       
   162 
       
   163 // ---------------------------------------------------------------------------
       
   164 // MailMsgPartId
       
   165 // ---------------------------------------------------------------------------
       
   166 //
       
   167 void CFSEmailUiSendAttachmentsListModelItem::SetMailMsgPartId( 
       
   168     const TFSMailMsgId aPartId )
       
   169     {
       
   170     FUNC_LOG;
       
   171     iMailMsgPartId = aPartId;
       
   172     }
       
   173 
       
   174 // ---------------------------------------------------------------------------
       
   175 // GetFileSize
       
   176 // ---------------------------------------------------------------------------
       
   177 //
       
   178 TInt CFSEmailUiSendAttachmentsListModelItem::FileSize() const
       
   179 	{
       
   180     FUNC_LOG;
       
   181 	return iFileSize;
       
   182 	}
       
   183 
       
   184 // ---------------------------------------------------------------------------
       
   185 // GetFileSize
       
   186 // ---------------------------------------------------------------------------
       
   187 //
       
   188 TInt CFSEmailUiSendAttachmentsListModelItem::ItemId() const
       
   189 	{
       
   190     FUNC_LOG;
       
   191 	return iItemId;
       
   192 	}
       
   193 
       
   194 // ---------------------------------------------------------------------------
       
   195 // SetItemId
       
   196 // Sets Id to item for identification
       
   197 // ---------------------------------------------------------------------------
       
   198 //
       
   199 void CFSEmailUiSendAttachmentsListModelItem::SetItemId( TFsTreeItemId aItemId )
       
   200 	{
       
   201     FUNC_LOG;
       
   202 	iItemId = aItemId;
       
   203 	}
       
   204 
       
   205 // ---------------------------------------------------------------------------
       
   206 // IsRemote
       
   207 // 
       
   208 // ---------------------------------------------------------------------------
       
   209 //
       
   210 TBool CFSEmailUiSendAttachmentsListModelItem::IsRemote()
       
   211     {
       
   212     FUNC_LOG;
       
   213     return iRemote;
       
   214     }
       
   215 
       
   216 // ---------------------------------------------------------------------------
       
   217 // IsReadOnly
       
   218 // 
       
   219 // ---------------------------------------------------------------------------
       
   220 //
       
   221 TBool CFSEmailUiSendAttachmentsListModelItem::IsReadOnly()
       
   222     {
       
   223     FUNC_LOG;
       
   224     // As a temporary solution, all remote attachments are made non-removable.
       
   225     // Intellisync protocol should support removing also remote attachments
       
   226     // but this doesn't seem to work currently in the Intellisync plugin.
       
   227     return iReadOnly || iRemote;
       
   228     }
       
   229 
       
   230 // ---------------------------------------------------------------------------
       
   231 // FileType
       
   232 // 
       
   233 // ---------------------------------------------------------------------------
       
   234 //
       
   235 TFileType CFSEmailUiSendAttachmentsListModelItem::FileType()
       
   236     {
       
   237     FUNC_LOG;
       
   238     return iFileType;
       
   239     }
       
   240 
       
   241 // ---------------------------------------------------------------------------
       
   242 // SetRemote
       
   243 // 
       
   244 // ---------------------------------------------------------------------------
       
   245 //
       
   246 void CFSEmailUiSendAttachmentsListModelItem::SetRemote( TBool aIsRemote )
       
   247     {
       
   248     FUNC_LOG;
       
   249     iRemote = aIsRemote;
       
   250     }
       
   251 
       
   252 
       
   253 //MODEL CLASS CONSTRUCTION
       
   254 
       
   255 // ---------------------------------------------------------------------------
       
   256 // Two-phased constructor.
       
   257 // ---------------------------------------------------------------------------
       
   258 //
       
   259 CFSEmailUiSendAttachmentsListModel* CFSEmailUiSendAttachmentsListModel::NewL( 
       
   260     CFreestyleEmailUiAppUi* aAppUi,
       
   261     CAlfEnv& aEnv,
       
   262     CFreestyleEmailUiSendAttachmentsListControl* aControl )
       
   263     {
       
   264     FUNC_LOG;
       
   265     CFSEmailUiSendAttachmentsListModel* self = 
       
   266     	CFSEmailUiSendAttachmentsListModel::NewLC( 
       
   267             aAppUi,
       
   268             aEnv,
       
   269             aControl );
       
   270     CleanupStack::Pop( self );
       
   271     return self;
       
   272     }
       
   273 
       
   274 // ---------------------------------------------------------------------------
       
   275 // Two-phased constructor.
       
   276 // ---------------------------------------------------------------------------
       
   277 //
       
   278 CFSEmailUiSendAttachmentsListModel* CFSEmailUiSendAttachmentsListModel::NewLC( 
       
   279     CFreestyleEmailUiAppUi* aAppUi,
       
   280     CAlfEnv& aEnv,
       
   281     CFreestyleEmailUiSendAttachmentsListControl* aControl )
       
   282     {
       
   283     FUNC_LOG;
       
   284     CFSEmailUiSendAttachmentsListModel* self = 
       
   285     	new (ELeave) CFSEmailUiSendAttachmentsListModel( aAppUi );
       
   286     CleanupStack::PushL( self );
       
   287     self->ConstructL( aEnv, aControl );
       
   288     return self;
       
   289     }
       
   290 
       
   291 // ---------------------------------------------------------------------------
       
   292 // Two-phased constructor.
       
   293 // ---------------------------------------------------------------------------
       
   294 //
       
   295 void CFSEmailUiSendAttachmentsListModel::ConstructL( 
       
   296     CAlfEnv& aEnv,
       
   297     CFreestyleEmailUiSendAttachmentsListControl* aControl )
       
   298     {
       
   299     FUNC_LOG;
       
   300     iEnv = &aEnv;
       
   301     iControl = aControl;
       
   302     iAttachmentsList = NULL;
       
   303     InitAttachmentListL();
       
   304     }
       
   305 
       
   306 // ---------------------------------------------------------------------------
       
   307 // c++ constructor.
       
   308 // ---------------------------------------------------------------------------
       
   309 //
       
   310 CFSEmailUiSendAttachmentsListModel::CFSEmailUiSendAttachmentsListModel( 
       
   311     CFreestyleEmailUiAppUi* aAppUi ) 
       
   312 	: iAppUi( aAppUi )
       
   313     {
       
   314     FUNC_LOG;
       
   315     }
       
   316 	
       
   317 // ---------------------------------------------------------------------------
       
   318 // c++ destructor.
       
   319 // ---------------------------------------------------------------------------
       
   320 //
       
   321 CFSEmailUiSendAttachmentsListModel::~CFSEmailUiSendAttachmentsListModel()
       
   322     {
       
   323     FUNC_LOG;
       
   324 	while ( Count() > 0 )
       
   325         {
       
   326         RemoveAndDestroy( 0 );
       
   327         }
       
   328 	// Close list resource.
       
   329 	iItems.Close();
       
   330     delete iAttachmentsList;
       
   331     }
       
   332 
       
   333 // ---------------------------------------------------------------------------
       
   334 // AppendL
       
   335 // ---------------------------------------------------------------------------
       
   336 //
       
   337 void CFSEmailUiSendAttachmentsListModel::AppendL( MFSListModelItem* aItem )
       
   338     {
       
   339     FUNC_LOG;
       
   340 	TInt err;
       
   341 	CFSEmailUiSendAttachmentsListModelItem* item = 
       
   342 		static_cast<CFSEmailUiSendAttachmentsListModelItem*>( aItem );
       
   343 	
       
   344 	err = iItems.Append( item );
       
   345 	User::LeaveIfError( err );
       
   346     }
       
   347 
       
   348 // ---------------------------------------------------------------------------
       
   349 // InsertL
       
   350 // ---------------------------------------------------------------------------
       
   351 //
       
   352 void CFSEmailUiSendAttachmentsListModel::InsertL( MFSListModelItem* aItem, TInt aIndex)
       
   353     {
       
   354     FUNC_LOG;
       
   355 	TInt err;
       
   356 	CFSEmailUiSendAttachmentsListModelItem* item = 
       
   357 		static_cast<CFSEmailUiSendAttachmentsListModelItem*>( aItem );
       
   358 	
       
   359 	err = iItems.Insert( item, aIndex );
       
   360 	User::LeaveIfError( err );
       
   361     }
       
   362 
       
   363 // ---------------------------------------------------------------------------
       
   364 // RemoveAndDestroy
       
   365 // ---------------------------------------------------------------------------
       
   366 //
       
   367 void CFSEmailUiSendAttachmentsListModel::RemoveAndDestroy( TInt aIndex )
       
   368     {
       
   369     FUNC_LOG;
       
   370 	delete Item( aIndex );
       
   371 	iItems.Remove( aIndex );
       
   372     }
       
   373 
       
   374 // ---------------------------------------------------------------------------
       
   375 // Item
       
   376 // Retuns valid item in model by index
       
   377 // ---------------------------------------------------------------------------
       
   378 //
       
   379 MFSListModelItem* CFSEmailUiSendAttachmentsListModel::Item( TInt aIndex )
       
   380 	{
       
   381     FUNC_LOG;
       
   382 	TInt numInList = iItems.Count();
       
   383 	if ( aIndex < 0 || aIndex >= numInList )
       
   384         {
       
   385         return NULL;
       
   386         }
       
   387 	
       
   388 	return iItems[aIndex];
       
   389 	}
       
   390 
       
   391 // ---------------------------------------------------------------------------
       
   392 // Count
       
   393 // ---------------------------------------------------------------------------
       
   394 //
       
   395 TInt CFSEmailUiSendAttachmentsListModel::Count() const
       
   396     {
       
   397     FUNC_LOG;
       
   398 	return iItems.Count();
       
   399     }
       
   400 
       
   401 // ---------------------------------------------------------------------------
       
   402 // AppUi
       
   403 // return appui pointer
       
   404 // ---------------------------------------------------------------------------
       
   405 //
       
   406 CFreestyleEmailUiAppUi* CFSEmailUiSendAttachmentsListModel::AppUi()
       
   407 	{
       
   408     FUNC_LOG;
       
   409 	return iAppUi;
       
   410 	}
       
   411 
       
   412 // ---------------------------------------------------------------------------
       
   413 // ReFreshList
       
   414 // Refresh attachment list eg. after item removal
       
   415 // ---------------------------------------------------------------------------
       
   416 //
       
   417 void CFSEmailUiSendAttachmentsListModel::ReFreshListL()
       
   418 	{
       
   419     FUNC_LOG;
       
   420 	// empty the list
       
   421 	if ( iAttachmentsList )
       
   422 		{
       
   423 		iAttachmentsList->RemoveAllL();
       
   424         iAttachmentsList->SetFocusedL(ETrue);
       
   425 		}
       
   426 
       
   427 	iAttachmentsList->HideListL();
       
   428 	
       
   429 	TRect screenRect;
       
   430     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, screenRect );
       
   431     iListLayout->SetSize( screenRect.Size() );
       
   432     iListLayout->UpdateChildrenLayout();
       
   433 
       
   434 	// header and dividers
       
   435 	CreateListSkeletonL();
       
   436 	// list model items
       
   437 	CreateListItemsL();
       
   438 
       
   439     if ( iAttachmentsList->IsEmpty(iLocalNode) &&
       
   440          !iAttachmentsList->ItemVisualizer(iLocalNode).IsHidden() )
       
   441         {
       
   442         iAttachmentsTreeListVisualizer->HideItemL( iLocalNode );
       
   443         }
       
   444     if ( iAttachmentsList->IsEmpty(iRemoteNode) &&
       
   445          !iAttachmentsList->ItemVisualizer(iRemoteNode).IsHidden() )
       
   446         {
       
   447         iAttachmentsTreeListVisualizer->HideItemL( iRemoteNode );
       
   448         }
       
   449 
       
   450     iAttachmentsList->ShowListL();
       
   451 
       
   452     // Set the focus on the topmost visible focusable item
       
   453     GoToTopL();
       
   454 	}
       
   455 
       
   456 
       
   457 // ---------------------------------------------------------------------------
       
   458 // ReScaleUiL
       
   459 //
       
   460 // 
       
   461 // ---------------------------------------------------------------------------
       
   462 //
       
   463 void CFSEmailUiSendAttachmentsListModel::ReScaleUiL()
       
   464     {
       
   465     FUNC_LOG;
       
   466     
       
   467     // No rescaling to do if the list is empty
       
   468     if ( iAttachmentsList->IsEmpty(iLocalNode) && iAttachmentsList->IsEmpty(iRemoteNode) )
       
   469         return;
       
   470     
       
   471     iAttachmentsList->HideListL();
       
   472         
       
   473     // Reset font heights
       
   474     // ------------------
       
   475     TInt fontHeight = iAppUi->LayoutHandler()->ListItemFontHeightInTwips();
       
   476 
       
   477     // <cmail/> Header item not used - UI update.
       
   478 	//</cmail>
       
   479 
       
   480     // Dividers
       
   481     iLocalNodeVisualiser->SetFontHeight( fontHeight );
       
   482     iRemoteNodeVisualiser->SetFontHeight( fontHeight );
       
   483     
       
   484     // Attachment items
       
   485     for ( TInt i=0; i<iItems.Count(); i++ )
       
   486         {
       
   487         MFsTreeItemVisualizer& attachmentVis = iAttachmentsList->ItemVisualizer( iItems[i]->ItemId() );
       
   488         attachmentVis.SetFontHeight( fontHeight );
       
   489         }       
       
   490     
       
   491     iAttachmentsList->ShowListL();
       
   492     }
       
   493 
       
   494 // ---------------------------------------------------------------------------
       
   495 // CreateListSkeletonL
       
   496 //
       
   497 // 
       
   498 // ---------------------------------------------------------------------------
       
   499 //
       
   500 void CFSEmailUiSendAttachmentsListModel::CreateListSkeletonL()
       
   501 	{
       
   502     FUNC_LOG;
       
   503 // <cmail> Removed listbox header lines because of modified UI specification.
       
   504 
       
   505 //</cmail>
       
   506     
       
   507     CreateListSeparatorL( 
       
   508         R_FSE_EDITOR_LOCAL_ATTACHMENTS,
       
   509         KFsTreeRootID,
       
   510         iLocalNodeVisualiser,
       
   511         iLocalNode );
       
   512 
       
   513     CreateListSeparatorL( 
       
   514         R_FSE_EDITOR_REMOTE_ATTACHMENTS,
       
   515         KFsTreeRootID,
       
   516         iRemoteNodeVisualiser,
       
   517         iRemoteNode );
       
   518     
       
   519     iAttachmentsList->SetItemsAlwaysExtendedL(ETrue);
       
   520     
       
   521     SetupTitlePaneTextL();
       
   522 	}
       
   523 
       
   524 // ---------------------------------------------------------------------------
       
   525 // CreateListItemsL
       
   526 // 
       
   527 // ---------------------------------------------------------------------------
       
   528 //
       
   529 void CFSEmailUiSendAttachmentsListModel::CreateListItemsL()
       
   530 	{
       
   531     FUNC_LOG;
       
   532 	CFSEmailUiSendAttachmentsListModelItem* item;
       
   533 	TInt count = Count();
       
   534 
       
   535 	for ( TInt i=0; i < count; ++i )
       
   536 		{
       
   537 		item = static_cast<CFSEmailUiSendAttachmentsListModelItem*>( Item( i ) );
       
   538 		// append item content to Freestyle tree list
       
   539 		AppendItemToAttachmentListL( item );
       
   540         }
       
   541 	}
       
   542 
       
   543 // ---------------------------------------------------------------------------
       
   544 // CreateListSeparatorL
       
   545 // 
       
   546 // ---------------------------------------------------------------------------
       
   547 //
       
   548 void CFSEmailUiSendAttachmentsListModel::CreateListSeparatorL( 
       
   549     TInt aResourceId, 
       
   550     TFsTreeItemId aParentNodeId,
       
   551     CFsTreePlainOneLineNodeVisualizer*& aVisualizer, 
       
   552     TFsTreeItemId& aSeparatorNodeId )
       
   553     {
       
   554     FUNC_LOG;
       
   555     // get screen rectangle
       
   556 	TRect screenRect;
       
   557 	AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screenRect );	
       
   558 	
       
   559 	// create data and visualizer objects
       
   560 	CFsTreePlainOneLineNodeData* separatorData = CFsTreePlainOneLineNodeData::NewL();
       
   561 	CleanupStack::PushL( separatorData );
       
   562     CFsTreePlainOneLineNodeVisualizer* separatorVisualiser = CFsTreePlainOneLineNodeVisualizer::NewL(*iAttachmentsList->TreeControl());
       
   563     CleanupStack::PushL( separatorVisualiser );
       
   564     
       
   565     // load resource string and set to separator object
       
   566 	HBufC* resourceString = StringLoader::LoadLC( aResourceId );
       
   567 	separatorData->SetDataL( *resourceString );
       
   568 	CleanupStack::PopAndDestroy( resourceString );
       
   569 
       
   570     // set properties of visualizer
       
   571     separatorVisualiser->SetSize( TSize( screenRect.Width(), iAppUi->LayoutHandler()->OneLineListNodeHeight() ) );
       
   572     separatorVisualiser->SetExtendable( EFalse );
       
   573 	
       
   574     //<cmail>
       
   575     //separatorVisualiser->SetFontHeight( iAppUi->LayoutHandler()->ListItemFontHeightInTwips() );		
       
   576     //</cmail>
       
   577 	separatorVisualiser->SetTextBold( ETrue );
       
   578 	separatorData->SetIconExpanded( iAppUi->FsTextureManager()->TextureByIndex( EListTextureNodeExpanded ) );
       
   579 	separatorData->SetIconCollapsed( iAppUi->FsTextureManager()->TextureByIndex( EListTextureNodeCollapsed ) );
       
   580 	
       
   581    	TRgb nodeTextColor = iAppUi->LayoutHandler()->ListNodeTextColor();
       
   582    	TRgb focusedTextColor = iAppUi->LayoutHandler()->ListFocusedStateTextSkinColor();
       
   583    	//<cmail>
       
   584    	//TRgb nodeBgColor = iAppUi->LayoutHandler()->ListNodeBackgroundColor();
       
   585     //</cmail>
       
   586 	separatorVisualiser->SetNormalStateTextColor( nodeTextColor );
       
   587 	separatorVisualiser->SetFocusedStateTextColor( focusedTextColor );
       
   588     //<cmail>
       
   589 	//separatorVisualiser->SetBackgroundColor( nodeBgColor );
       
   590     //</cmail>
       
   591 
       
   592     aVisualizer = separatorVisualiser;
       
   593 	CleanupStack::Pop( separatorVisualiser );
       
   594 	CleanupStack::Pop( separatorData );    
       
   595     aSeparatorNodeId = iAttachmentsList->InsertNodeL( *separatorData, *separatorVisualiser, aParentNodeId );
       
   596     }
       
   597 
       
   598 // ---------------------------------------------------------------------------
       
   599 // UpdateHeaderItemTextL
       
   600 // Update the attachment count and total size information shown in header
       
   601 // ---------------------------------------------------------------------------
       
   602 //
       
   603 void CFSEmailUiSendAttachmentsListModel::UpdateHeaderItemTextL()
       
   604     {
       
   605     FUNC_LOG;
       
   606     // Currently send attachment list headers doesn't contain any data that
       
   607     // need to be updated
       
   608     }
       
   609 
       
   610 // ---------------------------------------------------------------------------
       
   611 // AppendItemToAttachmentList
       
   612 // Appends item to graphical list from model list
       
   613 // ---------------------------------------------------------------------------
       
   614 //
       
   615 TFsTreeItemId CFSEmailUiSendAttachmentsListModel::AppendItemToAttachmentListL( 
       
   616     CFSEmailUiSendAttachmentsListModelItem* aItem )
       
   617 	{
       
   618     FUNC_LOG;
       
   619 	TFsTreeItemId itemId;
       
   620 	CFsTreePlainTwoLineItemData* twoLineItemData;
       
   621 	CFsTreePlainTwoLineItemVisualizer* twoLineItemVisualizer;
       
   622 
       
   623 	twoLineItemData = CFsTreePlainTwoLineItemData::NewL();
       
   624 	twoLineItemVisualizer = CFsTreePlainTwoLineItemVisualizer::NewL( *iAttachmentsList->TreeControl() );
       
   625 
       
   626 	// load localization strings for file size
       
   627 	HBufC* sizeDesc = TFsEmailUiUtility::CreateSizeDescLC( aItem->FileSize() );
       
   628 	HBufC* decoratedSize = StringLoader::LoadLC( R_FS_EMAILUI_SENDATTACHMENTS_ITEMSIZE_TXT,
       
   629 	                                             *sizeDesc );
       
   630 
       
   631 	// construct item 2nd row text
       
   632 	HBufC* row2Buffer = HBufC::NewLC( aItem->FileExtension().Length() + KSpace().Length() + decoratedSize->Length() );
       
   633 	TPtr row2Des = row2Buffer->Des();
       
   634 	row2Des.Copy( aItem->FileExtension() );
       
   635 	row2Des.Append( KSpace );
       
   636 	row2Des.Append( *decoratedSize );
       
   637     
       
   638     // set data to item
       
   639     twoLineItemData->SetDataL( aItem->FileName() );
       
   640     twoLineItemData->SetSecondaryDataL( *row2Buffer );
       
   641     
       
   642     // free resources
       
   643     CleanupStack::PopAndDestroy( row2Buffer );
       
   644    	CleanupStack::PopAndDestroy( decoratedSize );
       
   645    	CleanupStack::PopAndDestroy( sizeDesc );
       
   646     
       
   647    	// set icon
       
   648     CAlfTexture& itemTexture = TFsEmailUiUtility::GetAttachmentIcon( 
       
   649         aItem->FileType(), 
       
   650         *iAppUi->FsTextureManager() );
       
   651     twoLineItemData->SetIcon( itemTexture );
       
   652     
       
   653     // set item size and properties
       
   654 	TRect screenRect;
       
   655 	AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screenRect );	
       
   656 
       
   657 	twoLineItemVisualizer->SetSize( TSize(screenRect.Width(), iAppUi->LayoutHandler()->OneLineListItemHeight()) );
       
   658     twoLineItemVisualizer->SetExtendedSize( TSize(screenRect.Width(), 2 * iAppUi->LayoutHandler()->OneLineListItemHeight()) );
       
   659     twoLineItemVisualizer->SetFlags( twoLineItemVisualizer->Flags()|KFsTreeListItemHasMenu );
       
   660 
       
   661     twoLineItemVisualizer->SetExtendable( ETrue );
       
   662     twoLineItemVisualizer->SetFocusable( ETrue );
       
   663 
       
   664 	twoLineItemVisualizer->SetTextBold( EFalse );
       
   665 
       
   666    	TRgb normalTextColor = iAppUi->LayoutHandler()->ListNormalStateTextSkinColor();
       
   667    	if ( aItem->IsReadOnly() )
       
   668    	    {
       
   669    	    normalTextColor = iAppUi->LayoutHandler()->ComposerDimmedTextColor();
       
   670    	    }
       
   671    	TRgb focusedTextColor = iAppUi->LayoutHandler()->ListFocusedStateTextSkinColor();
       
   672     twoLineItemVisualizer->SetNormalStateTextColor( normalTextColor );
       
   673    	twoLineItemVisualizer->SetFocusedStateTextColor( focusedTextColor );
       
   674     
       
   675    	// Ensure the parent node of the item to be added is visible and expanded.
       
   676     TFsTreeItemId parentNodeId = aItem->IsRemote() ? iRemoteNode : iLocalNode;
       
   677     if ( iAttachmentsList->ItemVisualizer(parentNodeId).IsHidden() )
       
   678         {
       
   679         // Unhiding a node is a relatively heavy-weight operation. Thus, 
       
   680         // we need to ensure it's not called in vain.
       
   681         iAttachmentsTreeListVisualizer->UnhideItemL( parentNodeId );
       
   682         }
       
   683     iAttachmentsList->ExpandNodeL( parentNodeId );
       
   684 
       
   685     // insert item and catch id returned
       
   686     itemId = iAttachmentsList->InsertItemL( 
       
   687         *twoLineItemData, 
       
   688         *twoLineItemVisualizer, 
       
   689         parentNodeId );
       
   690 
       
   691     // set list item id to model item
       
   692     aItem->SetItemId( itemId );
       
   693     return itemId;
       
   694 	}
       
   695 
       
   696 // ---------------------------------------------------------------------------
       
   697 // RemoveItemByIndexL
       
   698 // Removes item by given index from list
       
   699 // ---------------------------------------------------------------------------
       
   700 //
       
   701 void CFSEmailUiSendAttachmentsListModel::RemoveItemByIndexL( const TInt aIndex )
       
   702 	{
       
   703     FUNC_LOG;
       
   704 	if ( aIndex >= 0 && aIndex < Count() )
       
   705 		{
       
   706 		CFSEmailUiSendAttachmentsListModelItem* item =
       
   707 		    static_cast<CFSEmailUiSendAttachmentsListModelItem*>( Item(aIndex) );
       
   708 		TFsTreeItemId deletedItemId = item->ItemId();
       
   709 
       
   710 		// remove attachment from mail message 
       
   711 		CNcsComposeView* composeView = 
       
   712 			static_cast<CNcsComposeView*>( iAppUi->View( MailEditorId ) );
       
   713 			
       
   714 		if ( composeView->NewMessage() )
       
   715 			{
       
   716 			// compose view is open, so remove attachment there
       
   717 			composeView->NewMessage()->RemoveChildPartL(
       
   718 				item->MailMsgPartId() );
       
   719 			}
       
   720 		else
       
   721 			{
       
   722 			CFSEmailUiSendAttachmentsListVisualiser* parentView = 
       
   723 				static_cast<CFSEmailUiSendAttachmentsListVisualiser*>(
       
   724                     iAppUi->View( SendAttachmentMngrViewId ) );
       
   725 			
       
   726             // Open message from framework and delete attachment
       
   727             CFSMailClient* mailClient = iAppUi->GetMailClient(); // not owned
       
   728 			CFSMailMessage* msg = mailClient->GetMessageByUidL( 
       
   729                 parentView->EditorParams().iMailboxId, 
       
   730                 parentView->EditorParams().iFolderId, 
       
   731                 parentView->EditorParams().iMsgId, 
       
   732                 EFSMsgDataStructure );
       
   733 			CleanupStack::PushL( msg );
       
   734 			msg->RemoveChildPartL( item->MailMsgPartId() );
       
   735 			msg->SaveMessageL();
       
   736 			CleanupStack::PopAndDestroy( msg );
       
   737 			}
       
   738 		
       
   739 		// Remove attachment item from model
       
   740 		RemoveAndDestroy( aIndex );
       
   741 
       
   742 		// Remove attachment item from tree list if present
       
   743 		if ( deletedItemId != KFsTreeNoneID )
       
   744 		    {
       
   745     		iAttachmentsList->RemoveL( deletedItemId );
       
   746     		
       
   747     		// Hide parent node of the removed item if it just became empty
       
   748     	    if ( iAttachmentsList->IsEmpty(iLocalNode) &&
       
   749     	         !iAttachmentsList->ItemVisualizer(iLocalNode).IsHidden() )
       
   750     	        {
       
   751     	        iAttachmentsTreeListVisualizer->HideItemL( iLocalNode );
       
   752     	        }
       
   753     	    if ( iAttachmentsList->IsEmpty(iRemoteNode) &&
       
   754     	         !iAttachmentsList->ItemVisualizer(iRemoteNode).IsHidden() )
       
   755     	        {
       
   756     	        iAttachmentsTreeListVisualizer->HideItemL( iRemoteNode );
       
   757     	        }
       
   758 		    }
       
   759 		}	
       
   760 	}
       
   761 
       
   762 // ---------------------------------------------------------------------------
       
   763 // RemoveAllAttachmentsL
       
   764 // Removes all attachment items from the model, list, and message
       
   765 // ---------------------------------------------------------------------------
       
   766 //
       
   767 void CFSEmailUiSendAttachmentsListModel::RemoveAllAttachmentsL()
       
   768     {
       
   769     FUNC_LOG;
       
   770     CNcsComposeView* composeView = 
       
   771         static_cast<CNcsComposeView*>( iAppUi->View(MailEditorId) );
       
   772     CFSMailMessage* msg = composeView->NewMessage();
       
   773         
       
   774     if ( !msg )
       
   775         {
       
   776         // Open message from framework
       
   777         CFSEmailUiSendAttachmentsListVisualiser* attListView = 
       
   778             static_cast<CFSEmailUiSendAttachmentsListVisualiser*>(
       
   779                     iAppUi->View( SendAttachmentMngrViewId ) );
       
   780         CFSMailClient* mailClient = iAppUi->GetMailClient(); // not owned
       
   781         msg = mailClient->GetMessageByUidL( 
       
   782                 attListView->EditorParams().iMailboxId, 
       
   783                 attListView->EditorParams().iFolderId, 
       
   784                 attListView->EditorParams().iMsgId, 
       
   785                 EFSMsgDataStructure );
       
   786         CleanupStack::PushL( msg );
       
   787         }
       
   788 
       
   789     // remove attachments from mail message 
       
   790     for ( TInt i = Count()-1 ; i >= 0 ; --i )
       
   791         {
       
   792         CFSEmailUiSendAttachmentsListModelItem* item =
       
   793             static_cast<CFSEmailUiSendAttachmentsListModelItem*>( Item(i) );
       
   794     
       
   795         TRAPD( err, msg->RemoveChildPartL( item->MailMsgPartId() ) );
       
   796         // Remove attachment item from model if message part was succesfully removed
       
   797         if ( !err )
       
   798             {
       
   799             RemoveAndDestroy( i );
       
   800             }
       
   801         }
       
   802     msg->SaveMessageL();
       
   803 
       
   804     // Delete msg if we own it
       
   805     if ( !composeView->NewMessage() )
       
   806         {
       
   807         CleanupStack::PopAndDestroy( msg );
       
   808         }
       
   809     
       
   810     // Update the tree list to match the model.
       
   811     ReFreshListL();
       
   812     }   
       
   813 
       
   814 // ---------------------------------------------------------------------------
       
   815 // HighlightedIndex
       
   816 // Returns currenlty higlighted index from list
       
   817 // ---------------------------------------------------------------------------
       
   818 //
       
   819 TInt CFSEmailUiSendAttachmentsListModel::HighlightedIndex()
       
   820 	{
       
   821     FUNC_LOG;
       
   822 	TInt ret( KErrNotFound );
       
   823 	
       
   824 	TFsTreeItemId focusedId = iAttachmentsList->FocusedItem();
       
   825 	// Map id to the index in model
       
   826 
       
   827 	for ( TInt i=0; i < iItems.Count(); ++i )
       
   828 		{
       
   829 		if ( focusedId == iItems[i]->ItemId() )
       
   830 			{
       
   831 			ret = i;
       
   832 			break;
       
   833 			}
       
   834 		}
       
   835 	return ret;
       
   836 	}
       
   837 
       
   838 // ---------------------------------------------------------------------------
       
   839 // AttachmentList
       
   840 // Returns pointer to attachment list
       
   841 // ---------------------------------------------------------------------------
       
   842 //
       
   843 CFsTreeList* CFSEmailUiSendAttachmentsListModel::AttachmentList()
       
   844 	{
       
   845     FUNC_LOG;
       
   846 	return iAttachmentsList;
       
   847 	}
       
   848 
       
   849 // ---------------------------------------------------------------------------
       
   850 // TotalAttachmentSize
       
   851 //
       
   852 // Retuns sum of all attachments sizes in kB from the model
       
   853 // ---------------------------------------------------------------------------
       
   854 //
       
   855 TInt CFSEmailUiSendAttachmentsListModel::TotalAttachmentSize()
       
   856 	{
       
   857     FUNC_LOG;
       
   858 	CFSEmailUiSendAttachmentsListModelItem* fileItem;
       
   859 	TInt totalSize = 0;
       
   860 	TInt count = Count();
       
   861 	
       
   862 	for ( TInt i=0; i < count; ++i )
       
   863 		{
       
   864 		fileItem = static_cast<CFSEmailUiSendAttachmentsListModelItem*>( Item( i ) );
       
   865 		totalSize += fileItem->FileSize();
       
   866 		}
       
   867 	return totalSize;
       
   868 	}
       
   869 
       
   870 // ---------------------------------------------------------------------------
       
   871 // InitAttachmentListL
       
   872 //
       
   873 // Creates new instance of attachment tree list
       
   874 // ---------------------------------------------------------------------------
       
   875 //
       
   876 void CFSEmailUiSendAttachmentsListModel::InitAttachmentListL()
       
   877 	{
       
   878     FUNC_LOG;
       
   879 	
       
   880 	if ( iAttachmentsList == NULL )
       
   881 		{
       
   882 
       
   883 		/*TRect screenRect;
       
   884 	 	AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screenRect );	
       
   885 		iListLayout = CAlfDeckLayout::AddNewL( *iControl );  
       
   886 	    iListLayout->SetSize( TSize( screenRect.Width(), screenRect.Height()) );*/
       
   887 	
       
   888 	    TRect screenRect;
       
   889 	    AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, screenRect );
       
   890         iListLayout = CAlfDeckLayout::AddNewL( *iControl );  
       
   891 	    iListLayout->SetSize( screenRect.Size() );
       
   892 	    
       
   893 	   	// Create attachments list tree list component 
       
   894 	    iAttachmentsTreeListVisualizer = CFsTreeVisualizerBase::NewL( 
       
   895             iControl, 
       
   896             *iListLayout );
       
   897 	   	iAttachmentsTreeListVisualizer->SetItemExpansionDelay( KListItemExpansionDelay );
       
   898 	    //<cmail> S60 skin support
       
   899 	    //iAttachmentsTreeListVisualizer->SetBackgroundTextureL( 
       
   900         //    iAppUi->FsTextureManager()->TextureByIndex( EBackgroundTextureMailList ) );
       
   901 	    //</cmail>
       
   902 	   	iAttachmentsTreeListVisualizer->SetMenuIcon( 
       
   903             iAppUi->FsTextureManager()->TextureByIndex( EListControlMenuIcon ) );		
       
   904   	    // Set page up and page down keys
       
   905 	   	iAttachmentsTreeListVisualizer->AddCustomPageUpKey( EStdKeyPageUp );
       
   906 	   	iAttachmentsTreeListVisualizer->AddCustomPageDownKey( EStdKeyPageDown );
       
   907 
       
   908 	  	// create list
       
   909 	    iAttachmentsList = CFsTreeList::NewL( *iAttachmentsTreeListVisualizer, *iEnv );
       
   910 	    iAttachmentsList->SetScrollbarVisibilityL( EFsScrollbarAuto );
       
   911 	  	iAttachmentsList->SetMarkTypeL( CFsTreeList::EFsTreeListMultiMarkable );	
       
   912 	  	iAttachmentsList->SetLoopingType( EFsTreeListLoopingDisabled );
       
   913 	    iAttachmentsList->SetIndentationL( 0 );
       
   914 	  	iAttachmentsList->AddObserverL( *this );
       
   915 	    iAppUi->LayoutHandler()->SetListMarqueeBehaviour( iAttachmentsList );
       
   916 
       
   917 	  	CreateListSkeletonL();
       
   918 		}
       
   919 
       
   920 	}
       
   921 
       
   922 //<cmail> touch
       
   923 
       
   924 // ---------------------------------------------------------------------------
       
   925 // TreeListEventL
       
   926 //
       
   927 // ---------------------------------------------------------------------------
       
   928 //
       
   929 
       
   930 void CFSEmailUiSendAttachmentsListModel::TreeListEventL( 
       
   931     const TFsTreeListEvent aEvent, 
       
   932     const TFsTreeItemId /*aId*/ )
       
   933 	{
       
   934     FUNC_LOG;
       
   935     
       
   936     CFSEmailUiSendAttachmentsListModelItem* item = 0;
       
   937     
       
   938     switch(aEvent)
       
   939         {
       
   940         case MFsTreeListObserver::EFsTreeListItemTouchAction:
       
   941             DoHandleActionL(); 
       
   942             break; 
       
   943         case MFsTreeListObserver::EFsTreeListItemTouchLongTap:
       
   944             item = GetSelectedItem();
       
   945             if(NULL != item)
       
   946                 iControl->ShowActionMenuL( item ); 
       
   947             break; 
       
   948         case MFsTreeListObserver::EFsTreeListItemTouchFocused:
       
   949             iControl->SetMskL(); 
       
   950             break; 
       
   951         default:
       
   952             //Just ignore rest of events
       
   953             break;             
       
   954         }                   
       
   955               
       
   956 	}
       
   957 
       
   958 // ---------------------------------------------------------------------------
       
   959 // Handles action for focused item.
       
   960 // ---------------------------------------------------------------------------
       
   961 //
       
   962 void CFSEmailUiSendAttachmentsListModel::HandleActionL()
       
   963     {
       
   964     FUNC_LOG;
       
   965     DoHandleActionL();
       
   966     }
       
   967 
       
   968 // ---------------------------------------------------------------------------
       
   969 // CFSEmailUiSendAttachmentsListModel::DoHandleActionL
       
   970 // ---------------------------------------------------------------------------
       
   971 //
       
   972 void CFSEmailUiSendAttachmentsListModel::DoHandleActionL( )
       
   973     {
       
   974     FUNC_LOG;
       
   975 
       
   976     TFsTreeItemId id = iAttachmentsList->FocusedItem(); 
       
   977     
       
   978     //Expand / Collapse
       
   979     if ( iAttachmentsList->IsNode(id) )
       
   980         {
       
   981         if ( iAttachmentsList->IsExpanded(id) )
       
   982             {
       
   983             CollapseL(); 
       
   984             }
       
   985         else
       
   986             {
       
   987             ExpandL(); 
       
   988             }
       
   989         }
       
   990     else //Open
       
   991         {
       
   992         iControl->OpenHighlightedFileL();
       
   993         }
       
   994   
       
   995     iControl->SetMskL();
       
   996     }
       
   997 
       
   998 //</cmail>
       
   999 
       
  1000 
       
  1001 
       
  1002 
       
  1003 // ---------------------------------------------------------------------------
       
  1004 // HasRemoteAttachments
       
  1005 // ---------------------------------------------------------------------------
       
  1006 //
       
  1007 TBool CFSEmailUiSendAttachmentsListModel::HasRemoteAttachments()
       
  1008     {
       
  1009     FUNC_LOG;
       
  1010     // remote files have no file path within local system
       
  1011     for ( TInt i=0; i<iItems.Count(); i++ )
       
  1012         {
       
  1013         if ( iItems[i]->IsRemote() )
       
  1014             {
       
  1015             return ETrue;
       
  1016             }
       
  1017         }
       
  1018     return EFalse;
       
  1019     }
       
  1020 
       
  1021 // ---------------------------------------------------------------------------
       
  1022 // HasReadOnlyAttachments
       
  1023 // ---------------------------------------------------------------------------
       
  1024 //
       
  1025 TBool CFSEmailUiSendAttachmentsListModel::HasReadOnlyAttachments()
       
  1026     {
       
  1027     FUNC_LOG;
       
  1028     // remote files have no file path within local system
       
  1029     for ( TInt i=0; i<iItems.Count(); i++ )
       
  1030         {
       
  1031         if ( iItems[i]->IsReadOnly() )
       
  1032             {
       
  1033             return ETrue;
       
  1034             }
       
  1035         }
       
  1036     return EFalse;
       
  1037     }
       
  1038 
       
  1039 // ---------------------------------------------------------------------------
       
  1040 // GetSelectedItem
       
  1041 // ---------------------------------------------------------------------------
       
  1042 //
       
  1043 CFSEmailUiSendAttachmentsListModelItem* CFSEmailUiSendAttachmentsListModel::GetSelectedItem()
       
  1044     {
       
  1045     FUNC_LOG;
       
  1046     TFsTreeItemId nodeId = iAttachmentsList->FocusedItem();
       
  1047 	//<cmail>
       
  1048     if ( nodeId == iLocalNode ||
       
  1049          nodeId == iRemoteNode ||
       
  1050          nodeId == KFsTreeNoneID )
       
  1051 	//</cmail>		 
       
  1052         {
       
  1053         return NULL;
       
  1054         }
       
  1055     else
       
  1056         {
       
  1057         return GetItemByNodeId( nodeId );
       
  1058         }
       
  1059     }
       
  1060 
       
  1061 // ---------------------------------------------------------------------------
       
  1062 // GetItemByNodeId
       
  1063 // ---------------------------------------------------------------------------
       
  1064 //
       
  1065 CFSEmailUiSendAttachmentsListModelItem* CFSEmailUiSendAttachmentsListModel::GetItemByNodeId( TFsTreeItemId aNodeId )
       
  1066     {
       
  1067     FUNC_LOG;
       
  1068     for ( TInt i=0; i<iItems.Count(); i++ )
       
  1069         {
       
  1070         if ( iItems[i]->ItemId() == aNodeId )
       
  1071             {
       
  1072             return iItems[i];
       
  1073             }
       
  1074         }
       
  1075     return NULL;
       
  1076     }
       
  1077 
       
  1078 TBool CFSEmailUiSendAttachmentsListModel::CanSelectPreviousItem()
       
  1079     {
       
  1080     FUNC_LOG;
       
  1081     return iAttachmentsList->FocusedItem() != iLocalNode;
       
  1082     }
       
  1083 
       
  1084 // ---------------------------------------------------------------------------
       
  1085 // Moves the focus to the topmost item
       
  1086 // ---------------------------------------------------------------------------
       
  1087 //
       
  1088 void CFSEmailUiSendAttachmentsListModel::GoToTopL()
       
  1089     {
       
  1090     FUNC_LOG;
       
  1091     // Focus first visible focusable item.
       
  1092     TFsTreeItemId topId = KErrNotFound;
       
  1093 
       
  1094     const TInt count = iAttachmentsList->CountChildren( KFsTreeRootID );
       
  1095     for ( TInt index = 0; index < count && topId == KErrNotFound; ++index )
       
  1096         {
       
  1097         TFsTreeItemId id =iAttachmentsList->Child( KFsTreeRootID, index );
       
  1098         if ( !iAttachmentsList->ItemVisualizer( id ).IsHidden() )
       
  1099             {
       
  1100             topId = id;
       
  1101             }
       
  1102         }
       
  1103 
       
  1104     if ( topId != KErrNotFound )
       
  1105         {
       
  1106         iAttachmentsTreeListVisualizer->SetFocusedItemL( topId );
       
  1107         }
       
  1108     }
       
  1109 
       
  1110 // ---------------------------------------------------------------------------
       
  1111 // Moves the focus to the bottommost item
       
  1112 // ---------------------------------------------------------------------------
       
  1113 //
       
  1114 void CFSEmailUiSendAttachmentsListModel::GoToBottomL()
       
  1115     {
       
  1116     FUNC_LOG;
       
  1117     if ( Count() )
       
  1118         { 
       
  1119         TInt topLevelCount = iAttachmentsList->CountChildren( KFsTreeRootID );
       
  1120         if ( topLevelCount )
       
  1121             {
       
  1122             // Get last visible top level item 
       
  1123             TFsTreeItemId bottomId = KErrNotFound;
       
  1124             TInt index = topLevelCount - 1;
       
  1125             do
       
  1126                 {
       
  1127                 bottomId = iAttachmentsList->Child( KFsTreeRootID, index );
       
  1128                 index--;
       
  1129                 }
       
  1130             while ( iAttachmentsList->ItemVisualizer(bottomId).IsHidden() && 
       
  1131                     index >= 0 );
       
  1132                 
       
  1133             if ( iAttachmentsList->IsNode(bottomId) )
       
  1134                 {
       
  1135                 TInt childCount = iAttachmentsList->CountChildren(bottomId);
       
  1136                 if ( childCount && iAttachmentsList->IsExpanded(bottomId) )
       
  1137                     {
       
  1138                     // Focus the last child of the bottom node if the node is expanded.
       
  1139                     bottomId = iAttachmentsList->Child( bottomId, childCount-1 );
       
  1140                     }
       
  1141                 }
       
  1142             iAttachmentsTreeListVisualizer->SetFocusedItemL( bottomId );            
       
  1143             }
       
  1144         }
       
  1145     }
       
  1146 
       
  1147 // ---------------------------------------------------------------------------
       
  1148 // Collapse nodes
       
  1149 // ---------------------------------------------------------------------------
       
  1150 //
       
  1151 void CFSEmailUiSendAttachmentsListModel::CollapseL()
       
  1152     {
       
  1153     FUNC_LOG;
       
  1154     TFsTreeItemId focId1 = iAttachmentsList->FocusedItem();
       
  1155     iAttachmentsList->CollapseNodeL(focId1);
       
  1156     }
       
  1157 // ---------------------------------------------------------------------------
       
  1158 // Expands nodes
       
  1159 // ---------------------------------------------------------------------------
       
  1160 //            
       
  1161 void CFSEmailUiSendAttachmentsListModel::ExpandL()
       
  1162     {
       
  1163     FUNC_LOG;
       
  1164     TFsTreeItemId focId = iAttachmentsList->FocusedItem();
       
  1165     iAttachmentsList->ExpandNodeL( focId );
       
  1166     }
       
  1167 // ---------------------------------------------------------------------------
       
  1168 // Collapses or expands all nodes
       
  1169 // ---------------------------------------------------------------------------
       
  1170 //
       
  1171 void CFSEmailUiSendAttachmentsListModel::CollapseExpandAllToggleL()
       
  1172     {
       
  1173     FUNC_LOG;
       
  1174     TBool collapseAllNodes( EFalse );
       
  1175     TInt count = iAttachmentsList->CountChildren( KFsTreeRootID );
       
  1176     for ( TInt i=0 ; i<count ; i++ )
       
  1177         {
       
  1178         TFsTreeItemId curId = iAttachmentsList->Child(KFsTreeRootID, i);
       
  1179         if ( iAttachmentsList->IsNode( curId ) &&
       
  1180              iAttachmentsList->IsExpanded( curId ) )
       
  1181             {
       
  1182             collapseAllNodes = ETrue;
       
  1183             break;
       
  1184             }	
       
  1185         }
       
  1186 
       
  1187     if ( collapseAllNodes )
       
  1188         {
       
  1189         iAttachmentsTreeListVisualizer->CollapseAllL();        
       
  1190         }
       
  1191     else
       
  1192         {
       
  1193        	TFsTreeItemId prevId = iAttachmentsList->FocusedItem(); // the focus may fall out of the screen unless manually reset
       
  1194         iAttachmentsTreeListVisualizer->ExpandAllL();
       
  1195     	iAttachmentsTreeListVisualizer->SetFocusedItemL( prevId );    
       
  1196         }
       
  1197     }
       
  1198 
       
  1199 // ---------------------------------------------------------------------------
       
  1200 // 
       
  1201 // ---------------------------------------------------------------------------
       
  1202 //
       
  1203 void CFSEmailUiSendAttachmentsListModel::Clear()
       
  1204     {
       
  1205     FUNC_LOG;
       
  1206     // <cmail> Remove all children of nodes on the list
       
  1207     if ( iAttachmentsList )
       
  1208         {
       
  1209         TRAP_IGNORE( iAttachmentsList->RemoveChildrenL( iRemoteNode ) );
       
  1210         TRAP_IGNORE( iAttachmentsList->RemoveChildrenL( iLocalNode ) );
       
  1211         }
       
  1212     // </cmail>
       
  1213     iItems.ResetAndDestroy();
       
  1214     }
       
  1215 
       
  1216 //<cmail>
       
  1217 // ---------------------------------------------------------------------------
       
  1218 // CFSEmailUiSendAttachmentsListModel::GetVisualizer
       
  1219 // ---------------------------------------------------------------------------
       
  1220 //
       
  1221 CFsTreeVisualizerBase* CFSEmailUiSendAttachmentsListModel::GetVisualizer()
       
  1222     {
       
  1223     FUNC_LOG;
       
  1224     return iAttachmentsTreeListVisualizer;
       
  1225     }
       
  1226 //</cmail>
       
  1227 
       
  1228 // ---------------------------------------------------------------------------
       
  1229 // 
       
  1230 // ---------------------------------------------------------------------------
       
  1231 //
       
  1232 CAlfLayout* CFSEmailUiSendAttachmentsListModel::GetParentLayout() const
       
  1233     {
       
  1234     return iListLayout;
       
  1235     }
       
  1236 
       
  1237 
       
  1238 // ---------------------------------------------------------------------------
       
  1239 // Sets up the title pane
       
  1240 // ---------------------------------------------------------------------------
       
  1241 //
       
  1242 void CFSEmailUiSendAttachmentsListModel::SetupTitlePaneTextL()
       
  1243     {
       
  1244     FUNC_LOG;
       
  1245     HBufC* titleText = StringLoader::LoadLC( R_FSE_VIEWER_ATTACHMENTS_VIEW_TITLE );
       
  1246     AppUi()->SetTitlePaneTextL( *titleText );
       
  1247     CleanupStack::PopAndDestroy( titleText );
       
  1248     }
       
  1249 
       
  1250 //</cmail>
       
  1251