|
1 /* |
|
2 * Copyright (c) 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: event view's container implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 // system includes |
|
19 #include <AknLayoutFont.h> |
|
20 #include <aknnavide.h> // CAknNavigationDecorator |
|
21 #include <aknnavilabel.h> // CAknNaviLabel |
|
22 #include <AknsBasicBackgroundControlContext.h> |
|
23 #include <AknBidiTextUtils.h> |
|
24 #include <AknsDrawUtils.h> |
|
25 #include <calrrule.h> |
|
26 #include <calalarm.h> |
|
27 #include <calentry.h> |
|
28 #include <calinstance.h> |
|
29 #include <NpdApi.h> |
|
30 #include <eikappui.h> |
|
31 #include <eikdef.h> |
|
32 #include <eikedwin.h> |
|
33 #include <eikenv.h> |
|
34 #include <eikmenup.h> // CEikMenuPane |
|
35 #include <eikmfne.h> |
|
36 #include <featmgr.h> // FeatureManager |
|
37 #include <eikrted.h> // CEikRichTextEditor |
|
38 #include <finditemdialog.h> |
|
39 #include <StringLoader.h> |
|
40 #include <txtrich.h> // CRichText |
|
41 #include <gdi.h> |
|
42 #include <ItemFinder.h> //Autofinder |
|
43 #include <finditemmenu.h> |
|
44 #include <finditem.hrh> |
|
45 #include <centralrepository.h> |
|
46 #include <cenrepnotifyhandler.h> |
|
47 #include <CommonUiInternalCRKeys.h> |
|
48 #include <calsession.h> |
|
49 #include <calencommonui.rsg> |
|
50 #include <AknUtils.h> |
|
51 #include <avkon.hrh> // EAknCmdHelp |
|
52 #include <avkon.mbg> |
|
53 #include <avkon.rsg> |
|
54 #include <aknlayoutscalable_apps.cdl.h> |
|
55 #include <aknnotewrappers.h> |
|
56 #include <csxhelp/cale.hlp.hrh> |
|
57 #include <calendateutils.h> |
|
58 #include <calenagendautils.h> |
|
59 #include <CalenInterimUtils2.h> |
|
60 #include <calentryview.h> |
|
61 #include <calattachment.h> |
|
62 #include <calcommon.h> |
|
63 #include <calendar.mbg> |
|
64 #include <Calendar.rsg> |
|
65 #include <centralrepository.h> |
|
66 #include <calencommands.hrh> // Calendar commands |
|
67 #include <calencontext.h> |
|
68 #include <caleninstanceid.h> // TCalenInstanceId |
|
69 #include <calenservices.h> |
|
70 #include <calentoolbar.h> |
|
71 #include <calcalendarinfo.h> |
|
72 #include <DocumentHandler.h> |
|
73 |
|
74 // user includes |
|
75 #include "caleneventviewcontainer.h" |
|
76 #include "caleneventview.h" |
|
77 #include "calennativeview.h" |
|
78 #include "calendarui_debug.h" |
|
79 #include "calenicondrawer.h" |
|
80 #include "calennotedatautil.h" |
|
81 #include "calendar.hrh" |
|
82 #include "calenentryutil.h" |
|
83 #include "CalenUid.h" // KUidCalendar |
|
84 #include "calenlocationutil.h" |
|
85 #include "CalendarPrivateCRKeys.h" |
|
86 #include "calenattachmentutils.h" |
|
87 #include "calenglobaldata.h" |
|
88 #include "CleanupResetAndDestroy.h" |
|
89 |
|
90 // LOCAL CONSTANTS AND MACROS |
|
91 _LIT( KWesternSummaryMarker, "\x200E" ); |
|
92 _LIT( KArabicSummaryMarker , "\x200F" ); |
|
93 _LIT(KSpace, " "); |
|
94 _LIT(KYearFormatString,"%F%Y"); |
|
95 _LIT(KAttachmentSeparator,"; "); |
|
96 _LIT8( KNotePadTextDataType, "text/plain" ); |
|
97 |
|
98 const TInt KDefaultRightMargin=0; |
|
99 const TInt KScrollViewerUp = 1; |
|
100 const TInt KScrollViewerDown = -1; |
|
101 const TInt KMaxDateLength = 32; |
|
102 |
|
103 //PANIC CODE |
|
104 enum TPanicCode |
|
105 { |
|
106 EPanicArrayOfSizeZero=2, |
|
107 }; |
|
108 |
|
109 // ================= MEMBER FUNCTIONS ========================================= |
|
110 |
|
111 // ---------------------------------------------------------------------------- |
|
112 // CCalenEventViewContainer::CCalenEventViewContainer |
|
113 // C++ constructor. |
|
114 // ---------------------------------------------------------------------------- |
|
115 // |
|
116 CCalenEventViewContainer::CCalenEventViewContainer(CCalenNativeView* aView, |
|
117 MCalenServices& aServices ) |
|
118 : CCalenContainer( aView, aServices ), |
|
119 iEntry(NULL), |
|
120 iAutomaticHlValue(ETrue), |
|
121 iAutomaticHlInitialized(EFalse) |
|
122 { |
|
123 TRACE_ENTRY_POINT; |
|
124 iNumOfLinesBeforeLocField = 0; |
|
125 iLocaleChanged = EFalse; |
|
126 TRACE_EXIT_POINT; |
|
127 } |
|
128 |
|
129 // ---------------------------------------------------------------------------- |
|
130 // CCalenEventViewContainer::~CCalenEventViewContainer |
|
131 // Destructor |
|
132 // ---------------------------------------------------------------------------- |
|
133 // |
|
134 CCalenEventViewContainer::~CCalenEventViewContainer() |
|
135 { |
|
136 TRACE_ENTRY_POINT; |
|
137 |
|
138 if(iEntry) |
|
139 { |
|
140 delete iEntry; |
|
141 } |
|
142 |
|
143 iFetchedEntries.ResetAndDestroy(); |
|
144 |
|
145 delete iParaFormat; |
|
146 delete iSearchBuf; |
|
147 delete iEventViewData; |
|
148 delete iTextEditor; |
|
149 delete iBgContext; |
|
150 delete iTimeFormat; |
|
151 delete iDateFormat; |
|
152 delete iDocHandler; |
|
153 delete iAutoFinder; |
|
154 delete iFindMenu; |
|
155 |
|
156 if( iNotifier ) |
|
157 { |
|
158 iNotifier->StopListening(); |
|
159 delete iNotifier; |
|
160 }; |
|
161 |
|
162 delete iCenRepSession; |
|
163 if(iLabel) |
|
164 delete iLabel; |
|
165 |
|
166 //Reset the attachment posiitons array |
|
167 iAttachmentPosInfoArray.Reset(); |
|
168 |
|
169 TRACE_EXIT_POINT; |
|
170 } |
|
171 |
|
172 // ---------------------------------------------------------------------------- |
|
173 // CCalenEventViewContainer::ConstructImplL |
|
174 // Third phase constructor. |
|
175 // This function was called CCalenNativeView::ConstructL(). |
|
176 // (other items were commented in a header). |
|
177 // ---------------------------------------------------------------------------- |
|
178 // |
|
179 void CCalenEventViewContainer::ConstructImplL() |
|
180 { |
|
181 TRACE_ENTRY_POINT; |
|
182 |
|
183 iTimeFormat = StringLoader::LoadL( R_QTN_TIME_USUAL_WITH_ZERO, CEikonEnv::Static() ); |
|
184 iDateFormat = StringLoader::LoadL( R_QTN_DATE_USUAL_WITH_ZERO, CEikonEnv::Static() ); |
|
185 |
|
186 iBgContext = CAknsBasicBackgroundControlContext::NewL( KAknsIIDQsnBgAreaMain, |
|
187 Rect(), |
|
188 ETrue ); |
|
189 |
|
190 iDocHandler = CDocumentHandler::NewL( iEikonEnv->Process() ); |
|
191 iAutoFinder = CItemFinder::NewL(); |
|
192 iFindMenu = CFindItemMenu::NewL( EFindItemMenuPlaceHolder ); |
|
193 iFindMenu->AttachItemFinderMenuL(0); |
|
194 |
|
195 iParaFormat = CParaFormat::NewL(); |
|
196 |
|
197 |
|
198 iTextEditor = new (ELeave) CEikRichTextEditor; |
|
199 iTextEditor->ConstructL(this, 0, 0, CEikEdwin::EReadOnly | CEikEdwin::EAvkonDisableCursor | |
|
200 CEikEdwin::ENoAutoSelection|CEikEdwin::EAvkonEditor); |
|
201 iTextEditor->SetMopParent(this); |
|
202 iTextEditor->SetRect( Rect() ); |
|
203 |
|
204 iLabel = new (ELeave) CEikLabel; |
|
205 iLabel->SetContainerWindowL(*this); |
|
206 iLabel->SetTextL(_L("")); |
|
207 iLabel->SetRect(Rect()); |
|
208 |
|
209 ReadAutoHlCenRepValueAndSetNotifyL(); |
|
210 |
|
211 CCalenEventView* eventView = static_cast<CCalenEventView*>( iView ); |
|
212 if( !( eventView->IsAlarmActiveInViewer() ) ) |
|
213 { |
|
214 SetAutomaticHighlightL(iAutomaticHlValue); |
|
215 } |
|
216 |
|
217 iDocHandler->SetExitObserver( this ); |
|
218 TRACE_EXIT_POINT; |
|
219 } |
|
220 |
|
221 // ---------------------------------------------------------------------------- |
|
222 // CCalenEventViewContainer::UpdateSize |
|
223 // Do layout changes after calendar settings are |
|
224 // changed. No necessary actions for this view. |
|
225 // ---------------------------------------------------------------------------- |
|
226 // |
|
227 void CCalenEventViewContainer::UpdateSize() |
|
228 { |
|
229 TRACE_ENTRY_POINT; |
|
230 |
|
231 TRACE_EXIT_POINT; |
|
232 } |
|
233 |
|
234 // ---------------------------------------------------------------------------- |
|
235 // CCalenEventViewContainer::CreateIconIndicesL |
|
236 // Second and final stage of population. |
|
237 // (other items were commented in a header). |
|
238 // ---------------------------------------------------------------------------- |
|
239 // |
|
240 void CCalenEventViewContainer::CreateIconIndicesL( RArray<MCalenServices::TCalenIcons>& /*aIndexArray*/ ) |
|
241 { |
|
242 TRACE_ENTRY_POINT; |
|
243 |
|
244 TRACE_EXIT_POINT; |
|
245 } |
|
246 |
|
247 // ---------------------------------------------------------------------------- |
|
248 // CCalenEventViewContainer::CompletePopulationL |
|
249 // Complete population |
|
250 // (other items were commented in a header). |
|
251 // ---------------------------------------------------------------------------- |
|
252 // |
|
253 void CCalenEventViewContainer::CompletePopulationL() |
|
254 { |
|
255 TRACE_ENTRY_POINT; |
|
256 if(iTextEditor && iTextEditor->Text()->DocumentLength() > 0 && iAutoFinder && |
|
257 iSelectedText.iCursorPos == 0 && iSelectedText.iAnchorPos == 0) |
|
258 { |
|
259 iAutoFinder->SetEditor((CEikRichTextEditor**)&iTextEditor); |
|
260 } |
|
261 |
|
262 iTextEditor->SetFocus(ETrue); |
|
263 ActivateL(); |
|
264 AddToStackAndMakeVisibleL(); |
|
265 DrawDeferred(); |
|
266 if(iSelectedText.iCursorPos > 0 || iSelectedText.iAnchorPos > 0) |
|
267 { |
|
268 //Set the text selection existed before layout change |
|
269 iTextEditor->SetCursorPosL(iSelectedText.iCursorPos, EFalse); |
|
270 iTextEditor->SetSelectionL(iSelectedText.iCursorPos,iSelectedText.iAnchorPos); |
|
271 } |
|
272 TRACE_EXIT_POINT; |
|
273 } |
|
274 |
|
275 // ---------------------------------------------------------------------------- |
|
276 // CCalenEventViewContainer::HandleNaviDecoratorEventL |
|
277 // ?implementation_description |
|
278 // (other items were commented in a header). |
|
279 // ---------------------------------------------------------------------------- |
|
280 // |
|
281 void CCalenEventViewContainer::HandleNaviDecoratorEventL( TInt /*aEventID*/ ) |
|
282 { |
|
283 TRACE_ENTRY_POINT; |
|
284 |
|
285 TRACE_EXIT_POINT; |
|
286 } |
|
287 |
|
288 // ---------------------------------------------------------------------------- |
|
289 // CCalenEventViewContainer::HandleLongTapEventL |
|
290 // processing of a long tap event |
|
291 // (other items were commented in a header). |
|
292 // ---------------------------------------------------------------------------- |
|
293 // |
|
294 void CCalenEventViewContainer::HandleLongTapEventL( const TPoint& /*aPenEventLocation*/, |
|
295 const TPoint& /*aPenEventScreenLocation*/ ) |
|
296 { |
|
297 TRACE_ENTRY_POINT; |
|
298 |
|
299 TRACE_EXIT_POINT; |
|
300 } |
|
301 |
|
302 // ---------------------------------------------------------------------------- |
|
303 // CCalenEventViewContainer::Draw |
|
304 // (other items were commented in a header). |
|
305 // ---------------------------------------------------------------------------- |
|
306 // |
|
307 void CCalenEventViewContainer::Draw(const TRect& /*aRect*/) const |
|
308 { |
|
309 TRACE_ENTRY_POINT; |
|
310 |
|
311 CWindowGc& gc = SystemGc(); |
|
312 |
|
313 TRect mainPane; |
|
314 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPane ); |
|
315 TRect bgContextRect( TPoint(0, 0), mainPane.Size() ); |
|
316 iBgContext->SetRect( bgContextRect); |
|
317 iBgContext->SetParentPos(mainPane.iTl); |
|
318 AknsDrawUtils::Background( AknsUtils::SkinInstance(), iBgContext, this, gc, Rect()); |
|
319 |
|
320 |
|
321 TRACE_EXIT_POINT; |
|
322 } |
|
323 |
|
324 // ---------------------------------------------------------------------------- |
|
325 // CCalenEventViewContainer::Sizechanged |
|
326 // Child control was resized. |
|
327 // (other items were commented in a header) |
|
328 // ---------------------------------------------------------------------------- |
|
329 // |
|
330 void CCalenEventViewContainer::SizeChanged() |
|
331 { |
|
332 TRACE_ENTRY_POINT; |
|
333 |
|
334 SetLayoutFromLookAndFeelL(); |
|
335 |
|
336 if (iTextEditor) |
|
337 { |
|
338 TRAPD(error,iTextEditor->HandleTextChangedL() ); |
|
339 if(error!=KErrNone) |
|
340 { |
|
341 // Do nothing to avoid warning |
|
342 } |
|
343 } |
|
344 |
|
345 TRACE_EXIT_POINT; |
|
346 } |
|
347 |
|
348 // ---------------------------------------------------------------------------- |
|
349 // CCalenEventViewContainer::CountComponentControls |
|
350 // Return child control count. |
|
351 // (other items were commented in a header). |
|
352 // ---------------------------------------------------------------------------- |
|
353 // |
|
354 TInt CCalenEventViewContainer::CountComponentControls() const |
|
355 { |
|
356 TRACE_ENTRY_POINT; |
|
357 TRACE_EXIT_POINT; |
|
358 return 2; |
|
359 } |
|
360 |
|
361 // ---------------------------------------------------------------------------- |
|
362 // CCalenEventViewContainer::ComponentControl |
|
363 // Return child control pointer. |
|
364 // (other items were commented in a header). |
|
365 // ---------------------------------------------------------------------------- |
|
366 // |
|
367 CCoeControl* CCalenEventViewContainer::ComponentControl(TInt aIndex) const // Child control index |
|
368 { |
|
369 TRACE_ENTRY_POINT; |
|
370 CCoeControl* control ( NULL ); |
|
371 switch(aIndex) |
|
372 { |
|
373 case 0: |
|
374 control = iTextEditor; |
|
375 break; |
|
376 |
|
377 case 1: |
|
378 control = iLabel; |
|
379 break; |
|
380 |
|
381 default: |
|
382 __ASSERT_DEBUG( 0, User::Invariant() ); |
|
383 break; |
|
384 } |
|
385 TRACE_EXIT_POINT; |
|
386 |
|
387 return control; |
|
388 } |
|
389 |
|
390 // ---------------------------------------------------------------------------- |
|
391 // CCalenEventViewContainer::OfferKeyEventL |
|
392 // Process key event. |
|
393 // (other items were commented in a header). |
|
394 // ---------------------------------------------------------------------------- |
|
395 // |
|
396 TKeyResponse CCalenEventViewContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType) |
|
397 { |
|
398 TRACE_ENTRY_POINT; |
|
399 |
|
400 TKeyResponse keyResponse(EKeyWasNotConsumed); |
|
401 |
|
402 if (aType == EEventKey) |
|
403 { |
|
404 switch (aKeyEvent.iCode) |
|
405 { |
|
406 case EKeyUpArrow: |
|
407 { |
|
408 iAutoFinder->NextItemOrScrollL( CItemFinder::ENextUp ); |
|
409 // Scroll the text view up by one line |
|
410 iTextEditor->MakeVisible(EFalse); |
|
411 TInt scrollLines = KScrollViewerUp; |
|
412 iTextEditor->TextView()->ScrollDisplayLinesL(scrollLines); |
|
413 iTextEditor->UpdateScrollBarsL(); |
|
414 iTextEditor->MakeVisible(ETrue); |
|
415 //Set focus immediately for highlight of auto find text |
|
416 iTextEditor->SetFocus(ETrue); |
|
417 keyResponse = EKeyWasConsumed; |
|
418 } |
|
419 break; |
|
420 |
|
421 case EKeyDownArrow: |
|
422 { |
|
423 iAutoFinder->NextItemOrScrollL( CItemFinder::ENextDown ); |
|
424 // Scroll the text view down by one line |
|
425 iTextEditor->MakeVisible(EFalse); |
|
426 TInt scrollLines = KScrollViewerDown; |
|
427 iTextEditor->TextView()->ScrollDisplayLinesL(scrollLines); |
|
428 iTextEditor->UpdateScrollBarsL(); |
|
429 iTextEditor->MakeVisible(ETrue); |
|
430 //Set focus immediately for highlight of auto find text |
|
431 iTextEditor->SetFocus(ETrue); |
|
432 keyResponse = EKeyWasConsumed; |
|
433 } |
|
434 break; |
|
435 |
|
436 case EKeyOK: |
|
437 { |
|
438 iView->HandleCommandL(ECalenCmdPromptThenEdit); |
|
439 keyResponse = EKeyWasConsumed; |
|
440 } |
|
441 break; |
|
442 case EKeyEscape: |
|
443 { |
|
444 // Calendar relaunched from cmd line - close viewer |
|
445 iView->HandleCommandL(EAknSoftkeyBack); |
|
446 keyResponse = EKeyWasConsumed; |
|
447 } |
|
448 break; |
|
449 case EKeyPhoneSend: |
|
450 { |
|
451 HandleNumberCallL(); |
|
452 break; |
|
453 } |
|
454 case EKeyBackspace: /* fall through... */ |
|
455 case EKeyDelete: |
|
456 { |
|
457 CCalenEventView* eventView = static_cast<CCalenEventView*>( iView ); |
|
458 if( !( eventView->IsAlarmActiveInViewer() ) ) |
|
459 { |
|
460 iView->HandleCommandL( ECalenDeleteCurrentEntry ); |
|
461 } |
|
462 } |
|
463 break; |
|
464 default: |
|
465 break; |
|
466 } |
|
467 } |
|
468 // For handling geokeys on corolla hardware |
|
469 // For Add location hard key |
|
470 if( aKeyEvent.iScanCode == EStdKeyApplication1C && aType == EEventKeyUp ) |
|
471 { |
|
472 if(CCalenLocationUtil::IsMapProviderAvailableL()) |
|
473 { |
|
474 CCalEntry::TType entryType = iEntry->EntryTypeL(); |
|
475 if(entryType == CCalEntry::EAppt) |
|
476 { |
|
477 iServices.IssueCommandL(ECalenGetLocationAndSave); |
|
478 } |
|
479 keyResponse = EKeyWasConsumed; |
|
480 } |
|
481 } |
|
482 // For Show location hard key |
|
483 else if( aKeyEvent.iScanCode == EStdKeyApplication1B && aType == EEventKeyUp ) |
|
484 { |
|
485 if(CCalenLocationUtil::IsMapProviderAvailableL()) |
|
486 { |
|
487 CCalEntry::TType entryType = iEntry->EntryTypeL(); |
|
488 if(entryType == CCalEntry::EAppt) |
|
489 { |
|
490 TPtrC location = iEntry->LocationL(); |
|
491 if(iEntry->GeoValueL()) |
|
492 { |
|
493 iServices.IssueCommandL(ECalenShowLocation); |
|
494 keyResponse = EKeyWasConsumed; |
|
495 } |
|
496 else if(location.Length()) |
|
497 { |
|
498 iServices.IssueCommandL(ECalenGetLocationAndReplace); |
|
499 } |
|
500 else |
|
501 { |
|
502 iServices.IssueCommandL(ECalenShowLocationQuery); |
|
503 } |
|
504 keyResponse = EKeyWasConsumed; |
|
505 } |
|
506 } |
|
507 } |
|
508 // Swallow all other keyevents to prevent the active container processing them. |
|
509 keyResponse = EKeyWasConsumed; |
|
510 |
|
511 TRACE_EXIT_POINT; |
|
512 return keyResponse; |
|
513 |
|
514 |
|
515 } |
|
516 |
|
517 // ---------------------------------------------------------------------------- |
|
518 // CCalenEventViewContainer::HandleNumberCallL |
|
519 // ---------------------------------------------------------------------------- |
|
520 // |
|
521 void CCalenEventViewContainer::HandleNumberCallL() |
|
522 { |
|
523 TRACE_ENTRY_POINT; |
|
524 |
|
525 const CItemFinder::CFindItemExt& findItem = iAutoFinder->CurrentItemExt(); |
|
526 |
|
527 if(findItem.iItemType != CItemFinder::EPhoneNumber) |
|
528 { |
|
529 return; |
|
530 } |
|
531 |
|
532 iFindMenu->HandleCallL( findItem.iItemDescriptor->Des() ); |
|
533 |
|
534 TRACE_EXIT_POINT; |
|
535 } |
|
536 |
|
537 // ---------------------------------------------------------------------------- |
|
538 // CCalenEventViewContainer::HandlePointerEventL |
|
539 // Process pointer event. |
|
540 // (other items were commented in a header). |
|
541 // ---------------------------------------------------------------------------- |
|
542 // |
|
543 void CCalenEventViewContainer::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
544 { |
|
545 TRACE_ENTRY_POINT; |
|
546 |
|
547 if(!AknLayoutUtils::PenEnabled()) |
|
548 { |
|
549 return; |
|
550 } |
|
551 |
|
552 CCalenEventView* eventView = static_cast<CCalenEventView*>( iView ); |
|
553 if( !( eventView->IsAlarmActiveInViewer() ) ) |
|
554 { |
|
555 if(iTextEditor->Rect().Contains(aPointerEvent.iPosition)) |
|
556 { |
|
557 switch(aPointerEvent.iType) |
|
558 { |
|
559 case TPointerEvent::EButton1Down: |
|
560 { |
|
561 iTextEditor->SetFocus(ETrue); |
|
562 |
|
563 // TODO: Uncomment this when enabling attachment support |
|
564 |
|
565 if(iEventViewData->AttachmentCount()) |
|
566 { |
|
567 CTextView *textView = iTextEditor->TextView(); |
|
568 |
|
569 TTmPosInfo2 *posInfo = new(ELeave) TTmPosInfo2; |
|
570 textView->FindXyPosL(aPointerEvent.iPosition,*posInfo); |
|
571 |
|
572 // Check if it is tapped on any attachment name, if yes then open that attachment |
|
573 CheckAndOpenTappedAttachment(posInfo); |
|
574 delete posInfo; |
|
575 } |
|
576 break; |
|
577 } |
|
578 case TPointerEvent::EDrag: |
|
579 { |
|
580 iTextEditor->SetFocus(ETrue); |
|
581 break; |
|
582 } |
|
583 case TPointerEvent::EButton1Up: |
|
584 { |
|
585 iTextEditor->SetFocus(ETrue); |
|
586 TInt curPos = iTextEditor->CursorPos(); |
|
587 TRect rect = iTextEditor->Rect(); |
|
588 if ( !iAutoFinder->ItemWasTappedL( aPointerEvent.iPosition - rect.iTl ) ) |
|
589 { |
|
590 // return; |
|
591 } |
|
592 break; |
|
593 } |
|
594 default: |
|
595 { |
|
596 break; |
|
597 } |
|
598 } |
|
599 iTextEditor->HandlePointerEventL(aPointerEvent); |
|
600 } |
|
601 } |
|
602 |
|
603 TRACE_EXIT_POINT; |
|
604 } |
|
605 |
|
606 // ---------------------------------------------------------------------------- |
|
607 // CCalenEventViewContainer::GetHelpContext |
|
608 // Get help context. |
|
609 // (other items were commented in a header). |
|
610 // ---------------------------------------------------------------------------- |
|
611 // |
|
612 void CCalenEventViewContainer::GetHelpContext(TCoeHelpContext& aContext) const |
|
613 { |
|
614 TRACE_ENTRY_POINT; |
|
615 |
|
616 aContext.iMajor = KUidCalendar; |
|
617 aContext.iContext = KCALE_HLP_NOTE_VIEWER; // need to change |
|
618 |
|
619 TRACE_EXIT_POINT; |
|
620 } |
|
621 |
|
622 // ---------------------------------------------------------------------------- |
|
623 // CCalenEventViewContainer::HandleResourceChange |
|
624 // Handles a resource relative event. |
|
625 // (other items were commented in a header). |
|
626 // ---------------------------------------------------------------------------- |
|
627 // |
|
628 void CCalenEventViewContainer::HandleResourceChange(TInt aType) |
|
629 { |
|
630 TRACE_ENTRY_POINT; |
|
631 |
|
632 CCalenContainer::HandleResourceChange( aType ); |
|
633 |
|
634 if( ( aType == KUidValueCoeColorSchemeChangeEvent ) || |
|
635 ( aType == KUidValueCoeZoomChangeEvent ) || |
|
636 ( aType == KUidValueCoeFontChangeEvent ) ) |
|
637 { |
|
638 CEikAppUi* appUi = static_cast<CEikAppUi*>( ControlEnv()->AppUi() ); |
|
639 SetRect( appUi->ClientRect() ); |
|
640 } |
|
641 |
|
642 if( KAknsMessageSkinChange == aType || |
|
643 KEikDynamicLayoutVariantSwitch == aType ) |
|
644 { |
|
645 SizeChanged(); |
|
646 |
|
647 if(iTextEditor->ScrollBarFrame()) |
|
648 { |
|
649 // make the scrollbars invisible |
|
650 iTextEditor->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, |
|
651 CEikScrollBarFrame::EOff); |
|
652 } |
|
653 |
|
654 // refresh |
|
655 TRAPD( error, iView->BeginRepopulationL() ); |
|
656 if( KErrNone != error ) |
|
657 { |
|
658 // To avoid warning. |
|
659 } |
|
660 } |
|
661 |
|
662 // Allow the coecontrol to handle the changes if any. |
|
663 CCoeControl::HandleResourceChange( aType ); |
|
664 |
|
665 TRACE_EXIT_POINT; |
|
666 } |
|
667 |
|
668 // ---------------------------------------------------------------------------- |
|
669 // CCalenEventViewContainer::BuildTextEditorL |
|
670 // Build text editor |
|
671 // (other items were commented in a header). |
|
672 // ---------------------------------------------------------------------------- |
|
673 // |
|
674 void CCalenEventViewContainer::BuildTextEditorL() |
|
675 { |
|
676 TRACE_ENTRY_POINT; |
|
677 |
|
678 iTextEditor->SetFocus(EFalse); |
|
679 iTextEditor->SetRect( Rect() ); |
|
680 iTextEditor->RichText()->Reset(); |
|
681 |
|
682 // Create the scroll bars. |
|
683 iTextEditor->CreateScrollBarFrameL(); |
|
684 iTextEditor->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto); |
|
685 iTextEditor->SetAknEditorFlags(EAknEditorFlagEnableScrollBars); |
|
686 iTextEditor->ScrollBarFrame()->VerticalScrollBar()->SetMopParent(this); |
|
687 |
|
688 iTextEditor->ScrollBarFrame()->SetScrollBarFrameObserver(this); |
|
689 |
|
690 TEikScrollBarModel h,v; |
|
691 TEikScrollBarFrameLayout lay; |
|
692 CEikAppUi* appUi = static_cast<CEikAppUi*>( ControlEnv()->AppUi() ); |
|
693 TRect rec = appUi->ClientRect(); |
|
694 // ASSERT( iTextEditor->ScrollBarFrame()->TileL( &h, &v, rec, rec, lay) ); |
|
695 |
|
696 SetLayoutFromLookAndFeelL(); |
|
697 |
|
698 SetupFontL(); |
|
699 |
|
700 TRACE_EXIT_POINT; |
|
701 } |
|
702 |
|
703 // ---------------------------------------------------------------------------- |
|
704 // CCalenEventViewContainer::SetIconsL |
|
705 // Set the icons |
|
706 // (other items were commented in a header). |
|
707 // ---------------------------------------------------------------------------- |
|
708 // |
|
709 void CCalenEventViewContainer::SetIconsL(CCalenIconDrawer* aIconDrawer) |
|
710 { |
|
711 // Create a TPictureHeader to insert our icons into the viewer |
|
712 TPictureHeader header; |
|
713 header.iPicture = TSwizzle<CPicture>(aIconDrawer); |
|
714 |
|
715 // Insert the icon drawer into the Rich Text Editor. This takes |
|
716 // ownership of the icon drawer. |
|
717 // Insert at index 0 in the document to cause the icons to be drawn when |
|
718 // the first line is visible. The icons will not be drawn at position 0, |
|
719 // but this position must be on the screen for the icons to be drawn. |
|
720 iTextEditor->RichText()->InsertL( iTextEditor->RichText()->DocumentLength(), header ); |
|
721 |
|
722 // Tell the text editor that it has been updated. This will cause |
|
723 // a redraw. |
|
724 iTextEditor->HandleTextChangedL(); |
|
725 } |
|
726 |
|
727 // ---------------------------------------------------------------------------- |
|
728 // CCalenEventViewContainer::CreateAndInitializeIconsDrawerL |
|
729 // Cretaes the CCalenIconDrawer object for the container and returns it |
|
730 // (other items were commented in a header). |
|
731 // ---------------------------------------------------------------------------- |
|
732 // |
|
733 CCalenIconDrawer* CCalenEventViewContainer::CreateAndInitializeIconsDrawerL() |
|
734 { |
|
735 // Create and populate the icon drawer. We need to do this first to prevent a long |
|
736 // summary text being drawn over the icons |
|
737 // Ownership of icon drawer transferred to rich text editor |
|
738 CCalenIconDrawer* iconDrawer = CCalenIconDrawer::NewL( iServices ); |
|
739 PopulateIconDrawerL(*iconDrawer); |
|
740 return iconDrawer; |
|
741 } |
|
742 // ---------------------------------------------------------------------------- |
|
743 // CCalenEventViewContainer::RequestInstanceViewL |
|
744 // Request for instance view |
|
745 // (other items were commented in a header). |
|
746 // ---------------------------------------------------------------------------- |
|
747 // |
|
748 TInt CCalenEventViewContainer::RequestInstanceViewL() |
|
749 { |
|
750 TRACE_ENTRY_POINT; |
|
751 |
|
752 MCalenContext& context = iServices.Context(); |
|
753 TCalenInstanceId instanceId = context.InstanceId(); |
|
754 TCalLocalUid entryLocalUid = instanceId.iEntryLocalUid; |
|
755 TTime instanceStartTime = context.InstanceId().iInstanceTime; |
|
756 |
|
757 if(iEntry) |
|
758 { |
|
759 delete iEntry; |
|
760 iEntry = NULL; |
|
761 } |
|
762 //If the timezone is changed after opening the viewer |
|
763 //We need to use the new instance time and need to update the context later |
|
764 // Get the active collection ids. |
|
765 RArray<TInt> colIdArray; |
|
766 CCalenNativeView::GetActiveCollectionidsL( iServices, colIdArray ); |
|
767 |
|
768 CCalInstanceView* instanceView = NULL; |
|
769 if(iLocaleChanged) |
|
770 { |
|
771 instanceView = iServices.InstanceViewL(colIdArray); |
|
772 CCalInstance* instance = FindPossibleInstanceL( instanceId,*instanceView ); |
|
773 if(instance) |
|
774 { |
|
775 instanceStartTime = instance->StartTimeL().TimeLocalL(); |
|
776 } |
|
777 } |
|
778 colIdArray.Reset(); |
|
779 |
|
780 iEntry = iServices.EntryViewL(context.InstanceId().iColId)->FetchL(entryLocalUid); |
|
781 |
|
782 TCalTime instanceDateTime; |
|
783 instanceDateTime.SetTimeLocalL( context.InstanceId().iInstanceTime ); |
|
784 |
|
785 if(!iEntry) |
|
786 { |
|
787 // If the entry is not let's not further proceed. |
|
788 // The entry has been removed by some other app eg. Synch. |
|
789 return KErrNotFound; |
|
790 } |
|
791 |
|
792 if(iEventViewData) |
|
793 { |
|
794 delete iEventViewData; |
|
795 iEventViewData = NULL; |
|
796 } |
|
797 iEventViewData = CCalenEntryUtil::NewL( *iEntry, instanceDateTime ); |
|
798 |
|
799 //If timezone is changed after opening the entry in the viewer |
|
800 //we need to update the instance id to the context |
|
801 if(iLocaleChanged) |
|
802 { |
|
803 iLocaleChanged = EFalse; |
|
804 instanceId.iInstanceTime = instanceStartTime; |
|
805 context.SetFocusDateAndTimeAndInstanceL( instanceDateTime,instanceId,TVwsViewId( KUidCalendar, KUidCalenEventView ) ); |
|
806 } |
|
807 TRACE_EXIT_POINT; |
|
808 return KErrNone; |
|
809 } |
|
810 |
|
811 // ---------------------------------------------------------------------------- |
|
812 // CCalenEventViewContainer::AddFieldsL |
|
813 // Add the data fields |
|
814 // (other items were commented in a header). |
|
815 // ---------------------------------------------------------------------------- |
|
816 // |
|
817 void CCalenEventViewContainer::AddFieldsL() |
|
818 { |
|
819 TRACE_ENTRY_POINT; |
|
820 // Initialize icon drawer |
|
821 CCalenIconDrawer* iconDrawer = CreateAndInitializeIconsDrawerL(); |
|
822 |
|
823 SetLabelContentL(*iLabel); |
|
824 // add subject field |
|
825 AddSubjectFieldL(); |
|
826 |
|
827 switch ( iEntry->EntryTypeL() ) |
|
828 { |
|
829 case CCalEntry::EReminder: |
|
830 case CCalEntry::EAppt: |
|
831 { |
|
832 // start time |
|
833 AddTimeFieldL(); |
|
834 |
|
835 // location |
|
836 AddLocationFieldL(); |
|
837 |
|
838 // Adds empty line |
|
839 AddEmptyLineL(); |
|
840 |
|
841 // alarm |
|
842 AddAlarmDateTimeFieldL(); |
|
843 |
|
844 // We want to show the repeat fields for repeating parent entries or |
|
845 // child entries. If the entry is a child then the repeat information from the |
|
846 // parent will be shown |
|
847 //if ((iEventViewData->IsRepeating()) || (Handler().Edited()->Entry().RecurrenceIdL().TimeUtcL() != Time::NullTTime())) |
|
848 if ((iEventViewData->IsRepeating()) || (iEntry->RecurrenceIdL().TimeUtcL() != Time::NullTTime())) |
|
849 { |
|
850 AddRepeatFieldL(); |
|
851 } |
|
852 |
|
853 iTitleTextId = R_CALEN_EVENT_VIEW_MEETING_TITLE; |
|
854 } |
|
855 break; |
|
856 |
|
857 case CCalEntry::EAnniv: |
|
858 { |
|
859 // date field |
|
860 AddDateFieldL(iEventViewData->StartDateTime()); |
|
861 |
|
862 // Adds empty line |
|
863 AddEmptyLineL(); |
|
864 |
|
865 // alarm |
|
866 AddAlarmDateTimeFieldL(); |
|
867 |
|
868 // Add the 'since' field. |
|
869 AddSinceFieldL(); |
|
870 |
|
871 iTitleTextId = R_CALEN_EVENT_VIEW_ANNIV_TITLE; |
|
872 } |
|
873 break; |
|
874 |
|
875 case CCalEntry::EEvent: |
|
876 { |
|
877 // If the start time is on the same day as the end time, just show the date. |
|
878 // Otherwise, show "start date - end date". |
|
879 TTime startTime = iEventViewData->StartDateTime(); |
|
880 TTime endTime = iEventViewData->EndDateTime(); |
|
881 |
|
882 // For allday (1 day) event Eg. "Start:- 12:00am, 15-08-2010 & End:-12:00am, 16-08-2010" |
|
883 // In viewer it should be displayed as "StartDate: 15-08-2010 & EndDate:15-08-2010" |
|
884 // No time filed is displayed. |
|
885 endTime -= TTimeIntervalDays( 1 ); |
|
886 |
|
887 // Set title to 'ALL DAY' |
|
888 iTitleTextId = R_CALEN_EVENT_VIEW_ALLDAY_TITLE; |
|
889 |
|
890 if( CalenDateUtils::OnSameDay(startTime, endTime) ) |
|
891 { |
|
892 AddDateFieldL( startTime ); |
|
893 } |
|
894 else |
|
895 { |
|
896 AddDateDateFieldL( startTime, endTime ); |
|
897 } |
|
898 |
|
899 // extra empty line between primary and secondary information |
|
900 AddEmptyLineL(); |
|
901 |
|
902 // alarm |
|
903 AddAlarmDateTimeFieldL(); |
|
904 |
|
905 // Currently it's not possible to create a repeating day note in the UI. |
|
906 // However, it is possible to import one from an iCalendar file or create |
|
907 // one in code. Therefore the repeat properties of day notes are shown |
|
908 // if they exist. If the entry is modified (in the editor), the repeat |
|
909 // properties will be lost. |
|
910 if(iEventViewData->IsRepeating()) |
|
911 { |
|
912 AddRepeatFieldL(); |
|
913 } |
|
914 |
|
915 } |
|
916 break; |
|
917 |
|
918 case CCalEntry::ETodo: |
|
919 { |
|
920 // extra empty line between primary and secondary information |
|
921 AddEmptyLineL(); |
|
922 |
|
923 // Due date |
|
924 TTime dueDate = iEventViewData->EventDateTime(); |
|
925 AddDateFieldL(R_QTN_CALE_EVENT_VIEW_DUE_DATE, dueDate); |
|
926 // Adds empty line |
|
927 AddEmptyLineL(); |
|
928 |
|
929 //Adds calendar info field to the viewer |
|
930 //AddCalendarInfoFieldL(); |
|
931 |
|
932 // Adds empty line |
|
933 //AddEmptyLineL(); |
|
934 |
|
935 // Alarm is only shown if the todo is not complete. |
|
936 //if (Handler().Entry().StatusL() != CCalEntry::ETodoCompleted) |
|
937 if (iEntry->StatusL() != CCalEntry::ETodoCompleted) |
|
938 { |
|
939 AddAlarmDateTimeFieldL(); |
|
940 } |
|
941 |
|
942 // Show completion date if complete |
|
943 else |
|
944 { |
|
945 AddDateFieldL(R_QTN_CALE_EVENT_VIEW_COMPLETED, iEntry->CompletedTimeL().TimeLocalL()); |
|
946 } |
|
947 |
|
948 // Priority |
|
949 AddPriorityFieldL(); |
|
950 |
|
951 // Repeat rules. Supporting repeating todos sounds like asking for trouble to me. |
|
952 if (iEventViewData->IsRepeating()) |
|
953 { |
|
954 AddRepeatFieldL(); |
|
955 } |
|
956 |
|
957 iTitleTextId = R_CALEN_EVENT_VIEW_TODO_TITLE; |
|
958 } |
|
959 break; |
|
960 |
|
961 default: |
|
962 __ASSERT_DEBUG(EFalse, User::Invariant()); |
|
963 break; |
|
964 } |
|
965 if(IsEventHasMapLocationL()) |
|
966 { |
|
967 // Update iNumOfLinesBeforeLocField |
|
968 CalcNumOfLinesBeforeLocation(); |
|
969 |
|
970 // Add map icon to the icon drawer |
|
971 iconDrawer->AddIconL( MCalenServices::ECalenMapIcon ); |
|
972 |
|
973 // Set the icon sizes |
|
974 iconDrawer->SetIconSizesFromLayout(iNumOfLinesBeforeLocField); |
|
975 } |
|
976 SetIconsL(iconDrawer); |
|
977 |
|
978 // Add Description |
|
979 AddDescriptionFieldL(); |
|
980 |
|
981 // Add attachment field |
|
982 // TODO: Uncomment this when enabling attachment support |
|
983 |
|
984 if(iEventViewData->AttachmentCount()) |
|
985 { |
|
986 AddAttachmentFieldL(); |
|
987 } |
|
988 |
|
989 TRACE_EXIT_POINT; |
|
990 } |
|
991 |
|
992 // ---------------------------------------------------------------------------- |
|
993 // CCalenEventViewContainer::SetLayoutFromLookAndFeelL |
|
994 // Set the layout data |
|
995 // (other items were commented in a header). |
|
996 // ---------------------------------------------------------------------------- |
|
997 // |
|
998 void CCalenEventViewContainer::SetLayoutFromLookAndFeelL() |
|
999 { |
|
1000 TRACE_ENTRY_POINT; |
|
1001 |
|
1002 iParaFormat->Reset(); |
|
1003 iParaFormatMask.ClearAll(); |
|
1004 iCharFormatMask.ClearAll(); |
|
1005 |
|
1006 iParaFormatMask.SetAttrib(EAttLeftMargin); |
|
1007 iParaFormatMask.SetAttrib(EAttRightMargin); |
|
1008 |
|
1009 // Get the main pane |
|
1010 TSize main_pane_size; |
|
1011 AknLayoutUtils::LayoutMetricsSize (AknLayoutUtils::EMainPane, main_pane_size); |
|
1012 TRect main_pane(main_pane_size); |
|
1013 |
|
1014 // Get main_cale_event_viewer_pane with main_pane as parent |
|
1015 TAknLayoutRect main_cale_event_viewer_pane; |
|
1016 main_cale_event_viewer_pane.LayoutRect(main_pane, AknLayoutScalable_Apps::main_cale_event_viewer_pane().LayoutLine() ); |
|
1017 |
|
1018 // Get listscroll_cale_event_viewer_pane with main_cale_event_viewer_pane as parent |
|
1019 TAknLayoutRect listscroll_cale_event_viewer_pane; |
|
1020 listscroll_cale_event_viewer_pane.LayoutRect(main_cale_event_viewer_pane.Rect(), AknLayoutScalable_Apps::listscroll_cale_event_viewer_pane().LayoutLine() ); |
|
1021 |
|
1022 // Get list_cale_ev2_pane with listscroll_cale_event_viewer_pane as parent |
|
1023 TAknLayoutRect list_cale_ev2_pane; |
|
1024 list_cale_ev2_pane.LayoutRect(listscroll_cale_event_viewer_pane.Rect(), AknLayoutScalable_Apps::list_cale_ev2_pane().LayoutLine() ); |
|
1025 |
|
1026 // Get the main pane |
|
1027 TAknLayoutRect main_cale_day_pane; |
|
1028 main_cale_day_pane.LayoutRect( Rect(), |
|
1029 AknLayoutScalable_Apps::main_cale_day_pane().LayoutLine() ); |
|
1030 |
|
1031 TAknLayoutRect listscroll_cale_day_pane; |
|
1032 listscroll_cale_day_pane.LayoutRect( main_cale_day_pane.Rect(), |
|
1033 AknLayoutScalable_Apps::listscroll_cale_day_pane( 0 ).LayoutLine() ); |
|
1034 |
|
1035 iLabel->SetRect(GetLabelRectL()); |
|
1036 |
|
1037 // Listbox layout |
|
1038 TAknLayoutRect list_cale_pane; |
|
1039 list_cale_pane.LayoutRect( main_cale_day_pane.Rect(), AknLayoutScalable_Apps::list_cale_pane( 3 ).LayoutLine() ); |
|
1040 |
|
1041 // Adjust the rect to show the map icon if necessary |
|
1042 TRect temp_list_cale_ev2_pane = list_cale_pane.Rect(); |
|
1043 |
|
1044 |
|
1045 iTextEditor->SetRect(temp_list_cale_ev2_pane); |
|
1046 |
|
1047 // Scrollbar layout |
|
1048 AknLayoutUtils::LayoutVerticalScrollBar( iTextEditor->ScrollBarFrame(), |
|
1049 listscroll_cale_day_pane.Rect(), |
|
1050 AknLayoutScalable_Apps::scroll_pane_cp09( 3 ).LayoutLine() ); |
|
1051 |
|
1052 // Get field_cale_ev2_pane with list_cale_ev2_pane as parent |
|
1053 TAknLayoutRect field_cale_ev2_pane; |
|
1054 field_cale_ev2_pane.LayoutRect(list_cale_ev2_pane.Rect(), AknLayoutScalable_Apps::field_cale_ev2_pane(0).LayoutLine() ); |
|
1055 |
|
1056 // Get field_cale_ev2_pane_t1 |
|
1057 TAknTextLineLayout field_cale_ev2_pane_t1 = AknLayoutScalable_Apps::field_cale_ev2_pane_t1(0).LayoutLine(); |
|
1058 |
|
1059 // Get heading layout properties from field_cale_ev2_pane_t1 with list_cale_ev2_pane as parent |
|
1060 TAknLayoutText headingTextLayout; |
|
1061 headingTextLayout.LayoutText(list_cale_ev2_pane.Rect(), field_cale_ev2_pane_t1); |
|
1062 |
|
1063 // Set heading indenting and font |
|
1064 if (!AknLayoutUtils::LayoutMirrored()) |
|
1065 { |
|
1066 // Normal L-R layout. |
|
1067 // Heading indent is heading text layout rect left x pos - |
|
1068 // text editor rect left xpos. The heading text layout rect gives us an absolute |
|
1069 // screen position, but the value that we need should be relative to |
|
1070 // the text editor itself |
|
1071 TInt headingIndentPixels = headingTextLayout.TextRect().iTl.iX - |
|
1072 list_cale_ev2_pane.Rect().iTl.iX; |
|
1073 iHeadingIndent = PixelsToTwips(headingIndentPixels); |
|
1074 } |
|
1075 else |
|
1076 { |
|
1077 // Mirrored, R-L layout. |
|
1078 // Heading indent is the text editor rect right x pos - |
|
1079 // the heading text layout rect right x pos |
|
1080 TInt headingIndentPixels = list_cale_ev2_pane.Rect().iBr.iX - |
|
1081 headingTextLayout.TextRect().iBr.iX; |
|
1082 iHeadingIndent = PixelsToTwips(headingIndentPixels); |
|
1083 } |
|
1084 |
|
1085 iHeadingFontSpec = headingTextLayout.Font()->FontSpecInTwips(); |
|
1086 iHeadingFontSpec.iFontStyle.SetStrokeWeight(EStrokeWeightBold); |
|
1087 iEmptyLineHeight = PixelsToTwips(headingTextLayout.TextRect().Height() / 2); |
|
1088 iHeadingFont = headingTextLayout.Font(); |
|
1089 |
|
1090 // Get field_cale_ev2_pane_t2 |
|
1091 TAknTextLineLayout field_cale_ev2_pane_t2 = AknLayoutScalable_Apps::field_cale_ev2_pane_t2(1).LayoutLine(); |
|
1092 |
|
1093 // Get body layout properties from field_cale_ev2_pane_t2 // with field_ev_content_pane as parent |
|
1094 TAknLayoutText bodyTextLayout; |
|
1095 bodyTextLayout.LayoutText(list_cale_ev2_pane.Rect(), field_cale_ev2_pane_t2); |
|
1096 iMaxWidth = bodyTextLayout.TextRect().Width(); |
|
1097 |
|
1098 // Set body indenting and font |
|
1099 if (!AknLayoutUtils::LayoutMirrored()) |
|
1100 { |
|
1101 // Normal L-R layout. |
|
1102 // Body text indent is body text layout rect left x pos - |
|
1103 // text editor rect left xpos. The heading text layout rect gives us an absolute |
|
1104 // screen position, but the value that we need should be relative to |
|
1105 // the text editor itself |
|
1106 TInt bodyIndentPixels = bodyTextLayout.TextRect().iTl.iX - |
|
1107 list_cale_ev2_pane.Rect().iTl.iX; |
|
1108 iBodyIndent = PixelsToTwips(bodyIndentPixels); |
|
1109 } |
|
1110 else |
|
1111 { |
|
1112 // Mirrored, R-L layout. |
|
1113 // Body indent is the text editor rect right x pos - |
|
1114 // the body text layout rect right x pos |
|
1115 TInt bodyIndentPixels = list_cale_ev2_pane.Rect().iBr.iX - |
|
1116 bodyTextLayout.TextRect().iBr.iX; |
|
1117 iBodyIndent = PixelsToTwips(bodyIndentPixels); |
|
1118 } |
|
1119 |
|
1120 iBodyFontSpec = bodyTextLayout.Font()->FontSpecInTwips(); |
|
1121 iBodyFont = bodyTextLayout.Font(); // Used for TryToFitL |
|
1122 |
|
1123 TRACE_EXIT_POINT; |
|
1124 } |
|
1125 |
|
1126 // ---------------------------------------------------------------------------- |
|
1127 // CCalenEventViewContainer::SetupFontL |
|
1128 // Set the font colour, and set default para/char format layers to the |
|
1129 // rich text editor. |
|
1130 // (other items were commented in a header). |
|
1131 // ---------------------------------------------------------------------------- |
|
1132 // |
|
1133 void CCalenEventViewContainer::SetupFontL() |
|
1134 { |
|
1135 TRACE_ENTRY_POINT; |
|
1136 |
|
1137 // Set desired character formatting attributes. Gets sensible text colour based on theme. |
|
1138 TRgb textColourFromSkin(255,0,0); // If you see bright red text, the skins api is broken! |
|
1139 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); // Does not transfer ownership. |
|
1140 AknsUtils::GetCachedColor(skin, textColourFromSkin, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6); |
|
1141 |
|
1142 TCharFormat charFormat; |
|
1143 TCharFormatMask charFormatMask; |
|
1144 // Set the text colour we found. |
|
1145 charFormat.iFontPresentation.iTextColor = TLogicalRgb(textColourFromSkin); |
|
1146 charFormatMask.SetAttrib(EAttColor); |
|
1147 |
|
1148 // Set up our paragraph formatting attributes. |
|
1149 CParaFormat* paraFormat = CParaFormat::NewLC(); |
|
1150 TParaFormatMask paraFormatMask; |
|
1151 |
|
1152 // Set up the default font so it's the same as the body text used. |
|
1153 // This means we can do without setting the para/char format layers |
|
1154 // when adding body text. |
|
1155 paraFormat->iLeftMarginInTwips = iBodyIndent; |
|
1156 paraFormatMask.SetAttrib(EAttLeftMargin); |
|
1157 paraFormatMask.SetAttrib(EAttRightMargin); |
|
1158 |
|
1159 charFormat.iFontSpec = iBodyFontSpec; |
|
1160 charFormatMask.SetAttrib(EAttFontHeight); |
|
1161 charFormatMask.SetAttrib(EAttFontTypeface); |
|
1162 charFormatMask.SetAttrib(EAttFontStrokeWeight); |
|
1163 |
|
1164 // Create some format layers based on the attributes we specified above. |
|
1165 // The underlying Edwin will take ownership of the format objects created below, so don't need to delete. |
|
1166 CParaFormatLayer* paraFormatLayer = CParaFormatLayer::NewL(paraFormat, paraFormatMask); |
|
1167 CleanupStack::PushL(paraFormatLayer); |
|
1168 CCharFormatLayer* charFormatLayer = CCharFormatLayer::NewL(charFormat, charFormatMask); |
|
1169 CleanupStack::Pop(paraFormatLayer); |
|
1170 |
|
1171 // Set the format layers. |
|
1172 iTextEditor->SetParaFormatLayer(paraFormatLayer); |
|
1173 iTextEditor->SetCharFormatLayer(charFormatLayer); |
|
1174 |
|
1175 // And get rid of paraFormat. All other allocations are owned by the CEikRichTextEditor. |
|
1176 CleanupStack::PopAndDestroy(paraFormat); |
|
1177 |
|
1178 TRACE_EXIT_POINT; |
|
1179 } |
|
1180 |
|
1181 // ----------------------------------------------------------------------------- |
|
1182 // CCalenViewerBase::PopulateIconDrawerL |
|
1183 // Ask IconDrawer to prepare icons that are going to be drawn |
|
1184 // (other items were commented in a header). |
|
1185 // ----------------------------------------------------------------------------- |
|
1186 // |
|
1187 void CCalenEventViewContainer::PopulateIconDrawerL(CCalenIconDrawer& aIconDrawer) |
|
1188 { |
|
1189 TRACE_ENTRY_POINT; |
|
1190 |
|
1191 // Alarm icon? |
|
1192 if( iEventViewData->IsAlarmActivated() ) |
|
1193 { |
|
1194 // For todos, only add the alarm icon if it's not completed. |
|
1195 if ( iEventViewData->EntryType() == CCalEntry::ETodo ) |
|
1196 { |
|
1197 // if(iEditedCalEntry.StatusL() != CCalEntry::ETodoCompleted) |
|
1198 if(iEntry->StatusL() != CCalEntry::ETodoCompleted) |
|
1199 { |
|
1200 aIconDrawer.AddIconL( MCalenServices::ECalenAlarmIcon ); |
|
1201 } |
|
1202 } |
|
1203 else |
|
1204 { |
|
1205 aIconDrawer.AddIconL( MCalenServices::ECalenAlarmIcon ); |
|
1206 } |
|
1207 } |
|
1208 |
|
1209 // Repeat / exception icon? |
|
1210 if (iEventViewData->IsRepeating()) |
|
1211 { |
|
1212 aIconDrawer.AddIconL( MCalenServices::ECalenRepeatIcon ); |
|
1213 } |
|
1214 else |
|
1215 { |
|
1216 if (iEntry->RecurrenceIdL().TimeUtcL() != Time::NullTTime()) |
|
1217 { |
|
1218 aIconDrawer.AddIconL( MCalenServices::ECalenRepeatExceptionIcon ); |
|
1219 } |
|
1220 } |
|
1221 |
|
1222 // Todo priority icon? |
|
1223 if (iEventViewData->EntryType() == CCalEntry::ETodo) |
|
1224 { |
|
1225 CCalenEntryUtil::TTodoPriority priority = iEventViewData->Priority(); |
|
1226 if (priority == CCalenEntryUtil::ETodoPriorityHigh) |
|
1227 { |
|
1228 aIconDrawer.AddIconL( MCalenServices::ECalenNotePriorityHigh ); |
|
1229 } |
|
1230 else if (priority == CCalenEntryUtil::ETodoPriorityLow) |
|
1231 { |
|
1232 aIconDrawer.AddIconL( MCalenServices::ECalenNotePriorityLow ); |
|
1233 } |
|
1234 else |
|
1235 { |
|
1236 // nothing |
|
1237 } |
|
1238 } |
|
1239 // Set the icon sizes |
|
1240 aIconDrawer.SetIconSizesFromLayout(iNumOfLinesBeforeLocField); |
|
1241 |
|
1242 // Get the icon drawer width |
|
1243 iIconDrawerWidthInPixels = aIconDrawer.WidthInPixels(); |
|
1244 |
|
1245 TRACE_EXIT_POINT; |
|
1246 } |
|
1247 |
|
1248 // ----------------------------------------------------------------------------- |
|
1249 // CCalenEventViewContainer::SetFormatAndAddHeadingL |
|
1250 // |
|
1251 // ----------------------------------------------------------------------------- |
|
1252 // |
|
1253 void CCalenEventViewContainer::SetFormatAndAddHeadingL(const TDesC& aHeading) |
|
1254 { |
|
1255 TRACE_ENTRY_POINT; |
|
1256 |
|
1257 iCharFormatMask.ClearAll(); |
|
1258 iParaFormat->iLeftMarginInTwips = iHeadingIndent; |
|
1259 iCharFormat.iFontSpec = iHeadingFontSpec; |
|
1260 iCharFormatMask.SetAttrib( EAttFontHeight ); |
|
1261 iCharFormatMask.SetAttrib( EAttFontTypeface ); |
|
1262 iCharFormatMask.SetAttrib( EAttFontStrokeWeight ); |
|
1263 AddFormattedTextL( aHeading ); |
|
1264 |
|
1265 TRACE_EXIT_POINT; |
|
1266 } |
|
1267 |
|
1268 // ----------------------------------------------------------------------------- |
|
1269 // CCalenEventViewContainer::SetFormatAndAddBodyL |
|
1270 // |
|
1271 // ----------------------------------------------------------------------------- |
|
1272 // |
|
1273 void CCalenEventViewContainer::SetFormatAndAddBodyL(const TDesC& aBody) |
|
1274 { |
|
1275 TRACE_ENTRY_POINT; |
|
1276 |
|
1277 iCharFormatMask.ClearAll(); |
|
1278 iParaFormat->iLeftMarginInTwips = iBodyIndent; |
|
1279 iCharFormat.iFontSpec = iBodyFontSpec; |
|
1280 iCharFormatMask.SetAttrib( EAttFontHeight ); |
|
1281 iCharFormatMask.SetAttrib( EAttFontTypeface ); |
|
1282 iCharFormatMask.SetAttrib( EAttFontStrokeWeight ); |
|
1283 AddFormattedTextL( aBody ); |
|
1284 |
|
1285 TRACE_EXIT_POINT; |
|
1286 } |
|
1287 |
|
1288 // ----------------------------------------------------------------------------- |
|
1289 // CCalenEventViewContainer::AddEmptyLineL |
|
1290 // |
|
1291 // ----------------------------------------------------------------------------- |
|
1292 // |
|
1293 void CCalenEventViewContainer::AddEmptyLineL() |
|
1294 { |
|
1295 TRACE_ENTRY_POINT; |
|
1296 |
|
1297 CParaFormat* paraFormat = CParaFormat::NewLC(); |
|
1298 TParaFormatMask paraFormatMask; |
|
1299 paraFormat->iLineSpacingControl = CParaFormat::ELineSpacingExactlyInTwips; |
|
1300 paraFormatMask.SetAttrib(EAttLineSpacingControl); |
|
1301 paraFormat->iLineSpacingInTwips = iEmptyLineHeight; |
|
1302 paraFormatMask.SetAttrib(EAttLineSpacing); |
|
1303 paraFormatMask.SetAttrib(EAttFontHighlightColor); |
|
1304 |
|
1305 CRichText* richText = iTextEditor->RichText(); |
|
1306 TInt startPos = richText->DocumentLength(); |
|
1307 richText->InsertL(richText->DocumentLength(), CEditableText::EParagraphDelimiter); |
|
1308 TInt endPos = richText->DocumentLength(); |
|
1309 |
|
1310 richText->ApplyParaFormatL(paraFormat, paraFormatMask, startPos, endPos - startPos); |
|
1311 |
|
1312 CleanupStack::PopAndDestroy(paraFormat); |
|
1313 |
|
1314 TRACE_EXIT_POINT; |
|
1315 } |
|
1316 |
|
1317 // ----------------------------------------------------------------------------- |
|
1318 // CCalenEventViewContainer::AddFormattedTextL |
|
1319 // Add a string to the view. |
|
1320 // (other items were commented in a header). |
|
1321 // ----------------------------------------------------------------------------- |
|
1322 // |
|
1323 void CCalenEventViewContainer::AddFormattedTextL(const TDesC& aText) |
|
1324 { |
|
1325 TRACE_ENTRY_POINT; |
|
1326 |
|
1327 CRichText* richText = iTextEditor->RichText(); |
|
1328 TInt startPos = richText->DocumentLength(); |
|
1329 HBufC* text = HBufC::NewLC( aText.Length() + 10); |
|
1330 TPtr target = text->Des(); |
|
1331 if(AknLayoutUtils::LayoutMirrored()) |
|
1332 { |
|
1333 target.Append(KArabicSummaryMarker); |
|
1334 } |
|
1335 else |
|
1336 { |
|
1337 target.Append(KWesternSummaryMarker); |
|
1338 } |
|
1339 target.Append(aText); |
|
1340 |
|
1341 richText->InsertL(startPos, target); |
|
1342 richText->InsertL(richText->DocumentLength(), CEditableText::EParagraphDelimiter); |
|
1343 TInt endPos = richText->DocumentLength(); |
|
1344 |
|
1345 richText->ApplyCharFormatL(iCharFormat, iCharFormatMask, startPos, endPos - startPos); |
|
1346 ++startPos; // Without this the previous paragraph is formatted as well, ie no indent |
|
1347 richText->ApplyParaFormatL(iParaFormat, iParaFormatMask, startPos, endPos - startPos); |
|
1348 CleanupStack::PopAndDestroy(text); |
|
1349 |
|
1350 TRACE_EXIT_POINT; |
|
1351 } |
|
1352 |
|
1353 // ----------------------------------------------------------------------------- |
|
1354 // CCalenEventViewContainer::AddDescriptionFieldL |
|
1355 // Add a description field to the view. |
|
1356 // (other items were commented in a header). |
|
1357 // ----------------------------------------------------------------------------- |
|
1358 // |
|
1359 void CCalenEventViewContainer::AddDescriptionFieldL() |
|
1360 { |
|
1361 TRACE_ENTRY_POINT; |
|
1362 //Add description |
|
1363 if (iEventViewData->Description() != KNullDesC) |
|
1364 { |
|
1365 AddTextFieldL(R_QTN_CALE_EVENT_VIEW_DESC, iEventViewData->Description()); |
|
1366 // Add in a paragraph delimeter character |
|
1367 // Without this, long descriptions get cut off half way down the last line. |
|
1368 CRichText* richText = iTextEditor->RichText(); |
|
1369 richText->InsertL(richText->DocumentLength(), CEditableText::EParagraphDelimiter); |
|
1370 } |
|
1371 TRACE_EXIT_POINT; |
|
1372 } |
|
1373 |
|
1374 // ----------------------------------------------------------------------------- |
|
1375 // CCalenEventViewContainer::AddSinceFieldL |
|
1376 // Add a since field to the view. |
|
1377 // (other items were commented in a header). |
|
1378 // ----------------------------------------------------------------------------- |
|
1379 // |
|
1380 void CCalenEventViewContainer::AddSinceFieldL() |
|
1381 { |
|
1382 TRACE_ENTRY_POINT; |
|
1383 |
|
1384 // Add since field, if the since year is different from the year of the instance opened. |
|
1385 // TInt instanceYear = Handler().Original().StartDateTime().DateTime().Year(); |
|
1386 TInt instanceYear = iEventViewData->StartDateTime().DateTime().Year(); |
|
1387 TTime seriesTime = ParentEntryL().StartTimeL().TimeLocalL(); |
|
1388 TInt seriesYear = seriesTime.DateTime().Year(); |
|
1389 |
|
1390 if( seriesYear != instanceYear ) |
|
1391 { |
|
1392 TBuf<32> formattedYear; |
|
1393 seriesTime.FormatL(formattedYear, KYearFormatString); |
|
1394 AknTextUtils::DisplayTextLanguageSpecificNumberConversion(formattedYear); |
|
1395 AddTextFieldL(R_QTN_CALE_EVENT_VIEW_SINCE, formattedYear); |
|
1396 } |
|
1397 TRACE_EXIT_POINT; |
|
1398 } |
|
1399 |
|
1400 // ----------------------------------------------------------------------------- |
|
1401 // CCalenEventViewContainer::AddTextFieldL |
|
1402 // Add a text field to the view. |
|
1403 // (other items were commented in a header). |
|
1404 // ----------------------------------------------------------------------------- |
|
1405 // |
|
1406 void CCalenEventViewContainer::AddTextFieldL(TInt aHeadingResource, TInt aBodyResource) |
|
1407 { |
|
1408 TRACE_ENTRY_POINT; |
|
1409 HBufC* textHeading = StringLoader::LoadLC(aHeadingResource); |
|
1410 SetFormatAndAddHeadingL(*textHeading); |
|
1411 CleanupStack::PopAndDestroy(textHeading); |
|
1412 |
|
1413 HBufC* textBody = StringLoader::LoadLC(aBodyResource); |
|
1414 SetFormatAndAddBodyL(*textBody); |
|
1415 CleanupStack::PopAndDestroy(textBody); |
|
1416 TRACE_EXIT_POINT; |
|
1417 } |
|
1418 |
|
1419 // ----------------------------------------------------------------------------- |
|
1420 // CCalenEventViewContainer::AddTextFieldL |
|
1421 // Add a text field to the view. |
|
1422 // (other items were commented in a header). |
|
1423 // ----------------------------------------------------------------------------- |
|
1424 // |
|
1425 void CCalenEventViewContainer::AddTextFieldL(TInt aHeadingResource, const TDesC& aBody) |
|
1426 { |
|
1427 TRACE_ENTRY_POINT; |
|
1428 |
|
1429 HBufC* textHeading = StringLoader::LoadLC(aHeadingResource); |
|
1430 SetFormatAndAddHeadingL(*textHeading); |
|
1431 CleanupStack::PopAndDestroy(textHeading); |
|
1432 |
|
1433 // If the value is empty, put a space in the output so we don't compress the empty line. |
|
1434 if( CalenAgendaUtils::IsEmptyText(aBody) ) |
|
1435 { |
|
1436 SetFormatAndAddBodyL(KSpace); |
|
1437 } |
|
1438 else |
|
1439 { |
|
1440 SetFormatAndAddBodyL(aBody); |
|
1441 } |
|
1442 TRACE_EXIT_POINT; |
|
1443 } |
|
1444 |
|
1445 // ----------------------------------------------------------------------------- |
|
1446 // CCalenEventViewContainer::AddSubjectFieldL |
|
1447 // Adds the entry's subject to the view. |
|
1448 // (other items were commented in a header). |
|
1449 // ----------------------------------------------------------------------------- |
|
1450 // |
|
1451 void CCalenEventViewContainer::AddSubjectFieldL() |
|
1452 { |
|
1453 TRACE_ENTRY_POINT; |
|
1454 |
|
1455 iParaFormat->iRightMarginInTwips = PixelsToTwips(iIconDrawerWidthInPixels); |
|
1456 if (iEventViewData->Summary() != KNullDesC) |
|
1457 { |
|
1458 SetFormatAndAddHeadingL(iEventViewData->Summary()); |
|
1459 } |
|
1460 else |
|
1461 { |
|
1462 HBufC* untitled = StringLoader::LoadLC(R_QTN_CALE_EVENT_VIEW_EMPTY_SUBJECT); |
|
1463 SetFormatAndAddHeadingL(*untitled); |
|
1464 CleanupStack::PopAndDestroy(untitled); |
|
1465 } |
|
1466 iParaFormat->iRightMarginInTwips = KDefaultRightMargin; |
|
1467 |
|
1468 TRACE_EXIT_POINT; |
|
1469 } |
|
1470 |
|
1471 // ----------------------------------------------------------------------------- |
|
1472 // CCalenEventViewContainer::AddLocationFieldL |
|
1473 // Adds the entry's location to the view. |
|
1474 // (other items were commented in a header). |
|
1475 // ----------------------------------------------------------------------------- |
|
1476 // |
|
1477 void CCalenEventViewContainer::AddLocationFieldL() |
|
1478 { |
|
1479 TRACE_ENTRY_POINT; |
|
1480 |
|
1481 |
|
1482 |
|
1483 iParaFormat->iRightMarginInTwips = PixelsToTwips(20); |
|
1484 if (iEventViewData->Location() != KNullDesC ) |
|
1485 { |
|
1486 SetFormatAndAddBodyL(iEventViewData->Location()); |
|
1487 } |
|
1488 iParaFormat->iRightMarginInTwips = KDefaultRightMargin; |
|
1489 TRACE_EXIT_POINT; |
|
1490 } |
|
1491 |
|
1492 // ----------------------------------------------------------------------------- |
|
1493 // CCalenEventViewContainer::AddPriorityFieldL |
|
1494 // Reads the priority from the entry and adds a field to the form accordingly. |
|
1495 // (other items were commented in a header). |
|
1496 // ----------------------------------------------------------------------------- |
|
1497 // |
|
1498 void CCalenEventViewContainer::AddPriorityFieldL() |
|
1499 { |
|
1500 TRACE_ENTRY_POINT; |
|
1501 |
|
1502 CCalenEntryUtil::TTodoPriority priority = iEventViewData->Priority(); |
|
1503 |
|
1504 // Don't add the priority field if it's normal priority. |
|
1505 if( priority != CCalenEntryUtil::ETodoPriorityNormal ) |
|
1506 { |
|
1507 CDesCArrayFlat* priorities = ControlEnv()->ReadDesCArrayResourceL(R_CALE_EVENT_VIEW_TODO_PRIORITY); |
|
1508 CleanupStack::PushL(priorities); |
|
1509 const TDesC& priorityText = (*priorities)[CalendarPriorityToFormPriority(priority)]; |
|
1510 AddTextFieldL(R_QTN_CALE_EVENT_VIEW_PRIO, priorityText); |
|
1511 CleanupStack::PopAndDestroy(); // priorities |
|
1512 } |
|
1513 TRACE_EXIT_POINT; |
|
1514 } |
|
1515 |
|
1516 |
|
1517 // ----------------------------------------------------------------------------- |
|
1518 // CCalenEventViewContainer::AddTimeFieldL |
|
1519 // Add a time field to the form. |
|
1520 // (other items were commented in a header). |
|
1521 // ----------------------------------------------------------------------------- |
|
1522 // |
|
1523 void CCalenEventViewContainer::AddTimeFieldL(TInt aLabelResource, const TTime& aTime) |
|
1524 { |
|
1525 TRACE_ENTRY_POINT; |
|
1526 |
|
1527 TBuf<32> formattedTime; |
|
1528 aTime.FormatL(formattedTime, *iTimeFormat); |
|
1529 AknTextUtils::DisplayTextLanguageSpecificNumberConversion(formattedTime); |
|
1530 AddTextFieldL(aLabelResource, formattedTime); |
|
1531 |
|
1532 TRACE_EXIT_POINT; |
|
1533 } |
|
1534 |
|
1535 // ----------------------------------------------------------------------------- |
|
1536 // CCalenEventViewContainer::AddDateFieldL |
|
1537 // Add a date field to the form. |
|
1538 // (other items were commented in a header). |
|
1539 // ----------------------------------------------------------------------------- |
|
1540 // |
|
1541 void CCalenEventViewContainer::AddDateFieldL(const TTime& aDate) |
|
1542 { |
|
1543 TRACE_ENTRY_POINT; |
|
1544 |
|
1545 TBuf<32> formattedDate; |
|
1546 aDate.FormatL(formattedDate, *iDateFormat); |
|
1547 AknTextUtils::DisplayTextLanguageSpecificNumberConversion(formattedDate); |
|
1548 SetFormatAndAddBodyL(formattedDate); |
|
1549 |
|
1550 TRACE_EXIT_POINT; |
|
1551 } |
|
1552 |
|
1553 // ----------------------------------------------------------------------------- |
|
1554 // CCalenEventViewContainer::AddDateFieldL |
|
1555 // Add a date field to the form. |
|
1556 // (other items were commented in a header). |
|
1557 // ----------------------------------------------------------------------------- |
|
1558 // |
|
1559 void CCalenEventViewContainer::AddDateFieldL(TInt aHeadingResource, const TTime& aDate) |
|
1560 { |
|
1561 TRACE_ENTRY_POINT; |
|
1562 |
|
1563 HBufC* textHeading = StringLoader::LoadLC(aHeadingResource); |
|
1564 SetFormatAndAddHeadingL(*textHeading); |
|
1565 CleanupStack::PopAndDestroy(textHeading); |
|
1566 AddDateFieldL(aDate); |
|
1567 |
|
1568 TRACE_EXIT_POINT; |
|
1569 } |
|
1570 // ----------------------------------------------------------------------------- |
|
1571 // CCalenEventViewContainer::AddDateFieldL |
|
1572 // Add a field to the form in the format "DATE - DATE". |
|
1573 // (other items were commented in a header). |
|
1574 // ----------------------------------------------------------------------------- |
|
1575 // |
|
1576 void CCalenEventViewContainer::AddDateDateFieldL(const TTime& aStartDate, const TTime& aEndDate) |
|
1577 { |
|
1578 TRACE_ENTRY_POINT; |
|
1579 |
|
1580 CDesCArrayFlat* strings = new CDesCArrayFlat( 2 ); |
|
1581 CleanupStack::PushL( strings ); |
|
1582 |
|
1583 TBuf<KMaxDateLength> firstDate; |
|
1584 aStartDate.FormatL( firstDate, *iDateFormat ); |
|
1585 AknTextUtils::DisplayTextLanguageSpecificNumberConversion(firstDate); |
|
1586 strings->AppendL( firstDate ); |
|
1587 |
|
1588 TBuf<KMaxDateLength> secondDate; |
|
1589 aEndDate.FormatL( secondDate, *iDateFormat ); |
|
1590 AknTextUtils::DisplayTextLanguageSpecificNumberConversion(secondDate); |
|
1591 strings->AppendL( secondDate ); |
|
1592 |
|
1593 HBufC* stringholder = StringLoader::LoadL( R_QTN_CALE_EVENT_VIEW_VALID_LIMITED, *strings ); |
|
1594 CleanupStack::PopAndDestroy( strings ); |
|
1595 CleanupStack::PushL( stringholder ); |
|
1596 |
|
1597 SetFormatAndAddBodyL(*stringholder); |
|
1598 CleanupStack::PopAndDestroy(stringholder); |
|
1599 |
|
1600 TRACE_EXIT_POINT; |
|
1601 } |
|
1602 |
|
1603 // ----------------------------------------------------------------------------- |
|
1604 // CCalenEventViewContainer::AddAlarmDateAndTimeFieldL |
|
1605 // Add a date and time field to the form, in the ordering according to |
|
1606 // localisation (date followed by the time). |
|
1607 // (other items were commented in a header). |
|
1608 // ----------------------------------------------------------------------------- |
|
1609 // |
|
1610 void CCalenEventViewContainer::AddAlarmDateAndTimeFieldL( const TTime& aTime ) |
|
1611 { |
|
1612 TRACE_ENTRY_POINT; |
|
1613 |
|
1614 CDesCArrayFlat* strings = new CDesCArrayFlat( 2 ); |
|
1615 CleanupStack::PushL( strings ); |
|
1616 |
|
1617 TBuf<KMaxDateLength> formattedTime; |
|
1618 aTime.FormatL( formattedTime, *iTimeFormat ); |
|
1619 AknTextUtils::DisplayTextLanguageSpecificNumberConversion(formattedTime); |
|
1620 strings->AppendL( formattedTime ); |
|
1621 |
|
1622 TBuf<KMaxDateLength> formattedDate; |
|
1623 aTime.FormatL( formattedDate, *iDateFormat ); |
|
1624 AknTextUtils::DisplayTextLanguageSpecificNumberConversion(formattedDate); |
|
1625 strings->AppendL( formattedDate ); |
|
1626 |
|
1627 HBufC* stringholder = StringLoader::LoadL( R_QTN_CALE_EVENT_VIEW_ALARM_TIME, *strings ); |
|
1628 CleanupStack::PopAndDestroy( strings ); |
|
1629 CleanupStack::PushL( stringholder ); |
|
1630 |
|
1631 AddTextFieldL( R_QTN_CALE_EVENT_VIEW_ALARM, *stringholder ); |
|
1632 CleanupStack::PopAndDestroy( stringholder ); |
|
1633 |
|
1634 TRACE_EXIT_POINT; |
|
1635 } |
|
1636 |
|
1637 // ----------------------------------------------------------------------------- |
|
1638 // CCalenEventViewContainer::AddAlarmDateTimeFieldL |
|
1639 // Reads the alarm from the entry and add a field containing its date-time. |
|
1640 // If the alarm is on the same day as the entry, only the time is shown. |
|
1641 // If no alarm is present, the field is not shown |
|
1642 // (other items were commented in a header). |
|
1643 // ----------------------------------------------------------------------------- |
|
1644 // |
|
1645 void CCalenEventViewContainer::AddAlarmDateTimeFieldL() |
|
1646 { |
|
1647 TRACE_ENTRY_POINT; |
|
1648 if( iEventViewData->IsAlarmActivated() ) |
|
1649 { |
|
1650 TTime alarmTime = iEventViewData->AlarmDateTime(); |
|
1651 alarmTime = CalenDateUtils::LimitToValidTime( alarmTime ); |
|
1652 |
|
1653 // If alarm is on the same day as the entry, AND the meeting only lasts one day, |
|
1654 // just show the alarm time and not the date. |
|
1655 if( CalenDateUtils::OnSameDay( alarmTime, iEventViewData->StartDateTime() ) && |
|
1656 CalenDateUtils::OnSameDay( iEventViewData->StartDateTime(), iEventViewData->EndDateTime() ) ) |
|
1657 { |
|
1658 // On same day, only show time. |
|
1659 AddTimeFieldL( R_QTN_CALE_EVENT_VIEW_ALARM, alarmTime ); |
|
1660 } |
|
1661 else |
|
1662 { |
|
1663 // Different days, show both date and time. |
|
1664 AddAlarmDateAndTimeFieldL( alarmTime ); |
|
1665 } |
|
1666 } |
|
1667 TRACE_EXIT_POINT; |
|
1668 } |
|
1669 |
|
1670 // ----------------------------------------------------------------------------- |
|
1671 // CCalenEventViewContainer::GetMinAndMaxTimesL |
|
1672 // Find the maximum and minimum times from the given array. |
|
1673 // (other items were commented in a header). |
|
1674 // ----------------------------------------------------------------------------- |
|
1675 // |
|
1676 void CCalenEventViewContainer::GetMinAndMaxTimesL( RArray<TCalTime>& aTimes, |
|
1677 TCalTime& aMinTime, |
|
1678 TCalTime& aMaxTime ) |
|
1679 { |
|
1680 TRACE_ENTRY_POINT; |
|
1681 |
|
1682 TInt minIndex=0; |
|
1683 TInt maxIndex=0; |
|
1684 |
|
1685 for( TInt i=1; i<aTimes.Count(); ++i ) |
|
1686 { |
|
1687 if( aTimes[i].TimeUtcL() > aTimes[maxIndex].TimeUtcL() ) |
|
1688 { |
|
1689 maxIndex = i; |
|
1690 } |
|
1691 else |
|
1692 { |
|
1693 if( aTimes[i].TimeUtcL() < aTimes[minIndex].TimeUtcL() ) |
|
1694 { |
|
1695 minIndex = i; |
|
1696 } |
|
1697 } |
|
1698 } |
|
1699 |
|
1700 aMinTime = aTimes[minIndex]; |
|
1701 aMaxTime = aTimes[maxIndex]; |
|
1702 |
|
1703 TRACE_EXIT_POINT; |
|
1704 } |
|
1705 // ----------------------------------------------------------------------------- |
|
1706 // CCalenEventViewContainer::RemoveDuplicateTimesL |
|
1707 // If there is more than one time at the same time, leave only one in the array. |
|
1708 // (other items were commented in a header). |
|
1709 // ----------------------------------------------------------------------------- |
|
1710 // |
|
1711 void CCalenEventViewContainer::RemoveDuplicateTimesL( RArray<TCalTime>& aTimes ) |
|
1712 { |
|
1713 TRACE_ENTRY_POINT; |
|
1714 |
|
1715 for( TInt i=0; i<aTimes.Count(); ++i ) |
|
1716 { |
|
1717 for( TInt j=aTimes.Count()-1; j>i; --j ) |
|
1718 { |
|
1719 if( aTimes[i].TimeUtcL() == aTimes[j].TimeUtcL() ) |
|
1720 { |
|
1721 aTimes.Remove( j ); |
|
1722 } |
|
1723 } |
|
1724 } |
|
1725 |
|
1726 TRACE_EXIT_POINT; |
|
1727 } |
|
1728 |
|
1729 // ----------------------------------------------------------------------------- |
|
1730 // CCalenEventViewContainer::RemoveExcludedTimesL |
|
1731 // From the given array of start dates, remove any which match up with an |
|
1732 // exception date and also have no child associated with them. |
|
1733 // (other items were commented in a header). |
|
1734 // ----------------------------------------------------------------------------- |
|
1735 // |
|
1736 void CCalenEventViewContainer::RemoveExcludedTimesL( RArray<TCalTime>& aStartDates, |
|
1737 RArray<TCalTime>& aExDates, |
|
1738 RPointerArray<CCalEntry>& aChildEntries ) |
|
1739 { |
|
1740 TRACE_ENTRY_POINT; |
|
1741 |
|
1742 for( TInt i=0; i<aExDates.Count(); ++i ) |
|
1743 { |
|
1744 for( TInt j=aStartDates.Count()-1; j>=0; --j ) |
|
1745 { |
|
1746 if( aStartDates[j].TimeUtcL() == aExDates[i].TimeUtcL() ) |
|
1747 { |
|
1748 TBool hasChild = EFalse; |
|
1749 for( TInt k=0; k<aChildEntries.Count(); ++k ) |
|
1750 { |
|
1751 if( aChildEntries[k]->RecurrenceIdL().TimeUtcL() == aStartDates[j].TimeUtcL() ) |
|
1752 { |
|
1753 hasChild = ETrue; |
|
1754 break; |
|
1755 } |
|
1756 } |
|
1757 |
|
1758 if( !hasChild ) |
|
1759 { |
|
1760 aStartDates.Remove( j ); |
|
1761 break; |
|
1762 } |
|
1763 } |
|
1764 } |
|
1765 } |
|
1766 |
|
1767 TRACE_EXIT_POINT; |
|
1768 } |
|
1769 |
|
1770 // ---------------------------------------------------- |
|
1771 // CCalenEventViewContainer::CalendaryPriorityToFormPriority |
|
1772 // Convert replication to confidentiality |
|
1773 // (other items were commented in a header). |
|
1774 // ---------------------------------------------------- |
|
1775 // |
|
1776 TInt CCalenEventViewContainer::CalendarPriorityToFormPriority(CCalenEntryUtil::TTodoPriority aCalPriority) |
|
1777 { |
|
1778 TRACE_ENTRY_POINT; |
|
1779 // Calendar priority is in same order as resource, starting from one number lower. |
|
1780 TRACE_EXIT_POINT; |
|
1781 return aCalPriority-1; |
|
1782 } |
|
1783 |
|
1784 // ----------------------------------------------------------------------------- |
|
1785 // CCalenEventViewContainer::TryToFitL |
|
1786 // Returns ETrue if the given string fits into aMaxWidth, |
|
1787 // using the font aFont - EFalse otherwise |
|
1788 // (other items were commented in a header). |
|
1789 // ----------------------------------------------------------------------------- |
|
1790 // |
|
1791 TBool CCalenEventViewContainer::TryToFitL( const TDesC& aStr, TInt aMaxWidth, const CFont& aFont ) |
|
1792 { |
|
1793 TRACE_ENTRY_POINT; |
|
1794 |
|
1795 TInt width = aFont.TextWidthInPixels(aStr); |
|
1796 // We add one because it seems the edwin wrapping doesn't quite agree with CFont's width. |
|
1797 ++width; |
|
1798 |
|
1799 TRACE_EXIT_POINT; |
|
1800 return width < aMaxWidth; |
|
1801 } |
|
1802 |
|
1803 // ----------------------------------------------------------------------------- |
|
1804 // CCalenEventViewContainer::PixelsToTwips |
|
1805 // Convert pixels to twips |
|
1806 // (other items were commented in a header). |
|
1807 // ----------------------------------------------------------------------------- |
|
1808 // |
|
1809 TInt CCalenEventViewContainer::PixelsToTwips(TInt aPixels) |
|
1810 { |
|
1811 TRACE_ENTRY_POINT; |
|
1812 |
|
1813 CWindowGc& windowGc = ControlEnv()->SystemGc(); |
|
1814 TInt twips = windowGc.Device()->HorizontalPixelsToTwips(aPixels); |
|
1815 |
|
1816 TRACE_EXIT_POINT; |
|
1817 return twips; |
|
1818 } |
|
1819 |
|
1820 // ----------------------------------------------------------------------------- |
|
1821 // CCalenEventViewContainer::GetSeriesRepeatInformationL |
|
1822 // Attempts to calculate the start and end dates of the series by looking at the |
|
1823 // given entry's RDates and RRule. If these dates have successfully been |
|
1824 // calculated, the function returns ETrue, or EFalse otherwise. |
|
1825 // (other items were commented in a header). |
|
1826 // ----------------------------------------------------------------------------- |
|
1827 // |
|
1828 TBool CCalenEventViewContainer::GetSeriesRepeatInformationL( CCalEntry& aEntry, |
|
1829 TCalenRepeatIndex& aRepeatIndex, |
|
1830 TTime& aSeriesStart, |
|
1831 TTime& aSeriesEnd ) |
|
1832 { |
|
1833 TRACE_ENTRY_POINT; |
|
1834 |
|
1835 TBool success; |
|
1836 |
|
1837 RArray<TCalTime> rdates; |
|
1838 CleanupClosePushL( rdates ); |
|
1839 |
|
1840 aEntry.GetRDatesL(rdates); |
|
1841 |
|
1842 if( rdates.Count() ) |
|
1843 { |
|
1844 // Calculate the start and end dates from the RDates. |
|
1845 |
|
1846 // We need to expand the RDates. This involves getting all the instance start dates, |
|
1847 // then removing any start date with an exdate but no modifying child for that instance. |
|
1848 // Include the entry start date in this, as that counts as part of the series. |
|
1849 rdates.AppendL( aEntry.StartTimeL() ); |
|
1850 |
|
1851 RemoveDuplicateTimesL( rdates ); |
|
1852 |
|
1853 RArray<TCalTime> exdates; |
|
1854 CleanupClosePushL( exdates ); |
|
1855 aEntry.GetExceptionDatesL( exdates ); |
|
1856 if( exdates.Count() ) |
|
1857 { |
|
1858 RemoveExcludedTimesL( rdates, exdates, AllInstancesL() ); |
|
1859 } |
|
1860 CleanupStack::PopAndDestroy( &exdates ); |
|
1861 |
|
1862 TCalRRule rrule; |
|
1863 if( iEntry->GetRRuleL(rrule) ) |
|
1864 { |
|
1865 // Hopefully no UI would create an entry with an RRule as well as RDates. |
|
1866 // Although the spec says it's possible, Calendar certainly can't. |
|
1867 // We have a vague go at including the RRule in the min/max date but |
|
1868 // don't bother removing exdates from it as we would then need to expand |
|
1869 // every instance of the RRule. |
|
1870 rdates.AppendL( rrule.DtStart() ); |
|
1871 rdates.AppendL( rrule.Until() ); |
|
1872 RemoveDuplicateTimesL( rdates ); |
|
1873 } |
|
1874 |
|
1875 // The true instance dates should be in the 'rdates' array. Now we just need |
|
1876 // the minimum and maximum times from here. |
|
1877 TCalTime min, max; |
|
1878 GetMinAndMaxTimesL( rdates, min, max ); |
|
1879 aSeriesStart = min.TimeLocalL(); |
|
1880 aSeriesEnd = max.TimeLocalL(); |
|
1881 |
|
1882 // Set the repeat type to "Other" for rdates. |
|
1883 aRepeatIndex = ERepeatOther; |
|
1884 success = ETrue; |
|
1885 } |
|
1886 else |
|
1887 { |
|
1888 TCalRRule rrule; |
|
1889 if( aEntry.GetRRuleL( rrule ) ) |
|
1890 { |
|
1891 // This 'switch' differs slightly from CalenNoteDataUtil::RepeatIndex in |
|
1892 // that we are a bit more generous in awarding repeat types instead of |
|
1893 // falling back to 'other' repeat type. |
|
1894 aRepeatIndex = ERepeatOther; |
|
1895 switch( rrule.Type() ) |
|
1896 { |
|
1897 case TCalRRule::EDaily: |
|
1898 { |
|
1899 if( rrule.Interval() == 1 ) |
|
1900 { |
|
1901 aRepeatIndex = ERepeatDaily; |
|
1902 } |
|
1903 else if( rrule.Interval() == 7 ) |
|
1904 { |
|
1905 aRepeatIndex = ERepeatWeekly; |
|
1906 } |
|
1907 else if( rrule.Interval() == 14 ) |
|
1908 { |
|
1909 aRepeatIndex = ERepeatBiWeekly; |
|
1910 } |
|
1911 else |
|
1912 { |
|
1913 // nothing |
|
1914 } |
|
1915 } |
|
1916 break; |
|
1917 |
|
1918 case TCalRRule::EWeekly: |
|
1919 { |
|
1920 TInt repeatInterval( rrule.Interval() ); |
|
1921 TBool status; |
|
1922 status = CalenNoteDataUtil::IsWorkdaysRepeatingL( rrule ); |
|
1923 if(status) |
|
1924 { |
|
1925 aRepeatIndex = ERepeatWorkdays ; |
|
1926 } |
|
1927 else |
|
1928 { |
|
1929 switch( repeatInterval ) |
|
1930 { |
|
1931 case 1: aRepeatIndex = ERepeatWeekly; |
|
1932 break; |
|
1933 case 2: aRepeatIndex = ERepeatBiWeekly; |
|
1934 break; |
|
1935 default:break; |
|
1936 } |
|
1937 } |
|
1938 } |
|
1939 break; |
|
1940 |
|
1941 case TCalRRule::EMonthly: |
|
1942 { |
|
1943 if( rrule.Interval() == 1 ) |
|
1944 { |
|
1945 aRepeatIndex = ERepeatMonthly; |
|
1946 } |
|
1947 } |
|
1948 break; |
|
1949 |
|
1950 case TCalRRule::EYearly: |
|
1951 { |
|
1952 if( rrule.Interval() == 1 ) |
|
1953 { |
|
1954 aRepeatIndex = ERepeatYearly; |
|
1955 } |
|
1956 } |
|
1957 break; |
|
1958 default: |
|
1959 break; |
|
1960 } |
|
1961 |
|
1962 aSeriesStart = rrule.DtStart().TimeLocalL(); |
|
1963 aSeriesEnd = rrule.Until().TimeLocalL(); |
|
1964 success = ETrue; |
|
1965 } |
|
1966 else |
|
1967 { |
|
1968 // No repeat information. |
|
1969 success = EFalse; |
|
1970 } |
|
1971 } |
|
1972 |
|
1973 CleanupStack::PopAndDestroy( &rdates ); |
|
1974 |
|
1975 return success; |
|
1976 |
|
1977 TRACE_EXIT_POINT; |
|
1978 } |
|
1979 |
|
1980 // ----------------------------------------------------------------------------- |
|
1981 // CCalenEventViewContainer::AddRepeatFieldL |
|
1982 // Add repeat text field to the |
|
1983 // (other items were commented in a header). |
|
1984 // ----------------------------------------------------------------------------- |
|
1985 // |
|
1986 void CCalenEventViewContainer::AddRepeatFieldL() |
|
1987 { |
|
1988 TRACE_ENTRY_POINT; |
|
1989 // Get the repeat rule from the entry. If this is a child entry, |
|
1990 // find the parent and get the repeat rule from that. |
|
1991 TCalRRule rrule; |
|
1992 TCalenRepeatIndex repeatIndex; |
|
1993 // 'start' is the start time of the series, not the start time of the instance we are viewing |
|
1994 TTime start; |
|
1995 TTime until; |
|
1996 |
|
1997 if( !GetSeriesRepeatInformationL( *iEntry, repeatIndex, start, until ) ) |
|
1998 { |
|
1999 // An entry with no RDates or RRule but a non-null recurrence id. |
|
2000 // This entry is a child. We have to get the parent to see the repeat information. |
|
2001 // We assert here - a parent really should have some form of repeat information. |
|
2002 __ASSERT_ALWAYS( GetSeriesRepeatInformationL( ParentEntryL(), repeatIndex, start, until ), |
|
2003 User::Invariant() ); |
|
2004 } |
|
2005 |
|
2006 // Set repIndex to be the resource used for the heading. |
|
2007 // This will be "Repeats daily", "Repeats weekly" etc. |
|
2008 TInt repIndex = -1; |
|
2009 |
|
2010 switch(repeatIndex) |
|
2011 { |
|
2012 case ERepeatDaily: |
|
2013 repIndex = R_QTN_CALE_EVENT_VIEW_REPEAT_DAILY; |
|
2014 break; |
|
2015 case ERepeatWeekly: |
|
2016 repIndex = R_QTN_CALE_EVENT_VIEW_REPEAT_WEEKLY; |
|
2017 break; |
|
2018 case ERepeatBiWeekly: |
|
2019 repIndex = R_QTN_CALE_EVENT_VIEW_REPEAT_FORTNIGHTLY; |
|
2020 break; |
|
2021 case ERepeatMonthly: |
|
2022 repIndex = R_QTN_CALE_EVENT_VIEW_REPEAT_MONTHLY; |
|
2023 break; |
|
2024 case ERepeatYearly: |
|
2025 repIndex = R_QTN_CALE_EVENT_VIEW_REPEAT_YEARLY; |
|
2026 break; |
|
2027 case ERepeatWorkdays: |
|
2028 repIndex = R_QTN_CALE_EVENT_VIEW_REPEAT_WORKDAYS; |
|
2029 break; |
|
2030 case ERepeatOther: |
|
2031 repIndex = R_QTN_CALE_EVENT_VIEW_REPEAT_OTHER; |
|
2032 break; |
|
2033 default: |
|
2034 ASSERT(EFalse); |
|
2035 break; |
|
2036 } |
|
2037 |
|
2038 TBuf<64> dateString; |
|
2039 |
|
2040 // Infinite repeat if repeat until is on or after the max time, or if repeat until is null. |
|
2041 TBool finiteRepeat = until < CalenDateUtils::BeginningOfDay( CalenDateUtils::MaxTime() ) |
|
2042 && until != Time::NullTTime(); |
|
2043 |
|
2044 if( finiteRepeat ) |
|
2045 { |
|
2046 // Finite repeat, string (e.g.) "17/01/2006 - 27/01/2006" |
|
2047 CDesCArrayFlat* strings = new CDesCArrayFlat( 2 ); |
|
2048 CleanupStack::PushL( strings ); |
|
2049 |
|
2050 TBuf<KMaxDateLength> formattedTime; |
|
2051 start.FormatL( formattedTime, *iDateFormat ); |
|
2052 AknTextUtils::DisplayTextLanguageSpecificNumberConversion(formattedTime); |
|
2053 strings->AppendL( formattedTime ); |
|
2054 |
|
2055 TBuf<KMaxDateLength> formattedDate; |
|
2056 until.FormatL( formattedDate, *iDateFormat ); |
|
2057 AknTextUtils::DisplayTextLanguageSpecificNumberConversion(formattedDate); |
|
2058 strings->AppendL( formattedDate ); |
|
2059 |
|
2060 HBufC* stringholder = StringLoader::LoadL( R_QTN_CALE_EVENT_VIEW_VALID_LIMITED, *strings ); |
|
2061 CleanupStack::PopAndDestroy( strings ); |
|
2062 CleanupStack::PushL( stringholder ); |
|
2063 |
|
2064 AddTextFieldL( repIndex, *stringholder ); |
|
2065 CleanupStack::PopAndDestroy( stringholder ); |
|
2066 } |
|
2067 else |
|
2068 { |
|
2069 // Repeats forever, string (e.g.) "From 17/01/2006" |
|
2070 CDesCArrayFlat* strings = new CDesCArrayFlat( 1 ); |
|
2071 CleanupStack::PushL( strings ); |
|
2072 |
|
2073 TBuf<KMaxDateLength> formattedTime; |
|
2074 start.FormatL( formattedTime, *iDateFormat ); |
|
2075 AknTextUtils::DisplayTextLanguageSpecificNumberConversion(formattedTime); |
|
2076 strings->AppendL( formattedTime ); |
|
2077 |
|
2078 HBufC* stringholder = StringLoader::LoadL( R_QTN_CALE_EVENT_VIEW_VALID_FOREVER, *strings ); |
|
2079 CleanupStack::PopAndDestroy( strings ); |
|
2080 CleanupStack::PushL( stringholder ); |
|
2081 |
|
2082 AddTextFieldL( repIndex, *stringholder ); |
|
2083 CleanupStack::PopAndDestroy( stringholder ); |
|
2084 } |
|
2085 |
|
2086 TRACE_EXIT_POINT; |
|
2087 } |
|
2088 |
|
2089 // ----------------------------------------------------------------------------- |
|
2090 // CCalenEventViewContainer::AddTimeFieldL |
|
2091 // Add entry time field text to the |
|
2092 // (other items were commented in a header). |
|
2093 // ----------------------------------------------------------------------------- |
|
2094 // |
|
2095 void CCalenEventViewContainer::AddTimeFieldL() |
|
2096 { |
|
2097 TRACE_ENTRY_POINT; |
|
2098 |
|
2099 // If the start time is on the same day as the end time, just show the date. |
|
2100 // Otherwise, show "start date - end date". |
|
2101 TTime startTime = iEventViewData->StartDateTime(); |
|
2102 TTime endTime = iEventViewData->EndDateTime(); |
|
2103 iTimeFieldLines = 1; // Increment the value to be considered while drawing the map icon |
|
2104 TBuf<64> concatString; |
|
2105 |
|
2106 if( CalenDateUtils::OnSameDay(startTime, endTime) ) |
|
2107 { |
|
2108 // String looks like (e.g.) "14:00 - 16:00 17/01/2006" |
|
2109 CDesCArrayFlat* strings = new CDesCArrayFlat( 3 ); |
|
2110 CleanupStack::PushL( strings ); |
|
2111 |
|
2112 TBuf<KMaxDateLength> formattedStartTime; |
|
2113 startTime.FormatL( formattedStartTime, *iTimeFormat ); |
|
2114 AknTextUtils::DisplayTextLanguageSpecificNumberConversion(formattedStartTime); |
|
2115 strings->AppendL( formattedStartTime ); |
|
2116 |
|
2117 TBuf<KMaxDateLength> formattedEndTime; |
|
2118 endTime.FormatL( formattedEndTime, *iTimeFormat ); |
|
2119 AknTextUtils::DisplayTextLanguageSpecificNumberConversion(formattedEndTime); |
|
2120 strings->AppendL( formattedEndTime ); |
|
2121 |
|
2122 TBuf<KMaxDateLength> formattedStartDate; |
|
2123 startTime.FormatL( formattedStartDate, *iDateFormat ); |
|
2124 AknTextUtils::DisplayTextLanguageSpecificNumberConversion(formattedStartDate); |
|
2125 strings->AppendL( formattedStartDate ); |
|
2126 |
|
2127 HBufC* stringholder = StringLoader::LoadLC( R_QTN_CALE_EVENT_VIEW_TIME_DAY, *strings ); |
|
2128 |
|
2129 TBool fits = TryToFitL(*stringholder, iMaxWidth, *iBodyFont); |
|
2130 if (fits) |
|
2131 { |
|
2132 SetFormatAndAddBodyL(*stringholder); |
|
2133 } |
|
2134 else |
|
2135 { |
|
2136 iTimeFieldLines++; // Increment the value to be considered while drawing the map icon |
|
2137 HBufC* wrappedStringholder = StringLoader::LoadLC( R_QTN_CALE_EVENT_VIEW_TIME_DAY_WRAPPED, *strings ); |
|
2138 SetFormatAndAddBodyL(*wrappedStringholder); |
|
2139 CleanupStack::PopAndDestroy(wrappedStringholder); |
|
2140 } |
|
2141 |
|
2142 CleanupStack::PopAndDestroy( stringholder ); |
|
2143 CleanupStack::PopAndDestroy( strings ); |
|
2144 } |
|
2145 else |
|
2146 { |
|
2147 // String looks like (e.g.) "14:00 16/01/2006 - 16:00 19/01/2006" |
|
2148 CDesCArrayFlat* strings = new CDesCArrayFlat( 3 ); |
|
2149 CleanupStack::PushL( strings ); |
|
2150 |
|
2151 TBuf<KMaxDateLength> formattedStartTime; |
|
2152 startTime.FormatL( formattedStartTime, *iTimeFormat ); |
|
2153 AknTextUtils::DisplayTextLanguageSpecificNumberConversion(formattedStartTime); |
|
2154 strings->AppendL( formattedStartTime ); |
|
2155 |
|
2156 TBuf<KMaxDateLength> formattedStartDate; |
|
2157 startTime.FormatL( formattedStartDate, *iDateFormat ); |
|
2158 AknTextUtils::DisplayTextLanguageSpecificNumberConversion(formattedStartDate); |
|
2159 strings->AppendL( formattedStartDate ); |
|
2160 |
|
2161 TBuf<KMaxDateLength> formattedEndTime; |
|
2162 endTime.FormatL( formattedEndTime, *iTimeFormat ); |
|
2163 AknTextUtils::DisplayTextLanguageSpecificNumberConversion(formattedEndTime); |
|
2164 strings->AppendL( formattedEndTime ); |
|
2165 |
|
2166 TBuf<KMaxDateLength> formattedEndDate; |
|
2167 endTime.FormatL( formattedEndDate, *iDateFormat ); |
|
2168 AknTextUtils::DisplayTextLanguageSpecificNumberConversion(formattedEndDate); |
|
2169 strings->AppendL( formattedEndDate ); |
|
2170 |
|
2171 HBufC* stringholder = StringLoader::LoadLC( R_QTN_CALE_EVENT_VIEW_TIME_DAYS, *strings ); |
|
2172 |
|
2173 TBool fits = TryToFitL(*stringholder, iMaxWidth, *iBodyFont); |
|
2174 if (fits) |
|
2175 { |
|
2176 SetFormatAndAddBodyL(*stringholder); |
|
2177 } |
|
2178 else |
|
2179 { |
|
2180 iTimeFieldLines++; |
|
2181 HBufC* wrappedStringholder = StringLoader::LoadLC( R_QTN_CALE_EVENT_VIEW_TIME_DAYS_WRAPPED, *strings ); |
|
2182 SetFormatAndAddBodyL(*wrappedStringholder); |
|
2183 CleanupStack::PopAndDestroy(wrappedStringholder); |
|
2184 } |
|
2185 |
|
2186 CleanupStack::PopAndDestroy( stringholder ); |
|
2187 CleanupStack::PopAndDestroy( strings ); |
|
2188 } |
|
2189 |
|
2190 TRACE_EXIT_POINT; |
|
2191 } |
|
2192 |
|
2193 // ----------------------------------------------------------------------------- |
|
2194 // CCalenEventViewContainer::MopSupplyObject |
|
2195 // Pass the skin information |
|
2196 // (other items were commented in a header). |
|
2197 // ----------------------------------------------------------------------------- |
|
2198 // |
|
2199 TTypeUid::Ptr CCalenEventViewContainer::MopSupplyObject( TTypeUid aId ) |
|
2200 { |
|
2201 return MAknsControlContext::SupplyMopObject( aId, iBgContext ); |
|
2202 } |
|
2203 |
|
2204 |
|
2205 // ----------------------------------------------------------------------------- |
|
2206 // CCalenEventViewContainer::BuildSearchBufferL |
|
2207 // Generate the text string to use for text searches |
|
2208 // (other items were commented in a header). |
|
2209 // ----------------------------------------------------------------------------- |
|
2210 // |
|
2211 void CCalenEventViewContainer::BuildSearchBufferL() |
|
2212 { |
|
2213 TRACE_ENTRY_POINT; |
|
2214 |
|
2215 // Get the full text from the form to use for search API. |
|
2216 TInt textLength = iTextEditor->RichText()->DocumentLength(); |
|
2217 |
|
2218 // Delete any existing search buffer |
|
2219 if (iSearchBuf) |
|
2220 { |
|
2221 delete iSearchBuf; |
|
2222 iSearchBuf = NULL; |
|
2223 } |
|
2224 |
|
2225 // Text searched is currently summary , location and description |
|
2226 iSearchBuf = HBufC::NewL(textLength); |
|
2227 TPtr searchPtr = iSearchBuf->Des(); |
|
2228 GetTextFieldsFromFormL(searchPtr); |
|
2229 |
|
2230 TRACE_EXIT_POINT; |
|
2231 } |
|
2232 |
|
2233 // ----------------------------------------------------------------------------- |
|
2234 // CCalenEventViewContainer::GetTextFieldsFromFormL |
|
2235 // Gets the text fields from the form into a descriptor for |
|
2236 // the find api to use. |
|
2237 // Currently uses subject, location and description only |
|
2238 // (other items were commented in a header). |
|
2239 // ----------------------------------------------------------------------------- |
|
2240 // |
|
2241 void CCalenEventViewContainer::GetTextFieldsFromFormL(TDes& aDesc) |
|
2242 { |
|
2243 TRACE_ENTRY_POINT; |
|
2244 |
|
2245 aDesc.Append(iEventViewData->Summary()); |
|
2246 aDesc.Append(_L(" \r\n")); |
|
2247 aDesc.Append(iEventViewData->Location()); |
|
2248 aDesc.Append(_L(" \r\n")); |
|
2249 aDesc.Append(iEventViewData->Description()); |
|
2250 aDesc.Append(_L(" \r\n")); |
|
2251 |
|
2252 TRACE_EXIT_POINT; |
|
2253 } |
|
2254 |
|
2255 // ----------------------------------------------------------------------------- |
|
2256 // CCalenEventViewContainer::GetTitleTextId |
|
2257 // Gets the title text resource |
|
2258 // ----------------------------------------------------------------------------- |
|
2259 // |
|
2260 TInt CCalenEventViewContainer::GetTitleTextId() |
|
2261 { |
|
2262 TRACE_ENTRY_POINT; |
|
2263 TRACE_EXIT_POINT; |
|
2264 return iTitleTextId; |
|
2265 } |
|
2266 |
|
2267 // ----------------------------------------------------------------------------- |
|
2268 // CCalenEventViewContainer::ParentEntryL |
|
2269 // Returns the parent entry of the entry being edited. |
|
2270 // (other items were commented in a header). |
|
2271 // ----------------------------------------------------------------------------- |
|
2272 // |
|
2273 CCalEntry& CCalenEventViewContainer::ParentEntryL() |
|
2274 { |
|
2275 TRACE_ENTRY_POINT; |
|
2276 MCalenContext& context = iServices.Context(); |
|
2277 |
|
2278 if(iFetchedEntries.Count() == 0) |
|
2279 { |
|
2280 iServices.EntryViewL(context.InstanceId().iColId)->FetchL( iEntry->UidL(), iFetchedEntries ); |
|
2281 } |
|
2282 __ASSERT_ALWAYS( iFetchedEntries.Count() > 0, User::Panic(_L("CCalenEventViewContainer::ParentEntryL"),EPanicArrayOfSizeZero)); |
|
2283 |
|
2284 TRACE_EXIT_POINT; |
|
2285 return *iFetchedEntries[0]; |
|
2286 } |
|
2287 |
|
2288 // ----------------------------------------------------------------------------- |
|
2289 // CCalenEventViewContainer::AllInstancesL |
|
2290 // Returns all the instances associated with the entry being edited. |
|
2291 // (other items were commented in a header). |
|
2292 // ----------------------------------------------------------------------------- |
|
2293 // |
|
2294 RPointerArray<CCalEntry>& CCalenEventViewContainer::AllInstancesL() |
|
2295 { |
|
2296 TRACE_ENTRY_POINT; |
|
2297 MCalenContext& context = iServices.Context(); |
|
2298 |
|
2299 if(iFetchedEntries.Count() == 0) |
|
2300 { |
|
2301 iServices.EntryViewL(context.InstanceId().iColId)->FetchL( iEntry->UidL(), iFetchedEntries ); |
|
2302 } |
|
2303 |
|
2304 TRACE_EXIT_POINT; |
|
2305 return iFetchedEntries; |
|
2306 } |
|
2307 |
|
2308 // ----------------------------------------------------------------------------- |
|
2309 // CCalenEventViewContainer::GetEventViewData |
|
2310 // Gets the Event View Data |
|
2311 // ----------------------------------------------------------------------------- |
|
2312 // |
|
2313 CCalenEntryUtil* CCalenEventViewContainer::GetEventViewData() |
|
2314 { |
|
2315 TRACE_ENTRY_POINT; |
|
2316 TRACE_EXIT_POINT; |
|
2317 return iEventViewData; |
|
2318 } |
|
2319 |
|
2320 // ----------------------------------------------------------------------------- |
|
2321 // CCalenEventViewContainer::ReadAutoHlCenRepValueAndSetNotifyL |
|
2322 // |
|
2323 // ----------------------------------------------------------------------------- |
|
2324 // |
|
2325 void CCalenEventViewContainer::ReadAutoHlCenRepValueAndSetNotifyL() |
|
2326 { |
|
2327 TRACE_ENTRY_POINT; |
|
2328 |
|
2329 if ( iAutomaticHlInitialized ) |
|
2330 return; |
|
2331 |
|
2332 // Create the session |
|
2333 iCenRepSession = CRepository::NewL( KCRUidCommonUi ); |
|
2334 |
|
2335 if( iCenRepSession ) |
|
2336 { |
|
2337 // Get the value of AutomaticHighlight key |
|
2338 iCenRepSession->Get( KCuiAutomaticHighlight, iAutomaticHlValue ); |
|
2339 // Create the notifer |
|
2340 iNotifier = |
|
2341 CCenRepNotifyHandler::NewL( |
|
2342 *this, *iCenRepSession, CCenRepNotifyHandler::EIntKey, |
|
2343 KCuiAutomaticHighlight ); |
|
2344 // Start listening |
|
2345 iNotifier->StartListeningL(); |
|
2346 } |
|
2347 |
|
2348 iAutomaticHlInitialized = ETrue; // Done once per viewer |
|
2349 |
|
2350 TRACE_EXIT_POINT; |
|
2351 } |
|
2352 |
|
2353 // ----------------------------------------------------------------------------- |
|
2354 // CCalenEventViewContainer::HandleNotifyInt |
|
2355 // Handles the incoming notifications of key changes |
|
2356 // ----------------------------------------------------------------------------- |
|
2357 // |
|
2358 void CCalenEventViewContainer::HandleNotifyInt( TUint32 /*aId*/, TInt aNewValue ) |
|
2359 { |
|
2360 TRACE_ENTRY_POINT; |
|
2361 |
|
2362 // Notifies changes on KCuiAutomaticHighlight |
|
2363 TRAPD(error,SetAutomaticHighlightL( aNewValue )); |
|
2364 if ( error != KErrNone ) |
|
2365 { |
|
2366 User::Panic(_L("CCalenEventViewContainer"),error); |
|
2367 } |
|
2368 TRACE_EXIT_POINT; |
|
2369 } |
|
2370 |
|
2371 |
|
2372 void CCalenEventViewContainer::HandleNotifyError( TUint32 /*aId*/,TInt /*aError*/, |
|
2373 CCenRepNotifyHandler* /*aHandler*/ ) |
|
2374 { |
|
2375 TRACE_ENTRY_POINT; |
|
2376 |
|
2377 if( iNotifier ) |
|
2378 { |
|
2379 iNotifier->StopListening(); |
|
2380 delete iNotifier; |
|
2381 iNotifier = NULL; |
|
2382 } |
|
2383 |
|
2384 delete iCenRepSession; |
|
2385 iCenRepSession = NULL; |
|
2386 |
|
2387 TRACE_EXIT_POINT; |
|
2388 } |
|
2389 |
|
2390 // ----------------------------------------------------------------------------- |
|
2391 // CCalenEventViewContainer::SetAutomaticHighlightL |
|
2392 // ----------------------------------------------------------------------------- |
|
2393 // |
|
2394 void CCalenEventViewContainer::SetAutomaticHighlightL( const TBool aSwitchON ) |
|
2395 { |
|
2396 TRACE_ENTRY_POINT; |
|
2397 |
|
2398 if ( iAutoFinder ) |
|
2399 { |
|
2400 // content highlight |
|
2401 if ( aSwitchON ) |
|
2402 { // switch ON |
|
2403 iAutoFinder->SetFindModeL( |
|
2404 CItemFinder::EPhoneNumber | |
|
2405 CItemFinder::EUrlAddress | |
|
2406 CItemFinder::EEmailAddress ); |
|
2407 |
|
2408 } |
|
2409 else |
|
2410 { // switch OFF |
|
2411 iAutoFinder->SetFindModeL( |
|
2412 CItemFinder::ENoneSelected ); |
|
2413 |
|
2414 } |
|
2415 } |
|
2416 |
|
2417 TRACE_EXIT_POINT; |
|
2418 } |
|
2419 |
|
2420 // ----------------------------------------------------------------------------- |
|
2421 // CCalenEventViewContainer::GetItemFinder |
|
2422 // ----------------------------------------------------------------------------- |
|
2423 // |
|
2424 CItemFinder* CCalenEventViewContainer::GetItemFinder() |
|
2425 { |
|
2426 TRACE_ENTRY_POINT; |
|
2427 TRACE_EXIT_POINT; |
|
2428 |
|
2429 return iAutoFinder; |
|
2430 } |
|
2431 // ----------------------------------------------------------------------------- |
|
2432 // CCalenEventViewContainer::GetFindItemMenu |
|
2433 // ----------------------------------------------------------------------------- |
|
2434 // |
|
2435 CFindItemMenu* CCalenEventViewContainer::GetFindItemMenu() |
|
2436 { |
|
2437 TRACE_ENTRY_POINT; |
|
2438 TRACE_EXIT_POINT; |
|
2439 |
|
2440 return iFindMenu; |
|
2441 } |
|
2442 |
|
2443 // ----------------------------------------------------------------------------- |
|
2444 // CCalenEventViewContainer::HandleScrollEventL |
|
2445 // Handles scroll events |
|
2446 // ----------------------------------------------------------------------------- |
|
2447 // |
|
2448 void CCalenEventViewContainer::HandleScrollEventL(CEikScrollBar* aScrollBar, |
|
2449 TEikScrollEvent aEventType) |
|
2450 { |
|
2451 TRACE_ENTRY_POINT; |
|
2452 |
|
2453 iTextEditor->HandleScrollEventL(aScrollBar,aEventType); |
|
2454 |
|
2455 TRACE_EXIT_POINT; |
|
2456 } |
|
2457 |
|
2458 // ----------------------------------------------------------------------------- |
|
2459 // CCalenEventViewContainer::HandleStopCommandL |
|
2460 // Handles scroll events |
|
2461 // ----------------------------------------------------------------------------- |
|
2462 // |
|
2463 void CCalenEventViewContainer::HandleStopCommandL() |
|
2464 { |
|
2465 TRACE_ENTRY_POINT; |
|
2466 |
|
2467 CCalenEventView* eventView = static_cast<CCalenEventView*>( iView ); |
|
2468 |
|
2469 eventView->HandleCommandL( ECalenStopAlarm ); |
|
2470 |
|
2471 TRACE_EXIT_POINT; |
|
2472 } |
|
2473 |
|
2474 // ---------------------------------------------------------------------------- |
|
2475 // CCalenEventViewContainer::IsEventHasMapLocationOrNoLocationTextL |
|
2476 // Stores the necessary information in the context |
|
2477 // and returns ETrue if event has geo coordinates else EFalse |
|
2478 // ---------------------------------------------------------------------------- |
|
2479 TBool CCalenEventViewContainer::IsEventHasMapLocationL() |
|
2480 { |
|
2481 CCalGeoValue* geoValue = iEntry->GeoValueL(); |
|
2482 if(geoValue) |
|
2483 { |
|
2484 delete geoValue; |
|
2485 return ETrue; |
|
2486 } |
|
2487 else |
|
2488 { |
|
2489 return EFalse; |
|
2490 } |
|
2491 } |
|
2492 |
|
2493 // ---------------------------------------------------------------------------- |
|
2494 // CCalenEventViewContainer::IsEventHasNoLocationTextL |
|
2495 // Returns ETrue if event has location text else EFalse |
|
2496 // ---------------------------------------------------------------------------- |
|
2497 TBool CCalenEventViewContainer::IsEventHasNoLocationTextL() |
|
2498 { |
|
2499 TPtrC location = iEntry->LocationL(); |
|
2500 if(!location.Length()) |
|
2501 { |
|
2502 return ETrue; |
|
2503 } |
|
2504 else |
|
2505 { |
|
2506 return EFalse; |
|
2507 } |
|
2508 } |
|
2509 |
|
2510 // ---------------------------------------------------------------------------- |
|
2511 // CCalenEventView::OnLocaleChangedL |
|
2512 // (other items were commented in a header). |
|
2513 // ---------------------------------------------------------------------------- |
|
2514 // |
|
2515 void CCalenEventViewContainer::HandleLocaleChangedL(/* TInt aReason */) |
|
2516 { |
|
2517 TRACE_ENTRY_POINT; |
|
2518 |
|
2519 iLocaleChanged = ETrue; |
|
2520 |
|
2521 TRACE_EXIT_POINT; |
|
2522 } |
|
2523 |
|
2524 // ----------------------------------------------------------------------------- |
|
2525 // CCalenEventViewContainer::AddCalendarInfoFieldL |
|
2526 // Adds calendar info field to the viewer |
|
2527 // ----------------------------------------------------------------------------- |
|
2528 // |
|
2529 void CCalenEventViewContainer::AddCalendarInfoFieldL() |
|
2530 { |
|
2531 TRACE_ENTRY_POINT; |
|
2532 TCalCollectionId colId = iServices.Context().InstanceId().iColId; |
|
2533 |
|
2534 RPointerArray<CCalCalendarInfo> calendarInfoList; |
|
2535 iServices.GetAllCalendarInfoL(calendarInfoList); |
|
2536 CleanupClosePushL(calendarInfoList); |
|
2537 |
|
2538 HBufC* calendarFileName = iServices.GetCalFileNameForCollectionId(colId).AllocLC(); |
|
2539 TInt index = calendarInfoList.Find( *calendarFileName, |
|
2540 CCalenEventViewContainer::CalendarInfoIdentifierL); |
|
2541 CleanupStack::PopAndDestroy(calendarFileName); |
|
2542 if(index != KErrNotFound) |
|
2543 { |
|
2544 // add the calendar info's text field |
|
2545 AddTextFieldL( |
|
2546 R_CALE_VIEWER_CALENDAR_INFO, calendarInfoList[index]->NameL()); |
|
2547 } |
|
2548 CleanupStack::PopAndDestroy(&calendarInfoList); |
|
2549 TRACE_EXIT_POINT; |
|
2550 } |
|
2551 |
|
2552 // ----------------------------------------------------------------------------- |
|
2553 // CCalenEventViewContainer::CalendarInfoIdentifierL |
|
2554 // Searches for the index in calendar info list based on calendar file name |
|
2555 // ----------------------------------------------------------------------------- |
|
2556 // |
|
2557 TBool CCalenEventViewContainer::CalendarInfoIdentifierL( const HBufC* aName, |
|
2558 const CCalCalendarInfo& aCalendarInfo) |
|
2559 { |
|
2560 TRACE_ENTRY_POINT; |
|
2561 TBool retVal = EFalse; |
|
2562 HBufC* calendarFileName = aCalendarInfo.FileNameL().AllocLC(); |
|
2563 retVal = calendarFileName->CompareF(*aName); |
|
2564 CleanupStack::PopAndDestroy(calendarFileName); |
|
2565 TRACE_EXIT_POINT; |
|
2566 return (!retVal); |
|
2567 } |
|
2568 |
|
2569 // ---------------------------------------------------------------------------- |
|
2570 // CCalenEventViewContainer::LabelRectL |
|
2571 // Returns the available label rect for this container |
|
2572 // ---------------------------------------------------------------------------- |
|
2573 TRect CCalenEventViewContainer::GetLabelRectL() |
|
2574 { |
|
2575 TRACE_ENTRY_POINT; |
|
2576 |
|
2577 // Get the main pane |
|
2578 TAknLayoutRect main_cale_day_pane; |
|
2579 main_cale_day_pane.LayoutRect( Rect(), |
|
2580 AknLayoutScalable_Apps::main_cale_day_pane().LayoutLine() ); |
|
2581 |
|
2582 TAknLayoutRect listscroll_cale_day_pane; |
|
2583 listscroll_cale_day_pane.LayoutRect( main_cale_day_pane.Rect(), |
|
2584 AknLayoutScalable_Apps::listscroll_cale_day_pane(1).LayoutLine() ); |
|
2585 |
|
2586 // Create a dummy label to find the layout rect |
|
2587 CEikLabel* dummyLabel = new( ELeave ) CEikLabel; |
|
2588 CleanupStack::PushL( dummyLabel ); |
|
2589 |
|
2590 |
|
2591 AknLayoutUtils::LayoutLabel( dummyLabel, listscroll_cale_day_pane.Rect(), |
|
2592 AknLayoutScalable_Apps::listscroll_cale_day_pane_t1( 0 ).LayoutLine() ); |
|
2593 |
|
2594 TRect labelRect = dummyLabel->Rect(); |
|
2595 |
|
2596 // Discard the label |
|
2597 CleanupStack::PopAndDestroy( dummyLabel ); |
|
2598 |
|
2599 TRACE_EXIT_POINT; |
|
2600 return labelRect; |
|
2601 } |
|
2602 // ---------------------------------------------------------------------------- |
|
2603 // CCalenEventViewContainer::SetLabelContentL |
|
2604 // ---------------------------------------------------------------------------- |
|
2605 // |
|
2606 void CCalenEventViewContainer::SetLabelContentL( CEikLabel& aLabel ) |
|
2607 { |
|
2608 TRACE_ENTRY_POINT; |
|
2609 const CFont* labelFont = NULL; |
|
2610 labelFont = AknLayoutUtils::FontFromId(EAknLogicalFontPrimarySmallFont,NULL); |
|
2611 aLabel.SetFont( labelFont ); |
|
2612 aLabel.SetLabelAlignment(ELayoutAlignLeft); |
|
2613 aLabel.OverrideColorL( EColorLabelTextEmphasis, KRgbBlack ); |
|
2614 |
|
2615 // get the multiple db data from services |
|
2616 RPointerArray<CCalCalendarInfo> calendarInfoList; |
|
2617 iServices.GetAllCalendarInfoL(calendarInfoList); |
|
2618 CleanupClosePushL(calendarInfoList); |
|
2619 |
|
2620 TCalCollectionId colId; |
|
2621 colId = iServices.Context().InstanceId().iColId; |
|
2622 |
|
2623 HBufC* calendarFileName = iServices.GetCalFileNameForCollectionId(colId).AllocLC(); |
|
2624 TInt calIndex = calendarInfoList.Find( *calendarFileName, |
|
2625 CCalenEventViewContainer::CalendarInfoIdentifierL); |
|
2626 CleanupStack::PopAndDestroy(calendarFileName); |
|
2627 |
|
2628 if(calIndex != KErrNotFound) |
|
2629 { |
|
2630 // add the calendar info's text field |
|
2631 aLabel.SetTextL(calendarInfoList[calIndex]->NameL()); |
|
2632 |
|
2633 TInt calendarColor = calendarInfoList[calIndex]->Color().Value(); |
|
2634 aLabel.OverrideColorL( EColorLabelHighlightFullEmphasis, calendarColor ); |
|
2635 |
|
2636 // Increment the iNumOfLinesBeforeLocField so that map icon is drwan at proper place |
|
2637 iNumOfLinesBeforeLocField = 1; |
|
2638 } |
|
2639 CleanupStack::PopAndDestroy(&calendarInfoList); |
|
2640 |
|
2641 aLabel.CropText(); |
|
2642 aLabel.SetEmphasis( CEikLabel::EFullEmphasis ); |
|
2643 TRACE_EXIT_POINT; |
|
2644 } |
|
2645 |
|
2646 // ---------------------------------------------------------------------------- |
|
2647 // CCalenEventViewContainer::AddAttachmentFieldL |
|
2648 // Adds attachment field |
|
2649 // ---------------------------------------------------------------------------- |
|
2650 // |
|
2651 void CCalenEventViewContainer::AddAttachmentFieldL() |
|
2652 { |
|
2653 TRACE_ENTRY_POINT; |
|
2654 |
|
2655 // format and add heading "Attachment:" |
|
2656 HBufC* textHeading = StringLoader::LoadLC(R_CALE_EVENT_VIEW_ATTACHMENT_INFO); |
|
2657 SetFormatAndAddHeadingL(*textHeading); |
|
2658 CleanupStack::PopAndDestroy(textHeading); |
|
2659 |
|
2660 |
|
2661 |
|
2662 RPointerArray<HBufC> attachmentNames; |
|
2663 |
|
2664 iEventViewData->AttachmentNamesL(attachmentNames); |
|
2665 TInt attachmentsCount = attachmentNames.Count(); |
|
2666 |
|
2667 //Reset the attachment posiitons array before addign them |
|
2668 iAttachmentPosInfoArray.Reset(); |
|
2669 |
|
2670 for(TInt i = 0; i < attachmentsCount; i++) |
|
2671 { |
|
2672 AddAttachmentNameL(*attachmentNames[i]); |
|
2673 } |
|
2674 // Add in a paragraph delimeter character |
|
2675 // Without this, long descriptions get cut off half way down the last line. |
|
2676 CRichText* richText = iTextEditor->RichText(); |
|
2677 richText->InsertL(richText->DocumentLength(), CEditableText::EParagraphDelimiter); |
|
2678 attachmentNames.ResetAndDestroy(); |
|
2679 |
|
2680 TRACE_EXIT_POINT; |
|
2681 } |
|
2682 |
|
2683 // ----------------------------------------------------------------------------- |
|
2684 // CCalenEventViewContainer::AddFormattedTextL |
|
2685 // Add a string to the view. |
|
2686 // (other items were commented in a header). |
|
2687 // ----------------------------------------------------------------------------- |
|
2688 // |
|
2689 void CCalenEventViewContainer::AddAttachmentNameL(const TDesC& aText) |
|
2690 { |
|
2691 TRACE_ENTRY_POINT; |
|
2692 |
|
2693 // Set the charatcer formats and paragraph formats |
|
2694 iCharFormatMask.ClearAll(); |
|
2695 iParaFormat->iLeftMarginInTwips = iBodyIndent; |
|
2696 iCharFormat.iFontSpec = iBodyFontSpec; |
|
2697 iCharFormat.iFontPresentation.iUnderline = EUnderlineOn; |
|
2698 iCharFormatMask.SetAttrib(EAttFontUnderline); |
|
2699 iCharFormatMask.SetAttrib(EAttFontHeight); |
|
2700 iCharFormatMask.SetAttrib(EAttFontTypeface) ; |
|
2701 iCharFormatMask.SetAttrib(EAttFontStrokeWeight); |
|
2702 |
|
2703 // Add the text into the richtext document |
|
2704 CRichText* richText = iTextEditor->RichText(); |
|
2705 TInt startPos = richText->DocumentLength(); |
|
2706 HBufC* text = HBufC::NewLC( aText.Length() + 10); |
|
2707 TPtr target = text->Des(); |
|
2708 if(AknLayoutUtils::LayoutMirrored()) |
|
2709 { |
|
2710 target.Append(KArabicSummaryMarker); |
|
2711 } |
|
2712 else |
|
2713 { |
|
2714 target.Append(KWesternSummaryMarker); |
|
2715 } |
|
2716 target.Append(aText); |
|
2717 target.Append(KAttachmentSeparator); // Append the attachment seperator |
|
2718 TTextPos posInfo; |
|
2719 posInfo.iDocStart = richText->DocumentLength(); |
|
2720 richText->InsertL(startPos, target); |
|
2721 posInfo.iDocEnd = richText->DocumentLength(); |
|
2722 iAttachmentPosInfoArray.Append(posInfo); |
|
2723 TInt endPos = richText->DocumentLength(); |
|
2724 richText->ApplyCharFormatL(iCharFormat, iCharFormatMask, startPos, (endPos - startPos - 1)); |
|
2725 ++startPos; // Without this the previous paragraph is formatted as well, ie no indent |
|
2726 richText->ApplyParaFormatL(iParaFormat, iParaFormatMask, startPos, (endPos - startPos - 1)); |
|
2727 CleanupStack::PopAndDestroy(text); |
|
2728 |
|
2729 TRACE_EXIT_POINT; |
|
2730 } |
|
2731 |
|
2732 // ---------------------------------------------------------------------------- |
|
2733 // CCalenEventViewContainer::OpenViewerL() |
|
2734 // Opens the attachment in the Viewer |
|
2735 // ---------------------------------------------------------------------------- |
|
2736 // |
|
2737 void CCalenEventViewContainer::OpenViewerL(TInt attachmentToBeOpened) |
|
2738 { |
|
2739 // Update the Attahcment model with the attahcments of the current entry |
|
2740 iServices.GetAttachmentData()->CheckForExistingAttachmentsL(iEntry); |
|
2741 |
|
2742 // Get the file handler |
|
2743 RFile file = iServices.GetAttachmentData()->GetAttachmentFileL( attachmentToBeOpened ); |
|
2744 |
|
2745 // Hide the toolbar before opening the attachment |
|
2746 MCalenToolbar* toolbar = iServices.ToolbarOrNull(); |
|
2747 if(toolbar && toolbar->IsVisible()) |
|
2748 { |
|
2749 toolbar->SetToolbarVisibilityL(EFalse); |
|
2750 } |
|
2751 |
|
2752 //open the attachment |
|
2753 OpenAttachmentViewerL(file, *this); |
|
2754 |
|
2755 // Unhide the toolbar after coming back |
|
2756 if(toolbar) |
|
2757 { |
|
2758 toolbar->SetToolbarVisibilityL(ETrue); |
|
2759 } |
|
2760 } |
|
2761 |
|
2762 // ---------------------------------------------------------------------------- |
|
2763 // CCalenEventViewContainer::HandleServerAppExit |
|
2764 // (other items were commented in a header). |
|
2765 // ---------------------------------------------------------------------------- |
|
2766 // |
|
2767 void CCalenEventViewContainer::HandleServerAppExit( TInt aReason) |
|
2768 { |
|
2769 TRACE_ENTRY_POINT; |
|
2770 |
|
2771 if (aReason == EAknCmdExit) |
|
2772 { |
|
2773 //issue this notification, which will be handled by attachmentui. |
|
2774 } |
|
2775 |
|
2776 TRACE_EXIT_POINT; |
|
2777 } |
|
2778 |
|
2779 // ---------------------------------------------------------------------------- |
|
2780 // CCalenEventViewContainer::CheckAndOpenTappedAttachment |
|
2781 // Checks if it is tapped on any attachment, if yes, then opens that attachment |
|
2782 // (other items were commented in a header). |
|
2783 // ---------------------------------------------------------------------------- |
|
2784 // |
|
2785 void CCalenEventViewContainer::CheckAndOpenTappedAttachment(TTmPosInfo2* posInfo) |
|
2786 { |
|
2787 // iterate through iAttachmentPosInfoArray to see if posInfo falls in any of the range |
|
2788 TInt attachmentToBeOpened = -1; |
|
2789 for(TInt i = 0; i < iAttachmentPosInfoArray.Count(); i++) |
|
2790 { |
|
2791 if( (posInfo->iDocPos.iPos >= iAttachmentPosInfoArray[i].iDocStart) && ( posInfo->iDocPos.iPos < iAttachmentPosInfoArray[i].iDocEnd )) |
|
2792 { |
|
2793 attachmentToBeOpened = i; |
|
2794 break; |
|
2795 } |
|
2796 } |
|
2797 if(attachmentToBeOpened != -1) |
|
2798 { |
|
2799 OpenViewerL(attachmentToBeOpened); |
|
2800 } |
|
2801 } |
|
2802 |
|
2803 // ---------------------------------------------------------------------------- |
|
2804 // CCalenEventViewContainer::CalcNumOfLinesBeforeLocation |
|
2805 // Calculates the number of line before locaiton field in the document of the rich text editor |
|
2806 // (other items were commented in a header). |
|
2807 // ---------------------------------------------------------------------------- |
|
2808 // |
|
2809 void CCalenEventViewContainer::CalcNumOfLinesBeforeLocation() |
|
2810 { |
|
2811 TRACE_ENTRY_POINT; |
|
2812 |
|
2813 CCalGeoValue* geoValue = iEntry->GeoValueL(); |
|
2814 if(geoValue) |
|
2815 { |
|
2816 // Get the count of lines before location field |
|
2817 // so that map icon is drwan exactly at the firlst line of location text on the event viewer |
|
2818 HBufC* visualText = NULL; |
|
2819 CArrayFixFlat<TInt>* lineWidths = new( ELeave )CArrayFixFlat<TInt>( 5 ); |
|
2820 CleanupStack::PushL( lineWidths ); |
|
2821 lineWidths->AppendL(iMaxWidth - iIconDrawerWidthInPixels); |
|
2822 // trim of enter keys entered at the end of the summary text, |
|
2823 TBuf<160> summary; |
|
2824 summary.Append(iEventViewData->Summary()); |
|
2825 TChar ch = 0x2029; // For Enter key |
|
2826 TInt length = iEventViewData->Summary().Length(); |
|
2827 TInt count = 0; |
|
2828 |
|
2829 while( length > 0 ) |
|
2830 { |
|
2831 if(summary[--length] == ch) |
|
2832 { |
|
2833 count++; |
|
2834 summary.Copy(summary.Left(length)); // trim off the enter key |
|
2835 } |
|
2836 } |
|
2837 |
|
2838 // Count the number of lines summary will occupy after squeezing enter keys at the end of the text |
|
2839 CArrayFixFlat<TPtrC>* textLines = new(ELeave)CArrayFixFlat<TPtrC>(5); |
|
2840 CleanupStack::PushL( textLines ); |
|
2841 visualText = AknBidiTextUtils::ConvertToVisualAndWrapToArrayWholeTextL(summary , |
|
2842 *lineWidths, |
|
2843 *iHeadingFont, |
|
2844 *textLines); |
|
2845 iNumOfLinesBeforeLocField += textLines->Count() + iTimeFieldLines; // Added for time and date field |
|
2846 if (iEventViewData->Summary() == KNullDesC) // If summary is NULL, then <Unnamed> will be added as first line, hence, increment it |
|
2847 { |
|
2848 iNumOfLinesBeforeLocField++; |
|
2849 } |
|
2850 iNumOfLinesBeforeLocField += count; // Add the number of enter keys added at the end of the summary |
|
2851 iTimeFieldLines = 0; // Reset the value |
|
2852 CleanupStack::PopAndDestroy(textLines); |
|
2853 CleanupStack::PopAndDestroy(lineWidths); |
|
2854 delete visualText; |
|
2855 delete geoValue; |
|
2856 } |
|
2857 } |
|
2858 |
|
2859 // ----------------------------------------------------------------------------- |
|
2860 // CCalenCommonUI::FindPossibleInstanceL |
|
2861 // Finds an instance with the given instance id and instance view. |
|
2862 // (other items were commented in a header). |
|
2863 // ----------------------------------------------------------------------------- |
|
2864 // |
|
2865 CCalInstance* CCalenEventViewContainer::FindPossibleInstanceL( |
|
2866 const TCalenInstanceId& aId, |
|
2867 CCalInstanceView& aInstanceView ) |
|
2868 { |
|
2869 TRACE_ENTRY_POINT; |
|
2870 |
|
2871 RPointerArray<CCalInstance> instances; |
|
2872 CleanupResetAndDestroyPushL( instances ); |
|
2873 |
|
2874 //If timezone is changed we need to read the latest instance time |
|
2875 //SO we are reading all the instances in the timerange of past 24 hrs ans next 24 hrs minus |
|
2876 //a minute so that instanceid shouldnt match with daily repeat meeting |
|
2877 TCalTime momentStart, momentEnd; |
|
2878 momentStart.SetTimeLocalL( (aId.iInstanceTime - TTimeIntervalDays(1)) + TTimeIntervalMinutes(1)); |
|
2879 momentEnd.SetTimeLocalL( (aId.iInstanceTime + TTimeIntervalDays(1)) - TTimeIntervalMinutes(1)); |
|
2880 CalCommon::TCalTimeRange range( momentStart, momentEnd ); |
|
2881 aInstanceView.FindInstanceL( instances, CalCommon::EIncludeAll, range ); |
|
2882 |
|
2883 CCalInstance* result = NULL; |
|
2884 |
|
2885 // For instances finishing the next day (now possible with unified DateTime editor), |
|
2886 // we have to do our best to match the instance time exactly - otherwise we could |
|
2887 // match the LocalUid to the incorrect instance in a series. |
|
2888 for ( TInt i=0; i < instances.Count() && !result; ++i ) |
|
2889 { |
|
2890 if( instances[i]->Entry().LocalUidL() == aId.iEntryLocalUid ) |
|
2891 { |
|
2892 // Check the instance time matches. |
|
2893 if( instances[i]->StartTimeL().TimeLocalL() == aId.iInstanceTime ) |
|
2894 { |
|
2895 result = instances[i]; |
|
2896 instances.Remove(i); |
|
2897 } |
|
2898 } |
|
2899 } |
|
2900 |
|
2901 if( !result ) |
|
2902 { |
|
2903 // Couldn't match the instance time exactly - just use the instance |
|
2904 // with the same LocalUid as the one we're looking for. |
|
2905 for ( TInt i=0; i < instances.Count() && !result; ++i ) |
|
2906 { |
|
2907 if( instances[i]->Entry().LocalUidL() == aId.iEntryLocalUid ) |
|
2908 { |
|
2909 result = instances[i]; |
|
2910 instances.Remove(i); |
|
2911 } |
|
2912 } |
|
2913 } |
|
2914 |
|
2915 CleanupStack::PopAndDestroy( &instances ); |
|
2916 |
|
2917 TRACE_EXIT_POINT; |
|
2918 return result; |
|
2919 } |
|
2920 |
|
2921 // ----------------------------------------------------------------------------- |
|
2922 // CCalenEventViewContainer::OpenAttachmentL |
|
2923 // Opens a particular attachment |
|
2924 // ----------------------------------------------------------------------------- |
|
2925 // |
|
2926 void CCalenEventViewContainer::OpenAttachmentViewerL(RFile& file, MAknServerAppExitObserver& /*aExitObserver*/) |
|
2927 { |
|
2928 TRACE_ENTRY_POINT; |
|
2929 |
|
2930 TBuf<250> fileName; |
|
2931 file.FullName(fileName); |
|
2932 TDataType datatype( CCalenAttachmentUtils::GetMimeTypeL(fileName) ); |
|
2933 |
|
2934 TInt ret = KErrNone; |
|
2935 |
|
2936 file.Close(); |
|
2937 RFs& fs = CEikonEnv::Static()->FsSession(); |
|
2938 |
|
2939 //open the file, before giving it to Notepad. |
|
2940 TInt err1 = file.Open( fs, fileName, EFileRead | EFileShareReadersOnly ); |
|
2941 CleanupClosePushL( file ); |
|
2942 |
|
2943 if(datatype == KNotePadTextDataType()) |
|
2944 { |
|
2945 const TDesC& notepadTitle = _L("NotePad"); |
|
2946 // file handle ownership transferred. |
|
2947 |
|
2948 // 1.File handle from arg has problem for notes since junk chars are reported in file. |
|
2949 // so we use another file handle exclusively open with filename an pass to note viewer. |
|
2950 // |
|
2951 // 2.Pass ETrue to 4th param ExecFileViewerL , to guess encoding. |
|
2952 RFile fileForNotes; |
|
2953 TInt err = fileForNotes.Open( fs, fileName, EFileRead | EFileShareReadersOnly ); |
|
2954 CleanupClosePushL( fileForNotes ); |
|
2955 ret = CNotepadApi::ExecFileViewerL( fileForNotes, |
|
2956 ¬epadTitle, |
|
2957 ETrue, |
|
2958 ETrue, |
|
2959 KCharacterSetIdentifierIso88591 ); |
|
2960 |
|
2961 CleanupStack::PopAndDestroy(&fileForNotes); |
|
2962 } |
|
2963 else |
|
2964 { |
|
2965 //doc handler will open the other files (other than text file). |
|
2966 TRAP( ret, iDocHandler->OpenFileEmbeddedL( file, datatype ) ); |
|
2967 } |
|
2968 CleanupStack::PopAndDestroy(&file); |
|
2969 |
|
2970 switch(ret) |
|
2971 { |
|
2972 case KErrNone: |
|
2973 break; |
|
2974 default: |
|
2975 { |
|
2976 CAknInformationNote* note = new ( ELeave ) CAknInformationNote; |
|
2977 HBufC* cannotOpen = StringLoader::LoadLC( |
|
2978 R_QTN_CALEN_INFO_CANNOT_OPEN, CEikonEnv::Static() ); |
|
2979 note->ExecuteLD( *cannotOpen ); |
|
2980 CleanupStack::PopAndDestroy(); |
|
2981 } |
|
2982 break; |
|
2983 } |
|
2984 TRACE_EXIT_POINT |
|
2985 } |
|
2986 |
|
2987 |
|
2988 // end of file |
|
2989 |