|
1 /* |
|
2 * Copyright (c) 2007-2009 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: CLS list item class implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "emailtrace.h" |
|
20 #include "cesmrclsitem.h"// CESMRClsItem |
|
21 |
|
22 #include "esmrfieldbuilderdef.h" |
|
23 #include <MVPbkContactLink.h> |
|
24 |
|
25 // ======== MEMBER FUNCTIONS ======== |
|
26 |
|
27 // ----------------------------------------------------------------------------- |
|
28 // CESMRClsItem::NewL |
|
29 // ----------------------------------------------------------------------------- |
|
30 // |
|
31 CESMRClsItem* CESMRClsItem::NewL( ) |
|
32 { |
|
33 FUNC_LOG; |
|
34 CESMRClsItem* object = CESMRClsItem::NewLC ( ); |
|
35 CleanupStack::Pop ( object ); |
|
36 return object; |
|
37 } |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // CESMRClsItem::NewLC |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 CESMRClsItem* CESMRClsItem::NewLC( ) |
|
44 { |
|
45 FUNC_LOG; |
|
46 CESMRClsItem* object = new (ELeave) CESMRClsItem(); |
|
47 CleanupStack::PushL ( object ); |
|
48 object->ConstructL ( ); |
|
49 return object; |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // CESMRClsItem::~CESMRClsItem |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 CESMRClsItem::~CESMRClsItem( ) |
|
57 { |
|
58 FUNC_LOG; |
|
59 delete iDisplayName; |
|
60 delete iEMailAddress; |
|
61 delete iFullText; |
|
62 delete iLink; |
|
63 iHighlights.Close(); |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CESMRClsItem::CloneLC |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 CESMRClsItem* CESMRClsItem::CloneLC() const |
|
71 { |
|
72 FUNC_LOG; |
|
73 CESMRClsItem* clone = CESMRClsItem::NewLC(); |
|
74 clone->SetDisplayNameL( DisplayName() ); |
|
75 clone->SetEmailAddressL( EmailAddress() ); |
|
76 if ( iLink ) |
|
77 { |
|
78 clone->SetContactLinkL( *iLink ); |
|
79 } |
|
80 clone->SetHighlightsL( Highlights() ); |
|
81 clone->SetIsMruItem( IsMruItem() ); |
|
82 if ( MultipleEmails() ) |
|
83 { |
|
84 clone->SetMultipleEmails( ); |
|
85 } |
|
86 return clone; |
|
87 } |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // CESMRClsItem::::SetDisplayNameL |
|
91 // ----------------------------------------------------------------------------- |
|
92 // |
|
93 void CESMRClsItem::SetDisplayNameL( const TDesC& aDisplayName ) |
|
94 { |
|
95 FUNC_LOG; |
|
96 HBufC* temp = aDisplayName.AllocL(); |
|
97 delete iDisplayName; |
|
98 iDisplayName = temp; |
|
99 } |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // CESMRClsItem::SetEmailAddressL |
|
103 // ----------------------------------------------------------------------------- |
|
104 // |
|
105 void CESMRClsItem::SetEmailAddressL( const TDesC& aEmailAddress ) |
|
106 { |
|
107 FUNC_LOG; |
|
108 HBufC* temp = aEmailAddress.AllocL(); |
|
109 delete iEMailAddress; |
|
110 iEMailAddress = temp; |
|
111 } |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // CESMRClsItem::SetContactId |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 void CESMRClsItem::SetContactLinkL( MVPbkContactLink& aLink ) |
|
118 { |
|
119 FUNC_LOG; |
|
120 MVPbkContactLink* copyLink = aLink.CloneLC(); |
|
121 CleanupStack::Pop(); //co |
|
122 delete iLink; |
|
123 iLink = copyLink; |
|
124 } |
|
125 |
|
126 // ----------------------------------------------------------------------------- |
|
127 // CESMRClsItem::SetIsMruItem |
|
128 // ----------------------------------------------------------------------------- |
|
129 // |
|
130 void CESMRClsItem::SetIsMruItem( TBool aIsMruItem ) |
|
131 { |
|
132 FUNC_LOG; |
|
133 iIsMruItem = aIsMruItem; |
|
134 } |
|
135 // ----------------------------------------------------------------------------- |
|
136 // CESMRClsItem::SetMultipleEmails |
|
137 // ----------------------------------------------------------------------------- |
|
138 // |
|
139 void CESMRClsItem::SetMultipleEmails( ) |
|
140 { |
|
141 FUNC_LOG; |
|
142 iMultipleEmails = ETrue; |
|
143 } |
|
144 |
|
145 // ----------------------------------------------------------------------------- |
|
146 // CESMRClsItem::Highlights |
|
147 // ----------------------------------------------------------------------------- |
|
148 // |
|
149 |
|
150 const RArray<TPsMatchLocation>& CESMRClsItem::Highlights() const |
|
151 { |
|
152 return iHighlights; |
|
153 } |
|
154 |
|
155 // ----------------------------------------------------------------------------- |
|
156 // CESMRClsItem::DisplayName |
|
157 // ----------------------------------------------------------------------------- |
|
158 // |
|
159 const TDesC& CESMRClsItem::DisplayName() const |
|
160 { |
|
161 FUNC_LOG; |
|
162 return *iDisplayName; |
|
163 } |
|
164 // ----------------------------------------------------------------------------- |
|
165 // CESMRClsItem::EmailAddress |
|
166 // ----------------------------------------------------------------------------- |
|
167 // |
|
168 const TDesC& CESMRClsItem::EmailAddress() const |
|
169 { |
|
170 FUNC_LOG; |
|
171 return *iEMailAddress; |
|
172 } |
|
173 |
|
174 // ----------------------------------------------------------------------------- |
|
175 // CESMRClsItem::FullText |
|
176 // ----------------------------------------------------------------------------- |
|
177 // |
|
178 const TDesC& CESMRClsItem::FullTextL() |
|
179 { |
|
180 FUNC_LOG; |
|
181 delete iFullText; |
|
182 iFullText = NULL; |
|
183 iFullText = HBufC::NewL( iDisplayName->Length() + |
|
184 KEmptySpace().Length() + |
|
185 iEMailAddress->Length() ); |
|
186 |
|
187 // don't add space if there is no display name |
|
188 if( iDisplayName->CompareC( KNullDesC ) ) |
|
189 { |
|
190 iFullText->Des().Append( *iDisplayName ); |
|
191 iFullText->Des().Append( KEmptySpace ); |
|
192 } |
|
193 iFullText->Des().Append( *iEMailAddress ); |
|
194 return *iFullText; |
|
195 } |
|
196 |
|
197 // ----------------------------------------------------------------------------- |
|
198 // CESMRClsItem::ContactItemId |
|
199 // ----------------------------------------------------------------------------- |
|
200 // |
|
201 MVPbkContactLink* CESMRClsItem::ContactLink() const |
|
202 { |
|
203 FUNC_LOG; |
|
204 return iLink; |
|
205 } |
|
206 |
|
207 // ----------------------------------------------------------------------------- |
|
208 // CESMRClsItem::IsMruItem |
|
209 // ----------------------------------------------------------------------------- |
|
210 // |
|
211 TBool CESMRClsItem::IsMruItem() const |
|
212 { |
|
213 FUNC_LOG; |
|
214 return iIsMruItem; |
|
215 } |
|
216 |
|
217 // ----------------------------------------------------------------------------- |
|
218 // CESMRClsItem::MultipleEmails |
|
219 // ----------------------------------------------------------------------------- |
|
220 // |
|
221 TBool CESMRClsItem::MultipleEmails() const |
|
222 { |
|
223 FUNC_LOG; |
|
224 return iMultipleEmails; |
|
225 } |
|
226 // ----------------------------------------------------------------------------- |
|
227 // CESMRClsItem::CFSEmailUiClsItem |
|
228 // ----------------------------------------------------------------------------- |
|
229 // |
|
230 CESMRClsItem::CESMRClsItem() |
|
231 : iMultipleEmails( EFalse ) |
|
232 { |
|
233 FUNC_LOG; |
|
234 //do nothing |
|
235 } |
|
236 |
|
237 // ----------------------------------------------------------------------------- |
|
238 // CESMRClsItem::ConstructL |
|
239 // ----------------------------------------------------------------------------- |
|
240 // |
|
241 void CESMRClsItem::ConstructL() |
|
242 { |
|
243 FUNC_LOG; |
|
244 iDisplayName = KNullDesC().AllocL(); |
|
245 iEMailAddress = KNullDesC().AllocL(); |
|
246 } |
|
247 |
|
248 // ----------------------------------------------------------------------------- |
|
249 // CompareHighlightElements |
|
250 // ----------------------------------------------------------------------------- |
|
251 // |
|
252 TInt CompareHighlightElements( TPsMatchLocation const& aElement, TPsMatchLocation const& aElement2) |
|
253 { |
|
254 return aElement.index - aElement2.index; |
|
255 } |
|
256 |
|
257 // ----------------------------------------------------------------------------- |
|
258 // CompareHighlightElements |
|
259 // ----------------------------------------------------------------------------- |
|
260 // |
|
261 void CESMRClsItem::SetHighlightsL( const RArray<TPsMatchLocation>& aHighlights ) |
|
262 { |
|
263 FUNC_LOG; |
|
264 iHighlights.Reset(); |
|
265 iHighlights.ReserveL( aHighlights.Count() ); |
|
266 |
|
267 // Convert right->left to left->right, this eases the visualisation |
|
268 for ( TInt i = 0; i < aHighlights.Count(); ++i ) |
|
269 { |
|
270 iHighlights.AppendL( aHighlights[i] ); |
|
271 if ( iHighlights[i].direction == TBidiText::ERightToLeft ) |
|
272 { |
|
273 iHighlights[i].index -= aHighlights[i].length - 1; |
|
274 iHighlights[i].direction = TBidiText::ELeftToRight; |
|
275 } |
|
276 } |
|
277 |
|
278 // Sort match locations according to index, this eases the visualisation |
|
279 TLinearOrder<TPsMatchLocation> highlightSortOrder( &CompareHighlightElements ); |
|
280 iHighlights.Sort(highlightSortOrder); |
|
281 } |
|
282 |
|
283 //EOF |
|
284 |