567 // command line. We do not want to update calendars stored focus |
567 // command line. We do not want to update calendars stored focus |
568 // in case we override any command line parameters |
568 // in case we override any command line parameters |
569 // Intentional fall through to EEikBidCancel below |
569 // Intentional fall through to EEikBidCancel below |
570 iEntryUiOutParams.iAction = ENoAction; |
570 iEntryUiOutParams.iAction = ENoAction; |
571 iEntryUiOutParams.iSpare = 0; |
571 iEntryUiOutParams.iSpare = 0; |
|
572 MCalenContext& context = iServices->Context(); |
|
573 HBufC* fileNamePtr = context.GetCalAlarmEntryFileNameL(); |
|
574 TCalLocalUid localUid = context.CalAlarmLocalUidL(); |
|
575 if (fileNamePtr != NULL && !fileNamePtr->CompareF(iGlobalData->GetCalFileNameForCollectionId(context.InstanceId().iColId)) |
|
576 && localUid == context.InstanceId().iEntryLocalUid) |
|
577 { |
|
578 context.ResetCalAlarmEntryFileName(); |
|
579 break; |
|
580 } |
572 // Fall through... |
581 // Fall through... |
573 } |
582 } |
574 case ECalenEditSeries: |
583 case ECalenEditSeries: |
575 case ECalenEditOccurrence: |
584 case ECalenEditOccurrence: |
576 case EAknCmdExit: |
585 case EAknCmdExit: |
656 // ----------------------------------------------------------------------------- |
665 // ----------------------------------------------------------------------------- |
657 // |
666 // |
658 TKeyResponse CCalenUnifiedEditor::OfferKeyEventL( const TKeyEvent& aKeyEvent, |
667 TKeyResponse CCalenUnifiedEditor::OfferKeyEventL( const TKeyEvent& aKeyEvent, |
659 TEventCode aType ) |
668 TEventCode aType ) |
660 { |
669 { |
661 TRACE_ENTRY_POINT; |
670 |
662 TBool isMapIconHandled = EFalse; |
671 TRACE_ENTRY_POINT; |
663 TKeyResponse keyResponse( EKeyWasNotConsumed ); |
672 TKeyResponse keyResponse( EKeyWasNotConsumed ); |
664 TInt ctrlid=IdOfFocusControl(); |
673 TInt ctrlid=IdOfFocusControl(); |
665 |
674 |
666 /* If KeyCallBack has not been called after construction |
675 /* If KeyCallBack has not been called after construction |
667 * (= initialization of iIdle) call it now to |
676 * (= initialization of iIdle) call it now to |
694 // opened is closing the application. |
703 // opened is closing the application. |
695 TryExitL( ECalenCmdCloseDialog ); |
704 TryExitL( ECalenCmdCloseDialog ); |
696 keyResponse = EKeyWasConsumed; |
705 keyResponse = EKeyWasConsumed; |
697 break; |
706 break; |
698 case EKeyEnter: // For Enter key |
707 case EKeyEnter: // For Enter key |
|
708 case EKeyDelete: // For Delete key |
699 { |
709 { |
700 keyResponse = CAknForm::OfferKeyEventL(aKeyEvent,aType); // Let framework handle the key event |
710 keyResponse = CAknForm::OfferKeyEventL(aKeyEvent,aType); // Let framework handle the key event |
701 // when enter key is pressed on subject line or on location line, call AddPictureL to recalculate the map icon position properly |
|
702 // as location field could habe moved up or down |
|
703 if(ctrlid == ECalenEditorPlace || ctrlid == ECalenEditorSubject) |
|
704 { |
|
705 CCalGeoValue* geoValue = iEditorDataHandler->Entry().GeoValueL(); |
|
706 if(geoValue) |
|
707 { |
|
708 isMapIconHandled = ETrue; |
|
709 AddPictureL(); |
|
710 delete geoValue; |
|
711 } |
|
712 } |
|
713 } |
|
714 break; |
|
715 case EKeyDelete: |
|
716 { |
|
717 if(ctrlid == ECalenEditorPlace) |
|
718 { |
|
719 CCalGeoValue* geoValue = iEditorDataHandler->Entry().GeoValueL(); |
|
720 if(geoValue) |
|
721 { |
|
722 CEikRichTextEditor* locationControl = static_cast<CEikRichTextEditor*>(Control(ECalenEditorPlace)); |
|
723 CRichText* text = locationControl->RichText(); |
|
724 TPtrC ptr = text->Read(0,text->DocumentLength()); |
|
725 TInt pos = ptr.Locate(TChar(CEditableText::EPictureCharacter)); |
|
726 if(locationControl->CursorPos() == pos) |
|
727 { |
|
728 isMapIconHandled = ETrue; |
|
729 keyResponse = EKeyWasConsumed; |
|
730 delete geoValue; |
|
731 break; |
|
732 } |
|
733 delete geoValue; |
|
734 } |
|
735 } |
|
736 keyResponse = CAknForm::OfferKeyEventL(aKeyEvent,aType); // Let framework handle the key event |
|
737 } |
711 } |
738 break; |
712 break; |
739 case EKeyBackspace: // For back space character |
713 case EKeyBackspace: // For back space character |
740 { |
714 { |
741 if(ctrlid == ECalenEditorPlace) |
715 if(ctrlid == ECalenEditorPlace || ECalenEditorSubject) |
742 { |
|
743 CCalGeoValue* geoValue = iEditorDataHandler->Entry().GeoValueL(); |
|
744 if(geoValue) |
|
745 { |
|
746 CEikRichTextEditor* locationControl = static_cast<CEikRichTextEditor*>(Control(ECalenEditorPlace)); |
|
747 CRichText* text = locationControl->RichText(); |
|
748 TPtrC ptr = text->Read(0,text->DocumentLength()); |
|
749 TInt pos = ptr.Locate(TChar(CEditableText::EPictureCharacter)); |
|
750 TInt curpos = locationControl->CursorPos(); |
|
751 |
|
752 // When only one visible character is there and picture byte is there at second position, then |
|
753 // empty the location field and redraw the map icon |
|
754 if(text->DocumentLength() <= 2) |
|
755 { |
|
756 TBuf<1> newLocation; |
|
757 SetEdwinTextL(ECalenEditorPlace, &newLocation); |
|
758 keyResponse = EKeyWasConsumed; |
|
759 delete geoValue; |
|
760 isMapIconHandled = ETrue; |
|
761 AddPictureL(); |
|
762 break; |
|
763 } |
|
764 // when cursor position is at the end, then since, picture byte is at the end |
|
765 // delete last but one character (for user, it looks as if last visible character is being deleted) |
|
766 // and redraw the icon |
|
767 else if( curpos == pos + 1) |
|
768 { |
|
769 text->DeleteL(text->DocumentLength() - 2,1); |
|
770 |
|
771 AddPictureL(); |
|
772 locationControl->SetCursorPosL(curpos - 1, EFalse); |
|
773 isMapIconHandled = ETrue; |
|
774 keyResponse = EKeyWasConsumed; |
|
775 delete geoValue; |
|
776 break; |
|
777 } |
|
778 delete geoValue; |
|
779 } |
|
780 } |
|
781 // This is to handle backspaces in subject field when there nore that one lines, |
|
782 // location field will move up, hence, need to redraw the map icon |
|
783 else if(ctrlid == ECalenEditorSubject) |
|
784 { |
716 { |
785 keyResponse = CAknForm::OfferKeyEventL(aKeyEvent,aType); |
717 keyResponse = CAknForm::OfferKeyEventL(aKeyEvent,aType); |
786 CCalGeoValue* geoValue = iEditorDataHandler->Entry().GeoValueL(); |
|
787 if(geoValue) |
|
788 { |
|
789 AddPictureL(); |
|
790 isMapIconHandled = ETrue; |
|
791 delete geoValue; |
|
792 } |
|
793 break; |
|
794 } |
718 } |
|
719 break; |
795 } |
720 } |
796 case EKeyLeftArrow: |
721 case EKeyLeftArrow: |
797 case EKeyRightArrow: |
722 case EKeyRightArrow: |
798 { |
723 { |
799 if( ECalenEditorEventType == IdOfFocusControl() ) |
724 if( ECalenEditorEventType == IdOfFocusControl() ) |
3340 } |
3228 } |
3341 UpdateFormL(); |
3229 UpdateFormL(); |
3342 TRACE_EXIT_POINT; |
3230 TRACE_EXIT_POINT; |
3343 } |
3231 } |
3344 |
3232 |
3345 // ----------------------------------------------------------------------------- |
|
3346 // CCalenUnifiedEditor::AddPictureL |
|
3347 // Adds Map icon onto the editors |
|
3348 // ----------------------------------------------------------------------------- |
|
3349 // |
|
3350 void CCalenUnifiedEditor::AddPictureL(TInt isNotFirstTime) |
|
3351 { |
|
3352 TRACE_ENTRY_POINT; |
|
3353 return; |
|
3354 |
|
3355 // Instantiate CMapIconPicture object 300x300 twips in size |
|
3356 CEikRichTextEditor* locationControl = static_cast<CEikRichTextEditor*>(Control(ECalenEditorPlace)); |
|
3357 |
|
3358 CRichText* text = locationControl->RichText(); |
|
3359 if(isNotFirstTime) |
|
3360 { |
|
3361 TPtrC ptr = text->Read(0,text->DocumentLength()); |
|
3362 TInt pos = ptr.Locate(TChar(CEditableText::EPictureCharacter)); |
|
3363 if(pos != -1) // If picture found, delete it so that it cna be drawn at new place |
|
3364 { |
|
3365 TRAP_IGNORE(text->DeleteL(pos,1)); |
|
3366 } |
|
3367 } |
|
3368 |
|
3369 // Get the rect of the caption of ECalenEditorPlace control |
|
3370 CEikLabel* label = this->ControlCaption(ECalenEditorPlace); |
|
3371 TRect rect = label->Rect(); |
|
3372 |
|
3373 CMapsIconPicture* picture = new( ELeave )CMapsIconPicture(/* TSize( 300, 300 )*/ *iServices, rect ); |
|
3374 CleanupStack::PushL(picture); |
|
3375 //Prepare the picture header, which will be inserted into the rich text |
|
3376 TPictureHeader header; |
|
3377 header.iPicture = TSwizzle<CPicture>(picture); |
|
3378 |
|
3379 // Position where we insert picture is not valid as it always draws icon depending the rect we provide |
|
3380 |
|
3381 text->InsertL(text->DocumentLength(), header); |
|
3382 |
|
3383 locationControl->HandleTextChangedL(); |
|
3384 CleanupStack::Pop(); // picture |
|
3385 |
|
3386 Control(ECalenEditorPlace)->DrawNow(); |
|
3387 |
|
3388 TRACE_EXIT_POINT; |
|
3389 } |
|
3390 |
3233 |
3391 // ----------------------------------------------------------------------------- |
3234 // ----------------------------------------------------------------------------- |
3392 // CCalenUnifiedEditor::AttachmentNamesL |
3235 // CCalenUnifiedEditor::AttachmentNamesL |
3393 // Provides all the attachments names |
3236 // Provides all the attachments names |
3394 // ----------------------------------------------------------------------------- |
3237 // ----------------------------------------------------------------------------- |