uigraphics/AknIcon/srvsrc/AknIconDataItem.cpp
changeset 0 05e9090e2422
equal deleted inserted replaced
-1:000000000000 0:05e9090e2422
       
     1 /*
       
     2 * Copyright (c) 2002 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:   
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 
       
    22 #include <e32std.h>
       
    23 
       
    24 #include "AknIconDataItem.h"
       
    25 #include "AknIconSrvDef.h"
       
    26 #include "AknIconFileNameCache.h"
       
    27 
       
    28 // CONSTANTS
       
    29 
       
    30 // ================= MEMBER FUNCTIONS ==========================================
       
    31 
       
    32 CAknIconDataItem::CAknIconDataItem()
       
    33     {
       
    34     }
       
    35 
       
    36 CAknIconDataItem::CAknIconDataItem( const TAknIconParams& aParams )
       
    37     {
       
    38     // This constructor is used when the object is instantiated in stack,
       
    39     // so CBase's zero initialization is not done.
       
    40     Mem::FillZ( this, sizeof( CAknIconDataItem ) );
       
    41     iFileNameRef = &aParams.iFileName;
       
    42     iIconId = aParams.iBitmapId;
       
    43     iAppIcon = aParams.iAppIcon;
       
    44     }
       
    45 
       
    46 CAknIconDataItem::~CAknIconDataItem()
       
    47     {
       
    48     }
       
    49 
       
    50 CAknIconDataItem* CAknIconDataItem::NewL( const TAknIconParams& aParams,
       
    51                                           CAknIconFileNameCache& aFileNameCache )
       
    52     {
       
    53     CAknIconDataItem* item = new( ELeave ) CAknIconDataItem;
       
    54     CleanupStack::PushL( item );
       
    55     item->ConstructL( aParams, aFileNameCache );
       
    56     CleanupStack::Pop();
       
    57     return item;
       
    58     }
       
    59 
       
    60 void CAknIconDataItem::ConstructL( const TAknIconParams& aParams,
       
    61                                    CAknIconFileNameCache& aFileNameCache )
       
    62     {
       
    63     // cache icon file name        
       
    64     iFileName = aFileNameCache.CacheIconFileNameL(aParams.iFileName);     
       
    65     iIconId = aParams.iBitmapId;
       
    66     iUserCount = 1;
       
    67     iAppIcon = aParams.iAppIcon;
       
    68     }
       
    69 
       
    70 #ifdef __WINSCW__            
       
    71 #pragma warning (disable:4706) // assignment within conditional expression
       
    72 #else
       
    73 #pragma diag_suppress 1293
       
    74 #pragma warning (disable:1293)
       
    75 #endif
       
    76 
       
    77 // -----------------------------------------------------------------------------
       
    78 // CAknIconDataItem::LinearOrder
       
    79 // -----------------------------------------------------------------------------
       
    80 //
       
    81 TInt CAknIconDataItem::LinearOrder(
       
    82     const CAknIconDataItem& aFirst,
       
    83     const CAknIconDataItem& aSecond )
       
    84     {
       
    85     TInt result;
       
    86 
       
    87     if ( !(result = aFirst.iIconId - aSecond.iIconId) )
       
    88         {
       
    89         const TDesC* firstFileName = aFirst.iFileNameRef ?
       
    90             aFirst.iFileNameRef : aFirst.iFileName;
       
    91 
       
    92         const TDesC* secondFileName = aSecond.iFileNameRef ?
       
    93             aSecond.iFileNameRef : aSecond.iFileName;
       
    94 
       
    95         result = firstFileName->CompareF( *secondFileName );
       
    96         if ( ! result )
       
    97             {
       
    98             result = aFirst.iAppIcon ^ aSecond.iAppIcon;
       
    99             }
       
   100         }
       
   101 
       
   102     return result;
       
   103     }
       
   104 
       
   105 #pragma warning (default:4706)
       
   106 
       
   107 // -----------------------------------------------------------------------------
       
   108 // CAknIconDataItem::GetInfo
       
   109 // -----------------------------------------------------------------------------
       
   110 //
       
   111 void CAknIconDataItem::GetInfo( TAknIconParams& aInfo ) const
       
   112     {
       
   113     // Note that '? :' statement does NOT work here,
       
   114     // because iFileNameRef and iFileName are different types of pointers!!!
       
   115     if ( iFileNameRef )
       
   116         {
       
   117         aInfo.iFileName = *iFileNameRef;
       
   118         }
       
   119     else
       
   120         {
       
   121         aInfo.iFileName = *iFileName;
       
   122         }
       
   123 
       
   124     aInfo.iBitmapId = iIconId;
       
   125     }
       
   126 
       
   127 //  End of File