|
1 /* |
|
2 * Copyright (c) 2005-2007 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: Phonebook 2 contact editor dialog UI field array. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "CPbk2UIFieldArray.h" |
|
19 #include "CPbk2UIField.h" |
|
20 #include <Pbk2UIControls.rsg> |
|
21 |
|
22 // Phonebook 2 |
|
23 #include <RPbk2LocalizedResourceFile.h> |
|
24 #include <Pbk2DataCaging.hrh> |
|
25 #include <MPbk2AppUi.h> |
|
26 #include <MPbk2ApplicationServices.h> |
|
27 #include "MPbk2UIField.h" |
|
28 |
|
29 // System includes |
|
30 #include <barsc.h> |
|
31 #include <barsread.h> |
|
32 #include <featmgr.h> |
|
33 |
|
34 |
|
35 // --------------------------------------------------------------------------- |
|
36 // CPbk2UIFieldArray::CPbk2UIFieldArray |
|
37 // --------------------------------------------------------------------------- |
|
38 // |
|
39 inline CPbk2UIFieldArray::CPbk2UIFieldArray(MPbk2UIFieldFactory& aFactory) |
|
40 :iFactory(aFactory) |
|
41 { |
|
42 } |
|
43 |
|
44 // --------------------------------------------------------------------------- |
|
45 // CPbk2UIFieldArray::ConstructL |
|
46 // --------------------------------------------------------------------------- |
|
47 // |
|
48 inline void CPbk2UIFieldArray::ConstructL( const TDesC& aResFile, RFs& aRFs ) |
|
49 { |
|
50 RPbk2LocalizedResourceFile resFile( &aRFs ); |
|
51 resFile.OpenLC(KPbk2RomFileDrive, |
|
52 KDC_RESOURCE_FILES_DIR, |
|
53 aResFile); |
|
54 |
|
55 TResourceReader reader; |
|
56 reader.SetBuffer( resFile.AllocReadLC( |
|
57 R_PBK2_UI_FIELD_PROPERTIES_CONTACT_EDITOR ) ); |
|
58 |
|
59 const TInt count = reader.ReadInt16(); |
|
60 for (TInt i = 0; i < count; ++i) |
|
61 { |
|
62 CPbk2UIField* field = CPbk2UIField::NewL( reader ); |
|
63 CleanupStack::PushL( field ); |
|
64 iFieldsArr.AppendL( field ); |
|
65 CleanupStack::Pop( field ); |
|
66 } |
|
67 |
|
68 // R_PBK2_UI_FIELD_PROPERTIES_CONTACT_EDITOR, resFile |
|
69 CleanupStack::PopAndDestroy(2); |
|
70 } |
|
71 |
|
72 // --------------------------------------------------------------------------- |
|
73 // CPbk2UIFieldArray::NewL |
|
74 // --------------------------------------------------------------------------- |
|
75 // |
|
76 EXPORT_C CPbk2UIFieldArray* CPbk2UIFieldArray::NewL |
|
77 ( const TDesC& aResFile, |
|
78 RFs& aRFs, |
|
79 MPbk2UIFieldFactory& aFactory ) |
|
80 { |
|
81 CPbk2UIFieldArray* self = new(ELeave) CPbk2UIFieldArray( aFactory ); |
|
82 CleanupStack::PushL(self); |
|
83 self->ConstructL( aResFile, aRFs); |
|
84 CleanupStack::Pop(self); |
|
85 return self; |
|
86 } |
|
87 |
|
88 // --------------------------------------------------------------------------- |
|
89 // CPbk2UIFieldArray::~CPbk2UIFieldArray |
|
90 // --------------------------------------------------------------------------- |
|
91 // |
|
92 CPbk2UIFieldArray::~CPbk2UIFieldArray() |
|
93 { |
|
94 iFieldsArr.ResetAndDestroy(); |
|
95 } |
|
96 |
|
97 // --------------------------------------------------------------------------- |
|
98 // CPbk2UIFieldArray::Count |
|
99 // --------------------------------------------------------------------------- |
|
100 // |
|
101 TInt CPbk2UIFieldArray::Count() const |
|
102 { |
|
103 return iFieldsArr.Count(); |
|
104 } |
|
105 |
|
106 // --------------------------------------------------------------------------- |
|
107 // CPbk2UIFieldArray::At |
|
108 // --------------------------------------------------------------------------- |
|
109 // |
|
110 MPbk2UIField& CPbk2UIFieldArray::At |
|
111 (TInt aIndex) const |
|
112 { |
|
113 return *iFieldsArr[aIndex]; |
|
114 } |
|
115 |
|
116 // --------------------------------------------------------------------------- |
|
117 // CPbk2UIFieldArray::GetUIFieldFactory |
|
118 // --------------------------------------------------------------------------- |
|
119 // |
|
120 const MPbk2UIFieldFactory& CPbk2UIFieldArray::GetUIFieldFactory() const |
|
121 { |
|
122 return iFactory; |
|
123 } |
|
124 |
|
125 // --------------------------------------------------------------------------- |
|
126 // CPbk2UIFieldArray::AppendL |
|
127 // --------------------------------------------------------------------------- |
|
128 // |
|
129 void CPbk2UIFieldArray::AppendL(MPbk2UIFieldArray& aUIFieldArray) |
|
130 { |
|
131 TInt count = aUIFieldArray.Count(); |
|
132 for(TInt idx = 0; idx < count; idx++) |
|
133 { |
|
134 const MPbk2UIField& field = aUIFieldArray.At(idx); |
|
135 iFieldsArr.AppendL(&field); |
|
136 } |
|
137 } |
|
138 |
|
139 // --------------------------------------------------------------------------- |
|
140 // CPbk2UIFieldArray::RemoveAt |
|
141 // --------------------------------------------------------------------------- |
|
142 // |
|
143 void CPbk2UIFieldArray::RemoveAt( TInt aIndex ) |
|
144 { |
|
145 iFieldsArr.Remove(aIndex); |
|
146 } |
|
147 |
|
148 |
|
149 // End of File |