|
1 /* |
|
2 * Copyright (c) 2002 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 class for Calendar Day view |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <calencommands.hrh> // Calendar commands |
|
19 #include <AknBidiTextUtils.h> |
|
20 #include <AknUtils.h> |
|
21 #include <eikenv.h> |
|
22 #include <PUAcodes.hrh> |
|
23 #include <StringLoader.h> |
|
24 #include <txtrich.h> |
|
25 #include <calentry.h> |
|
26 #include <calinstance.h> |
|
27 #include <calrrule.h> |
|
28 #include <calalarm.h> |
|
29 #include <centralrepository.h> |
|
30 #include <Calendar.rsg> |
|
31 #include <calsession.h> |
|
32 #include <caleninstanceid.h> // TCalenInstanceId |
|
33 #include <calenviewutils.h> |
|
34 #include <calenagendautils.h> |
|
35 #include "CalendarVariant.hrh" |
|
36 #ifdef RD_CALEN_MIDNIGHT_VISUALIZATION |
|
37 #include <calendateutils.h> |
|
38 #endif // RD_CALEN_MIDNIGHT_VISUALIZATION |
|
39 #include <calcalendarinfo.h> |
|
40 #include <calenservices.h> |
|
41 |
|
42 //debug |
|
43 #include "calendarui_debug.h" |
|
44 #include "calendaylistboxmodel.h" |
|
45 #include "calencontroller.h" |
|
46 #include "CalendarVariant.hrh" |
|
47 #include "calendaylistbox.h" |
|
48 #include "calentodoview.h" // for priorities |
|
49 #include "calendar.hrh" |
|
50 #include "CalendarPrivateCRKeys.h" |
|
51 #include "calenglobaldata.h" |
|
52 |
|
53 // LOCAL CONSTANTS AND MACROS |
|
54 _LIT(KDesTimeSpace, " "); |
|
55 _LIT(KDesSeparator, "\t"); |
|
56 _LIT(KIconSeperatorFormat, "%d\t"); // Day LB icon seperator format |
|
57 |
|
58 #ifdef RD_CALEN_MIDNIGHT_VISUALIZATION |
|
59 _LIT(KUnicodeRightwardsArrow, "\x2192"); // -> |
|
60 _LIT(KUnicodeLeftwardsArrow, "\x2190"); // <- |
|
61 _LIT(K24hFmt12am, " 00"); // already starts at hr 00 |
|
62 _LIT(K24hFmt12pm, "24 "); |
|
63 #endif // RD_CALEN_MIDNIGHT_VISUALIZATION |
|
64 |
|
65 |
|
66 const TInt KTimedNoteMaxLines(4); |
|
67 const TInt KHypenBufSize(4); |
|
68 const TInt KNonTimedNoteMaxLines(1); |
|
69 |
|
70 // KMaxColumnDataLength is Avkon defined minimal maximum length for column texts. |
|
71 const TInt KMaxLengthOfDisplayedText(KTimedNoteMaxLines * KMaxColumnDataLength); |
|
72 |
|
73 // =========================== MEMBER FUNCTIONS =============================== |
|
74 |
|
75 // ---------------------------------------------------------------------------- |
|
76 // CCalenDayListBoxModel::CCalenDayListBoxModel |
|
77 // C++ default constructor can NOT contain any code, that |
|
78 // might leave. |
|
79 // ---------------------------------------------------------------------------- |
|
80 // |
|
81 CCalenDayListBoxModel::CCalenDayListBoxModel() |
|
82 { |
|
83 TRACE_ENTRY_POINT; |
|
84 TRACE_EXIT_POINT; |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CCalenDayListBoxModel::ConstructL |
|
89 // Symbian 2nd phase constructor can leave. |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 void CCalenDayListBoxModel::ConstructL( const CCalenDayContainer* aDayContainer ) |
|
93 { |
|
94 TRACE_ENTRY_POINT; |
|
95 |
|
96 iDayContainer = aDayContainer; |
|
97 iItemTextArray = new(ELeave) CDesCArrayFlat(5); |
|
98 |
|
99 // Read time formats |
|
100 iTimeFormat = StringLoader::LoadL( R_QTN_TIME_USUAL_WITH_ZERO ); |
|
101 |
|
102 TRACE_EXIT_POINT; |
|
103 } |
|
104 |
|
105 void CCalenDayListBoxModel::UpdateLayoutValues( TInt aLayoutVariant, |
|
106 TBool aMidnightVisualization) |
|
107 { |
|
108 TRACE_ENTRY_POINT; |
|
109 |
|
110 CCalenDayListBox::ReadLayout( |
|
111 aLayoutVariant, |
|
112 iLocale, |
|
113 iLaf.iGfxA, |
|
114 iLaf.iTextA, |
|
115 iLaf.iTextB, |
|
116 iLaf.iTextC, |
|
117 iLaf.iIconA, |
|
118 iLaf.iIconB, |
|
119 aMidnightVisualization ); |
|
120 |
|
121 TRACE_EXIT_POINT; |
|
122 } |
|
123 |
|
124 // Destructor |
|
125 CCalenDayListBoxModel::~CCalenDayListBoxModel() |
|
126 { |
|
127 TRACE_ENTRY_POINT; |
|
128 |
|
129 delete iTimeFormat; |
|
130 delete iItemTextArray; |
|
131 |
|
132 TRACE_EXIT_POINT; |
|
133 } |
|
134 |
|
135 // ----------------------------------------------------------------------------- |
|
136 // CCalenDayListBoxModel::NewL |
|
137 // Two-phased constructor. |
|
138 // ----------------------------------------------------------------------------- |
|
139 // |
|
140 CCalenDayListBoxModel* CCalenDayListBoxModel::NewL( const CCalenDayContainer* aDayContainer ) |
|
141 { |
|
142 TRACE_ENTRY_POINT; |
|
143 |
|
144 CCalenDayListBoxModel* self = |
|
145 new( ELeave ) CCalenDayListBoxModel(); |
|
146 |
|
147 CleanupStack::PushL( self ); |
|
148 self->ConstructL( aDayContainer ); |
|
149 CleanupStack::Pop( self ); |
|
150 |
|
151 TRACE_EXIT_POINT; |
|
152 return self; |
|
153 } |
|
154 |
|
155 // ---------------------------------------------------------------------------- |
|
156 // CCalenDayListBoxModel::?member_function |
|
157 // ?implementation_description |
|
158 // (other items were commented in a header). |
|
159 // ---------------------------------------------------------------------------- |
|
160 // |
|
161 CDesCArrayFlat* CCalenDayListBoxModel::ItemTextArray() |
|
162 { |
|
163 TRACE_ENTRY_POINT; |
|
164 |
|
165 TRACE_EXIT_POINT; |
|
166 return iItemTextArray; |
|
167 } |
|
168 |
|
169 // ---------------------------------------------------------------------------- |
|
170 // CCalenDayListBoxModel::?member_function |
|
171 // ?implementation_description |
|
172 // (other items were commented in a header). |
|
173 // ---------------------------------------------------------------------------- |
|
174 // |
|
175 void CCalenDayListBoxModel::GetEntryTextDataL(CCalEntry& aEntry, |
|
176 TDes& aBuf) const |
|
177 { |
|
178 TRACE_ENTRY_POINT; |
|
179 |
|
180 const TInt maxLen( aBuf.MaxLength() - KTimedNoteMaxLines * KAknBidiExtraSpacePerLine ); |
|
181 CalenViewUtils::GetSummaryLocationTextL( aEntry, aBuf, maxLen ); |
|
182 |
|
183 TRACE_EXIT_POINT; |
|
184 } |
|
185 |
|
186 #ifndef RD_CALEN_MIDNIGHT_VISUALIZATION |
|
187 // ---------------------------------------------------------------------------- |
|
188 // CCalenDayListBoxModel::?member_function |
|
189 // ?implementation_description |
|
190 // (other items were commented in a header). |
|
191 // ---------------------------------------------------------------------------- |
|
192 // |
|
193 void CCalenDayListBoxModel::LimitStartAndEndTime(TTime& aCurrentDay, |
|
194 TTime& aStart, |
|
195 TTime& aEnd) |
|
196 { |
|
197 TRACE_ENTRY_POINT; |
|
198 |
|
199 TTimeIntervalDays days(aCurrentDay.DaysFrom(TTime(TInt64(0)))); |
|
200 TTimeIntervalDays startDays(aStart.DaysFrom(TTime(TInt64(0)))); |
|
201 TTimeIntervalDays endDays(aEnd.DaysFrom(TTime(TInt64(0)))); |
|
202 |
|
203 // set start time to 00:00, if event starts before current day |
|
204 if (startDays != days) |
|
205 { |
|
206 aStart = TTime(TInt64(0)) + startDays; |
|
207 } |
|
208 |
|
209 // Set end time to 23:59, if event continues to next day |
|
210 if (endDays != days) |
|
211 { |
|
212 TDateTime endDate = aEnd.DateTime(); |
|
213 endDate.SetHour(ECalenMaxHour); |
|
214 endDate.SetMinute(ECalenMaxMinute); |
|
215 aEnd = endDate; |
|
216 } |
|
217 |
|
218 TRACE_EXIT_POINT; |
|
219 } |
|
220 |
|
221 // ---------------------------------------------------------------------------- |
|
222 // CCalenDayListBoxModel::?member_function |
|
223 // ?implementation_description |
|
224 // (other items were commented in a header). |
|
225 // ---------------------------------------------------------------------------- |
|
226 // |
|
227 void CCalenDayListBoxModel::InsertTimeL(TDes& aBuf, |
|
228 const TTime& aTime) |
|
229 { |
|
230 TRACE_ENTRY_POINT; |
|
231 |
|
232 TBuf<32> timeDes; |
|
233 aTime.FormatL( timeDes, *iTimeFormat ); |
|
234 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( timeDes ); |
|
235 AknBidiTextUtils::ConvertToVisualAndClipL( timeDes, |
|
236 *iLaf.iTextA.Font(), |
|
237 iLaf.iTextA.TextRect().Width(), |
|
238 iLaf.iTextA.TextRect().Width() ); |
|
239 aBuf.Append(timeDes); |
|
240 |
|
241 TRACE_EXIT_POINT; |
|
242 } |
|
243 |
|
244 #else // Midnight is ON |
|
245 |
|
246 void CCalenDayListBoxModel::InsertTimeL(TDes& aBuf, const TTime& aTime, const TTimeStringFormat aInsert) |
|
247 { |
|
248 TRACE_ENTRY_POINT; |
|
249 |
|
250 TBuf<32> timeDes; |
|
251 switch(aInsert) |
|
252 { |
|
253 case EInsertTimeGiven: |
|
254 aTime.FormatL( timeDes, *iTimeFormat ); |
|
255 break; |
|
256 |
|
257 case EInsert00: |
|
258 timeDes = K24hFmt12am(); |
|
259 break; |
|
260 |
|
261 case EInsert24: |
|
262 timeDes = K24hFmt12pm(); |
|
263 break; |
|
264 |
|
265 default: |
|
266 ASSERT(KErrArgument); |
|
267 } |
|
268 |
|
269 |
|
270 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( timeDes ); |
|
271 AknBidiTextUtils::ConvertToVisualAndClipL( timeDes, |
|
272 *iLaf.iTextA.Font(), |
|
273 iLaf.iTextA.TextRect().Width(), |
|
274 iLaf.iTextA.TextRect().Width() ); |
|
275 aBuf.Append(timeDes); |
|
276 |
|
277 TRACE_EXIT_POINT; |
|
278 } |
|
279 |
|
280 |
|
281 #endif // RD_CALEN_MIDNIGHT_VISUALIZATION |
|
282 |
|
283 |
|
284 // ---------------------------------------------------------------------------- |
|
285 // CCalenDayListBoxModel::?member_function |
|
286 // ?implementation_description |
|
287 // (other items were commented in a header). |
|
288 // ---------------------------------------------------------------------------- |
|
289 // |
|
290 #ifdef RD_CALEN_MIDNIGHT_VISUALIZATION |
|
291 void CCalenDayListBoxModel::InsertHyphenL(TDes& aBuf, |
|
292 const TTime& aStart, |
|
293 const TTime& aEnd) |
|
294 |
|
295 #else // keep the old definition |
|
296 void CCalenDayListBoxModel::InsertHyphen(TDes& aBuf, |
|
297 const TTime& aStart, |
|
298 const TTime& aEnd) |
|
299 #endif //RD_CALEN_MIDNIGHT_VISUALIZATION |
|
300 { |
|
301 TRACE_ENTRY_POINT; |
|
302 |
|
303 if (aStart != aEnd) |
|
304 { |
|
305 |
|
306 TBuf<KHypenBufSize> hyphen; |
|
307 hyphen.Append(TChar(KPuaCodeNarrowDash)); |
|
308 |
|
309 #ifdef RD_CALEN_MIDNIGHT_VISUALIZATION |
|
310 |
|
311 AknBidiTextUtils::ConvertToVisualAndClipL( hyphen, |
|
312 *iLaf.iTextB.Font(), |
|
313 iLaf.iTextB.TextRect().Width(), |
|
314 iLaf.iTextB.TextRect().Width() ); |
|
315 aBuf.Append(hyphen); |
|
316 #else |
|
317 aBuf.Append(hyphen); |
|
318 #endif // RD_CALEN_MIDNIGHT_VISUALIZATION |
|
319 } |
|
320 |
|
321 TRACE_EXIT_POINT; |
|
322 } |
|
323 |
|
324 // --------------------------------------------------------- |
|
325 // CCalenDayListBoxModel::LastLineWidth |
|
326 // Calculates a last line width |
|
327 // (other items were commented in a header). |
|
328 // --------------------------------------------------------- |
|
329 // |
|
330 TInt CCalenDayListBoxModel::LastLineWidthL(TInt aWidth, CCalEntry& aEntry) const |
|
331 { |
|
332 TRACE_ENTRY_POINT; |
|
333 |
|
334 CCalAlarm* alarmObj = aEntry.AlarmL(); |
|
335 TBool alarm( alarmObj ? ETrue : EFalse ); |
|
336 delete alarmObj; |
|
337 |
|
338 TCalRRule ignore; |
|
339 TBool repeat(CalenAgendaUtils::IsRepeatingL(aEntry)); |
|
340 |
|
341 TBool priority( EFalse ); |
|
342 |
|
343 if( aEntry.EntryTypeL() == CCalEntry::ETodo && |
|
344 aEntry.PriorityL() != ETodoPriorityNormal ) |
|
345 { |
|
346 priority = ETrue; |
|
347 } |
|
348 |
|
349 // Check if this entry has any geovalues for the location field |
|
350 CCalGeoValue* geovalue = aEntry.GeoValueL(); |
|
351 TBool mapIcon( geovalue ? ETrue : EFalse); |
|
352 delete geovalue; |
|
353 |
|
354 TInt width( aWidth ); |
|
355 |
|
356 // FIXME, actually these should be read from LAF! |
|
357 |
|
358 if( alarm && repeat || alarm && priority || repeat && priority || mapIcon && alarm || mapIcon && repeat || mapIcon && priority) |
|
359 { |
|
360 width = aWidth -( iLaf.iIconB.Rect().Width() + iLaf.iIconA.Rect().Width() ); |
|
361 } |
|
362 else if( alarm || repeat || priority || mapIcon) |
|
363 { |
|
364 width = aWidth - iLaf.iIconA.Rect().Width(); |
|
365 } |
|
366 width = width - KAknBidiExtraSpacePerLine; |
|
367 |
|
368 TRACE_EXIT_POINT; |
|
369 return width; |
|
370 } |
|
371 |
|
372 // --------------------------------------------------------- |
|
373 // CCalenDayListBoxModel::WrapTextL |
|
374 // (other items were commented in a header). |
|
375 // --------------------------------------------------------- |
|
376 // |
|
377 HBufC* CCalenDayListBoxModel::WrapTextL( |
|
378 CCalEntry& aEntry, |
|
379 CArrayFixFlat<TPtrC>& aLineArray) const |
|
380 { |
|
381 TRACE_ENTRY_POINT; |
|
382 |
|
383 // This is rather complicated algorithm to calculate how many |
|
384 // lines given text takes. |
|
385 // |
|
386 // (Note: in below description of problem and solution we for simplicity |
|
387 // consider only meeting entries with maximum of 4 lines of text, but |
|
388 // code handles Todos, Day Events and Anniversaries with max 1 line |
|
389 // of text. It should be easy to adapt it to have different maximum number |
|
390 // of lines.) |
|
391 // |
|
392 // As UI spec says, textual representation of entry |
|
393 // (subject + location) takes as many lines as it needs. |
|
394 // If it doesn't fit to maximum number of lines (4), it is |
|
395 // truncated. |
|
396 // |
|
397 // Problem is that last line of entry might contain less space for |
|
398 // text than previous lines, as it can contain icons for alarm, repeat |
|
399 // and priority. Because Avkon APIs for text wrapping and truncating |
|
400 // cannot handle situation, in which line count is not defined AND |
|
401 // last line length varies, we have to programmatically try |
|
402 // to wrap and fit text first to 1 line, then to 2 lines, then to |
|
403 // 3 lines and finally truncate it to 4 lines. |
|
404 |
|
405 TBool isTimed = |
|
406 aEntry.EntryTypeL() == CCalEntry::EAppt || |
|
407 aEntry.EntryTypeL() == CCalEntry::EReminder; |
|
408 const TInt KMaxLines = |
|
409 isTimed ? KTimedNoteMaxLines : KNonTimedNoteMaxLines; |
|
410 |
|
411 const TInt KLineWidth = iLaf.iTextC.TextRect().Width(); |
|
412 |
|
413 CArrayFixFlat<TInt>* lineWidths = new( ELeave )CArrayFixFlat<TInt>( 5 ); |
|
414 CleanupStack::PushL( lineWidths ); |
|
415 |
|
416 // last line width is always dependent on icons and is thus calculated. |
|
417 // We insert last line width to line widths buffer here, and try to fit |
|
418 // text to this single line. After that we always add line with normal |
|
419 // width BEFORE this last line. |
|
420 // I.e. |
|
421 // 1st try: { LastLineWidth } |
|
422 // 2nd try: { NormalLineWidth, LastLineWidth } |
|
423 // 3rd try: { NormalLineWidth, NormalLineWidth, LastLineWidth } |
|
424 // ... |
|
425 lineWidths->AppendL( LastLineWidthL( KLineWidth, aEntry ) ); |
|
426 |
|
427 // Get entry text |
|
428 HBufC* text = HBufC::NewLC( KMaxLengthOfDisplayedText ); |
|
429 TPtr textPtr = text->Des(); |
|
430 GetEntryTextDataL( aEntry, textPtr ); |
|
431 |
|
432 // First we try to fit text to [1, max_lines - 1] (i.e. 1,2 or 3 lines) |
|
433 TBool doesFit = EFalse; |
|
434 HBufC* visualText = NULL; |
|
435 while ( ! doesFit && lineWidths->Count() < KMaxLines ) |
|
436 { |
|
437 // Convert*WholeTextL wraps all text, so that if it doesn't |
|
438 // fit to given lines, it uses last line width to wrap remaining |
|
439 // texts. This is useful, because we then know did it fit or not. |
|
440 // |
|
441 // Note that it constructs new text buffer (visualText) that |
|
442 // has to be destroyed, if it's not used. If it's used, this |
|
443 // text has to be returned to caller and caller takes care of |
|
444 // destroying. This memory management is unfortunately complicated, |
|
445 // so be careful if you modify. |
|
446 visualText = |
|
447 AknBidiTextUtils::ConvertToVisualAndWrapToArrayWholeTextL( |
|
448 *text, |
|
449 *lineWidths, |
|
450 *iLaf.iTextC.Font(), |
|
451 aLineArray); |
|
452 CleanupStack::PushL( visualText ); |
|
453 |
|
454 // If amount of splitted lines is same (or less than) currently |
|
455 // tried lines, we can fit text to this amount of lines. |
|
456 TInt triedLines = lineWidths->Count(); |
|
457 if ( aLineArray.Count() <= triedLines ) |
|
458 { |
|
459 doesFit = ETrue; |
|
460 // In case Avkon method wraps text to less lines than we tried |
|
461 // it means that text fits to less lines, but icons has to |
|
462 // be put to empty line after text! |
|
463 // We have to manually add that empty line. |
|
464 if ( aLineArray.Count() < triedLines ) |
|
465 { |
|
466 aLineArray.AppendL( TPtrC(KNullDesC) ); |
|
467 } |
|
468 break; // exit from loop, we could fit text. |
|
469 } |
|
470 else |
|
471 { |
|
472 // Release visualText buffer and reset line array, because |
|
473 // we couldn't fit text on this try. |
|
474 CleanupStack::PopAndDestroy( visualText ); |
|
475 visualText = NULL; |
|
476 aLineArray.Reset(); |
|
477 |
|
478 // Prepend normal line width, and try again with more lines. |
|
479 // (Note: last line width stays last, because we prepend) |
|
480 lineWidths->InsertL( 0, KLineWidth ); |
|
481 } |
|
482 } |
|
483 |
|
484 HBufC* result = NULL; |
|
485 if ( doesFit ) |
|
486 { |
|
487 // If we could fit, we return visualText and caller has |
|
488 // to memory manage it. TPtrs in aLineArray points to this text |
|
489 // buffer. |
|
490 result = visualText; |
|
491 CleanupStack::Pop( visualText ); |
|
492 CleanupStack::PopAndDestroy( text ); |
|
493 } |
|
494 else |
|
495 { |
|
496 // If we couldn't fit before, we wrap text to max lines and truncate |
|
497 // it with ellipsis. |
|
498 TInt triedLines = lineWidths->Count(); |
|
499 |
|
500 // truncate and add ellipsis |
|
501 TPtr truncatedText = text->Des(); |
|
502 const TBool KUseEllipsis = ETrue; |
|
503 AknBidiTextUtils::ConvertToVisualAndWrapToArrayL( |
|
504 truncatedText, |
|
505 *lineWidths, |
|
506 *iLaf.iTextC.Font(), |
|
507 aLineArray, |
|
508 KUseEllipsis ); |
|
509 |
|
510 // In case Avkon method wrapped text to less lines than we tried |
|
511 // it means that text fits to less lines, but icons has to |
|
512 // be put to empty line after text! |
|
513 // We have to manually add that empty line. |
|
514 if ( aLineArray.Count() < triedLines ) |
|
515 { |
|
516 aLineArray.AppendL( TPtrC(KNullDesC) ); |
|
517 } |
|
518 |
|
519 // We return original text, because |
|
520 // AknBidiTextUtils::ConvertToVisualAndWrapToArrayL |
|
521 // modifies that and TPtrs in aLineArray points to that buffer |
|
522 result = text; |
|
523 CleanupStack::Pop( text ); |
|
524 } |
|
525 |
|
526 CleanupStack::PopAndDestroy( lineWidths ); |
|
527 |
|
528 TRACE_EXIT_POINT; |
|
529 return result; |
|
530 }; |
|
531 |
|
532 // ---------------------------------------------------------------------------- |
|
533 // CCalenDayListBoxModel::?member_function |
|
534 // ?implementation_description |
|
535 // (other items were commented in a header). |
|
536 // ---------------------------------------------------------------------------- |
|
537 // |
|
538 void CCalenDayListBoxModel::CreateListBoxDataL( |
|
539 CArrayFixFlat<CCalenDayContainer::SItemInfo>& aLayoutTable, |
|
540 CArrayFixFlat<TInt>& aCellArray, |
|
541 MCalenServices& aServices, |
|
542 /*CCalInstanceView* aInstanceView*/ |
|
543 TTime aCurrentDay) |
|
544 { |
|
545 TRACE_ENTRY_POINT; |
|
546 |
|
547 iItemTextArray->Reset(); |
|
548 TBool isAllDayEvent; |
|
549 RPointerArray<CCalCalendarInfo> calendarInfoList; |
|
550 aServices.GetAllCalendarInfoL(calendarInfoList); |
|
551 CleanupClosePushL(calendarInfoList); |
|
552 |
|
553 HBufC* listItemData = HBufC::NewLC(ECalenCharsInLine); |
|
554 |
|
555 // iterate layout |
|
556 for (TInt loop(0); loop < aLayoutTable.Count(); ++loop) |
|
557 { |
|
558 CCalenDayContainer::SItemInfo& itemInfo = aLayoutTable[loop]; |
|
559 |
|
560 CCalEntry& entry = itemInfo.iTmpInstance->Entry(); |
|
561 isAllDayEvent = EFalse; |
|
562 if (entry.EntryTypeL() == CCalEntry::EAppt || entry.EntryTypeL() |
|
563 == CCalEntry::EEvent) |
|
564 { |
|
565 isAllDayEvent = CalenViewUtils::IsAlldayEventL( |
|
566 *itemInfo.iTmpInstance); |
|
567 } |
|
568 TCalCollectionId collectionId = |
|
569 itemInfo.iTmpInstance->InstanceIdL().iCollectionId; |
|
570 HBufC* calendarFileName = aServices.GetCalFileNameForCollectionId(collectionId).AllocLC(); |
|
571 TInt index = calendarInfoList.Find( *calendarFileName, |
|
572 CCalenDayListBoxModel::CalendarInfoIdentifierL ); |
|
573 |
|
574 CleanupStack::PopAndDestroy(calendarFileName); |
|
575 |
|
576 if (index != KErrNotFound && calendarInfoList[index]->Enabled()) |
|
577 { |
|
578 itemInfo.iColor = calendarInfoList[index]->Color().Value(); |
|
579 TPtr ptr = listItemData->Des(); |
|
580 ptr.Zero(); |
|
581 |
|
582 TTime start(TInt64(0)); |
|
583 TTime end(TInt64(0)); |
|
584 |
|
585 if ((entry.EntryTypeL() == CCalEntry::EAppt || entry.EntryTypeL() |
|
586 == CCalEntry::EReminder) && (!isAllDayEvent)) |
|
587 { |
|
588 // meeting notes |
|
589 // \t14:00\t-\t |
|
590 // 0 1 2 |
|
591 // |
|
592 // no icon |
|
593 ptr.Append(KDesSeparator); |
|
594 |
|
595 TTimeIntervalMinutes duration; |
|
596 entry.EndTimeL().TimeLocalL().MinutesFrom( |
|
597 entry.StartTimeL().TimeLocalL(), duration); |
|
598 start = itemInfo.iTmpInstance->Time().TimeLocalL(); |
|
599 end = start + duration; |
|
600 #ifdef RD_CALEN_MIDNIGHT_VISUALIZATION |
|
601 InsertStartTimeL(ptr, start, aCurrentDay); |
|
602 #else |
|
603 LimitStartAndEndTime( aCurrentDay, start, end ); |
|
604 |
|
605 InsertTimeL(ptr, start); |
|
606 #endif // RD_CALEN_MIDNIGHT_VISUALIZATION |
|
607 if (!AknLayoutUtils::LayoutMirrored()) |
|
608 { |
|
609 ptr.Append(KDesSeparator); |
|
610 } |
|
611 |
|
612 #ifdef RD_CALEN_MIDNIGHT_VISUALIZATION |
|
613 InsertHyphenL(ptr, start, end); |
|
614 #else |
|
615 InsertHyphen(ptr, start, end); |
|
616 #endif // RD_CALEN_MIDNIGHT_VISUALIZATION |
|
617 if (AknLayoutUtils::LayoutMirrored()) |
|
618 { |
|
619 ptr.Append(KDesSeparator); |
|
620 } |
|
621 |
|
622 ptr.Append(KDesSeparator); |
|
623 } |
|
624 else |
|
625 // Set icons and times for entry |
|
626 { |
|
627 // non-timed notes |
|
628 TBuf<3> icon; |
|
629 icon.Num( |
|
630 static_cast<TInt64> (iDayContainer->IconIndexFromEntryL( |
|
631 entry, isAllDayEvent))); |
|
632 // icon\t\t\t |
|
633 // 0 1 2 |
|
634 // gfxA textA textB |
|
635 ptr.Append(icon); |
|
636 ptr.Append(KDesSeparator); |
|
637 ptr.Append(KDesSeparator); |
|
638 ptr.Append(KDesSeparator); |
|
639 } |
|
640 |
|
641 // textLines contain |
|
642 CArrayFixFlat<TPtrC>* textLines = new (ELeave) CArrayFixFlat< |
|
643 TPtrC> (5); |
|
644 CleanupStack::PushL(textLines); |
|
645 |
|
646 // After WrapTextL call, visualText contains wrapped text in |
|
647 // memory buffer, textLines contain text pointers |
|
648 // (into visualText memory buffer) of beginning of each line of text. |
|
649 HBufC* visualText = WrapTextL(entry, *textLines); |
|
650 CleanupStack::PushL(visualText); |
|
651 |
|
652 // Put first line of text to current list line |
|
653 if (textLines->Count()) |
|
654 { |
|
655 ptr.Append(textLines->At(0)); |
|
656 } |
|
657 |
|
658 TBool isEndDisplayed = ETrue; |
|
659 // For subsequent text lines, we create separate list lines. |
|
660 if ((end != start) && (!isAllDayEvent)) |
|
661 { |
|
662 isEndDisplayed = EFalse; |
|
663 } |
|
664 for (TInt i(1); i < textLines->Count() || !isEndDisplayed; i++) |
|
665 { |
|
666 if (itemInfo.iTopLine == KIndexError) |
|
667 { |
|
668 itemInfo.iTopLine = iItemTextArray->Count(); |
|
669 } |
|
670 iItemTextArray->AppendL(*listItemData); |
|
671 ptr.Zero(); |
|
672 ptr.Append(KDesSeparator); |
|
673 // Sets an end time in second line |
|
674 if (!isEndDisplayed) |
|
675 { |
|
676 __ASSERT_ALWAYS( i == 1, User::Invariant() ); |
|
677 |
|
678 #ifdef RD_CALEN_MIDNIGHT_VISUALIZATION |
|
679 InsertEndTimeL(ptr, end, aCurrentDay); |
|
680 #else |
|
681 InsertTimeL(ptr, end); |
|
682 #endif // RD_CALEN_MIDNIGHT_VISUALIZATION |
|
683 isEndDisplayed = ETrue; |
|
684 } |
|
685 else |
|
686 { |
|
687 ptr.Append(KDesTimeSpace); |
|
688 } |
|
689 ptr.Append(KDesSeparator); |
|
690 ptr.Append(KDesSeparator); |
|
691 if (i < textLines->Count()) |
|
692 { |
|
693 ptr.Append(textLines->At(i)); |
|
694 } |
|
695 } |
|
696 |
|
697 // end of last line (also for non-timed notes) |
|
698 ptr.Append(KDesSeparator); |
|
699 |
|
700 CleanupStack::PopAndDestroy(visualText); |
|
701 CleanupStack::PopAndDestroy(textLines); |
|
702 |
|
703 // Alarm, repeat and priority icons |
|
704 iDayContainer->InsertAdditionalIconsL(entry, |
|
705 KIconSeperatorFormat(), ptr); |
|
706 |
|
707 // append created list item data to array of list items |
|
708 aCellArray.AppendL(iItemTextArray->Count()); |
|
709 |
|
710 if (itemInfo.iTopLine == KIndexError) |
|
711 { |
|
712 itemInfo.iTopLine = iItemTextArray->Count(); |
|
713 } |
|
714 iItemTextArray->AppendL(*listItemData); |
|
715 } |
|
716 } |
|
717 CleanupStack::PopAndDestroy(listItemData); |
|
718 CleanupStack::PopAndDestroy(&calendarInfoList); |
|
719 |
|
720 TRACE_EXIT_POINT; |
|
721 } |
|
722 |
|
723 #ifdef RD_CALEN_MIDNIGHT_VISUALIZATION |
|
724 void CCalenDayListBoxModel::InsertStartTimeL(TDes& aBuf, |
|
725 const TTime& aStartTime, |
|
726 const TTime& aCurrentDay) |
|
727 { |
|
728 TRACE_ENTRY_POINT; |
|
729 |
|
730 TBuf<6> arrow; |
|
731 TBuf<50> formattedStartTime; |
|
732 TBool mirrored( AknLayoutUtils::LayoutMirrored() ); |
|
733 |
|
734 if(StartsBeforeFocusedDay(aStartTime, aCurrentDay)) |
|
735 { |
|
736 arrow = GetArrowIndicator(mirrored); |
|
737 |
|
738 // need to format end time acc.to 12hr or 24hr format |
|
739 if(TimeFormat() == ETime24) |
|
740 { |
|
741 // 24 hour. show 00 only |
|
742 InsertTimeL(formattedStartTime, aStartTime, EInsert00); |
|
743 } |
|
744 else |
|
745 { |
|
746 // 12 hour. show hh:mm am/pm |
|
747 formattedStartTime = GetFormattedStartTimeL(aCurrentDay); |
|
748 } |
|
749 } |
|
750 else |
|
751 { |
|
752 // meeting starts after 12:00 am on current day |
|
753 // add start time as it is |
|
754 InsertTimeL( formattedStartTime, aStartTime ); |
|
755 } |
|
756 |
|
757 if(mirrored) |
|
758 { |
|
759 // For mirrored UI layouts: |
|
760 aBuf.Append(formattedStartTime); |
|
761 aBuf.Append(arrow); |
|
762 } |
|
763 else |
|
764 { |
|
765 // For western UI layouts: |
|
766 aBuf.Append(arrow); |
|
767 aBuf.Append(formattedStartTime); |
|
768 } |
|
769 |
|
770 TRACE_EXIT_POINT; |
|
771 } |
|
772 |
|
773 TBool CCalenDayListBoxModel::StartsBeforeFocusedDay(const TTime& aStartTime, |
|
774 const TTime& aFocusedTime) |
|
775 { |
|
776 TRACE_ENTRY_POINT; |
|
777 |
|
778 const TTime focusedDay12am = CalenDateUtils::BeginningOfDay(aFocusedTime); |
|
779 if(aStartTime < focusedDay12am) |
|
780 { |
|
781 TRACE_EXIT_POINT; |
|
782 return ETrue; |
|
783 } |
|
784 |
|
785 TRACE_EXIT_POINT; |
|
786 return EFalse; |
|
787 } |
|
788 |
|
789 TBool CCalenDayListBoxModel::EndsAfterFocusedDay(const TTime& aEndTime, |
|
790 const TTime& aFocusedTime) |
|
791 { |
|
792 TRACE_ENTRY_POINT; |
|
793 |
|
794 const TTime nextDay12am = CalenDateUtils::BeginningOfDay(aFocusedTime) |
|
795 + TTimeIntervalDays(1); |
|
796 |
|
797 if(aEndTime >= nextDay12am) |
|
798 { |
|
799 TRACE_EXIT_POINT; |
|
800 return ETrue; |
|
801 } |
|
802 |
|
803 TRACE_EXIT_POINT; |
|
804 return EFalse; |
|
805 } |
|
806 |
|
807 const TDesC& CCalenDayListBoxModel::GetArrowIndicator(const TBool aMirroredLayout) |
|
808 { |
|
809 TRACE_ENTRY_POINT; |
|
810 |
|
811 if(aMirroredLayout) |
|
812 { |
|
813 // unicode leftwards arrow for right to left layouts |
|
814 TRACE_EXIT_POINT; |
|
815 return KUnicodeLeftwardsArrow; |
|
816 } |
|
817 |
|
818 // unicode rightwards arrow for left to right layouts |
|
819 TRACE_EXIT_POINT; |
|
820 return KUnicodeRightwardsArrow; |
|
821 } |
|
822 |
|
823 const TDesC& CCalenDayListBoxModel::GetFormattedStartTimeL(const TTime& aFocusedTime) |
|
824 { |
|
825 TRACE_ENTRY_POINT; |
|
826 |
|
827 iFormattedStartTime.Zero(); |
|
828 const TTime focusedDay12am = CalenDateUtils::BeginningOfDay(aFocusedTime); |
|
829 InsertTimeL(iFormattedStartTime, focusedDay12am); |
|
830 |
|
831 TRACE_EXIT_POINT; |
|
832 return iFormattedStartTime; |
|
833 } |
|
834 |
|
835 const TDesC& CCalenDayListBoxModel::GetFormattedEndTimeL(const TTime& aFocusedTime) |
|
836 { |
|
837 TRACE_ENTRY_POINT; |
|
838 |
|
839 iFormattedEndTime.Zero(); |
|
840 const TTime focusedDay24hrs = CalenDateUtils::BeginningOfDay(aFocusedTime) |
|
841 + TTimeIntervalDays(1); |
|
842 |
|
843 InsertTimeL(iFormattedEndTime, focusedDay24hrs); |
|
844 |
|
845 TRACE_EXIT_POINT; |
|
846 return iFormattedEndTime; |
|
847 } |
|
848 |
|
849 void CCalenDayListBoxModel::InsertEndTimeL(TDes& aBuf, |
|
850 const TTime& aEndTime, |
|
851 const TTime& aCurrentDay) |
|
852 { |
|
853 TRACE_ENTRY_POINT; |
|
854 |
|
855 TBuf<6> arrow; |
|
856 TBuf<50> formattedEndTime; |
|
857 TBool mirrored( AknLayoutUtils::LayoutMirrored() ); |
|
858 |
|
859 if(EndsAfterFocusedDay(aEndTime, aCurrentDay)) |
|
860 { |
|
861 arrow = GetArrowIndicator(mirrored); |
|
862 |
|
863 // need to format end time acc.to 12hr or 24hr format |
|
864 if(TimeFormat() == ETime24) |
|
865 { |
|
866 // 24 hour. show 24 only |
|
867 InsertTimeL(formattedEndTime, aEndTime, EInsert24); |
|
868 } |
|
869 else |
|
870 { |
|
871 // 12 hour. show hh:mm am/pm |
|
872 formattedEndTime = GetFormattedEndTimeL(aCurrentDay); |
|
873 } |
|
874 } |
|
875 else |
|
876 { |
|
877 // meeting does not continue after 24:00 on current day |
|
878 // add start time as it is |
|
879 InsertTimeL( formattedEndTime, aEndTime ); |
|
880 } |
|
881 |
|
882 if(mirrored) |
|
883 { |
|
884 // For Mirrored Layouts: |
|
885 aBuf.Append(arrow); |
|
886 aBuf.Append(formattedEndTime); |
|
887 } |
|
888 else |
|
889 { |
|
890 // For Western Layouts: |
|
891 aBuf.Append(formattedEndTime); |
|
892 aBuf.Append(arrow); |
|
893 } |
|
894 |
|
895 TRACE_EXIT_POINT; |
|
896 } |
|
897 |
|
898 TTimeFormat CCalenDayListBoxModel::TimeFormat() const |
|
899 { |
|
900 TLocale locale; |
|
901 return locale.TimeFormat(); |
|
902 } |
|
903 #endif // RD_CALEN_MIDNIGHT_VISUALIZATION |
|
904 |
|
905 |
|
906 // ----------------------------------------------------------------------------- |
|
907 // CCalenDayListBoxModel::CalendarInfoIdentifierL |
|
908 // Searches for the index in calendar info list based on calendar file name |
|
909 // ----------------------------------------------------------------------------- |
|
910 // |
|
911 TBool CCalenDayListBoxModel::CalendarInfoIdentifierL( |
|
912 const HBufC* aName, const CCalCalendarInfo& aCalendarInfo) |
|
913 { |
|
914 TRACE_ENTRY_POINT; |
|
915 TBool retVal = EFalse; |
|
916 HBufC* calendarFileName = aCalendarInfo.FileNameL().AllocLC(); |
|
917 retVal = calendarFileName->CompareF(*aName); |
|
918 CleanupStack::PopAndDestroy(calendarFileName); |
|
919 TRACE_EXIT_POINT; |
|
920 return (!retVal); |
|
921 } |
|
922 |
|
923 // End of File |
|
924 |