emailuis/emailui/src/FreestyleEmailUiMailListModel.cpp
branchRCL_3
changeset 64 3533d4323edc
child 80 726fba06891a
equal deleted inserted replaced
63:d189ee25cf9d 64:3533d4323edc
       
     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:  FreestyleEmailUi double line list model and model item implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // SYSTEM INCLUDES
       
    20 //<cmail>
       
    21 #include "emailtrace.h"
       
    22 #include "cfsmailmessage.h"
       
    23 //</cmail>
       
    24 
       
    25 
       
    26 // INTERNAL INCLUDES
       
    27 #include "FreestyleEmailUiAppui.h"
       
    28 #include "FreestyleEmailUiMailListModel.h"
       
    29 #include "FreestyleEmailUiUtilities.h"
       
    30 
       
    31 
       
    32 // MODEL ITEM CONSTRUCTION
       
    33 CFSEmailUiMailListModelItem* CFSEmailUiMailListModelItem::NewL( CFSMailMessage* aMessagePtr,
       
    34 																	TModelItemType aModelItemtype )
       
    35     {
       
    36     FUNC_LOG;
       
    37     CFSEmailUiMailListModelItem* self = CFSEmailUiMailListModelItem::NewLC( aMessagePtr, aModelItemtype );
       
    38     CleanupStack::Pop(self);
       
    39     return self;
       
    40     }
       
    41 
       
    42 CFSEmailUiMailListModelItem* CFSEmailUiMailListModelItem::NewLC( CFSMailMessage* aMessagePtr,
       
    43 																	TModelItemType aModelItemtype )
       
    44 	{
       
    45     FUNC_LOG;
       
    46     CFSEmailUiMailListModelItem* self = new (ELeave) CFSEmailUiMailListModelItem( aMessagePtr, aModelItemtype );
       
    47     CleanupStack::PushL(self);
       
    48     return self;
       
    49 	}
       
    50 
       
    51 CFSEmailUiMailListModelItem::CFSEmailUiMailListModelItem( CFSMailMessage* aMessagePtr,
       
    52 															  TModelItemType aModelItemtype ) 
       
    53    	:iMessagePtr( aMessagePtr ),
       
    54    	iModelItemType( aModelItemtype ),
       
    55    	iSeparatorText( 0 ),
       
    56    	iFsTreeListId( 0 )
       
    57     {
       
    58     FUNC_LOG;
       
    59     }
       
    60 
       
    61 CFSEmailUiMailListModelItem::~CFSEmailUiMailListModelItem() 
       
    62     {
       
    63     FUNC_LOG;
       
    64    	delete iSeparatorText;
       
    65    	if ( iModelItemType == ETypeMailItem )
       
    66    	    {
       
    67         delete iMessagePtr;
       
    68    	    }
       
    69    	else
       
    70    	    {
       
    71    	    // In case of separator item, the message is not owned. This is just a pointer
       
    72    	    // to the first message belonging under this separator. The ownership is on the
       
    73    	    // next mail item.
       
    74    	    iMessagePtr = NULL;
       
    75    	    }
       
    76     }
       
    77 
       
    78 
       
    79 void CFSEmailUiMailListModelItem::SetSeparatorTextL( const TDesC& aSeparatorText )
       
    80     {
       
    81     FUNC_LOG;
       
    82     delete iSeparatorText;
       
    83     iSeparatorText = NULL;
       
    84     iSeparatorText = aSeparatorText.AllocL();
       
    85     }
       
    86 	
       
    87 
       
    88 
       
    89 
       
    90 //MODEL CLASS CONSTRUCTION
       
    91 CFSEmailUiMailListModel* CFSEmailUiMailListModel::NewL( CFreestyleEmailUiAppUi* aAppUi, TBool aSearchList )
       
    92     {
       
    93     FUNC_LOG;
       
    94     CFSEmailUiMailListModel* self = CFSEmailUiMailListModel::NewLC( aAppUi, aSearchList );
       
    95     CleanupStack::Pop(self);
       
    96     return self;
       
    97     }
       
    98 
       
    99 CFSEmailUiMailListModel* CFSEmailUiMailListModel::NewLC( CFreestyleEmailUiAppUi* aAppUi, TBool aSearchList )
       
   100     {
       
   101     FUNC_LOG;
       
   102     CFSEmailUiMailListModel* self = new (ELeave) CFSEmailUiMailListModel( aAppUi );
       
   103     CleanupStack::PushL(self);
       
   104     self->ConstructL( aSearchList );
       
   105     return self;
       
   106     }
       
   107 
       
   108 void CFSEmailUiMailListModel::ConstructL( TBool aSearchList )
       
   109     {
       
   110     FUNC_LOG;
       
   111     // set default sort criteria
       
   112     iSortCriteria.iField = EFSMailSortByDate;
       
   113     iSortCriteria.iOrder = EFSMailDescending;
       
   114     
       
   115     if ( !aSearchList )
       
   116         {
       
   117         // Set TLS pointer to point ourselves. This is needed to access our
       
   118         // data from static (find/sort) functions.
       
   119         TInt err = UserSvr::DllSetTls( KTlsHandleMailListModel, this );
       
   120         }
       
   121     }
       
   122  
       
   123 CFSEmailUiMailListModel::CFSEmailUiMailListModel( CFreestyleEmailUiAppUi* aAppUi ) 
       
   124 	: iAppUi( aAppUi )
       
   125     {
       
   126     FUNC_LOG;
       
   127     }
       
   128 	
       
   129 CFSEmailUiMailListModel::~CFSEmailUiMailListModel()
       
   130     {
       
   131     FUNC_LOG;
       
   132 	iItems.ResetAndDestroy();
       
   133     }
       
   134 
       
   135 void CFSEmailUiMailListModel::AppendL(MFSListModelItem* aItem)
       
   136     {
       
   137     FUNC_LOG;
       
   138 	TInt err;
       
   139 	CFSEmailUiMailListModelItem* newItem = static_cast< CFSEmailUiMailListModelItem* >(aItem);
       
   140 	err = iItems.Append( newItem );	
       
   141 	User::LeaveIfError(err);
       
   142 	
       
   143 	// If mail item was added as first child of a separator, the message pointer
       
   144 	// of the separator has to be reset.
       
   145 	TInt insertionPoint = iItems.Count()-1; 
       
   146     if ( insertionPoint > 0 &&
       
   147          newItem->ModelItemType() == ETypeMailItem &&
       
   148          iItems[insertionPoint-1]->ModelItemType() == ETypeSeparator )
       
   149         {
       
   150         iItems[insertionPoint-1]->SetMessagePtr( &newItem->MessagePtr() );
       
   151         }
       
   152     }
       
   153 	
       
   154 void CFSEmailUiMailListModel::InsertL( MFSListModelItem* aItem, TInt aIndex )
       
   155     {
       
   156     FUNC_LOG;
       
   157 	TInt err;	
       
   158     CFSEmailUiMailListModelItem* newItem = static_cast< CFSEmailUiMailListModelItem* >(aItem);
       
   159 	err = iItems.Insert( newItem, aIndex);	
       
   160 	User::LeaveIfError(err);
       
   161 
       
   162     // If mail item was added as first child of a separator, the message pointer
       
   163     // of the separator has to be reset.
       
   164     if ( aIndex > 0 &&
       
   165          newItem->ModelItemType() == ETypeMailItem &&
       
   166          iItems[aIndex-1]->ModelItemType() == ETypeSeparator )
       
   167         {
       
   168         iItems[aIndex-1]->SetMessagePtr( &newItem->MessagePtr() );
       
   169         }
       
   170     }
       
   171 
       
   172 void CFSEmailUiMailListModel::RemoveAndDestroy(TInt aIndex)
       
   173     {
       
   174     FUNC_LOG;
       
   175 	delete Item(aIndex);
       
   176 	iItems.Remove(aIndex);
       
   177 	iItems.Compress();
       
   178 	
       
   179 	// If the removed item was the first child of a preceeding node item, then the message
       
   180 	// pointer in the node item has to be updated.
       
   181 	if ( aIndex > 0 && iItems[aIndex-1]->ModelItemType() == ETypeSeparator )
       
   182 	    {
       
   183 	    if ( aIndex < iItems.Count() && iItems[aIndex]->ModelItemType() == ETypeMailItem )
       
   184 	        {
       
   185 	        iItems[aIndex-1]->SetMessagePtr( &iItems[aIndex]->MessagePtr() );
       
   186 	        }
       
   187 	    else
       
   188 	        {
       
   189 	        iItems[aIndex-1]->SetMessagePtr( NULL );
       
   190 	        }
       
   191 	    }
       
   192     }
       
   193 
       
   194 MFSListModelItem* CFSEmailUiMailListModel::Item( TInt aIndex )
       
   195 	{
       
   196     FUNC_LOG;
       
   197 	TInt numInList = iItems.Count();
       
   198 	if ( aIndex < 0 || aIndex >= numInList )
       
   199 	   {
       
   200 	   return NULL;
       
   201        }	
       
   202 	return iItems[aIndex];
       
   203 	}
       
   204 
       
   205 const MFSListModelItem* CFSEmailUiMailListModel::Item( TInt aIndex ) const
       
   206     {
       
   207     FUNC_LOG;
       
   208     TInt numInList = iItems.Count();
       
   209     if ( aIndex < 0 || aIndex >= numInList )
       
   210        {
       
   211        return NULL;
       
   212        }
       
   213     return iItems[aIndex];
       
   214     }
       
   215 
       
   216 TInt CFSEmailUiMailListModel::Count() const
       
   217     {
       
   218     FUNC_LOG;
       
   219 	return iItems.Count();
       
   220     }
       
   221 
       
   222 CFreestyleEmailUiAppUi* CFSEmailUiMailListModel::AppUi()
       
   223 	{
       
   224     FUNC_LOG;
       
   225 	return iAppUi;
       
   226 	}
       
   227 
       
   228 void CFSEmailUiMailListModel::SetSortCriteria( TFSMailSortCriteria aSortCriteria )
       
   229     {
       
   230     FUNC_LOG;
       
   231     iSortCriteria = aSortCriteria;
       
   232     }
       
   233 
       
   234 TFSMailSortCriteria CFSEmailUiMailListModel::SortCriteria()
       
   235     {
       
   236     FUNC_LOG;
       
   237     return iSortCriteria;
       
   238     }
       
   239 
       
   240 void CFSEmailUiMailListModel::SortL()
       
   241     {
       
   242     FUNC_LOG;
       
   243     TLinearOrder<CFSEmailUiMailListModelItem> orderFunc( CompareModelItemsL );
       
   244     iItems.Sort( orderFunc );
       
   245     }
       
   246 
       
   247 void CFSEmailUiMailListModel::ReplaceMessagePtr( TInt aIndex, CFSMailMessage* aNewPtr )
       
   248     {
       
   249     FUNC_LOG;
       
   250     CFSEmailUiMailListModelItem* item = 
       
   251         static_cast< CFSEmailUiMailListModelItem* >( Item(aIndex) );
       
   252     
       
   253     if ( item ) // Safety
       
   254         {
       
   255         // Mail type items own the message. Delete the existing message first.
       
   256         if ( item->ModelItemType() == ETypeMailItem )
       
   257             {
       
   258             delete &item->MessagePtr();
       
   259             }
       
   260         item->SetMessagePtr( aNewPtr );
       
   261         
       
   262         // If the item was the first child of a node, then also message pointer in the parent
       
   263         // node needs to be updated
       
   264         if ( aIndex > 0 &&
       
   265              item->ModelItemType() == ETypeMailItem &&
       
   266              iItems[aIndex-1]->ModelItemType() == ETypeSeparator )
       
   267             {
       
   268             iItems[aIndex-1]->SetMessagePtr( aNewPtr );
       
   269             }
       
   270         }
       
   271     }
       
   272 
       
   273 TInt CFSEmailUiMailListModel::GetInsertionPointL( const CFSEmailUiMailListModelItem& aItemToInsert ) const
       
   274     {
       
   275     FUNC_LOG;
       
   276     TInt index;
       
   277     TLinearOrder<CFSEmailUiMailListModelItem> orderFunc( CompareModelItemsL );
       
   278     TInt ret = iItems.SpecificFindInOrder( &aItemToInsert, index, orderFunc, EArrayFindMode_First );
       
   279     return index;
       
   280     }
       
   281 
       
   282 TInt CFSEmailUiMailListModel::GetInsertionPointL( const CFSEmailUiMailListModelItem& aItemToInsert,
       
   283                                                   TInt& aChildIdx,
       
   284                                                   TInt& aParentNodeIdx ) const
       
   285     {
       
   286     FUNC_LOG;
       
   287     TInt index = GetInsertionPointL( aItemToInsert );
       
   288     
       
   289     // Find out the parent node
       
   290     aChildIdx = KErrNotFound;
       
   291     aParentNodeIdx = KErrNotFound;
       
   292     if ( index > 0 )
       
   293         {
       
   294         CFSEmailUiMailListModelItem* preceedingItem = iItems[index-1];
       
   295         if ( MessagesBelongUnderSameSeparatorL( aItemToInsert.MessagePtr(), 
       
   296                                                 preceedingItem->MessagePtr(),
       
   297                                                 iSortCriteria.iField ) )
       
   298             {
       
   299             // The new item belongs under the same node as the previous item
       
   300             // (or the previous item is a node under which the item belongs).
       
   301             // Find out the previous node item.
       
   302             aParentNodeIdx = index-1;
       
   303             while ( aParentNodeIdx >= 0 && iItems[aParentNodeIdx]->ModelItemType() != ETypeSeparator )
       
   304                 {
       
   305                 aParentNodeIdx--;
       
   306                 }
       
   307             if ( aParentNodeIdx >= 0 )
       
   308                 {
       
   309                 aChildIdx = index - aParentNodeIdx - 1;
       
   310                 }
       
   311             }
       
   312         }
       
   313     
       
   314     return index;
       
   315     }
       
   316 
       
   317 TInt CFSEmailUiMailListModel::CompareModelItemsL( const CFSEmailUiMailListModelItem& aItem1,
       
   318                                                   const CFSEmailUiMailListModelItem& aItem2 )
       
   319     {
       
   320     FUNC_LOG;
       
   321     // Retrieve the current sort criteria from model instance in TLS
       
   322     CFSEmailUiMailListModel* self = 
       
   323         static_cast<CFSEmailUiMailListModel*>( UserSvr::DllTls(KTlsHandleMailListModel) );
       
   324     TFSMailSortCriteria sortCriteria = self->SortCriteria();
       
   325     
       
   326     TInt value = CompareMessagesL( aItem1.MessagePtr(), 
       
   327                                    aItem2.MessagePtr(), 
       
   328                                    sortCriteria.iField );
       
   329     
       
   330     // The logic of the CompareMessagesL matches ascending order. In descending mode it must
       
   331     // be inverted.
       
   332     if ( sortCriteria.iOrder == EFSMailDescending )
       
   333         {
       
   334         value = -value;
       
   335         }
       
   336     
       
   337     // If items are equal with the primary sorting criterion and this primary criterion
       
   338     // is not date sort, then descending date order is used as secondary criterion.
       
   339     if ( !value && sortCriteria.iField != EFSMailSortByDate )
       
   340         {
       
   341         value = -CompareMessagesL( aItem1.MessagePtr(),
       
   342                                    aItem2.MessagePtr(),
       
   343                                    EFSMailSortByDate );
       
   344         }
       
   345     
       
   346     // Some magic is needed in case one of the items (but not both) is a separator
       
   347     if ( aItem1.ModelItemType() == ETypeSeparator && aItem2.ModelItemType() == ETypeMailItem )
       
   348         {
       
   349         if ( !value )
       
   350             { // In case an item is equal to the first item under the node, it's greater than the node
       
   351             value = -1;
       
   352             }
       
   353         else if ( value > 0 )
       
   354             {
       
   355             // In case an item is smaller than the first item under the node, it may still be greater 
       
   356             // than the node (i.e. when the item belongs under this same node).
       
   357             if ( MessagesBelongUnderSameSeparatorL( aItem1.MessagePtr(), 
       
   358                                                     aItem2.MessagePtr(), 
       
   359                                                     sortCriteria.iField ) )
       
   360                 {
       
   361                 value = -1;
       
   362                 }
       
   363             }
       
   364         }
       
   365     else if ( aItem1.ModelItemType() == ETypeMailItem && aItem2.ModelItemType() == ETypeSeparator )
       
   366         {
       
   367         if ( !value )
       
   368             { // In case an item is equal to the first item under the node, it's greater than the node
       
   369             value = 1;
       
   370             }
       
   371         else if ( value < 0 )
       
   372             {
       
   373             // In case an item is smaller than the first item under the node, it may still be greater 
       
   374             // than the node (i.e. when the item belongs under this same node).
       
   375             if ( MessagesBelongUnderSameSeparatorL( aItem1.MessagePtr(), 
       
   376                                                     aItem2.MessagePtr(), 
       
   377                                                     sortCriteria.iField ) )
       
   378                 {
       
   379                 value = 1;
       
   380                 }
       
   381             }
       
   382         }
       
   383     
       
   384     return value;
       
   385     }
       
   386 
       
   387 // ---------------------------------------------------------------------------
       
   388 // CompareMessagesL
       
   389 // Compares given messages using the given sorting mode. Return positive 
       
   390 // value if aMessage1 is greater, negative value if aMessage1 is smaller, and 
       
   391 // 0 if the messages are equal.
       
   392 // ---------------------------------------------------------------------------
       
   393 //
       
   394 TInt CFSEmailUiMailListModel::CompareMessagesL( const CFSMailMessage& aMessage1, 
       
   395                                                 const CFSMailMessage& aMessage2,
       
   396                                                 TFSMailSortField aSortField )
       
   397     {
       
   398     FUNC_LOG;
       
   399     // For now, cast away the constness from the argument because CFSMailMessage does 
       
   400     // not declare all its logically constant functions as const. This is dirty and
       
   401     // should be fixed in the CFSMailMessage interface.
       
   402     CFSMailMessage& message1 = const_cast<CFSMailMessage&>( aMessage1 );
       
   403     CFSMailMessage& message2 = const_cast<CFSMailMessage&>( aMessage2 );
       
   404     
       
   405     TInt retVal = 0;
       
   406     
       
   407     switch ( aSortField )
       
   408         {
       
   409         case EFSMailSortByFlagStatus:
       
   410             {
       
   411             TInt compVal1 = 0;
       
   412             if ( message1.IsFlagSet(EFSMsgFlag_FollowUpComplete) ) { compVal1 = 1; }
       
   413             else if ( message1.IsFlagSet(EFSMsgFlag_FollowUp) ) { compVal1 = 2; }
       
   414 
       
   415             TInt compVal2 = 0;
       
   416             if ( message2.IsFlagSet(EFSMsgFlag_FollowUpComplete) ) { compVal2 = 1; }
       
   417             else if ( message2.IsFlagSet(EFSMsgFlag_FollowUp) ) { compVal2 = 2; }
       
   418 
       
   419             retVal = compVal1 - compVal2;
       
   420             }
       
   421             break;
       
   422         case EFSMailSortByPriority:
       
   423             {
       
   424             TInt compVal1 = 1;
       
   425             if ( message1.IsFlagSet(EFSMsgFlag_Low) ) { compVal1 = 0; }
       
   426             else if ( message1.IsFlagSet(EFSMsgFlag_Important) ) { compVal1 = 2; }
       
   427 
       
   428             TInt compVal2 = 1;
       
   429             if ( message2.IsFlagSet(EFSMsgFlag_Low) ) { compVal2 = 0; }
       
   430             else if ( message2.IsFlagSet(EFSMsgFlag_Important) ) { compVal2 = 2; }
       
   431 
       
   432             retVal = compVal1 - compVal2;
       
   433             }
       
   434             break;
       
   435         case EFSMailSortByRecipient:
       
   436             {
       
   437             CFSMailAddress* toAddress1(NULL);
       
   438             CFSMailAddress* toAddress2(NULL); 
       
   439 
       
   440             RPointerArray<CFSMailAddress>& toArray1 = message1.GetToRecipients();
       
   441             RPointerArray<CFSMailAddress>& toArray2 = message2.GetToRecipients();
       
   442             if ( toArray1.Count() )
       
   443                 {
       
   444                 toAddress1 = toArray1[0];
       
   445                 }           
       
   446             if ( toArray2.Count() )
       
   447                 {
       
   448                 toAddress2 = toArray2[0];
       
   449                 }           
       
   450             retVal = TFsEmailUiUtility::CompareMailAddressesL( toAddress1, toAddress2 );
       
   451             }
       
   452             break;
       
   453         case EFSMailSortBySender:
       
   454             {
       
   455             CFSMailAddress* fromAddress1 = message1.GetSender();
       
   456             CFSMailAddress* fromAddress2 = message2.GetSender();
       
   457             retVal = TFsEmailUiUtility::CompareMailAddressesL( fromAddress1, fromAddress2 );
       
   458             }
       
   459             break;
       
   460         case EFSMailSortByAttachment:
       
   461             {
       
   462             TInt compVal1 = 0;
       
   463             if ( message1.IsFlagSet(EFSMsgFlag_Attachments) ) { compVal1 = 1; }
       
   464 
       
   465             TInt compVal2 = 0;
       
   466             if ( message2.IsFlagSet(EFSMsgFlag_Attachments) ) { compVal2 = 1; }
       
   467 
       
   468             retVal = compVal1 - compVal2;
       
   469             }
       
   470             break;
       
   471         case EFSMailSortByUnread:
       
   472             {
       
   473             TInt compVal1 = 0;
       
   474             if ( message1.IsFlagSet(EFSMsgFlag_Read) ) { compVal1 = 1; }
       
   475 
       
   476             TInt compVal2 = 0;
       
   477             if ( message2.IsFlagSet(EFSMsgFlag_Read) ) { compVal2 = 1; }
       
   478 
       
   479             retVal = compVal1 - compVal2;
       
   480             }
       
   481             break;
       
   482         case EFSMailSortBySubject:
       
   483             {
       
   484             retVal = TFsEmailUiUtility::CompareMailSubjectsL( &message1, &message2 );
       
   485             }
       
   486             break;  
       
   487         case EFSMailSortByDate:
       
   488             {
       
   489             TTime time1 = message1.GetDate();
       
   490             TTime time2 = message2.GetDate();
       
   491             TTimeIntervalSeconds diff;
       
   492             TInt err = time1.SecondsFrom( time2, diff );
       
   493             if ( !err )
       
   494                 {
       
   495                 // Normal case, no overflow
       
   496                 retVal = diff.Int();
       
   497                 }
       
   498             else
       
   499                 {
       
   500                 // Overflow happens if the difference in time stamps is more than roughly 68 years.
       
   501                 // This is a very unlikely special case but handle it properly just in case.
       
   502                 retVal = ( time1 > time2 ? 1 : -1 );
       
   503                 }
       
   504             }
       
   505             break;
       
   506         default:
       
   507             {
       
   508             retVal = 0;
       
   509             }
       
   510             break;
       
   511         }
       
   512     
       
   513     return retVal;
       
   514     }
       
   515 
       
   516 TBool CFSEmailUiMailListModel::MessagesBelongUnderSameSeparatorL( 
       
   517                                                            const CFSMailMessage& aMessage1, 
       
   518                                                            const CFSMailMessage& aMessage2,
       
   519                                                            TFSMailSortField aSortField )
       
   520     {
       
   521     FUNC_LOG;
       
   522     TBool retVal = EFalse;
       
   523     
       
   524     switch ( aSortField )
       
   525         {
       
   526         case EFSMailSortByFlagStatus:
       
   527         case EFSMailSortByPriority:
       
   528         case EFSMailSortByRecipient:
       
   529         case EFSMailSortBySender:
       
   530         case EFSMailSortByAttachment:
       
   531         case EFSMailSortByUnread:
       
   532         case EFSMailSortBySubject:
       
   533             {
       
   534             retVal = ( !CompareMessagesL(aMessage1, aMessage2, aSortField) );
       
   535             }
       
   536             break;
       
   537         case EFSMailSortByDate:
       
   538             {
       
   539             TTime time1InHomeTime = aMessage1.GetDate();
       
   540             TTime time2InHomeTime = aMessage2.GetDate();
       
   541             TLocale currentLocaleSettings;      
       
   542             time1InHomeTime += currentLocaleSettings.UniversalTimeOffset();                      
       
   543             time1InHomeTime += currentLocaleSettings.QueryHomeHasDaylightSavingOn() 
       
   544                                   ? TTimeIntervalHours(1) : TTimeIntervalHours(0);          
       
   545             time2InHomeTime += currentLocaleSettings.UniversalTimeOffset();                      
       
   546             time2InHomeTime += currentLocaleSettings.QueryHomeHasDaylightSavingOn() 
       
   547                                   ? TTimeIntervalHours(1) : TTimeIntervalHours(0);      
       
   548             // Check that the day of the year and the year number are the same
       
   549             TInt day1 = time1InHomeTime.DayNoInYear();
       
   550             TInt day2 = time2InHomeTime.DayNoInYear();
       
   551             TTimeIntervalYears year1 = time1InHomeTime.YearsFrom(0);
       
   552             TTimeIntervalYears year2 = time2InHomeTime.YearsFrom(0);
       
   553             retVal = ( day1 == day2 && year1 == year2 );
       
   554             }
       
   555             break;
       
   556         default:
       
   557             {
       
   558             retVal = EFalse;
       
   559             }
       
   560             break;
       
   561         }
       
   562     
       
   563     return retVal;
       
   564     }
       
   565 
       
   566 /**
       
   567  * CFSEmailUiMailListModel::Reset
       
   568  */
       
   569 void CFSEmailUiMailListModel::Reset()
       
   570     {
       
   571     FUNC_LOG;
       
   572 	iItems.ResetAndDestroy();
       
   573     iSortCriteria.iField = EFSMailSortByDate;
       
   574     iSortCriteria.iOrder = EFSMailDescending;
       
   575     }
       
   576 
       
   577 void CFSEmailUiMailListModel::GetItemIdsUnderNodeL( const TFsTreeItemId aNodeId, 
       
   578         RFsTreeItemIdList& aMessageIds ) const
       
   579     {
       
   580     FUNC_LOG;
       
   581     aMessageIds.Reset();
       
   582     const TInt count(iItems.Count());
       
   583     for (TInt index = 0; index < count; index++)
       
   584         {
       
   585         if (iItems[index]->CorrespondingListId() == aNodeId)
       
   586             {            
       
   587             // Found the node Id, now get all the items under it
       
   588             while (++index < count && iItems[index]->ModelItemType() == ETypeMailItem)
       
   589                 {
       
   590                 aMessageIds.AppendL(iItems[index]->CorrespondingListId());
       
   591                 }
       
   592             break;
       
   593             }
       
   594         }        
       
   595     }