|
1 /* |
|
2 * Copyright (c) 2005-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: List box model |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // System Includes |
|
20 #include <e32keys.h> |
|
21 |
|
22 // User Include |
|
23 #include "locsysuilbmodel.h" |
|
24 #include "locationsettings.h" |
|
25 |
|
26 // Constants |
|
27 const TInt KMaxDescriptionText = 0x100; |
|
28 |
|
29 // ========================= MEMBER FUNCTIONS ================================ |
|
30 |
|
31 // --------------------------------------------------------------------------- |
|
32 // CLocSysUiLBModel::CLocSysUiLBModel |
|
33 // Default Constructor |
|
34 // |
|
35 // --------------------------------------------------------------------------- |
|
36 // |
|
37 CLocSysUiLBModel::CLocSysUiLBModel( RPointerArray<CLocationSettings>& |
|
38 aSettingsArray ) |
|
39 :iSettingsArray( aSettingsArray ) |
|
40 { |
|
41 } |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 // CLocSysUiLBModel::~CLocSysUiLBModel |
|
45 // Destructor |
|
46 // |
|
47 // --------------------------------------------------------------------------- |
|
48 // |
|
49 CLocSysUiLBModel::~CLocSysUiLBModel() |
|
50 { |
|
51 delete iBuffer; |
|
52 } |
|
53 |
|
54 // --------------------------------------------------------------------------- |
|
55 // CLocSysUiLBModel* CLocSysUiLBModel::NewL |
|
56 // Two-phased constructor |
|
57 // |
|
58 // @param aSettingsArray Reference to the Settings UI array |
|
59 //@return CLocSysUiLBModel* Reference to the object created |
|
60 // |
|
61 // --------------------------------------------------------------------------- |
|
62 // |
|
63 CLocSysUiLBModel* CLocSysUiLBModel::NewL( |
|
64 RPointerArray<CLocationSettings>& aSettingsArray ) |
|
65 { |
|
66 CLocSysUiLBModel* self = new(ELeave)CLocSysUiLBModel( aSettingsArray ); |
|
67 CleanupStack::PushL( self ); |
|
68 self->ConstructL(); |
|
69 CleanupStack::Pop( self ); |
|
70 return self; |
|
71 } |
|
72 |
|
73 // --------------------------------------------------------------------------- |
|
74 // void CLocSysUiLBModel::ConstructL |
|
75 // Second Phase of the two phase constructor. |
|
76 // |
|
77 // --------------------------------------------------------------------------- |
|
78 // |
|
79 void CLocSysUiLBModel::ConstructL() |
|
80 { |
|
81 // Allocate the conversion buffer. The maximum length of the conversion buffer |
|
82 // is limited to 256 characters |
|
83 iBuffer = HBufC::NewL( KMaxDescriptionText ); |
|
84 |
|
85 } |
|
86 |
|
87 // --------------------------------------------------------------------------- |
|
88 // CLocationSettings* CLocSysUiLBModel::SettingsUi |
|
89 // Returns the Settings UI corresponding to a particular Index value. |
|
90 // The index value starts from 0 |
|
91 // |
|
92 // @param aIndex Index of the Settings Ui which is requested |
|
93 // @return CLocationSettings& Referrence to the Settings UI corresponding |
|
94 // to the index. |
|
95 // --------------------------------------------------------------------------- |
|
96 // |
|
97 CLocationSettings& CLocSysUiLBModel::SettingsUiL( TInt aIndex ) |
|
98 { |
|
99 if( aIndex < 0 || aIndex >= iSettingsArray.Count()) |
|
100 { |
|
101 User::Leave( KErrNotFound ); |
|
102 } |
|
103 return *iSettingsArray[ aIndex ]; |
|
104 } |
|
105 |
|
106 // --------------------------------------------------------------------------- |
|
107 // void CLocationSettings::UpdateListBoxContentsL |
|
108 // Updates the List box contents |
|
109 // |
|
110 // @param aSettingsArray Reference to the Settings UI array |
|
111 // --------------------------------------------------------------------------- |
|
112 // |
|
113 void CLocSysUiLBModel::UpdateListBoxContentsL( |
|
114 RPointerArray<CLocationSettings>& aSettingsArray ) |
|
115 { |
|
116 iSettingsArray= aSettingsArray; |
|
117 } |
|
118 |
|
119 // --------------------------------------------------------------------------- |
|
120 // TInt CLocSysUiLBModel::MdcaCount() const |
|
121 // Inherited from MDesCArray. Returns the total number of items in the |
|
122 // Settings description array |
|
123 // |
|
124 // @return TInt The total number of elements in the Settings Description array |
|
125 // --------------------------------------------------------------------------- |
|
126 // |
|
127 TInt CLocSysUiLBModel::MdcaCount() const |
|
128 { |
|
129 return iSettingsArray.Count(); |
|
130 } |
|
131 |
|
132 // --------------------------------------------------------------------------- |
|
133 // TPtrC16 CLocSysUiLBModel::MdcaPoint() const |
|
134 // Inherited from MDesCArray. Returns the list box entry corresponding to the |
|
135 // index value |
|
136 // |
|
137 // @param aIndex The index whose list box entry needs to be retrieved |
|
138 // @return TPtr16 The list box description |
|
139 // --------------------------------------------------------------------------- |
|
140 // |
|
141 TPtrC16 CLocSysUiLBModel::MdcaPoint( TInt aIndex ) const |
|
142 { |
|
143 // Zero the internal buffer |
|
144 TPtr ptr( iBuffer->Des()); |
|
145 ptr.Zero(); |
|
146 |
|
147 // Format "\t%S\t%d\t\t\t%S" |
|
148 |
|
149 // Append the first tab |
|
150 ptr.Append( EKeyTab ); |
|
151 |
|
152 // If the index is within the range append the caption string |
|
153 if ( aIndex >= 0 && aIndex < iSettingsArray.Count()) |
|
154 { |
|
155 CLocationSettings* settingsItem = iSettingsArray[ aIndex ]; |
|
156 TPtrC caption = settingsItem->Caption(); |
|
157 ptr.Append( caption ); |
|
158 } |
|
159 |
|
160 // Append the second tab |
|
161 ptr.Append( EKeyTab ); |
|
162 |
|
163 // Append the third tab |
|
164 ptr.Append( EKeyTab ); |
|
165 |
|
166 // Append the fourth tab |
|
167 ptr.Append( EKeyTab ); |
|
168 |
|
169 // Append the fifth tab |
|
170 ptr.Append( EKeyTab ); |
|
171 |
|
172 return ptr; |
|
173 } |
|
174 |