meetingrequest/mrgui/mrfieldbuilderplugin/src/cesmrviewerdescriptionfield.cpp
branchRCL_3
changeset 12 4ce476e64c59
parent 4 e7aa27f58ae1
child 14 b13141f05c3d
equal deleted inserted replaced
11:0396474f30f5 12:4ce476e64c59
     1 /*
     1 /*
     2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). 
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    29 
    29 
    30 //<cmail>
    30 //<cmail>
    31 #include "cesmrurlparserplugin.h"
    31 #include "cesmrurlparserplugin.h"
    32 //</cmail>
    32 //</cmail>
    33 #include <calentry.h>
    33 #include <calentry.h>
    34 #include <AknUtils.h>
    34 #include <aknutils.h>
    35 #include <StringLoader.h>
    35 #include <stringloader.h>
    36 #include <esmrgui.rsg>
    36 #include <esmrgui.rsg>
    37 #include <avkon.rsg>
    37 #include <avkon.rsg>
    38 #include <txtrich.h>
    38 #include <txtrich.h>
    39 
    39 
    40 #include "emailtrace.h"
    40 #include "emailtrace.h"
    69 CESMRViewerDescriptionField::~CESMRViewerDescriptionField( )
    69 CESMRViewerDescriptionField::~CESMRViewerDescriptionField( )
    70     {
    70     {
    71     FUNC_LOG;
    71     FUNC_LOG;
    72     delete iLocationPlugin;
    72     delete iLocationPlugin;
    73     delete iFeatures;
    73     delete iFeatures;
    74     delete iLocation;
    74     delete iUrlParser;
    75     }
    75     }
    76 
    76 
    77 // ---------------------------------------------------------------------------
    77 // ---------------------------------------------------------------------------
    78 // CESMRViewerDescriptionField::InitializeL()
    78 // CESMRViewerDescriptionField::InitializeL()
    79 // ---------------------------------------------------------------------------
    79 // ---------------------------------------------------------------------------
    81 void CESMRViewerDescriptionField::InitializeL()
    81 void CESMRViewerDescriptionField::InitializeL()
    82     {
    82     {
    83     FUNC_LOG;
    83     FUNC_LOG;
    84     TAknLayoutText layoutText =
    84     TAknLayoutText layoutText =
    85         NMRLayoutManager::GetLayoutText( Rect(), NMRLayoutManager::EMRTextLayoutMultiRowTextEditor );
    85         NMRLayoutManager::GetLayoutText( Rect(), NMRLayoutManager::EMRTextLayoutMultiRowTextEditor );
    86     iRichTextViewer->SetFontL ( layoutText.Font(), iLayout );
    86     iRichTextViewer->SetFontL( layoutText.Font() );
       
    87     iRichTextViewer->ApplyLayoutChangesL();
       
    88     
    87     if ( IsFocused() )
    89     if ( IsFocused() )
    88         {
    90         {
    89         iRichTextViewer->FocusChanged( EDrawNow );
    91         iRichTextViewer->FocusChanged( EDrawNow );
    90         }
    92         }
    91 
    93 
    92     iRichTextViewer->HandleTextChangedL();
    94     iRichTextViewer->HandleTextChangedL();
       
    95     iRichTextViewer->SetEventQueue( iEventQueue );
    93     }
    96     }
    94 
    97 
    95 // ---------------------------------------------------------------------------
    98 // ---------------------------------------------------------------------------
    96 // CESMRViewerDescriptionField::InternalizeL()
    99 // CESMRViewerDescriptionField::InternalizeL()
    97 // ---------------------------------------------------------------------------
   100 // ---------------------------------------------------------------------------
   100     {
   103     {
   101     FUNC_LOG;
   104     FUNC_LOG;
   102     TPtrC text = aEntry.Entry().DescriptionL ( );
   105     TPtrC text = aEntry.Entry().DescriptionL ( );
   103     if( text.Length() == 0 )
   106     if( text.Length() == 0 )
   104         {
   107         {
   105         iObserver->RemoveControl( FieldId() );
   108         iObserver->HideControl( FieldId() );
   106         }
   109         }
   107     else if ( FeaturesL().FeatureSupported(
   110     else if ( FeaturesL().FeatureSupported(
   108                 CESMRFeatureSettings::EESMRUIMnFwIntegration ) )
   111                 CESMRFeatureSettings::EESMRUIMnFwIntegration ) )
   109         {
   112         {
   110         AddShowOnMapLinkL( aEntry );
   113         AddShowOnMapLinkL( aEntry );
   111         }
   114         }
   112     else
   115     else
   113         {
   116         {
       
   117         TPtrC text = aEntry.Entry().DescriptionL();
   114         iRichTextViewer->SetTextL( &text, ETrue );
   118         iRichTextViewer->SetTextL( &text, ETrue );
   115         iRichTextViewer->SetMargins( KMargin );
   119         iRichTextViewer->SetMargins( KMargin );
   116         }
   120         }
   117     iDisableRedraw = ETrue;
   121     iDisableRedraw = ETrue;
   118     }
   122     }
   125         const TKeyEvent& aEvent, TEventCode aType )
   129         const TKeyEvent& aEvent, TEventCode aType )
   126     {
   130     {
   127     FUNC_LOG;
   131     FUNC_LOG;
   128     TKeyResponse response = EKeyWasNotConsumed;
   132     TKeyResponse response = EKeyWasNotConsumed;
   129     response = iRichTextViewer->OfferKeyEventL ( aEvent, aType );
   133     response = iRichTextViewer->OfferKeyEventL ( aEvent, aType );
   130     
   134 
   131     //track up and down events to change MSK
   135     //track up and down events to change MSK
   132     if ( aType == EEventKey )
   136     if ( aType == EEventKey )
   133         {
   137         {
   134         if ( aEvent.iCode == EKeyUpArrow || aEvent.iCode == EKeyDownArrow )
   138         if ( aEvent.iCode == EKeyUpArrow || aEvent.iCode == EKeyDownArrow )
   135             {
   139             {
   136             if ( FeaturesL().FeatureSupported(
   140             if ( !iRichTextViewer->GetSelectedLink() )
   137                     CESMRFeatureSettings::EESMRUIMnFwIntegration ) )
       
   138                 {
   141                 {
   139                 SetShowOnMapLinkMiddleSoftKeyL();
   142                 // Restore default middle softkey if field does not contain link
       
   143                 RestoreMiddleSoftKeyL();
   140                 }
   144                 }
   141             else
   145             }
   142                 {
   146         }
   143                 if ( iRichTextViewer->GetSelectedLink() )
       
   144                     {
       
   145                     SetMiddleSoftKeyVisible( ETrue );
       
   146                     }
       
   147                 else
       
   148                     {
       
   149                     RestoreMiddleSoftKeyL();
       
   150                     }
       
   151                 }
       
   152             }
       
   153         }    
       
   154     return response;
   147     return response;
   155     }
   148     }
   156 
   149 
   157 // ---------------------------------------------------------------------------
   150 // ---------------------------------------------------------------------------
   158 // CESMRViewerDescriptionField::SetContainerWindowL()
   151 // CESMRViewerDescriptionField::SetContainerWindowL()
   160 //
   153 //
   161 void CESMRViewerDescriptionField::SetContainerWindowL( const CCoeControl& aContainer )
   154 void CESMRViewerDescriptionField::SetContainerWindowL( const CCoeControl& aContainer )
   162     {
   155     {
   163     CESMRField::SetContainerWindowL( aContainer );
   156     CESMRField::SetContainerWindowL( aContainer );
   164     iRichTextViewer->SetContainerWindowL( aContainer );
   157     iRichTextViewer->SetContainerWindowL( aContainer );
       
   158     iRichTextViewer->SetParent( this );
   165     }
   159     }
   166 
   160 
   167 // ---------------------------------------------------------------------------
   161 // ---------------------------------------------------------------------------
   168 // CESMRViewerDescriptionField::MinimumSize()
   162 // CESMRViewerDescriptionField::MinimumSize()
   169 // ---------------------------------------------------------------------------
   163 // ---------------------------------------------------------------------------
   177         NMRLayoutManager::GetFieldLayoutRect( listRect, 1 ).Rect();
   171         NMRLayoutManager::GetFieldLayoutRect( listRect, 1 ).Rect();
   178     TRect rowRect =
   172     TRect rowRect =
   179         NMRLayoutManager::GetFieldRowLayoutRect( fieldRect, 1 ).Rect();
   173         NMRLayoutManager::GetFieldRowLayoutRect( fieldRect, 1 ).Rect();
   180     TRect viewerRect =
   174     TRect viewerRect =
   181         NMRLayoutManager::GetLayoutText( rowRect, NMRLayoutManager::EMRTextLayoutMultiRowTextEditor ).TextRect();
   175         NMRLayoutManager::GetLayoutText( rowRect, NMRLayoutManager::EMRTextLayoutMultiRowTextEditor ).TextRect();
   182     
   176 
   183     fieldRect.Resize( 0, iSize.iHeight - viewerRect.Height() );
   177     fieldRect.Resize( 0, iSize.iHeight - viewerRect.Height() );
   184     fieldRect.SetWidth( Parent()->Rect().Width() );
   178     fieldRect.SetWidth( Parent()->Rect().Width() );
   185     return fieldRect.Size();
   179     return fieldRect.Size();
   186     }
   180     }
   187 
   181 
   191 //
   185 //
   192 void CESMRViewerDescriptionField::SizeChanged()
   186 void CESMRViewerDescriptionField::SizeChanged()
   193     {
   187     {
   194     TRect rect( Rect() );
   188     TRect rect( Rect() );
   195     rect = NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 ).Rect();
   189     rect = NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 ).Rect();
   196     
   190 
   197     TRect viewerRect =
   191     TRect viewerRect =
   198         NMRLayoutManager::GetLayoutText( 
   192         NMRLayoutManager::GetLayoutText(
   199                 rect, 
   193                 rect,
   200                 NMRLayoutManager::EMRTextLayoutMultiRowTextEditor ).TextRect();
   194                 NMRLayoutManager::EMRTextLayoutMultiRowTextEditor ).TextRect();
   201     
   195 
   202     iRichTextViewer->SetRect( 
   196     TRect bgRect( viewerRect.iTl,
   203             TRect( viewerRect.iTl, 
   197             TSize( viewerRect.Width(), iSize.iHeight ) );
       
   198     // Move focus rect so that it's relative to field's position.
       
   199     bgRect.Move( -Position() );
       
   200 
       
   201     // Setting Font for the rich text viewer
       
   202     TAknLayoutText text = NMRLayoutManager::GetLayoutText(
       
   203                 Rect(),
       
   204                 NMRLayoutManager::EMRTextLayoutTextEditor );
       
   205 
       
   206     // Failures are ignored. 
       
   207     TRAP_IGNORE( 
       
   208             // Try setting font 
       
   209             iRichTextViewer->SetFontL( text.Font() );
       
   210             // Try applying changes
       
   211             iRichTextViewer->ApplyLayoutChangesL();
       
   212             );
       
   213 
       
   214     iRichTextViewer->SetRect(
       
   215             TRect( viewerRect.iTl,
   204                     TSize( viewerRect.Width(), iSize.iHeight ) ) );
   216                     TSize( viewerRect.Width(), iSize.iHeight ) ) );
       
   217 
       
   218     bgRect.SetHeight( iRichTextViewer->Rect().Height() );
       
   219     SetFocusRect( bgRect );
   205     }
   220     }
   206 
   221 
   207 // ---------------------------------------------------------------------------
   222 // ---------------------------------------------------------------------------
   208 // CESMRViewerDescriptionField::CountComponentControls()
   223 // CESMRViewerDescriptionField::CountComponentControls()
   209 // ---------------------------------------------------------------------------
   224 // ---------------------------------------------------------------------------
   235 TBool CESMRViewerDescriptionField::HandleEdwinSizeEventL(CEikEdwin* /*aEdwin*/,
   250 TBool CESMRViewerDescriptionField::HandleEdwinSizeEventL(CEikEdwin* /*aEdwin*/,
   236         TEdwinSizeEvent /*aType*/, TSize aSize )
   251         TEdwinSizeEvent /*aType*/, TSize aSize )
   237     {
   252     {
   238     FUNC_LOG;
   253     FUNC_LOG;
   239     iSize = aSize;
   254     iSize = aSize;
   240     
   255 
   241     if ( iObserver && iDisableRedraw )
   256     if ( iObserver && iDisableRedraw )
   242         {
   257         {
   243         iObserver->ControlSizeChanged ( this );
   258         iObserver->ControlSizeChanged ( this );
   244         }
   259         }
   245 
   260 
   246     return iDisableRedraw;
   261     return iDisableRedraw;
   247     }
   262     }
   248 
   263 
   249 // ---------------------------------------------------------------------------
   264 // ---------------------------------------------------------------------------
       
   265 // CESMRViewerDescriptionField::HandleRichTextLinkSelection
       
   266 // ---------------------------------------------------------------------------
       
   267 //
       
   268 TBool CESMRViewerDescriptionField::HandleRichTextLinkSelection(
       
   269         const CESMRRichTextLink* aLink )
       
   270     {
       
   271     TBool result = EFalse;
       
   272     if ( aLink &&
       
   273          aLink->Type() == CESMRRichTextLink::ETypeLocationUrl )
       
   274         {
       
   275         TRAPD( error, ShowLocationOnMapL( *aLink ) )
       
   276         if ( error )
       
   277             {
       
   278             iCoeEnv->HandleError( error );
       
   279             }
       
   280         result = ETrue;
       
   281         }
       
   282     return result;
       
   283     }
       
   284 
       
   285 // ---------------------------------------------------------------------------
   250 // CESMRViewerDescriptionField::CESMRViewerDescriptionField()
   286 // CESMRViewerDescriptionField::CESMRViewerDescriptionField()
   251 // ---------------------------------------------------------------------------
   287 // ---------------------------------------------------------------------------
   252 //
   288 //
   253 CESMRViewerDescriptionField::CESMRViewerDescriptionField( )
   289 CESMRViewerDescriptionField::CESMRViewerDescriptionField( )
   254     {
   290     {
   255     FUNC_LOG;
   291     FUNC_LOG;
   256     //do nothing
   292     SetFieldId( EESMRFieldDescription );
       
   293     SetFocusType( EESMRHighlightFocus );
   257     }
   294     }
   258 
   295 
   259 // ---------------------------------------------------------------------------
   296 // ---------------------------------------------------------------------------
   260 // CESMRViewerDescriptionField::ConstructL()
   297 // CESMRViewerDescriptionField::ConstructL()
   261 // ---------------------------------------------------------------------------
   298 // ---------------------------------------------------------------------------
   263 void CESMRViewerDescriptionField::ConstructL( )
   300 void CESMRViewerDescriptionField::ConstructL( )
   264     {
   301     {
   265     FUNC_LOG;
   302     FUNC_LOG;
   266     iRichTextViewer = CESMRRichTextViewer::NewL( this );
   303     iRichTextViewer = CESMRRichTextViewer::NewL( this );
   267     iRichTextViewer->SetEdwinSizeObserver( this );
   304     iRichTextViewer->SetEdwinSizeObserver( this );
       
   305     CESMRField::ConstructL( iRichTextViewer ); // ownership transferred
   268     iRichTextViewer->SetParent( this );
   306     iRichTextViewer->SetParent( this );
   269     
   307     iRichTextViewer->SetLinkObserver( this );
   270     SetFieldId( EESMRFieldDescription );
   308     }
   271     }
   309 
   272 
   310 // ---------------------------------------------------------------------------
   273 // ---------------------------------------------------------------------------
   311 // CESMRViewerDescriptionField::GetCursorLineVerticalPos()
   274 // CESMRViewerDescriptionField::GetMinimumVisibleVerticalArea()
   312 // ---------------------------------------------------------------------------
   275 // ---------------------------------------------------------------------------
   313 //
   276 //
   314 void CESMRViewerDescriptionField::GetCursorLineVerticalPos( TInt& aUpper, TInt& aLower )
   277 void CESMRViewerDescriptionField::GetMinimumVisibleVerticalArea(TInt& aUpper, TInt& aLower)
       
   278     {
   315     {
   279     FUNC_LOG;
   316     FUNC_LOG;
   280     aLower = iRichTextViewer->CurrentLineNumber() * iRichTextViewer->RowHeight();
   317     aLower = iRichTextViewer->CurrentLineNumber() * iRichTextViewer->RowHeight();
   281     aUpper = aLower - iRichTextViewer->RowHeight();
   318     aUpper = aLower - iRichTextViewer->RowHeight();
   282     }
   319     }
   293 
   330 
   294 // ---------------------------------------------------------------------------
   331 // ---------------------------------------------------------------------------
   295 // CESMRViewerDescriptionField::ExecuteGenericCommandL()
   332 // CESMRViewerDescriptionField::ExecuteGenericCommandL()
   296 // ---------------------------------------------------------------------------
   333 // ---------------------------------------------------------------------------
   297 //
   334 //
   298 void CESMRViewerDescriptionField::ExecuteGenericCommandL( TInt aCommand )
   335 TBool CESMRViewerDescriptionField::ExecuteGenericCommandL( TInt aCommand )
   299     {
   336     {
   300     FUNC_LOG;
   337     FUNC_LOG;
       
   338     TBool isUsed( EFalse );
   301     switch ( aCommand )
   339     switch ( aCommand )
   302         {
   340         {
   303         case EESMRCmdClipboardCopy:
   341         case EESMRCmdClipboardCopy:
   304             {
   342             {
   305             iRichTextViewer->CopyCurrentLinkToClipBoardL();
   343             iRichTextViewer->CopyCurrentLinkToClipBoardL();
       
   344             isUsed = ETrue;
   306             break;
   345             break;
   307             }
   346             }
   308         case EESMRCmdShowOnMap:
   347         case EAknSoftkeySelect:
   309             {
   348             {
   310             if ( FeaturesL().FeatureSupported(
   349             iRichTextViewer->LinkSelectedL();
   311                  CESMRFeatureSettings::EESMRUIMnFwIntegration ) )
   350             isUsed = ETrue;
   312                 {
       
   313                 const CESMRRichTextLink* link =
       
   314                     iRichTextViewer->GetSelectedLink();
       
   315                 if ( link )
       
   316                 	{
       
   317                 	LocationPluginL().ShowOnMapL( *iLocation, link->Value() );
       
   318                 	}
       
   319                 }
       
   320             break;
   351             break;
   321             }
   352             }
   322         case EAknSoftkeySelect:
   353         default:
   323             {
   354             {
   324             iRichTextViewer->LinkSelectedL();
       
   325             break;
   355             break;
   326             }
   356             }
   327         default:
   357         }
   328             {
   358     return isUsed;
   329             break;
       
   330             }
       
   331         }
       
   332     }
   359     }
   333 
   360 
   334 // ---------------------------------------------------------------------------
   361 // ---------------------------------------------------------------------------
   335 // CESMRDescriptionField::SetOutlineFocusL
   362 // CESMRDescriptionField::SetOutlineFocusL
   336 // ---------------------------------------------------------------------------
   363 // ---------------------------------------------------------------------------
   337 //
   364 //
   338 void CESMRViewerDescriptionField::SetOutlineFocusL( TBool aFocus )
   365 void CESMRViewerDescriptionField::SetOutlineFocusL( TBool aFocus )
   339     {
   366     {
   340     FUNC_LOG;
   367     FUNC_LOG;
   341     CESMRField::SetOutlineFocusL ( aFocus );
   368     CESMRField::SetOutlineFocusL ( aFocus );
   342     
   369 
   343     iRichTextViewer->SetFocus( aFocus );
   370     iRichTextViewer->SetFocus( aFocus );
   344     
   371 
   345     if ( FeaturesL().FeatureSupported(
   372     if ( FeaturesL().FeatureSupported(
   346             CESMRFeatureSettings::EESMRUIMnFwIntegration ) )
   373             CESMRFeatureSettings::EESMRUIMnFwIntegration ) )
   347         {
   374         {
   348         if ( aFocus )
   375         if ( aFocus )
   349             {
   376             {
   350             SetShowOnMapLinkMiddleSoftKeyL();
   377             SetShowOnMapLinkMiddleSoftKeyL();
   351             }
   378             }
   352         }
   379         }
   353     
   380 
   354     if ( !aFocus )
   381     if ( !aFocus )
   355         {
   382         {
   356         //need to tell action menu that focus has changed
   383         //need to tell action menu that focus has changed
   357         iRichTextViewer->ResetActionMenuL();
   384         iRichTextViewer->ResetActionMenuL();
   358         }
   385         }
   359     }
   386     }
   360 
   387 
   361 // ---------------------------------------------------------------------------
   388 // ---------------------------------------------------------------------------
       
   389 // CESMRDescriptionField::HandleLongtapEventL
       
   390 // ---------------------------------------------------------------------------
       
   391 //
       
   392 void CESMRViewerDescriptionField::HandleLongtapEventL(
       
   393         const TPoint& aPosition )
       
   394     {
       
   395     FUNC_LOG;
       
   396     
       
   397     if ( iRichTextViewer->Rect().Contains( aPosition ) )
       
   398         {
       
   399         if( iRichTextViewer->LinkSelectedL() )
       
   400         	{
       
   401 			HandleTactileFeedbackL();        
       
   402         	}
       
   403         		
       
   404         }
       
   405     }
       
   406 
       
   407 // ---------------------------------------------------------------------------
   362 // CESMRViewerDescriptionField::AddShowOnMapLinkL
   408 // CESMRViewerDescriptionField::AddShowOnMapLinkL
   363 // ---------------------------------------------------------------------------
   409 // ---------------------------------------------------------------------------
   364 //
   410 //
   365 void CESMRViewerDescriptionField::AddShowOnMapLinkL( MESMRCalEntry& aEntry )
   411 void CESMRViewerDescriptionField::AddShowOnMapLinkL( MESMRCalEntry& aEntry )
   366     {
   412     {
   367     FUNC_LOG;
   413     FUNC_LOG;
   368     TInt command( EESMRCmdDisableWaypointIcon );
   414 
   369     CESMRUrlParserPlugin* urlParser = CESMRUrlParserPlugin::NewL();
       
   370     CleanupStack::PushL( urlParser );
       
   371     TPtrC urlPointer;
   415     TPtrC urlPointer;
   372     TInt position;
   416     TInt position;
   373     position = urlParser->FindLocationUrl( aEntry.Entry().DescriptionL(), 
   417     position = UrlParserL().FindLocationUrl( aEntry.Entry().DescriptionL(),
   374                                            urlPointer );
   418                                            urlPointer );
   375     CleanupStack::PopAndDestroy( urlParser );
   419 
   376     // Location url is found and need to be replaced with show on map link
   420     // Location url is found and need to be replaced with show on map link
   377     if ( position >= KErrNone )
   421     if ( position >= KErrNone )
   378         {
   422         {
   379         HBufC* showOnMapBuf =
   423         HBufC* showOnMapBuf =
   380             StringLoader::LoadLC( R_MEET_REQ_LINK_SHOW_ON_MAP,
   424             StringLoader::LoadLC( R_MEET_REQ_LINK_SHOW_ON_MAP,
   385         TPtr descriptionPointer( description->Des() );
   429         TPtr descriptionPointer( description->Des() );
   386         descriptionPointer.Append( aEntry.Entry().DescriptionL() );
   430         descriptionPointer.Append( aEntry.Entry().DescriptionL() );
   387         descriptionPointer.Replace( position,
   431         descriptionPointer.Replace( position,
   388                                     urlPointer.Length(),
   432                                     urlPointer.Length(),
   389                                     *showOnMapBuf );
   433                                     *showOnMapBuf );
   390         CESMRRichTextLink* showOnMapLink = CESMRRichTextLink::NewL( position, 
   434         CESMRRichTextLink* showOnMapLink = CESMRRichTextLink::NewL( position,
   391                                              showOnMapBuf->Length(), 
   435                                              showOnMapBuf->Length(),
   392                                              urlPointer,
   436                                              urlPointer,
   393                                              CESMRRichTextLink::ETypeLocationUrl,
   437                                              CESMRRichTextLink::ETypeLocationUrl,
   394                                              CESMRRichTextLink::ETriggerKeyOk );
   438                                              CESMRRichTextLink::ETriggerKeyOk );
   395         CleanupStack::PushL( showOnMapLink );
   439         CleanupStack::PushL( showOnMapLink );
   396         iRichTextViewer->SetTextL( description, ETrue );
   440         iRichTextViewer->SetTextL( description, ETrue );
   397         iRichTextViewer->InsertLinkL( showOnMapLink, 0 ); 
   441         iRichTextViewer->InsertLinkL( showOnMapLink, 0 );
   398         CleanupStack::Pop( showOnMapLink );                
   442         CleanupStack::Pop( showOnMapLink );
   399         iRichTextViewer->HandleTextChangedL();
   443         iRichTextViewer->HandleTextChangedL();
   400         CleanupStack::PopAndDestroy( description );
   444         CleanupStack::PopAndDestroy( description );
   401         CleanupStack::PopAndDestroy( showOnMapBuf );
   445         CleanupStack::PopAndDestroy( showOnMapBuf );
   402         command = EESMRCmdEnableWaypointIcon;
   446 
   403         
   447         StoreGeoValueL(
   404         const TDesC& location = aEntry.Entry().LocationL();
   448                 aEntry.Entry(),
   405         delete iLocation;
   449                 urlPointer );
   406         iLocation = NULL; 
       
   407         iLocation = location.AllocL();     
       
   408         }
   450         }
   409     // No location url found. Other description text is added to field.
   451     // No location url found. Other description text is added to field.
   410     else
   452     else
   411         {
   453         {
   412         TPtrC text = aEntry.Entry().DescriptionL();
   454         TPtrC text = aEntry.Entry().DescriptionL();
   413         iRichTextViewer->SetTextL( &text, ETrue );
   455         iRichTextViewer->SetTextL( &text, ETrue );
   414         }
   456         }
   415     
   457 
   416     iRichTextViewer->SetMargins( KMargin );
   458     iRichTextViewer->SetMargins( KMargin );
   417     NotifyEventL( command );
       
   418     }
   459     }
   419 
   460 
   420 // ---------------------------------------------------------------------------
   461 // ---------------------------------------------------------------------------
   421 // CESMRViewerDescriptionField::SetShowOnMapLinkMiddleSoftKeyL
   462 // CESMRViewerDescriptionField::SetShowOnMapLinkMiddleSoftKeyL
   422 // ---------------------------------------------------------------------------
   463 // ---------------------------------------------------------------------------
   433             }
   474             }
   434         else
   475         else
   435             {
   476             {
   436             RestoreMiddleSoftKeyL();
   477             RestoreMiddleSoftKeyL();
   437             }
   478             }
   438         
   479 
   439         SetMiddleSoftKeyVisible( ETrue );
   480         SetMiddleSoftKeyVisible( ETrue );
   440         }
   481         }
   441     else
   482     else
   442         {
   483         {
   443         RestoreMiddleSoftKeyL();
   484         RestoreMiddleSoftKeyL();
   453     FUNC_LOG;
   494     FUNC_LOG;
   454     if ( !iFeatures )
   495     if ( !iFeatures )
   455         {
   496         {
   456         iFeatures = CESMRFeatureSettings::NewL();
   497         iFeatures = CESMRFeatureSettings::NewL();
   457         }
   498         }
   458     
   499 
   459     return *iFeatures;
   500     return *iFeatures;
   460     }
   501     }
   461 
   502 
   462 // ---------------------------------------------------------------------------
   503 // ---------------------------------------------------------------------------
   463 // CESMRViewerDescriptionField::LocationPluginL
   504 // CESMRViewerDescriptionField::LocationPluginL
   468     FUNC_LOG;
   509     FUNC_LOG;
   469     if ( !iLocationPlugin )
   510     if ( !iLocationPlugin )
   470         {
   511         {
   471         iLocationPlugin = CESMRLocationPlugin::NewL();
   512         iLocationPlugin = CESMRLocationPlugin::NewL();
   472         }
   513         }
   473     
   514 
   474     return *iLocationPlugin;
   515     return *iLocationPlugin;
   475     }
   516     }
   476 
   517 
       
   518 // ---------------------------------------------------------------------------
       
   519 // CESMRViewerDescriptionField::ShowLocationOnMapL
       
   520 // ---------------------------------------------------------------------------
       
   521 //
       
   522 void CESMRViewerDescriptionField::ShowLocationOnMapL(
       
   523         const CESMRRichTextLink& aLink )
       
   524     {
       
   525     FUNC_LOG;
       
   526 
       
   527     if ( FeaturesL().FeatureSupported(
       
   528             CESMRFeatureSettings::EESMRUIMnFwIntegration ) )
       
   529         {
       
   530         LocationPluginL().ShowOnMapL( aLink.Value() );
       
   531         }
       
   532     }
       
   533 
       
   534 // ---------------------------------------------------------------------------
       
   535 // CESMRViewerDescriptionField::StoreGeoValueL
       
   536 // ---------------------------------------------------------------------------
       
   537 //
       
   538 void CESMRViewerDescriptionField::StoreGeoValueL(
       
   539         CCalEntry& aCalEntry,
       
   540         const TDesC& aLocationUrl )
       
   541     {
       
   542     FUNC_LOG;
       
   543 
       
   544     TReal lat, lon;
       
   545     CCalGeoValue* geoVal = aCalEntry.GeoValueL();
       
   546 
       
   547     if ( !geoVal || ! geoVal->GetLatLong( lat, lon ) )
       
   548         {
       
   549         // GEO value not set. Convert URL
       
   550         geoVal = UrlParserL().CreateGeoValueLC( aLocationUrl );
       
   551         aCalEntry.SetGeoValueL( *geoVal );
       
   552         CleanupStack::Pop( geoVal );
       
   553 
       
   554         NotifyEventL( EESMRCmdEnableWaypointIcon );
       
   555         }
       
   556     }
       
   557 
       
   558 // ---------------------------------------------------------------------------
       
   559 // CESMRViewerDescriptionField::UrlParserL
       
   560 // ---------------------------------------------------------------------------
       
   561 //
       
   562 CESMRUrlParserPlugin& CESMRViewerDescriptionField::UrlParserL()
       
   563     {
       
   564     FUNC_LOG;
       
   565 
       
   566     if ( !iUrlParser )
       
   567         {
       
   568         iUrlParser = CESMRUrlParserPlugin::NewL();
       
   569         }
       
   570 
       
   571     return *iUrlParser;
       
   572     }
       
   573 
   477 //EOF
   574 //EOF
   478 
   575