Example Application Guide

 

geoprofileslbmodel.cpp

00001 /*
00002 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
00003 * All rights reserved.
00004 * This component and the accompanying materials are made available
00005 * under the terms of the License "Eclipse Public License v1.0"
00006 * which accompanies this distribution, and is available
00007 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
00008 *
00009 * Initial Contributors:
00010 * Nokia Corporation - initial contribution.
00011 *
00012 * Contributors:
00013 *
00014 * Description:  List box model for Geo Profiles Application UI.
00015 *
00016 */
00017 
00018 
00019 // SYSTEM INCLUDES 
00020 
00021 // USER INCLUDES
00022 #include "geoprofileslbmodel.h"
00023 #include "geoprofile.h"
00024 
00025 // CONSTANT DEFINTION
00026 const TInt KGeoProfilesBufferSize = 256;
00027     
00028 // ---------------------------------------------------------------------------
00029 // CGeoProfilesLBModel::CGeoProfilesLBModel
00030 // ---------------------------------------------------------------------------
00031 //
00032 CGeoProfilesLBModel::CGeoProfilesLBModel( 
00033                     RPointerArray<CGeoProfile>*  aGeoProfiles )
00034     :iGeoProfiles( aGeoProfiles )
00035     {    
00036     }
00037 
00038 // ---------------------------------------------------------------------------
00039 // CGeoProfilesLBModel::~CGeoProfilesLBModel
00040 // ---------------------------------------------------------------------------
00041 //    
00042 CGeoProfilesLBModel::~CGeoProfilesLBModel()
00043     {
00044     // Delete the Conversion buffer
00045     delete iBuffer;   
00046     }
00047 
00048 // ---------------------------------------------------------------------------
00049 // CGeoProfilesLBModel::NewL
00050 // ---------------------------------------------------------------------------
00051 // 
00052 CGeoProfilesLBModel* CGeoProfilesLBModel::NewL( 
00053                          RPointerArray<CGeoProfile>*     aGeoProfiles )
00054     {
00055     CGeoProfilesLBModel* self = new ( ELeave ) CGeoProfilesLBModel( aGeoProfiles );
00056     CleanupStack::PushL( self );
00057     self->ConstructL();
00058     CleanupStack::Pop( self );
00059     return self;
00060     }
00061 
00062 // ---------------------------------------------------------------------------
00063 // void CGeoProfilesLBModel::ConstructL
00064 // ---------------------------------------------------------------------------
00065 //
00066 void CGeoProfilesLBModel::ConstructL()
00067     {
00068     // Allocate the Conversion buffer
00069     iBuffer = HBufC::NewL( KGeoProfilesBufferSize );
00070     }
00071 
00072 // ---------------------------------------------------------------------------
00073 // void CGeoProfilesLBModel::UpdateModelL
00074 // ---------------------------------------------------------------------------
00075 //
00076 void CGeoProfilesLBModel::UpdateModel( 
00077                         RPointerArray<CGeoProfile>*      aGeoProfiles )
00078     {
00079     iGeoProfiles = aGeoProfiles;
00080     }
00081 
00082 // ---------------------------------------------------------------------------
00083 // TInt CGeoProfilesLBModel::MdcaCount
00084 // ---------------------------------------------------------------------------
00085 //
00086 TInt CGeoProfilesLBModel::MdcaCount() const
00087     {
00088     return iGeoProfiles->Count();       
00089     }
00090     
00091 // ---------------------------------------------------------------------------
00092 // TPtrC16 CGeoProfilesLBModel::MdcaPoint
00093 // ---------------------------------------------------------------------------
00094 //
00095 TPtrC16 CGeoProfilesLBModel::MdcaPoint(  TInt aIndex  ) const
00096     {
00097     // Create formatted item string.
00098     // list item string format: // Format "\t%S\t\t%S"
00099         TPtr16  buf( iBuffer->Des());
00100         buf.Zero();
00101             
00102     if ( iGeoProfiles->Count() < aIndex )
00103         {
00104         return buf;
00105         }
00106        
00107     // Pack the contents into the Buffer. We dont have to re-allocate the buffer
00108     // everytime. Currently the string length is restricted to 256. 
00109     // 
00110     // !!! Could be a potential problem !!!!!
00111                     
00112     // Tabulator Defintion
00113     _LIT( KTab, "\t" );
00114     
00115         // Append the Tab Key
00116         buf.Append( KTab );    
00117         
00118         // Append the Geo Profile Name
00119         buf.Append( (*iGeoProfiles)[ aIndex ]->GeoPlaceName());
00120         
00121         // Append the Tab Key
00122         buf.Append( KTab );
00123         
00124         // Append the Tab Key
00125         buf.Append( KTab );
00126                 
00127         // Append the Geo Profile Name
00128         buf.Append( (*iGeoProfiles)[ aIndex ]->ProfileName());
00129 
00130     return buf;
00131     
00132     }

© Nokia 2009

Back to top