uiservicetab/vimpstui/src/cvimpstuisinglelistboxarray.cpp
changeset 0 5e5d6b214f4f
child 14 9fdee5e1da30
equal deleted inserted replaced
-1:000000000000 0:5e5d6b214f4f
       
     1 /*
       
     2 * Copyright (c) 2008 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:  CVIMPSTUiArray-array decorator
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include	"cvimpstuisinglelistboxarray.h"
       
    21 #include    "tvimpstconsts.h"
       
    22 #include    "vimpstutils.h"
       
    23 #include    "mvimpstprocessarray.h"
       
    24 #include 	<vimpstuires.rsg>
       
    25 #include    "tvimpstenums.h"
       
    26 
       
    27 // platform includes
       
    28 
       
    29 #include    <AknUtils.h>
       
    30 #include    <StringLoader.h>
       
    31 #include    <AknIconUtils.h>
       
    32 #include    <AknIconArray.h>
       
    33 #include    <eikclbd.h>
       
    34 #include    <AknsConstants.h>
       
    35 
       
    36 #include    <vimpstui.mbg>
       
    37 
       
    38 // ================= MEMBER FUNCTIONS =======================
       
    39 
       
    40 // Two-phased constructor.
       
    41 CVIMPSTUiSingleListboxArray* CVIMPSTUiSingleListboxArray::NewL(MVIMPSTProcessArray& aItemModel,
       
    42 							            CColumnListBoxData* aListboxData,
       
    43 							            CVIMPSTUiSingleStyleListBox& aListBox
       
    44 							            )
       
    45     {
       
    46     CVIMPSTUiSingleListboxArray* self = new (ELeave) CVIMPSTUiSingleListboxArray( aItemModel, 
       
    47     								aListboxData, aListBox);
       
    48     								
       
    49     CleanupStack::PushL( self );
       
    50     self->ConstructL();
       
    51     CleanupStack::Pop( self );
       
    52     return self;
       
    53     }
       
    54 
       
    55 // Destructor
       
    56 CVIMPSTUiSingleListboxArray::~CVIMPSTUiSingleListboxArray()
       
    57     {
       
    58     delete iData;
       
    59     }
       
    60 
       
    61 // C++ default constructor can NOT contain any code, that
       
    62 // might leave.
       
    63 //
       
    64 CVIMPSTUiSingleListboxArray::CVIMPSTUiSingleListboxArray( MVIMPSTProcessArray& aItemModel,
       
    65         CColumnListBoxData* aListboxData, CVIMPSTUiSingleStyleListBox& aListBox /*= NULL*/)
       
    66     :
       
    67      iItemArray(aItemModel), 
       
    68      iListboxData( aListboxData ),
       
    69      iListBox(aListBox)
       
    70     {
       
    71     }
       
    72 
       
    73 // Symbian OS default constructor can leave.
       
    74 void CVIMPSTUiSingleListboxArray::ConstructL()
       
    75 	{
       
    76 	
       
    77 	 // maximum length of icons appended to identification
       
    78     // There can be four icons (A+B and two on D-column)
       
    79     iMaxLengthOfIcons =
       
    80         KContactOnlineIconA().Length()+  // longest A-Column icon
       
    81         KEmptyIconC().Length() + // longest C-column icon
       
    82         KContactNewMsgIcon().Length(); // longest D-Column icon
       
    83     // Reserve enough memory to handle maximum size item
       
    84 	iData = HBufC::NewL( KFriendsListMaxIdentificationLength +
       
    85 	                     KStatusMsgMaxLength +
       
    86 					     iMaxLengthOfIcons );
       
    87 
       
    88     }
       
    89 
       
    90 
       
    91 // ---------------------------------------------------------
       
    92 // CVIMPSTUiSingleListboxArray::MdcaCount
       
    93 // Returns the number of descriptor elements in a descriptor array.
       
    94 // (other items were commented in a header).
       
    95 // ---------------------------------------------------------
       
    96 //
       
    97 TInt CVIMPSTUiSingleListboxArray::MdcaCount() const
       
    98 	{
       
    99 	return iItemArray.Count();
       
   100 	}
       
   101 
       
   102 // ---------------------------------------------------------
       
   103 // CVIMPSTUiSingleListboxArray::MdcaCount
       
   104 // Return pointer to descriptor data in given index of an array
       
   105 // (other items were commented in a header).
       
   106 // ---------------------------------------------------------
       
   107 //
       
   108 TPtrC16 CVIMPSTUiSingleListboxArray::MdcaPoint( TInt aIndex ) const
       
   109 	{
       
   110 	// Although this is a const method, we do change the member data.
       
   111 	// This is done because of performance
       
   112 	// -> no need to create new buffer every time.
       
   113     TPtr dataPtr( iData->Des() );
       
   114     dataPtr.Zero();
       
   115 
       
   116     // fetch the item and process correct type    
       
   117     TVIMPSTEnums::TItem type = iItemArray.GetType(aIndex);
       
   118 
       
   119     switch( type )
       
   120         {
       
   121         case TVIMPSTEnums::EOwnStatusItem:
       
   122 	        {
       
   123 	        TRAP_IGNORE( AppendOwnDataL(dataPtr,aIndex ) );
       
   124 	        break;	
       
   125 	        }
       
   126 		
       
   127         case TVIMPSTEnums::EContactItem: 
       
   128 			{
       
   129 			// contact item
       
   130 	    	TRAP_IGNORE( AppendContactL(dataPtr,aIndex ) );
       
   131 			break;
       
   132 			}
       
   133 			
       
   134         } //end outer switch
       
   135     return dataPtr;
       
   136 	}
       
   137 	
       
   138 
       
   139 // ---------------------------------------------------------
       
   140 // CVIMPSTUiSingleListboxArray::AppendContact
       
   141 // Append formatted contact identification to buffer
       
   142 // (other items were commented in a header).
       
   143 // ---------------------------------------------------------
       
   144 //
       
   145 void CVIMPSTUiSingleListboxArray::AppendContactL( TPtr& aBuffer,
       
   146                                       TInt aIndex
       
   147                                       ) const
       
   148     {
       
   149     // A-column
       
   150      aBuffer.Append( KEmptyIconA );
       
   151     // B-column
       
   152      TPtrC identification(iItemArray.GetItemNameText(aIndex) );
       
   153      aBuffer.Append( identification.Left(KFriendsListMaxIdentificationLength) );
       
   154 
       
   155      //C-Column
       
   156      aBuffer.Append( KEmptyIconC );
       
   157 
       
   158      // D-Column
       
   159      if( iItemArray.IsMsgPending( aIndex ) )
       
   160          {
       
   161          aBuffer.Append( KContactNewMsgIcon );   
       
   162          }
       
   163      else
       
   164          {
       
   165          aBuffer.Append( KEmptyIconC );  
       
   166          } 
       
   167     }
       
   168 
       
   169 // ---------------------------------------------------------
       
   170 // CVIMPSTUiSingleListboxArray::AppendContact
       
   171 // Append formatted contact identification to buffer
       
   172 // (other items were commented in a header).
       
   173 // ---------------------------------------------------------
       
   174 //
       
   175 void CVIMPSTUiSingleListboxArray::AppendOwnDataL( TPtr& aBuffer,
       
   176                                       TInt aIndex
       
   177                                       ) const
       
   178 	{    
       
   179 	// no need to append any icon in the a coloum as there is no presence service.
       
   180 	 // A-column
       
   181 	 aBuffer.Append( KEmptyIconA );
       
   182 	 
       
   183      // B-column
       
   184     TPtrC identification(iItemArray.GetItemNameText(aIndex));
       
   185     aBuffer.Append( identification.Left( KFriendsListMaxIdentificationLength ) );
       
   186 
       
   187 
       
   188     //C-Column
       
   189     aBuffer.Append( KEmptyIconA );
       
   190     
       
   191     //D-Column
       
   192     aBuffer.Append( KEmptyIconA );
       
   193    }
       
   194 
       
   195 // ---------------------------------------------------------
       
   196 // CVIMPSTUiSingleListboxArray::AppendContactListL
       
   197 // Append formatted contact list identification to buffer
       
   198 // (other items were commented in a header).
       
   199 // ---------------------------------------------------------
       
   200 //
       
   201 void CVIMPSTUiSingleListboxArray::AppendContactListL( TPtr& /*aBuffer*/, 
       
   202         TInt /*aIndex */) const
       
   203         {
       
   204         // add functionality when contactlists  supported
       
   205         }
       
   206 
       
   207 
       
   208 //  End of File