|
1 /* |
|
2 * Copyright (c) 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: Tree item data derived class able to store plain text. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "emailtrace.h" |
|
21 #include "fstreeplaintwolineitemdata.h" |
|
22 #include <e32cmn.h> |
|
23 // <cmail> SF |
|
24 #include <alf/alftexture.h> |
|
25 // </cmail> |
|
26 |
|
27 // ======== MEMBER FUNCTIONS ======== |
|
28 |
|
29 // --------------------------------------------------------------------------- |
|
30 // Two-phased constructor. |
|
31 // --------------------------------------------------------------------------- |
|
32 // |
|
33 EXPORT_C CFsTreePlainTwoLineItemData* CFsTreePlainTwoLineItemData::NewL( ) |
|
34 { |
|
35 FUNC_LOG; |
|
36 CFsTreePlainTwoLineItemData* self = |
|
37 new( ELeave ) CFsTreePlainTwoLineItemData( ); |
|
38 CleanupStack::PushL(self); |
|
39 self->ConstructL( ); |
|
40 CleanupStack::Pop(self); |
|
41 return self; |
|
42 } |
|
43 |
|
44 // --------------------------------------------------------------------------- |
|
45 // C++ destructor. |
|
46 // --------------------------------------------------------------------------- |
|
47 // |
|
48 CFsTreePlainTwoLineItemData::~CFsTreePlainTwoLineItemData() |
|
49 { |
|
50 FUNC_LOG; |
|
51 delete iSecondaryData; |
|
52 delete iPreviewPaneData; |
|
53 delete iDateTimeData; |
|
54 } |
|
55 |
|
56 // --------------------------------------------------------------------------- |
|
57 // Copies data to the descriptor given as a parameter. |
|
58 // --------------------------------------------------------------------------- |
|
59 // |
|
60 TDesC& CFsTreePlainTwoLineItemData::SecondaryData( ) const |
|
61 { |
|
62 FUNC_LOG; |
|
63 return *iSecondaryData; |
|
64 } |
|
65 |
|
66 // --------------------------------------------------------------------------- |
|
67 // Copies data from the descriptor given as a parameter. |
|
68 // --------------------------------------------------------------------------- |
|
69 // |
|
70 void CFsTreePlainTwoLineItemData::SetSecondaryDataL( const TDesC& aData ) |
|
71 { |
|
72 FUNC_LOG; |
|
73 delete iSecondaryData; |
|
74 iSecondaryData = NULL; |
|
75 |
|
76 TInt eolIndex = aData.Find(_L("\n")); |
|
77 if (eolIndex==KErrNotFound) |
|
78 { |
|
79 iSecondaryData = aData.AllocL(); |
|
80 } |
|
81 else |
|
82 { |
|
83 iSecondaryData = HBufC::NewL(eolIndex+3); |
|
84 *iSecondaryData = aData.Left(eolIndex); |
|
85 TPtr16 desc = iSecondaryData->Des(); |
|
86 desc.Append(_L("...")); |
|
87 } |
|
88 } |
|
89 |
|
90 // --------------------------------------------------------------------------- |
|
91 // Returns length (not size) of the data descriptor. |
|
92 // --------------------------------------------------------------------------- |
|
93 // |
|
94 TUint CFsTreePlainTwoLineItemData::SecondaryDataLength() const |
|
95 { |
|
96 FUNC_LOG; |
|
97 TUint length = 0; |
|
98 if ( iSecondaryData ) |
|
99 { |
|
100 length = iSecondaryData->Length(); |
|
101 } |
|
102 else |
|
103 { |
|
104 length = 0; |
|
105 } |
|
106 return length; |
|
107 } |
|
108 |
|
109 // --------------------------------------------------------------------------- |
|
110 // Sets preview pane text. |
|
111 // --------------------------------------------------------------------------- |
|
112 // |
|
113 void CFsTreePlainTwoLineItemData::SetPreviewPaneDataL( const TDesC& aData ) |
|
114 { |
|
115 FUNC_LOG; |
|
116 delete iPreviewPaneData; |
|
117 iPreviewPaneData = NULL; |
|
118 |
|
119 TInt eolIndex = aData.Find(_L("\n")); |
|
120 if (eolIndex==KErrNotFound) |
|
121 { |
|
122 iPreviewPaneData = aData.AllocL(); |
|
123 } |
|
124 else |
|
125 { |
|
126 iPreviewPaneData = HBufC::NewL(eolIndex+3); |
|
127 *iPreviewPaneData = aData.Left(eolIndex); |
|
128 TPtr16 desc = iPreviewPaneData->Des(); |
|
129 desc.Append(_L("...")); |
|
130 } |
|
131 } |
|
132 |
|
133 // --------------------------------------------------------------------------- |
|
134 // Returns preview pane text. |
|
135 // --------------------------------------------------------------------------- |
|
136 // |
|
137 TDesC& CFsTreePlainTwoLineItemData::PreviewPaneData( ) const |
|
138 { |
|
139 FUNC_LOG; |
|
140 return *iPreviewPaneData; |
|
141 } |
|
142 |
|
143 // --------------------------------------------------------------------------- |
|
144 // Returns length (not size) of the preview pane data descriptor. |
|
145 // --------------------------------------------------------------------------- |
|
146 // |
|
147 TUint CFsTreePlainTwoLineItemData::PreviewPaneDataLength() const |
|
148 { |
|
149 FUNC_LOG; |
|
150 TUint length = 0; |
|
151 if ( iPreviewPaneData ) |
|
152 { |
|
153 length = iPreviewPaneData->Length(); |
|
154 } |
|
155 else |
|
156 { |
|
157 length = 0; |
|
158 } |
|
159 return length; |
|
160 } |
|
161 |
|
162 // --------------------------------------------------------------------------- |
|
163 // Sets texture for a flag icon. |
|
164 // --------------------------------------------------------------------------- |
|
165 // |
|
166 void CFsTreePlainTwoLineItemData::SetFlagIcon ( CAlfTexture& aIcon ) |
|
167 { |
|
168 FUNC_LOG; |
|
169 iFlagIcon = &aIcon; |
|
170 } |
|
171 |
|
172 // --------------------------------------------------------------------------- |
|
173 // Returns flag icon texture. |
|
174 // --------------------------------------------------------------------------- |
|
175 // |
|
176 const CAlfTexture& CFsTreePlainTwoLineItemData::FlagIcon ( ) const |
|
177 { |
|
178 FUNC_LOG; |
|
179 return *iFlagIcon; |
|
180 } |
|
181 |
|
182 // --------------------------------------------------------------------------- |
|
183 // Returns information wether icon for a flag is set. |
|
184 // --------------------------------------------------------------------------- |
|
185 // |
|
186 TBool CFsTreePlainTwoLineItemData::IsFlagIconSet ( ) const |
|
187 { |
|
188 FUNC_LOG; |
|
189 TBool retVal = EFalse; |
|
190 if ( iFlagIcon ) |
|
191 { |
|
192 retVal = ETrue; |
|
193 } |
|
194 else |
|
195 { |
|
196 retVal = EFalse; |
|
197 } |
|
198 return retVal; |
|
199 } |
|
200 |
|
201 // --------------------------------------------------------------------------- |
|
202 // Functions sets text for a time and date visual. |
|
203 // --------------------------------------------------------------------------- |
|
204 // |
|
205 void CFsTreePlainTwoLineItemData::SetDateTimeDataL ( const TDesC& aData ) |
|
206 { |
|
207 FUNC_LOG; |
|
208 delete iDateTimeData; |
|
209 iDateTimeData = NULL; |
|
210 |
|
211 TInt eolIndex = aData.Find(_L("\n")); |
|
212 if (eolIndex==KErrNotFound) |
|
213 { |
|
214 iDateTimeData = aData.AllocL(); |
|
215 } |
|
216 else |
|
217 { |
|
218 iDateTimeData = HBufC::NewL(eolIndex+3); |
|
219 *iDateTimeData = aData.Left(eolIndex); |
|
220 TPtr16 desc = iDateTimeData->Des(); |
|
221 desc.Append(_L("...")); |
|
222 } |
|
223 } |
|
224 |
|
225 // --------------------------------------------------------------------------- |
|
226 // Returns date and time text. |
|
227 // --------------------------------------------------------------------------- |
|
228 // |
|
229 TDesC& CFsTreePlainTwoLineItemData::DateTimeData ( ) const |
|
230 { |
|
231 FUNC_LOG; |
|
232 return *iDateTimeData; |
|
233 } |
|
234 |
|
235 // --------------------------------------------------------------------------- |
|
236 // Returns length of the date and time text. |
|
237 // --------------------------------------------------------------------------- |
|
238 // |
|
239 TUint CFsTreePlainTwoLineItemData::DateTimeDataLength ( ) const |
|
240 { |
|
241 FUNC_LOG; |
|
242 TUint length = 0; |
|
243 if ( iDateTimeData ) |
|
244 { |
|
245 length = iDateTimeData->Length(); |
|
246 } |
|
247 else |
|
248 { |
|
249 length = 0; |
|
250 } |
|
251 return length; |
|
252 } |
|
253 |
|
254 // --------------------------------------------------------------------------- |
|
255 // Sets texture for a priority icon. |
|
256 // --------------------------------------------------------------------------- |
|
257 // |
|
258 void CFsTreePlainTwoLineItemData::SetPriorityIcon ( CAlfTexture& aIcon ) |
|
259 { |
|
260 FUNC_LOG; |
|
261 iPriorityIcon = &aIcon; |
|
262 } |
|
263 |
|
264 // --------------------------------------------------------------------------- |
|
265 // Returns priority texture. |
|
266 // --------------------------------------------------------------------------- |
|
267 // |
|
268 const CAlfTexture& CFsTreePlainTwoLineItemData::PriorityIcon ( ) const |
|
269 { |
|
270 FUNC_LOG; |
|
271 return *iPriorityIcon; |
|
272 } |
|
273 |
|
274 // --------------------------------------------------------------------------- |
|
275 // Returns information wether texture for a priority icon is set. |
|
276 // --------------------------------------------------------------------------- |
|
277 // |
|
278 TBool CFsTreePlainTwoLineItemData::IsPriorityIconSet ( ) const |
|
279 { |
|
280 FUNC_LOG; |
|
281 TBool retVal = EFalse; |
|
282 if ( iPriorityIcon ) |
|
283 { |
|
284 retVal = ETrue; |
|
285 } |
|
286 else |
|
287 { |
|
288 retVal = EFalse; |
|
289 } |
|
290 return retVal; |
|
291 } |
|
292 |
|
293 |
|
294 // from base class MFsTreeItemData |
|
295 |
|
296 // --------------------------------------------------------------------------- |
|
297 // Type of the data item. |
|
298 // From base class MFsTreeItemData |
|
299 // --------------------------------------------------------------------------- |
|
300 // |
|
301 TFsTreeItemDataType CFsTreePlainTwoLineItemData::Type() const |
|
302 { |
|
303 FUNC_LOG; |
|
304 return KFsTreePlainTwoLineItemDataType; |
|
305 } |
|
306 |
|
307 // --------------------------------------------------------------------------- |
|
308 // C++ constructor. |
|
309 // --------------------------------------------------------------------------- |
|
310 // |
|
311 CFsTreePlainTwoLineItemData::CFsTreePlainTwoLineItemData( ) |
|
312 : iFlagIcon ( NULL ), |
|
313 iPriorityIcon ( NULL ) |
|
314 { |
|
315 FUNC_LOG; |
|
316 |
|
317 } |
|
318 |
|
319 // --------------------------------------------------------------------------- |
|
320 // Second phase constructor. |
|
321 // --------------------------------------------------------------------------- |
|
322 // |
|
323 void CFsTreePlainTwoLineItemData::ConstructL( ) |
|
324 { |
|
325 FUNC_LOG; |
|
326 SetSecondaryDataL( KNullDesC ); |
|
327 SetPreviewPaneDataL( KNullDesC ); |
|
328 SetDateTimeDataL( KNullDesC ); |
|
329 } |
|
330 |