202 void CESMRViewerAttendeesField::SizeChanged( ) |
209 void CESMRViewerAttendeesField::SizeChanged( ) |
203 { |
210 { |
204 FUNC_LOG; |
211 FUNC_LOG; |
205 // Store iRichTextViewer original width. |
212 // Store iRichTextViewer original width. |
206 TInt richTextViewerWidth = iRichTextViewer->Size().iWidth; |
213 TInt richTextViewerWidth = iRichTextViewer->Size().iWidth; |
207 |
214 |
208 // Get field's rect |
215 // Get field's rect |
209 TRect rect( Rect() ); |
216 TRect rect( Rect() ); |
210 |
217 |
211 // First row for title |
218 // First row for title |
212 TAknLayoutRect rowLayoutRect = |
219 TAknLayoutRect rowLayoutRect = |
213 NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 ); |
220 NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 ); |
214 TRect rowRect = rowLayoutRect.Rect(); |
221 TRect rowRect = rowLayoutRect.Rect(); |
215 |
222 |
216 // Layout title to first row's rect |
223 // Layout title to first row's rect |
217 TAknTextComponentLayout titleLayout = |
224 TAknTextComponentLayout titleLayout = |
218 NMRLayoutManager::GetTextComponentLayout( |
225 NMRLayoutManager::GetTextComponentLayout( |
219 NMRLayoutManager::EMRTextLayoutText ); |
226 NMRLayoutManager::EMRTextLayoutText ); |
220 AknLayoutUtils::LayoutLabel( iTitle, rect, titleLayout ); |
227 AknLayoutUtils::LayoutLabel( iTitle, rect, titleLayout ); |
221 // Color should be overrided after layouting |
228 |
222 // If this function leaves we'll have to use default color |
229 TAknLayoutText labelLayout = |
223 TRAP_IGNORE( AknLayoutUtils::OverrideControlColorL( |
230 NMRLayoutManager::GetLayoutText( |
224 *iTitle, |
231 rect, NMRLayoutManager::EMRTextLayoutText ); |
225 EColorLabelText, |
232 |
226 KRgbBlack )); |
233 // Setting font for the label |
227 |
234 iTitle->SetFont( labelLayout.Font() ); |
|
235 |
228 // Move upper left corner below first line and get second row's rect. |
236 // Move upper left corner below first line and get second row's rect. |
229 rect.iTl.iY += rowRect.Height(); |
237 rect.iTl.iY += rowRect.Height(); |
230 rowLayoutRect = |
238 rowLayoutRect = |
231 NMRLayoutManager::GetFieldRowLayoutRect( rect, 2 ); |
239 NMRLayoutManager::GetFieldRowLayoutRect( rect, 2 ); |
232 rowRect = rowLayoutRect.Rect(); |
240 rowRect = rowLayoutRect.Rect(); |
233 |
241 |
234 // Get default 1 row editor rect. |
242 // Get default 1 row editor rect. |
235 TAknLayoutText viewerLayoutText = |
243 TAknLayoutText viewerLayoutText = |
236 NMRLayoutManager::GetLayoutText( rowRect, |
244 NMRLayoutManager::GetLayoutText( rowRect, |
237 NMRLayoutManager::EMRTextLayoutMultiRowTextEditor ); |
245 NMRLayoutManager::EMRTextLayoutMultiRowTextEditor ); |
238 TRect viewerRect = viewerLayoutText.TextRect(); |
246 TRect viewerRect = viewerLayoutText.TextRect(); |
239 // Resize resize it's height according to actual height required by edwin. |
247 // Resize resize it's height according to actual height required by edwin. |
240 viewerRect.Resize( 0, iExpandedSize.iHeight - viewerRect.Height() ); |
248 viewerRect.Resize( 0, iExpandedSize.iHeight - viewerRect.Height() ); |
241 iRichTextViewer->SetRect( viewerRect ); |
249 |
|
250 // Layouting focus |
|
251 TRect bgRect( 0, 0, 0, 0 ); |
|
252 if( iCalAttendees.Count() > 1 ) |
|
253 { |
|
254 bgRect.SetRect( |
|
255 TPoint( viewerRect.iTl.iX, |
|
256 viewerRect.iTl.iY - FocusMargin() ), |
|
257 TPoint( viewerRect.iBr.iX, |
|
258 viewerRect.iBr.iY + FocusMargin() ) ); |
|
259 } |
|
260 else |
|
261 { |
|
262 TAknLayoutRect bgLayoutRect = |
|
263 NMRLayoutManager::GetLayoutRect( |
|
264 rowRect, NMRLayoutManager::EMRLayoutTextEditorBg ); |
|
265 bgRect = bgLayoutRect.Rect(); |
|
266 } |
|
267 |
|
268 // Move focus rect so that it's relative to field's position. |
|
269 bgRect.Move( -Position() ); |
|
270 SetFocusRect( bgRect ); |
|
271 |
|
272 iRichTextViewer->SetRect( viewerRect ); |
|
273 |
|
274 // Failures are ignored. |
|
275 TRAP_IGNORE( |
|
276 iRichTextViewer->SetFontL( viewerLayoutText.Font() ); |
|
277 if( iCalAttendees.Count() > 0 ) |
|
278 { |
|
279 iRichTextViewer->SetLineSpacingL( LineSpacing() ); |
|
280 } |
|
281 iRichTextViewer->ApplyLayoutChangesL(); |
|
282 ); |
242 |
283 |
243 // Update AttendeesList only if iRichTextViewer width was changed. |
284 // Update AttendeesList only if iRichTextViewer width was changed. |
244 // This happens when screen orientation changes e.g. This check |
285 // This happens when screen orientation changes e.g. This check |
245 // also prevents recursive calls to UpdateAttendeesListL since |
286 // also prevents recursive calls to UpdateAttendeesListL since |
246 // it causes edwin size changed event. |
287 // it causes edwin size changed event. |
247 if ( iRichTextViewer->Size().iWidth != richTextViewerWidth ) |
288 if ( iRichTextViewer->Size().iWidth != richTextViewerWidth ) |
248 { |
289 { |
|
290 // Most of this case is screen orientation, in this case we need to |
|
291 // Record the index of focusing link, after updating link array, then |
|
292 // reset the focusing to original one. |
|
293 TInt focusingIndex = iRichTextViewer->GetFocusLink(); |
249 // Ignore leave, there's nothing we can do if leave occurs. |
294 // Ignore leave, there's nothing we can do if leave occurs. |
250 TRAP_IGNORE( UpdateAttendeesListL() ); |
295 TRAP_IGNORE( UpdateAttendeesListL() ); |
|
296 if ( KErrNotFound != focusingIndex ) |
|
297 { |
|
298 iRichTextViewer->SetFocusLink( focusingIndex ); |
|
299 } |
251 //wake up current contact menu selection by calling this |
300 //wake up current contact menu selection by calling this |
252 iRichTextViewer->FocusChanged(ENoDrawNow); |
301 iRichTextViewer->FocusChanged(ENoDrawNow); |
253 } |
302 } |
254 |
|
255 DrawDeferred(); |
|
256 } |
303 } |
257 |
304 |
258 // ----------------------------------------------------------------------------- |
305 // ----------------------------------------------------------------------------- |
259 // CESMRViewerAttendeesField::OfferKeyEventL |
306 // CESMRViewerAttendeesField::OfferKeyEventL |
260 // ----------------------------------------------------------------------------- |
307 // ----------------------------------------------------------------------------- |
295 |
342 |
296 // --------------------------------------------------------------------------- |
343 // --------------------------------------------------------------------------- |
297 // CESMRViewerAttendeesField::SetContainerWindowL() |
344 // CESMRViewerAttendeesField::SetContainerWindowL() |
298 // --------------------------------------------------------------------------- |
345 // --------------------------------------------------------------------------- |
299 // |
346 // |
300 void CESMRViewerAttendeesField::SetContainerWindowL( |
347 void CESMRViewerAttendeesField::SetContainerWindowL( |
301 const CCoeControl& aContainer ) |
348 const CCoeControl& aContainer ) |
302 { |
349 { |
303 CESMRField::SetContainerWindowL( aContainer ); |
350 CESMRField::SetContainerWindowL( aContainer ); |
304 iRichTextViewer->SetContainerWindowL( aContainer ); |
351 iRichTextViewer->SetContainerWindowL( aContainer ); |
|
352 iRichTextViewer->SetParent( this ); |
305 } |
353 } |
306 |
354 |
307 // --------------------------------------------------------------------------- |
355 // --------------------------------------------------------------------------- |
308 // CESMRViewerAttendeesField::MinimumSize() |
356 // CESMRViewerAttendeesField::MinimumSize() |
309 // --------------------------------------------------------------------------- |
357 // --------------------------------------------------------------------------- |
310 // |
358 // |
311 TSize CESMRViewerAttendeesField::MinimumSize() |
359 TSize CESMRViewerAttendeesField::MinimumSize() |
312 { |
360 { |
313 // Parent rect will be list area later --> no need to calculate it manually. |
361 // Parent rect will be list area later --> no need to calculate it manually. |
314 TRect parentRect = Parent()->Rect(); |
362 TRect parentRect = Parent()->Rect(); |
315 TRect contentRect = NMRLayoutManager::GetLayoutRect( |
363 // TODO: Remove this after new list area is completed. See previous comment. |
|
364 TRect contentRect = NMRLayoutManager::GetLayoutRect( |
316 parentRect, NMRLayoutManager::EMRLayoutListArea ).Rect(); |
365 parentRect, NMRLayoutManager::EMRLayoutListArea ).Rect(); |
317 // We have two lines; title and richtextviewer. |
366 // We have two lines; title and richtextviewer. |
318 TRect fieldRect = |
367 TRect fieldRect = |
319 NMRLayoutManager::GetFieldLayoutRect( contentRect, 2 ).Rect(); |
368 NMRLayoutManager::GetFieldLayoutRect( contentRect, 2 ).Rect(); |
320 // Get row size for second row (richtext viewer). |
369 // Get row size for second row (richtext viewer). |
321 TRect rowRect = |
370 TRect rowRect = |
322 NMRLayoutManager::GetFieldRowLayoutRect( fieldRect, 2 ).Rect(); |
371 NMRLayoutManager::GetFieldRowLayoutRect( fieldRect, 2 ).Rect(); |
323 // Get size for default 1 line editor. |
372 // Get size for default 1 line editor. |
324 TRect viewerRect = NMRLayoutManager::GetLayoutText( |
373 TRect viewerRect = NMRLayoutManager::GetLayoutText( |
325 rowRect, |
374 rowRect, |
326 NMRLayoutManager::EMRTextLayoutMultiRowTextEditor ).TextRect(); |
375 NMRLayoutManager::EMRTextLayoutMultiRowTextEditor ).TextRect(); |
327 // Adjust field size so that there's room for expandable editor. |
376 // Adjust field size so that there's room for expandable editor. |
328 fieldRect.Resize( 0, iExpandedSize.iHeight - viewerRect.Height() ); |
377 fieldRect.Resize( 0, iExpandedSize.iHeight - viewerRect.Height() ); |
329 return fieldRect.Size(); |
378 return fieldRect.Size(); |
330 } |
379 } |
331 |
380 |
332 // --------------------------------------------------------------------------- |
381 // --------------------------------------------------------------------------- |
333 // CESMRViewerAttendeesField::ExecuteGenericCommandL() |
382 // CESMRViewerAttendeesField::ExecuteGenericCommandL() |
334 // --------------------------------------------------------------------------- |
383 // --------------------------------------------------------------------------- |
335 // |
384 // |
336 void CESMRViewerAttendeesField::ExecuteGenericCommandL( TInt aCommand ) |
385 TBool CESMRViewerAttendeesField::ExecuteGenericCommandL( TInt aCommand ) |
337 { |
386 { |
338 FUNC_LOG; |
387 FUNC_LOG; |
339 switch ( aCommand ) |
388 |
340 { |
389 TBool isUsed( EFalse ); |
341 case EESMRCmdClipboardCopy: |
390 if (aCommand == EESMRCmdShowAllAttendees) |
342 { |
391 { |
343 iRichTextViewer->CopyCurrentLinkValueToClipBoardL(); |
392 iShowAllAttendees = ETrue; |
344 break; |
393 UpdateAttendeesListL(); |
345 } |
394 |
346 case EESMRCmdShowAllAttendees: |
395 RestoreMiddleSoftKeyL(); |
347 { |
396 //wake up current contact menu selection by calling this |
348 iShowAllAttendees = ETrue; |
397 iRichTextViewer->FocusChanged(ENoDrawNow); |
349 UpdateAttendeesListL(); |
398 |
350 |
399 isUsed = ETrue; |
351 RestoreMiddleSoftKeyL(); |
400 } |
352 //wake up current contact menu selection by calling this |
401 if ( aCommand == EAknSoftkeySelect ) |
353 iRichTextViewer->FocusChanged(ENoDrawNow); |
402 { |
354 break; |
403 iRichTextViewer->LinkSelectedL(); |
355 } |
404 isUsed = ETrue; |
356 case EAknSoftkeySelect: |
405 } |
357 { |
406 |
358 iRichTextViewer->LinkSelectedL(); |
407 return isUsed; |
359 break; |
408 } |
360 } |
409 |
361 default: |
410 // ----------------------------------------------------------------------------- |
362 // do nothing for now.. |
411 // CESMRViewerAttendeesField::HandleLongtapEventL |
363 break; |
412 // ----------------------------------------------------------------------------- |
|
413 // |
|
414 void CESMRViewerAttendeesField::HandleLongtapEventL( const TPoint& aPosition ) |
|
415 { |
|
416 FUNC_LOG; |
|
417 |
|
418 if ( iRichTextViewer->Rect().Contains( aPosition ) ) |
|
419 { |
|
420 iRichTextViewer->LinkSelectedL(); |
|
421 HandleTactileFeedbackL(); |
364 } |
422 } |
365 } |
423 } |
366 |
424 |
367 // ----------------------------------------------------------------------------- |
425 // ----------------------------------------------------------------------------- |
368 // CESMRViewerAttendeesField::HandleEdwinSizeEventL |
426 // CESMRViewerAttendeesField::HandleEdwinSizeEventL |
455 CESMRViewerAttendeesField::CESMRViewerAttendeesField( |
512 CESMRViewerAttendeesField::CESMRViewerAttendeesField( |
456 CCalAttendee::TCalRole aRole ) : |
513 CCalAttendee::TCalRole aRole ) : |
457 iRole( aRole) |
514 iRole( aRole) |
458 { |
515 { |
459 FUNC_LOG; |
516 FUNC_LOG; |
460 //do nothing |
517 SetFocusType( EESMRHighlightFocus ); |
461 } |
518 } |
462 |
519 |
463 // ----------------------------------------------------------------------------- |
520 // ----------------------------------------------------------------------------- |
464 // CESMRViewerAttendeesField::ClipTextLC |
521 // CESMRViewerAttendeesField::ClipTextLC |
465 // ----------------------------------------------------------------------------- |
522 // ----------------------------------------------------------------------------- |
466 // |
523 // |
467 HBufC* CESMRViewerAttendeesField::ClipTextLC( |
524 HBufC* CESMRViewerAttendeesField::ClipTextLC( |
468 const TDesC& aText, const CFont& aFont, TInt aWidth ) |
525 const TDesC& aText, const CFont& aFont, TInt aWidth ) |
469 { |
526 { |
470 FUNC_LOG; |
527 FUNC_LOG; |
471 HBufC* text = HBufC::NewLC( aText.Length() + KAknBidiExtraSpacePerLine ); |
528 HBufC* text = HBufC::NewLC( aText.Length() + KAknBidiExtraSpacePerLine ); |
472 TPtr textPtr = text->Des(); |
529 TPtr textPtr = text->Des(); |
473 AknBidiTextUtils::ConvertToVisualAndClip( |
530 AknBidiTextUtils::ConvertToVisualAndClip( |
474 aText, textPtr, aFont, aWidth, aWidth ); |
531 aText, textPtr, aFont, aWidth, aWidth ); |
475 return text; |
532 return text; |
476 } |
533 } |
477 |
534 |
478 |
|
479 // ----------------------------------------------------------------------------- |
535 // ----------------------------------------------------------------------------- |
480 // CESMRViewerAttendeesField::UpdateAttendeesListL |
536 // CESMRViewerAttendeesField::UpdateAttendeesListL |
481 // ----------------------------------------------------------------------------- |
537 // ----------------------------------------------------------------------------- |
482 // |
538 // |
483 void CESMRViewerAttendeesField::UpdateAttendeesListL() |
539 void CESMRViewerAttendeesField::UpdateAttendeesListL() |
484 { |
540 { |
485 FUNC_LOG; |
541 FUNC_LOG; |
486 RBuf buffer; // codescanner::resourcenotoncleanupstack |
542 RBuf buffer; // codescanner::resourcenotoncleanupstack |
487 buffer.CleanupClosePushL(); |
543 buffer.CleanupClosePushL(); |
488 |
544 |
489 iRichTextViewer->SetMargins( KMargin ); |
545 TAknLayoutText text = NMRLayoutManager::GetLayoutText( |
490 |
546 Rect(), |
491 TSize oldSize = Size(); |
547 NMRLayoutManager::EMRTextLayoutTextEditor ); |
492 |
548 const CFont* font = text.Font(); |
|
549 |
|
550 // TODO: correct icon zise to correct one. Ask from UI specifier. |
|
551 TSize iconSize( 20, 20); |
|
552 |
|
553 TInt maxLineWidth = iRichTextViewer->LayoutWidth(); |
|
554 maxLineWidth -= font->TextWidthInPixels( KAddressDelimeterSemiColon ); |
|
555 maxLineWidth -= iconSize.iWidth; |
|
556 |
|
557 RPointerArray<CESMRRichTextLink> attendeeLinks; // codescanner::resourcenotoncleanupstack |
|
558 TCleanupItem arrayCleanup( RPointerArrayResetAndDestroy, &attendeeLinks ); |
|
559 CleanupStack::PushL( arrayCleanup ); |
|
560 attendeeLinks.ReserveL(iCalAttendees.Count()); |
|
561 for ( TInt i = 0; i < iCalAttendees.Count(); ++i ) |
|
562 { |
|
563 CCalAttendee* attendee = iCalAttendees[i]; |
|
564 |
|
565 // Attendee email address. |
|
566 TPtrC addr = attendee->Address(); |
|
567 // Attendee common name. |
|
568 TPtrC name = attendee->CommonName(); |
|
569 // Actual text to be added to attendee field (email or common name). |
|
570 TPtrC text = addr; |
|
571 |
|
572 // If attendee has common name, use it instead. |
|
573 if ( name.Length() > 0 ) |
|
574 { |
|
575 text.Set( name ); |
|
576 } |
|
577 |
|
578 HBufC* clippedTextHBufC = ClipTextLC( text, *font, maxLineWidth ); |
|
579 TPtr clippedText = clippedTextHBufC->Des(); |
|
580 clippedText.Trim(); |
|
581 |
|
582 if ( clippedText.Length() > 0 ) |
|
583 { |
|
584 CESMRRichTextLink* link = CESMRRichTextLink::NewL( |
|
585 buffer.Length(), |
|
586 clippedText.Length() + |
|
587 KAddressDelimeterSemiColon().Length(), |
|
588 addr, |
|
589 CESMRRichTextLink::ETypeEmail, |
|
590 CESMRRichTextLink::ETriggerKeyRight ); |
|
591 CleanupStack::PushL( link ); |
|
592 attendeeLinks.AppendL( link ); |
|
593 CleanupStack::Pop( link ); |
|
594 |
|
595 // Append text and semicolon to buffer. |
|
596 buffer.ReAllocL( buffer.Length() + |
|
597 clippedText.Length() + |
|
598 KAddressDelimeterSemiColon().Length() + |
|
599 KNewLine().Length() ); |
|
600 buffer.Append( clippedText ); |
|
601 buffer.Append( KAddressDelimeterSemiColon ); |
|
602 buffer.Append( KNewLine ); |
|
603 } |
|
604 |
|
605 CleanupStack::PopAndDestroy( clippedTextHBufC ); |
|
606 |
|
607 // End loop if we have exceeded KMaxLineCount and |
|
608 // we don't want to show all attendees |
|
609 if ( attendeeLinks.Count() > KMaxLineCount && !iShowAllAttendees ) |
|
610 { |
|
611 break; |
|
612 } |
|
613 } |
|
614 |
|
615 // If there are more lines in use than KMaxLineCount and |
|
616 // we don't want to show all attendees, leave only |
|
617 // KMaxLineCount-1 attendees and add 'show all' |
|
618 // link to the end. |
|
619 if ( attendeeLinks.Count() > KMaxLineCount && !iShowAllAttendees ) |
|
620 { |
|
621 // Remove unnecessary part of buffer. |
|
622 buffer.SetLength( attendeeLinks[KMaxLineCount - 1]->StartPos() ); |
|
623 |
|
624 // Remove links from the list. |
|
625 while ( attendeeLinks.Count() >= KMaxLineCount ) |
|
626 { |
|
627 delete attendeeLinks[KMaxLineCount - 1]; |
|
628 attendeeLinks.Remove( KMaxLineCount - 1 ); |
|
629 } |
|
630 |
|
631 // Create and append 'show all' link. |
|
632 CESMRRichTextLink* showAllLink; |
|
633 HBufC* showAllBuf = StringLoader::LoadLC( R_QTN_MEET_REQ_SHOW_ALL ); |
|
634 buffer.ReAllocL( buffer.Length() + |
|
635 showAllBuf->Length() ); |
|
636 showAllLink = CESMRRichTextLink::NewL( buffer.Length ( ), |
|
637 showAllBuf->Length(), KNullDesC, |
|
638 CESMRRichTextLink::ETypeShowAll, |
|
639 CESMRRichTextLink::ETriggerKeyOk ); |
|
640 buffer.Append( *showAllBuf ); |
|
641 CleanupStack::PopAndDestroy( showAllBuf ); |
|
642 CleanupStack::PushL( showAllLink ); |
|
643 attendeeLinks.AppendL( showAllLink ); |
|
644 CleanupStack::Pop( showAllLink ); |
|
645 } |
|
646 // Remove unnecessary new line from the end of buffer. |
|
647 else if ( buffer.Length() >= KNewLine().Length() ) |
|
648 { |
|
649 buffer.SetLength( buffer.Length() - KNewLine().Length() ); |
|
650 } |
|
651 |
|
652 if ( buffer.Length() > 0 ) |
|
653 { |
|
654 iRichTextViewer->SetTextL( &buffer ); |
|
655 iRichTextViewer->SetMargins( KMargin ); |
|
656 |
|
657 // Add all links to iRichTextViewer. |
|
658 while ( attendeeLinks.Count() > 0 ) |
|
659 { |
|
660 CESMRRichTextLink* link = attendeeLinks[0]; |
|
661 CleanupStack::PushL( link ); |
|
662 attendeeLinks.Remove( 0 ); |
|
663 iRichTextViewer->AddLinkL( link ); |
|
664 CleanupStack::Pop( link ); |
|
665 } |
|
666 } |
|
667 SizeChanged(); |
|
668 CleanupStack::PopAndDestroy( &attendeeLinks ); |
|
669 CleanupStack::PopAndDestroy( &buffer ); |
|
670 } |
|
671 |
|
672 // --------------------------------------------------------------------------- |
|
673 // CESMRViewerAttendeesField::LineSpacing |
|
674 // --------------------------------------------------------------------------- |
|
675 // |
|
676 TInt CESMRViewerAttendeesField::LineSpacing() |
|
677 { |
|
678 FUNC_LOG; |
|
679 // Calculates the line spacing based on default one line layout data |
|
680 TInt lineSpacing( 0 ); |
|
681 |
493 TRect rect( Rect() ); |
682 TRect rect( Rect() ); |
494 TAknLayoutText layoutText = |
683 |
495 NMRLayoutManager::GetLayoutText( rect, |
684 TAknLayoutRect rowLayoutRect = |
496 NMRLayoutManager::EMRTextLayoutMultiRowTextEditor ); |
685 NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 ); |
497 TRect viewerRect = layoutText.TextRect(); |
686 TRect rowRect = rowLayoutRect.Rect(); |
498 TInt maxLineWidth = viewerRect.Size().iWidth; |
687 |
499 const CFont* font = layoutText.Font(); |
688 TAknLayoutText labelLayout = |
500 |
689 NMRLayoutManager::GetLayoutText( |
501 if ( maxLineWidth > 0 ) // control size is set |
690 rect, NMRLayoutManager::EMRTextLayoutTextEditor ); |
502 { |
691 |
503 TInt linkCount = iCalAttendees.Count(); |
692 TRect defaultTextRect = labelLayout.TextRect(); |
504 TBool notAllShown(EFalse); |
693 |
505 if ( !iShowAllAttendees ) |
694 TInt difference = rowRect.Height() - defaultTextRect.Height(); |
506 { |
695 |
507 linkCount = Min(KMaxLineCount, iCalAttendees.Count() ); |
696 lineSpacing = difference * 2; |
508 notAllShown = ( linkCount != iCalAttendees.Count() ); |
697 |
509 } |
698 return lineSpacing; |
510 |
699 } |
511 RPointerArray<CESMRRichTextLink> attendeeLinks; // codescanner::resourcenotoncleanupstack |
700 |
512 TCleanupItem arrayCleanup( RPointerArrayResetAndDestroy, &attendeeLinks ); |
701 // --------------------------------------------------------------------------- |
513 CleanupStack::PushL( arrayCleanup ); |
702 // CESMRViewerAttendeesField::FocusMargin |
514 attendeeLinks.ReserveL( linkCount ); |
703 // --------------------------------------------------------------------------- |
515 |
704 // |
516 for ( TInt i = 0; i < linkCount; ++i ) |
705 TInt CESMRViewerAttendeesField::FocusMargin() |
517 { |
706 { |
518 CCalAttendee* attendee = iCalAttendees[i]; |
707 FUNC_LOG; |
519 |
708 // Calculates focus margin based on default one line layout data |
520 // Attendee email address. |
709 TInt focusMagin( 0 ); |
521 TPtrC addr = attendee->Address(); |
710 |
522 // Attendee common name. |
711 TRect rect( Rect() ); |
523 TPtrC name = attendee->CommonName(); |
712 |
524 // Actual text to be added to attendee field (email or common name). |
713 TAknLayoutRect rowLayoutRect = |
525 TPtrC text = addr; |
714 NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 ); |
526 |
715 TRect rowRect = rowLayoutRect.Rect(); |
527 // If attendee has common name, use it instead. |
716 |
528 if ( name.Length() > 0 ) |
717 TAknLayoutText labelLayout = |
529 { |
718 NMRLayoutManager::GetLayoutText( |
530 text.Set( name ); |
719 rect, NMRLayoutManager::EMRTextLayoutTextEditor ); |
531 } |
720 |
532 |
721 TRect defaultTextRect = labelLayout.TextRect(); |
533 if ( text.Length() > 0 ) |
722 |
534 { |
723 TAknLayoutRect bgLayoutRect = |
535 CESMRRichTextLink* link = CESMRRichTextLink::NewL( |
724 NMRLayoutManager::GetLayoutRect( |
536 buffer.Length(), |
725 rect, NMRLayoutManager::EMRLayoutTextEditorBg ); |
537 text.Length() + |
726 TRect defaultBgRect( bgLayoutRect.Rect() ); |
538 KAddressDelimeterSemiColon().Length(), |
727 |
539 addr, |
728 TInt difference = defaultBgRect.Height() - defaultTextRect.Height(); |
540 CESMRRichTextLink::ETypeEmail, |
729 |
541 CESMRRichTextLink::ETriggerKeyRight ); |
730 focusMagin = TReal( difference / 2 ); |
542 CleanupStack::PushL( link ); |
731 |
543 attendeeLinks.AppendL( link ); |
732 return focusMagin; |
544 CleanupStack::Pop( link ); |
733 } |
545 |
734 |
546 // Append text and semicolon to buffer. |
|
547 buffer.ReAllocL( buffer.Length() + |
|
548 text.Length() + |
|
549 KAddressDelimeterSemiColon().Length() + |
|
550 KNewLine().Length() ); |
|
551 buffer.Append( text ); |
|
552 buffer.Append( KAddressDelimeterSemiColon ); |
|
553 buffer.Append( KNewLine ); |
|
554 } |
|
555 } |
|
556 |
|
557 // If there are more lines in use than KMaxLineCount and |
|
558 // we don't want to show all attendees, leave only |
|
559 // KMaxLineCount-1 attendees and add 'show all' |
|
560 // link to the end. |
|
561 if ( notAllShown ) |
|
562 { |
|
563 // Create and append 'show all' link. |
|
564 CESMRRichTextLink* showAllLink; |
|
565 HBufC* showAllBuf = StringLoader::LoadLC( R_QTN_MEET_REQ_SHOW_ALL ); |
|
566 buffer.ReAllocL( buffer.Length() + |
|
567 showAllBuf->Length() ); |
|
568 showAllLink = CESMRRichTextLink::NewL( buffer.Length ( ), |
|
569 showAllBuf->Length(), KNullDesC, |
|
570 CESMRRichTextLink::ETypeShowAll, |
|
571 CESMRRichTextLink::ETriggerKeyOk ); |
|
572 buffer.Append( *showAllBuf ); |
|
573 CleanupStack::PopAndDestroy( showAllBuf ); |
|
574 CleanupStack::PushL( showAllLink ); |
|
575 attendeeLinks.AppendL( showAllLink ); |
|
576 CleanupStack::Pop( showAllLink ); |
|
577 } |
|
578 |
|
579 // Remove unnecessary new line from the end of buffer. |
|
580 else if ( buffer.Length() >= KNewLine().Length() ) |
|
581 { |
|
582 buffer.SetLength( buffer.Length() - KNewLine().Length() ); |
|
583 } |
|
584 |
|
585 if ( buffer.Length() > 0 ) |
|
586 { |
|
587 iRichTextViewer->SetTextL( &buffer ); |
|
588 |
|
589 // Add all links to iRichTextViewer. |
|
590 while ( attendeeLinks.Count() > 0 ) |
|
591 { |
|
592 CESMRRichTextLink* link = attendeeLinks[0]; |
|
593 CleanupStack::PushL( link ); |
|
594 attendeeLinks.Remove( 0 ); |
|
595 iRichTextViewer->AddLinkL( link ); |
|
596 CleanupStack::Pop( link ); |
|
597 } |
|
598 } |
|
599 |
|
600 CleanupStack::PopAndDestroy( &attendeeLinks ); |
|
601 |
|
602 TSize newSize = Size(); |
|
603 if (oldSize != newSize) |
|
604 { |
|
605 CMRListPane* parent = static_cast<CMRListPane*>(Parent()); |
|
606 parent->SizeChanged(); |
|
607 } |
|
608 } |
|
609 CleanupStack::PopAndDestroy( &buffer ); |
|
610 } |
|
611 |
|
612 |
|
613 // ----------------------------------------------------------------------------- |
|
614 // CESMRViewerAttendeesField::HandlePointerEventL |
|
615 // ----------------------------------------------------------------------------- |
|
616 // |
|
617 void CESMRViewerAttendeesField::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
618 { |
|
619 CCoeControl::HandlePointerEventL(aPointerEvent); |
|
620 } |
|
621 // End of file |
735 // End of file |
622 |
736 |