wvsettings20/IMPSSrc/TIMPSSAPSettingsListItemNameKey.cpp
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 2003 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:  Key for sorting CIMPSSAPSettingsListItem's.
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include "TIMPSSAPSettingsListItemNameKey.h"
       
    20 #include "cimpssapsettingslistitem.h"
       
    21 
       
    22 // ================= MEMBER FUNCTIONS =======================
       
    23 
       
    24 // -----------------------------------------------------------------------------
       
    25 // IMPSSAPProtectionHandler::TIMPSSAPSettingsListItemNameKey()
       
    26 // -----------------------------------------------------------------------------
       
    27 //
       
    28 TIMPSSAPSettingsListItemNameKey::TIMPSSAPSettingsListItemNameKey( TBool aAscending )
       
    29         : TKeyArrayFix( 0, ECmpCollated, sizeof( CIMPSSAPSettingsListItem* ) ),
       
    30         iAscending( aAscending )
       
    31     {
       
    32     }
       
    33 
       
    34 // -----------------------------------------------------------------------------
       
    35 // IMPSSAPProtectionHandler::Compare()
       
    36 // -----------------------------------------------------------------------------
       
    37 //
       
    38 TInt TIMPSSAPSettingsListItemNameKey::Compare( TInt aLeft, TInt aRight ) const
       
    39     {
       
    40     //The list item array holds actually pointers to list items.
       
    41     //At() method returns TAny pointer, pointing to list item pointer in the array
       
    42     //==> TAny pointer needs to be casted to CIMPSSAPSettingsListItem pointer pointer.
       
    43     CIMPSSAPSettingsListItem* leftItem = * ( reinterpret_cast< CIMPSSAPSettingsListItem** > ( At( aLeft ) ) );
       
    44     CIMPSSAPSettingsListItem* rightItem = * ( reinterpret_cast< CIMPSSAPSettingsListItem** > ( At( aRight ) ) );
       
    45 
       
    46     TPtrC leftName( leftItem->Name() );
       
    47     TPtrC rightName( rightItem->Name() );
       
    48 
       
    49     TInt status = leftName.CompareC( rightName );
       
    50 
       
    51     if ( !iAscending )
       
    52         {
       
    53         status *= -1; //flip order, if ascending
       
    54         }
       
    55 
       
    56     return status;
       
    57     }
       
    58 
       
    59 
       
    60 //  End of File