emailuis/emailui/src/FreestyleEmailUiMailListModel.cpp
changeset 0 8466d47a6819
child 1 12c456ceeff2
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:  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     // Mail type items own the message. Delete the existing message first.
       
   254     if ( item->ModelItemType() == ETypeMailItem )
       
   255         {
       
   256         delete &item->MessagePtr();
       
   257         }
       
   258     item->SetMessagePtr( aNewPtr );
       
   259     
       
   260     // If the item was the first child of a node, then also message pointer in the parent
       
   261     // node needs to be updated
       
   262     if ( aIndex > 0 &&
       
   263          item->ModelItemType() == ETypeMailItem &&
       
   264          iItems[aIndex-1]->ModelItemType() == ETypeSeparator )
       
   265         {
       
   266         iItems[aIndex-1]->SetMessagePtr( aNewPtr );
       
   267         }
       
   268     }
       
   269 
       
   270 TInt CFSEmailUiMailListModel::GetInsertionPointL( const CFSEmailUiMailListModelItem& aItemToInsert ) const
       
   271     {
       
   272     FUNC_LOG;
       
   273     TInt index;
       
   274     TLinearOrder<CFSEmailUiMailListModelItem> orderFunc( CompareModelItemsL );
       
   275     TInt ret = iItems.SpecificFindInOrder( &aItemToInsert, index, orderFunc, EArrayFindMode_First );
       
   276     return index;
       
   277     }
       
   278 
       
   279 TInt CFSEmailUiMailListModel::GetInsertionPointL( const CFSEmailUiMailListModelItem& aItemToInsert,
       
   280                                                   TInt& aChildIdx,
       
   281                                                   TInt& aParentNodeIdx ) const
       
   282     {
       
   283     FUNC_LOG;
       
   284     TInt index = GetInsertionPointL( aItemToInsert );
       
   285     
       
   286     // Find out the parent node
       
   287     aChildIdx = KErrNotFound;
       
   288     aParentNodeIdx = KErrNotFound;
       
   289     if ( index > 0 )
       
   290         {
       
   291         CFSEmailUiMailListModelItem* preceedingItem = iItems[index-1];
       
   292         if ( MessagesBelongUnderSameSeparatorL( aItemToInsert.MessagePtr(), 
       
   293                                                 preceedingItem->MessagePtr(),
       
   294                                                 iSortCriteria.iField ) )
       
   295             {
       
   296             // The new item belongs under the same node as the previous item
       
   297             // (or the previous item is a node under which the item belongs).
       
   298             // Find out the previous node item.
       
   299             aParentNodeIdx = index-1;
       
   300             while ( aParentNodeIdx >= 0 && iItems[aParentNodeIdx]->ModelItemType() != ETypeSeparator )
       
   301                 {
       
   302                 aParentNodeIdx--;
       
   303                 }
       
   304             if ( aParentNodeIdx >= 0 )
       
   305                 {
       
   306                 aChildIdx = index - aParentNodeIdx - 1;
       
   307                 }
       
   308             }
       
   309         }
       
   310     
       
   311     return index;
       
   312     }
       
   313 
       
   314 TInt CFSEmailUiMailListModel::CompareModelItemsL( const CFSEmailUiMailListModelItem& aItem1,
       
   315                                                   const CFSEmailUiMailListModelItem& aItem2 )
       
   316     {
       
   317     FUNC_LOG;
       
   318     // Retrieve the current sort criteria from model instance in TLS
       
   319     CFSEmailUiMailListModel* self = 
       
   320         static_cast<CFSEmailUiMailListModel*>( UserSvr::DllTls(KTlsHandleMailListModel) );
       
   321     TFSMailSortCriteria sortCriteria = self->SortCriteria();
       
   322     
       
   323     TInt value = CompareMessagesL( aItem1.MessagePtr(), 
       
   324                                    aItem2.MessagePtr(), 
       
   325                                    sortCriteria.iField );
       
   326     
       
   327     // The logic of the CompareMessagesL matches ascending order. In descending mode it must
       
   328     // be inverted.
       
   329     if ( sortCriteria.iOrder == EFSMailDescending )
       
   330         {
       
   331         value = -value;
       
   332         }
       
   333     
       
   334     // If items are equal with the primary sorting criterion and this primary criterion
       
   335     // is not date sort, then descending date order is used as secondary criterion.
       
   336     if ( !value && sortCriteria.iField != EFSMailSortByDate )
       
   337         {
       
   338         value = -CompareMessagesL( aItem1.MessagePtr(),
       
   339                                    aItem2.MessagePtr(),
       
   340                                    EFSMailSortByDate );
       
   341         }
       
   342     
       
   343     // Some magic is needed in case one of the items (but not both) is a separator
       
   344     if ( aItem1.ModelItemType() == ETypeSeparator && aItem2.ModelItemType() == ETypeMailItem )
       
   345         {
       
   346         if ( !value )
       
   347             { // In case an item is equal to the first item under the node, it's greater than the node
       
   348             value = -1;
       
   349             }
       
   350         else if ( value > 0 )
       
   351             {
       
   352             // In case an item is smaller than the first item under the node, it may still be greater 
       
   353             // than the node (i.e. when the item belongs under this same node).
       
   354             if ( MessagesBelongUnderSameSeparatorL( aItem1.MessagePtr(), 
       
   355                                                     aItem2.MessagePtr(), 
       
   356                                                     sortCriteria.iField ) )
       
   357                 {
       
   358                 value = -1;
       
   359                 }
       
   360             }
       
   361         }
       
   362     else if ( aItem1.ModelItemType() == ETypeMailItem && aItem2.ModelItemType() == ETypeSeparator )
       
   363         {
       
   364         if ( !value )
       
   365             { // In case an item is equal to the first item under the node, it's greater than the node
       
   366             value = 1;
       
   367             }
       
   368         else if ( value < 0 )
       
   369             {
       
   370             // In case an item is smaller than the first item under the node, it may still be greater 
       
   371             // than the node (i.e. when the item belongs under this same node).
       
   372             if ( MessagesBelongUnderSameSeparatorL( aItem1.MessagePtr(), 
       
   373                                                     aItem2.MessagePtr(), 
       
   374                                                     sortCriteria.iField ) )
       
   375                 {
       
   376                 value = 1;
       
   377                 }
       
   378             }
       
   379         }
       
   380     
       
   381     return value;
       
   382     }
       
   383 
       
   384 // ---------------------------------------------------------------------------
       
   385 // CompareMessagesL
       
   386 // Compares given messages using the given sorting mode. Return positive 
       
   387 // value if aMessage1 is greater, negative value if aMessage1 is smaller, and 
       
   388 // 0 if the messages are equal.
       
   389 // ---------------------------------------------------------------------------
       
   390 //
       
   391 TInt CFSEmailUiMailListModel::CompareMessagesL( const CFSMailMessage& aMessage1, 
       
   392                                                 const CFSMailMessage& aMessage2,
       
   393                                                 TFSMailSortField aSortField )
       
   394     {
       
   395     FUNC_LOG;
       
   396     // For now, cast away the constness from the argument because CFSMailMessage does 
       
   397     // not declare all its logically constant functions as const. This is dirty and
       
   398     // should be fixed in the CFSMailMessage interface.
       
   399     CFSMailMessage& message1 = const_cast<CFSMailMessage&>( aMessage1 );
       
   400     CFSMailMessage& message2 = const_cast<CFSMailMessage&>( aMessage2 );
       
   401     
       
   402     TInt retVal = 0;
       
   403     
       
   404     switch ( aSortField )
       
   405         {
       
   406         case EFSMailSortByFlagStatus:
       
   407             {
       
   408             TInt compVal1 = 0;
       
   409             if ( message1.IsFlagSet(EFSMsgFlag_FollowUpComplete) ) { compVal1 = 1; }
       
   410             else if ( message1.IsFlagSet(EFSMsgFlag_FollowUp) ) { compVal1 = 2; }
       
   411 
       
   412             TInt compVal2 = 0;
       
   413             if ( message2.IsFlagSet(EFSMsgFlag_FollowUpComplete) ) { compVal2 = 1; }
       
   414             else if ( message2.IsFlagSet(EFSMsgFlag_FollowUp) ) { compVal2 = 2; }
       
   415 
       
   416             retVal = compVal1 - compVal2;
       
   417             }
       
   418             break;
       
   419         case EFSMailSortByPriority:
       
   420             {
       
   421             TInt compVal1 = 1;
       
   422             if ( message1.IsFlagSet(EFSMsgFlag_Low) ) { compVal1 = 0; }
       
   423             else if ( message1.IsFlagSet(EFSMsgFlag_Important) ) { compVal1 = 2; }
       
   424 
       
   425             TInt compVal2 = 1;
       
   426             if ( message2.IsFlagSet(EFSMsgFlag_Low) ) { compVal2 = 0; }
       
   427             else if ( message2.IsFlagSet(EFSMsgFlag_Important) ) { compVal2 = 2; }
       
   428 
       
   429             retVal = compVal1 - compVal2;
       
   430             }
       
   431             break;
       
   432         case EFSMailSortByRecipient:
       
   433             {
       
   434             CFSMailAddress* toAddress1(NULL);
       
   435             CFSMailAddress* toAddress2(NULL); 
       
   436 
       
   437             RPointerArray<CFSMailAddress>& toArray1 = message1.GetToRecipients();
       
   438             RPointerArray<CFSMailAddress>& toArray2 = message2.GetToRecipients();
       
   439             if ( toArray1.Count() )
       
   440                 {
       
   441                 toAddress1 = toArray1[0];
       
   442                 }           
       
   443             if ( toArray2.Count() )
       
   444                 {
       
   445                 toAddress2 = toArray2[0];
       
   446                 }           
       
   447             retVal = TFsEmailUiUtility::CompareMailAddressesL( toAddress1, toAddress2 );
       
   448             }
       
   449             break;
       
   450         case EFSMailSortBySender:
       
   451             {
       
   452             CFSMailAddress* fromAddress1 = message1.GetSender();
       
   453             CFSMailAddress* fromAddress2 = message2.GetSender();
       
   454             retVal = TFsEmailUiUtility::CompareMailAddressesL( fromAddress1, fromAddress2 );
       
   455             }
       
   456             break;
       
   457         case EFSMailSortByAttachment:
       
   458             {
       
   459             TInt compVal1 = 0;
       
   460             if ( message1.IsFlagSet(EFSMsgFlag_Attachments) ) { compVal1 = 1; }
       
   461 
       
   462             TInt compVal2 = 0;
       
   463             if ( message2.IsFlagSet(EFSMsgFlag_Attachments) ) { compVal2 = 1; }
       
   464 
       
   465             retVal = compVal1 - compVal2;
       
   466             }
       
   467             break;
       
   468         case EFSMailSortByUnread:
       
   469             {
       
   470             TInt compVal1 = 1;
       
   471             if ( message1.IsFlagSet(EFSMsgFlag_Read) ) { compVal1 = 0; }
       
   472 
       
   473             TInt compVal2 = 1;
       
   474             if ( message2.IsFlagSet(EFSMsgFlag_Read) ) { compVal2 = 0; }
       
   475 
       
   476             retVal = compVal1 - compVal2;
       
   477             }
       
   478             break;
       
   479         case EFSMailSortBySubject:
       
   480             {
       
   481             retVal = TFsEmailUiUtility::CompareMailSubjectsL( &message1, &message2 );
       
   482             }
       
   483             break;  
       
   484         case EFSMailSortByDate:
       
   485             {
       
   486             TTime time1 = message1.GetDate();
       
   487             TTime time2 = message2.GetDate();
       
   488             TTimeIntervalSeconds diff;
       
   489             TInt err = time1.SecondsFrom( time2, diff );
       
   490             if ( !err )
       
   491                 {
       
   492                 // Normal case, no overflow
       
   493                 retVal = diff.Int();
       
   494                 }
       
   495             else
       
   496                 {
       
   497                 // Overflow happens if the difference in time stamps is more than roughly 68 years.
       
   498                 // This is a very unlikely special case but handle it properly just in case.
       
   499                 retVal = ( time1 > time2 ? 1 : -1 );
       
   500                 }
       
   501             }
       
   502             break;
       
   503         default:
       
   504             {
       
   505             retVal = 0;
       
   506             }
       
   507             break;
       
   508         }
       
   509     
       
   510     return retVal;
       
   511     }
       
   512 
       
   513 TBool CFSEmailUiMailListModel::MessagesBelongUnderSameSeparatorL( 
       
   514                                                            const CFSMailMessage& aMessage1, 
       
   515                                                            const CFSMailMessage& aMessage2,
       
   516                                                            TFSMailSortField aSortField )
       
   517     {
       
   518     FUNC_LOG;
       
   519     TBool retVal = EFalse;
       
   520     
       
   521     switch ( aSortField )
       
   522         {
       
   523         case EFSMailSortByFlagStatus:
       
   524         case EFSMailSortByPriority:
       
   525         case EFSMailSortByRecipient:
       
   526         case EFSMailSortBySender:
       
   527         case EFSMailSortByAttachment:
       
   528         case EFSMailSortByUnread:
       
   529         case EFSMailSortBySubject:
       
   530             {
       
   531             retVal = ( !CompareMessagesL(aMessage1, aMessage2, aSortField) );
       
   532             }
       
   533             break;
       
   534         case EFSMailSortByDate:
       
   535             {
       
   536             TTime time1InHomeTime = aMessage1.GetDate();
       
   537             TTime time2InHomeTime = aMessage2.GetDate();
       
   538             TLocale currentLocaleSettings;      
       
   539             time1InHomeTime += currentLocaleSettings.UniversalTimeOffset();                      
       
   540             time1InHomeTime += currentLocaleSettings.QueryHomeHasDaylightSavingOn() 
       
   541                                   ? TTimeIntervalHours(1) : TTimeIntervalHours(0);          
       
   542             time2InHomeTime += currentLocaleSettings.UniversalTimeOffset();                      
       
   543             time2InHomeTime += currentLocaleSettings.QueryHomeHasDaylightSavingOn() 
       
   544                                   ? TTimeIntervalHours(1) : TTimeIntervalHours(0);      
       
   545             // Check that the day of the year and the year number are the same
       
   546             TInt day1 = time1InHomeTime.DayNoInYear();
       
   547             TInt day2 = time2InHomeTime.DayNoInYear();
       
   548             TTimeIntervalYears year1 = time1InHomeTime.YearsFrom(0);
       
   549             TTimeIntervalYears year2 = time2InHomeTime.YearsFrom(0);
       
   550             retVal = ( day1 == day2 && year1 == year2 );
       
   551             }
       
   552             break;
       
   553         default:
       
   554             {
       
   555             retVal = EFalse;
       
   556             }
       
   557             break;
       
   558         }
       
   559     
       
   560     return retVal;
       
   561     }
       
   562 
       
   563 /**
       
   564  * CFSEmailUiMailListModel::Reset
       
   565  */
       
   566 void CFSEmailUiMailListModel::Reset()
       
   567     {
       
   568     FUNC_LOG;
       
   569 	iItems.ResetAndDestroy();
       
   570     iSortCriteria.iField = EFSMailSortByDate;
       
   571     iSortCriteria.iOrder = EFSMailDescending;
       
   572     }
       
   573