cmmanager/cmmgr/Framework/Src/cmlistboxmodel.cpp
branchRCL_3
changeset 58 83ca720e2b9a
parent 0 5a93021fdf25
equal deleted inserted replaced
57:05bc53fe583b 58:83ca720e2b9a
       
     1 /*
       
     2 * Copyright (c) 2006 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:  Implementation of CCmListboxModel
       
    15 *
       
    16 */
       
    17 
       
    18 #include <AknIconArray.h>
       
    19 #include <aknlists.h>
       
    20 #include <StringLoader.h>
       
    21 #include <cmmanager.rsg>
       
    22 
       
    23 #include "cmlistboxmodel.h"
       
    24 #include "cmlistitem.h"
       
    25 #include <cmcommonconstants.h>
       
    26 #include "cmlistitemlist.h"
       
    27 
       
    28 // ---------------------------------------------------------------------------
       
    29 // CCmListboxModel::CCmListboxModel
       
    30 // ---------------------------------------------------------------------------
       
    31 //
       
    32 CCmListboxModel::CCmListboxModel()
       
    33     : iOffset( 0 )
       
    34     {
       
    35     }
       
    36 
       
    37 // ---------------------------------------------------------------------------
       
    38 // CCmListboxModel::~CCmListboxModel
       
    39 // ---------------------------------------------------------------------------
       
    40 //
       
    41 CCmListboxModel::~CCmListboxModel()
       
    42     {
       
    43     //ResetAndCmroy(); // deletes all elements...
       
    44     }
       
    45 
       
    46 // ---------------------------------------------------------------------------
       
    47 // CCmListboxModel::MdcaCount
       
    48 // ---------------------------------------------------------------------------
       
    49 //
       
    50 TInt CCmListboxModel::MdcaCount() const
       
    51     {
       
    52     return Count();
       
    53     }
       
    54 
       
    55 // ---------------------------------------------------------------------------
       
    56 // CCmListboxModel::SetOwnIconOffset
       
    57 // ---------------------------------------------------------------------------
       
    58 //
       
    59 void CCmListboxModel::SetOwnIconOffset( TInt aOffset )
       
    60     {
       
    61     iOffset = aOffset;
       
    62     }
       
    63 
       
    64 // ---------------------------------------------------------------------------
       
    65 // CCmListboxModel::MdcaPoint
       
    66 // ---------------------------------------------------------------------------
       
    67 //
       
    68 TPtrC CCmListboxModel::MdcaPoint( TInt aIndex ) const
       
    69     {
       
    70     // We need to cast away the const-ness from the buffer.
       
    71     // It was definitely made for formatting!
       
    72     FormatListboxText( aIndex,
       
    73                        MUTABLE_CAST( TBuf<KMaxCmListboxName>&, iBuf ) );
       
    74 
       
    75     return iBuf;
       
    76     }
       
    77 
       
    78 // ---------------------------------------------------------------------------
       
    79 // CCmListboxModel::FormatListboxText
       
    80 // ---------------------------------------------------------------------------
       
    81 //
       
    82 void CCmListboxModel::FormatListboxText( TInt aIndex,
       
    83                                          TDes& aBuf ) const
       
    84     {
       
    85     TRAP_IGNORE( FormatListboxTextL( aIndex, aBuf ) );
       
    86     }
       
    87     
       
    88 // ---------------------------------------------------------------------------
       
    89 // CCmListboxModel::FormatListboxTextL
       
    90 // ---------------------------------------------------------------------------
       
    91 //
       
    92 void CCmListboxModel::FormatListboxTextL( TInt aIndex,
       
    93                                           TDes& aBuf ) const
       
    94     {
       
    95     aBuf.Zero();
       
    96     TUint icon = At( aIndex )->IconIndex();
       
    97     if ( At(aIndex)->IsSingleLine() )
       
    98         {
       
    99         if ( At(aIndex)->IsProtected() )
       
   100             {
       
   101             aBuf.Format( KListItemFormatEmbDestProt, 
       
   102                          icon, 
       
   103                          &At( aIndex )->Name(), 
       
   104                          KCmReservedIconIndexProtected );
       
   105             }
       
   106         else            
       
   107             {
       
   108             aBuf.Format( KListItemFormatEmbDest, 
       
   109                          icon,
       
   110                          &At( aIndex )->Name() );            
       
   111             }
       
   112         }
       
   113      else
       
   114         {
       
   115         HBufC* secondLine;
       
   116         secondLine = StringLoader::LoadLC( R_CMMANAGERUI_METHOD_PRIORITY_OTHER,
       
   117                                            At( aIndex )->Priority() + 1 );
       
   118     if ( At( aIndex )->IsDefault() )
       
   119         {
       
   120             aBuf.Format( KListItemFormatCmProt,
       
   121                          icon, 
       
   122                          &At( aIndex )->Name(), 
       
   123                          secondLine, 
       
   124                          KCmReservedIconIndexDefaultConn );
       
   125         }
       
   126     else
       
   127         {
       
   128         if ( At(aIndex)->IsProtected() )
       
   129             {
       
   130             aBuf.Format( KListItemFormatCmProt, 
       
   131                          icon, 
       
   132                          &At( aIndex )->Name(), 
       
   133                          secondLine, 
       
   134                          KCmReservedIconIndexProtected );    
       
   135             }
       
   136         else if ( At(aIndex)->IsVpnOverDestination() )
       
   137             {
       
   138             CleanupStack::PopAndDestroy( secondLine );
       
   139             
       
   140             secondLine = StringLoader::LoadLC( R_QTN_NETW_CONSET_METHOD_PRIORITY_AUTO);
       
   141 
       
   142             aBuf.Format( KListItemFormatCm, 
       
   143                          icon,
       
   144                          &At( aIndex )->Name(),
       
   145                          secondLine );
       
   146             }
       
   147         else
       
   148             {
       
   149             aBuf.Format( KListItemFormatCm, 
       
   150                          icon, 
       
   151                          &At( aIndex )->Name(), 
       
   152                          secondLine );
       
   153             }
       
   154          }
       
   155             
       
   156         CleanupStack::PopAndDestroy( secondLine );
       
   157         }
       
   158     }
       
   159