uiservicetab/vimpststorage/src/cvimpststoragecontactsorter.cpp
branchRCL_3
changeset 14 9fdee5e1da30
parent 0 5e5d6b214f4f
equal deleted inserted replaced
13:796276a1bdcc 14:9fdee5e1da30
    19 // INCLUDE FILES
    19 // INCLUDE FILES
    20 #include    "cvimpststoragecontactsorter.h"
    20 #include    "cvimpststoragecontactsorter.h"
    21 #include    "mvimpststoragecontact.h"
    21 #include    "mvimpststoragecontact.h"
    22 #include    "tvimpstenums.h"
    22 #include    "tvimpstenums.h"
    23 #include    "cvimpststoragedefs.h"
    23 #include    "cvimpststoragedefs.h"
    24 #include 	"vimpstdebugtrace.h"
    24 #include "uiservicetabtracer.h"
    25 
    25 
    26 // The order of contacts if sorted by status
    26 // The order of contacts if sorted by status
    27 const TInt KConstOnline  = 1;
    27 const TInt KConstOnline  = 1;
    28 const TInt KConstBusy	= 2;
    28 const TInt KConstBusy	= 2;
    29 const TInt KConstAway    = 3;
    29 const TInt KConstAway    = 3;
    41 // Compares alphabetically using MVIMPSTStorageContact::Identification and 
    41 // Compares alphabetically using MVIMPSTStorageContact::Identification and 
    42 // TDesC::CompareC
    42 // TDesC::CompareC
    43 TInt CompareAlphabetically( const MVIMPSTStorageContact& aFirst, 
    43 TInt CompareAlphabetically( const MVIMPSTStorageContact& aFirst, 
    44                            const MVIMPSTStorageContact& aSecond )
    44                            const MVIMPSTStorageContact& aSecond )
    45     {
    45     {
       
    46 	TRACER_AUTO;
    46     return aFirst.Name().CompareC( aSecond.Name(),
    47     return aFirst.Name().CompareC( aSecond.Name(),
    47                                              KCollationLevel, NULL );
    48                                              KCollationLevel, NULL );
    48     }
    49     }
    49 
    50 
    50 
    51 
    51 // Group the contact by it's status. 
    52 // Group the contact by it's status. 
    52 TInt OrderContact( const MVIMPSTStorageContact& aContact )
    53 TInt OrderContact( const MVIMPSTStorageContact& aContact )
    53     {
    54     {
       
    55 	TRACER_AUTO;
    54      // Contact is not blocked, group by presence status
    56      // Contact is not blocked, group by presence status
    55       switch( aContact.OnlineStatus() )
    57       switch( aContact.OnlineStatus() )
    56             {
    58             {
    57             case TVIMPSTEnums::EOnline:
    59             case TVIMPSTEnums::EOnline:
    58                 {
    60                 {
    96 
    98 
    97 // Compares by contact status, -1 = aFirst is greater, 1 = aSecond is greater.
    99 // Compares by contact status, -1 = aFirst is greater, 1 = aSecond is greater.
    98 TInt CompareByPresence( const MVIMPSTStorageContact& aFirst, 
   100 TInt CompareByPresence( const MVIMPSTStorageContact& aFirst, 
    99                         const MVIMPSTStorageContact& aSecond )
   101                         const MVIMPSTStorageContact& aSecond )
   100     {
   102     {
       
   103 	TRACER_AUTO;
   101     TInt firstGroup( OrderContact( aFirst ) );
   104     TInt firstGroup( OrderContact( aFirst ) );
   102     TInt secondGroup( OrderContact( aSecond ) );
   105     TInt secondGroup( OrderContact( aSecond ) );
   103 
   106 
   104     // If both contacts belong to same group, sort alphabetically
   107     // If both contacts belong to same group, sort alphabetically
   105     if( firstGroup == secondGroup )
   108     if( firstGroup == secondGroup )
   114 // ================= MEMBER FUNCTIONS =======================
   117 // ================= MEMBER FUNCTIONS =======================
   115 
   118 
   116 // Two-phased constructor.
   119 // Two-phased constructor.
   117 CVIMPSTStorageContactSorter* CVIMPSTStorageContactSorter::NewL() 
   120 CVIMPSTStorageContactSorter* CVIMPSTStorageContactSorter::NewL() 
   118     {
   121     {
       
   122 	TRACER_AUTO;
   119     CVIMPSTStorageContactSorter* self = new( ELeave ) CVIMPSTStorageContactSorter();
   123     CVIMPSTStorageContactSorter* self = new( ELeave ) CVIMPSTStorageContactSorter();
   120     return self;
   124     return self;
   121     }
   125     }
   122 
   126 
   123 // Destructor
   127 // Destructor
   124 CVIMPSTStorageContactSorter::~CVIMPSTStorageContactSorter()
   128 CVIMPSTStorageContactSorter::~CVIMPSTStorageContactSorter()
   125     {
   129     {
   126     TRACE( T_LIT("CVIMPSTStorageContactSorter::~CVIMPSTStorageContactSorter") );
   130 	TRACER_AUTO;
   127     }
   131     }
   128 
   132 
   129 // ---------------------------------------------------------
   133 // ---------------------------------------------------------
   130 // CVIMPSTStorageContactSorter::Sort( RPointerArray<MVIMPSTStorageContact>& aList )
   134 // CVIMPSTStorageContactSorter::Sort( RPointerArray<MVIMPSTStorageContact>& aList )
   131 // Sorts given array.
   135 // Sorts given array.
   132 // ---------------------------------------------------------
   136 // ---------------------------------------------------------
   133 //
   137 //
   134 void CVIMPSTStorageContactSorter::Sort( RPointerArray< MVIMPSTStorageContact >& aList )
   138 void CVIMPSTStorageContactSorter::Sort( RPointerArray< MVIMPSTStorageContact >& aList )
   135     {
   139     {
   136     TRACE( T_LIT("CVIMPSTStorageContactSorter::Sort() begin") );
   140 	TRACER_AUTO;
   137     aList.Sort( iAlgorithm );
   141     aList.Sort( iAlgorithm );
   138     TRACE( T_LIT("CVIMPSTStorageContactSorter::Sort() end") );
       
   139     }
   142     }
   140 
   143 
   141 // ---------------------------------------------------------
   144 // ---------------------------------------------------------
   142 // CVIMPSTStorageContactSorter::Compare( const MVIMPSTStorageContact& aFirst, 
   145 // CVIMPSTStorageContactSorter::Compare( const MVIMPSTStorageContact& aFirst, 
   143 //                                  const MVIMPSTStorageContact& aSecond ) const
   146 //                                  const MVIMPSTStorageContact& aSecond ) const
   146 // ---------------------------------------------------------
   149 // ---------------------------------------------------------
   147 //
   150 //
   148 TInt CVIMPSTStorageContactSorter::Compare( const MVIMPSTStorageContact& aFirst, 
   151 TInt CVIMPSTStorageContactSorter::Compare( const MVIMPSTStorageContact& aFirst, 
   149                                     const MVIMPSTStorageContact& aSecond ) const
   152                                     const MVIMPSTStorageContact& aSecond ) const
   150     {
   153     {
       
   154 	TRACER_AUTO;
   151     return iAlgorithm.operator TGeneralLinearOrder()( &aFirst, &aSecond );
   155     return iAlgorithm.operator TGeneralLinearOrder()( &aFirst, &aSecond );
   152     }
   156     }
   153 
   157 
   154 // C++ default constructor can NOT contain any code, that
   158 // C++ default constructor can NOT contain any code, that
   155 // might leave.
   159 // might leave.
   167 // ---------------------------------------------------------
   171 // ---------------------------------------------------------
   168 //
   172 //
   169 void CVIMPSTStorageContactSorter::SetSortAlgorithm( 
   173 void CVIMPSTStorageContactSorter::SetSortAlgorithm( 
   170                             MVIMPSTStorageContact::TSortAlgorithm aAlgorithm )
   174                             MVIMPSTStorageContact::TSortAlgorithm aAlgorithm )
   171     {    
   175     {    
       
   176 	TRACER_AUTO;
   172     switch( aAlgorithm )
   177     switch( aAlgorithm )
   173             {
   178             {
   174         case MVIMPSTStorageContact::ECompareByPresence: 
   179         case MVIMPSTStorageContact::ECompareByPresence: 
   175             {
   180             {
   176             iAlgorithm = 
   181             iAlgorithm =