meetingrequest/mrgui/mrfieldbuilderplugin/src/cesmrdescriptionfield.cpp
branchRCL_3
changeset 12 4ce476e64c59
parent 0 8466d47a6819
child 16 b5fbb9b25d57
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".
    13 *
    13 *
    14 * Description:  ESMR Description (summary) field implementation
    14 * Description:  ESMR Description (summary) field implementation
    15  *
    15  *
    16 */
    16 */
    17 
    17 
    18 
       
    19 #include "emailtrace.h"
       
    20 #include <calentry.h>
       
    21 #include <StringLoader.h>
       
    22 #include <esmrgui.rsg>
       
    23 #include <AknUtils.h>
       
    24 #include <AknsDrawUtils.h>
       
    25 #include <AknsFrameBackgroundControlContext.h>
       
    26 //<cmail>
       
    27 #include "cesmrurlparserplugin.h"
       
    28 //</cmail>
       
    29 
       
    30 #include "cesmrdescriptionfield.h"
    18 #include "cesmrdescriptionfield.h"
    31 #include "mesmrlistobserver.h"
    19 #include "mesmrlistobserver.h"
    32 #include "cesmreditor.h"
    20 #include "cesmreditor.h"
    33 #include "cesmrrichtextlink.h"
    21 #include "cesmrrichtextlink.h"
    34 #include "cesmrlayoutmgr.h"
       
    35 #include "esmrfieldbuilderdef.h"
    22 #include "esmrfieldbuilderdef.h"
    36 #include "cesmrfeaturesettings.h"
    23 #include "cesmrfeaturesettings.h"
    37 #include "cesmrglobalnote.h"
    24 #include "cesmrglobalnote.h"
    38 
    25 #include "nmrlayoutmanager.h"
    39 namespace{ // codescanner::namespace
    26 #include "nmrbitmapmanager.h"
    40 const TInt KFieldInnerShrink(3);
    27 //<cmail>
    41 }//namespace
    28 #include "cesmrurlparserplugin.h"
       
    29 //</cmail>
       
    30 
       
    31 #include <calentry.h>
       
    32 #include <stringloader.h>
       
    33 #include <esmrgui.rsg>
       
    34 #include <aknutils.h>
       
    35 #include <aknsbasicbackgroundcontrolcontext.h>
       
    36 #include <eikmfne.h>
       
    37 
       
    38 // DEBUG
       
    39 #include "emailtrace.h"
       
    40 
       
    41 namespace // codescanner::namespace
       
    42     {
       
    43     /// Field's component count, iDescription
       
    44     const TInt KComponentCount( 1 );
       
    45     }//namespace
    42 
    46 
    43 // ======== MEMBER FUNCTIONS ========
    47 // ======== MEMBER FUNCTIONS ========
    44 
    48 
    45 // ---------------------------------------------------------------------------
    49 // ---------------------------------------------------------------------------
    46 // CESMRDescriptionField::NewL
    50 // CESMRDescriptionField::NewL
    61 // ---------------------------------------------------------------------------
    65 // ---------------------------------------------------------------------------
    62 //
    66 //
    63 CESMRDescriptionField::~CESMRDescriptionField( )
    67 CESMRDescriptionField::~CESMRDescriptionField( )
    64     {
    68     {
    65     FUNC_LOG;
    69     FUNC_LOG;
    66     delete iFrameBgContext;
       
    67     
       
    68     delete iLocationLink;
    70     delete iLocationLink;
    69     
       
    70     delete iFeatures;
    71     delete iFeatures;
       
    72     delete iBgControlContext;
       
    73     delete iUrlParser;
    71     }
    74     }
    72 
    75 
    73 // ---------------------------------------------------------------------------
    76 // ---------------------------------------------------------------------------
    74 // CESMRDescriptionField::InitializeL
    77 // CESMRDescriptionField::InitializeL
    75 // ---------------------------------------------------------------------------
    78 // ---------------------------------------------------------------------------
    76 //
    79 //
    77 void CESMRDescriptionField::InitializeL()
    80 void CESMRDescriptionField::InitializeL()
    78     {
    81     {
    79     FUNC_LOG;
    82     FUNC_LOG;
    80     iDescription->SetFontL( iLayout->Font (iCoeEnv, iFieldId ), iLayout );
    83     // Do nothing
    81     }
    84     }
    82 
    85 
    83 // ---------------------------------------------------------------------------
    86 // ---------------------------------------------------------------------------
    84 // CESMRDescriptionField::InternalizeL
    87 // CESMRDescriptionField::InternalizeL
    85 // ---------------------------------------------------------------------------
    88 // ---------------------------------------------------------------------------
    89     FUNC_LOG;
    92     FUNC_LOG;
    90     CCalEntry& entry = aEntry.Entry ( );
    93     CCalEntry& entry = aEntry.Entry ( );
    91     HBufC* summary = entry.DescriptionL().AllocLC ( );
    94     HBufC* summary = entry.DescriptionL().AllocLC ( );
    92 
    95 
    93     // externalize is done only when there is text and its NOT the default one.
    96     // externalize is done only when there is text and its NOT the default one.
    94     if ( summary->Length ( )> 0 && iDescription->DefaultText().Compare (*summary )!= 0 )
    97     if ( summary->Length ( )> 0 &&
       
    98             iDescription->DefaultText().Compare (*summary )!= 0 )
    95         {
    99         {
    96         iDescription->ClearSelectionAndSetTextL ( *summary );
   100         iDescription->ClearSelectionAndSetTextL ( *summary );
    97         if ( FeaturesL().FeatureSupported(
   101         if ( FeaturesL().FeatureSupported(
    98                 CESMRFeatureSettings::EESMRUIMnFwIntegration ) )
   102                 CESMRFeatureSettings::EESMRUIMnFwIntegration ) )
    99             {
   103             {
   114 //
   118 //
   115 void CESMRDescriptionField::ExternalizeL( MESMRCalEntry& aEntry )
   119 void CESMRDescriptionField::ExternalizeL( MESMRCalEntry& aEntry )
   116     {
   120     {
   117     FUNC_LOG;
   121     FUNC_LOG;
   118     HBufC* buf = iDescription->GetTextInHBufL();
   122     HBufC* buf = iDescription->GetTextInHBufL();
   119 
   123     CCalEntry& entry = aEntry.Entry();
       
   124     
   120     if( buf )
   125     if( buf )
   121         {
   126         {
   122         CleanupStack::PushL( buf );
   127         CleanupStack::PushL( buf );
   123 
   128 
   124         if( iDescription->DefaultText().Compare( *buf ) != 0 )
   129         if( iDescription->DefaultText().Compare( *buf ) != 0 )
   125             {
   130             {
   126             CCalEntry& entry = aEntry.Entry();
   131             // Edited text. Add link to description text
   127                         
       
   128             HBufC* newBuf = AddLinkToTextL( *buf );
   132             HBufC* newBuf = AddLinkToTextL( *buf );
   129             if( newBuf )
   133             if( newBuf )
   130                 {
   134                 {
   131                 CleanupStack::PopAndDestroy( buf );
   135                 CleanupStack::PopAndDestroy( buf );
   132                 buf = newBuf;
   136                 buf = newBuf;
   133                 CleanupStack::PushL( buf );
   137                 CleanupStack::PushL( buf );
   134                 }
   138                 }
   135             entry.SetDescriptionL( *buf );
   139             entry.SetDescriptionL( *buf );
   136             }
   140             }
       
   141         else if ( iLocationLink )
       
   142             {
       
   143             // Location link set
       
   144             entry.SetDescriptionL( iLocationLink->Value() );
       
   145             }
       
   146         else if ( entry.DescriptionL().Length() != 0 )
       
   147             {
       
   148             // Clear old description
       
   149             entry.SetDescriptionL( KNullDesC );
       
   150             }
   137         CleanupStack::PopAndDestroy( buf );
   151         CleanupStack::PopAndDestroy( buf );
   138         }
   152         }
   139     else if( iLocationLink )
   153     else if( iLocationLink )
   140         {
   154         {
   141         CCalEntry& entry = aEntry.Entry();
       
   142         entry.SetDescriptionL( iLocationLink->Value() );
   155         entry.SetDescriptionL( iLocationLink->Value() );
   143         }
   156         }
   144     else
   157     else
   145         {
   158         {
   146         CCalEntry& entry = aEntry.Entry();
       
   147         entry.SetDescriptionL( KNullDesC );
   159         entry.SetDescriptionL( KNullDesC );
   148         }
   160         }
   149     }
   161     }
   150 
   162 
   151 // ---------------------------------------------------------------------------
   163 // ---------------------------------------------------------------------------
   161         ChangeMiddleSoftKeyL(EESMRCmdSaveMR,R_QTN_MSK_SAVE);
   173         ChangeMiddleSoftKeyL(EESMRCmdSaveMR,R_QTN_MSK_SAVE);
   162         }
   174         }
   163     }
   175     }
   164 
   176 
   165 // ---------------------------------------------------------------------------
   177 // ---------------------------------------------------------------------------
   166 // CESMRDescriptionField::ExpandedHeight
       
   167 // ---------------------------------------------------------------------------
       
   168 //
       
   169 TInt CESMRDescriptionField::ExpandedHeight( ) const
       
   170     {
       
   171     FUNC_LOG;
       
   172     return iSize.iHeight;
       
   173     }
       
   174 
       
   175 // ---------------------------------------------------------------------------
       
   176 // CESMRDescriptionField::OfferKeyEventL
   178 // CESMRDescriptionField::OfferKeyEventL
   177 // ---------------------------------------------------------------------------
   179 // ---------------------------------------------------------------------------
   178 //
   180 //
   179 TKeyResponse CESMRDescriptionField::OfferKeyEventL(const TKeyEvent& aEvent,
   181 TKeyResponse CESMRDescriptionField::OfferKeyEventL(const TKeyEvent& aEvent,
   180         TEventCode aType )
   182         TEventCode aType )
   181     {
   183     {
   182     FUNC_LOG;
   184     FUNC_LOG;
   183     return iDescription->OfferKeyEventL( aEvent, aType );
   185     TKeyResponse response( EKeyWasNotConsumed);
       
   186     response = iDescription->OfferKeyEventL( aEvent, aType );
       
   187 
       
   188     if ( aType == EEventKey &&
       
   189          ( aEvent.iScanCode != EStdKeyUpArrow &&
       
   190           aEvent.iScanCode != EStdKeyDownArrow ))
       
   191         {
       
   192         iDescription->DrawDeferred();
       
   193         }
       
   194 
       
   195     return response;
   184     }
   196     }
   185 
   197 
   186 // ---------------------------------------------------------------------------
   198 // ---------------------------------------------------------------------------
   187 // CESMRDescriptionField::HandleEdwinSizeEventL
   199 // CESMRDescriptionField::HandleEdwinSizeEventL
   188 // ---------------------------------------------------------------------------
   200 // ---------------------------------------------------------------------------
   189 //
   201 //
   190 TBool CESMRDescriptionField::HandleEdwinSizeEventL(CEikEdwin* /*aEdwin*/,
   202 TBool CESMRDescriptionField::HandleEdwinSizeEventL(CEikEdwin* /*aEdwin*/,
   191         TEdwinSizeEvent /*aType*/, TSize aSize )
   203         TEdwinSizeEvent /*aType*/, TSize aSize )
   192     {
   204     {
   193     FUNC_LOG;
   205     FUNC_LOG;
   194     iSize = aSize;
   206     if ( aSize != iSize )
   195     iSize.iHeight -= KEditorDifference;
   207         {
   196 
   208         iSize = aSize;
   197     if (iLayout->CurrentFontZoom() == EAknUiZoomSmall ||
   209 
   198         iLayout->CurrentFontZoom() == EAknUiZoomVerySmall)
   210         if ( iObserver )
   199         {
   211             {
   200         iSize.iHeight -= KEditorDifference;
   212             iObserver->ControlSizeChanged ( this );
   201         }
   213             }
   202 
   214 
   203     if ( iObserver )
   215         if( iDescription->LineCount() != iLineCount )
   204         {
   216             {
   205         iObserver->ControlSizeChanged ( this );
   217             // Line count has changed, the whole component needs
   206         }
   218             // to be redrawn
   207 
   219             DrawDeferred();
   208     if( iFrameBgContext )
   220 
   209         {
   221             // Also if new line count is less than previous one, we
   210         TRect visibleRect = CalculateVisibleRect( iDescription->Rect() );
   222             // need to redraw the parent also (this is the last field).
   211         iFrameBgContext->SetFrameRects( visibleRect, visibleRect );
   223             // Otherwise the removed line will remain on the screen
       
   224             // until parent is redrawn.
       
   225             if( iDescription->LineCount() < iLineCount )
       
   226                 {
       
   227                 Parent()->DrawDeferred();
       
   228                 }
       
   229             iLineCount = iDescription->LineCount();
       
   230             }
   212         }
   231         }
   213 
   232 
   214     return ETrue;
   233     return ETrue;
   215     }
   234     }
   216 
   235 
   217 // ---------------------------------------------------------------------------
   236 // ---------------------------------------------------------------------------
   218 // CESMRDescriptionField::HandleEdwinEventL
   237 // CESMRDescriptionField::HandleEdwinEventL
   219 // ---------------------------------------------------------------------------
   238 // ---------------------------------------------------------------------------
   220 //
   239 //
   221 void CESMRDescriptionField::HandleEdwinEventL(CEikEdwin* aEdwin,TEdwinEvent aEventType)
   240 void CESMRDescriptionField::HandleEdwinEventL(
   222 	{
   241         CEikEdwin* aEdwin,TEdwinEvent aEventType)
       
   242     {
   223     FUNC_LOG;
   243     FUNC_LOG;
   224     if ( aEdwin == iDescription
   244     if ( aEdwin == iDescription
   225     		&& aEventType == EEventTextUpdate )
   245          && aEventType == EEventTextUpdate )
   226         {
   246         {
   227         HBufC* text = iDescription->GetTextInHBufL();
   247         HBufC* text = iDescription->GetTextInHBufL();
   228         if ( text )
   248         if ( text )
   229             {
   249             {
   230             CleanupStack::PushL( text );
   250             CleanupStack::PushL( text );
   231             TInt textLength( text->Length() );
   251             TInt textLength( text->Length() );
   232             if ( iDescription->GetLimitLength() <= textLength )
   252             if ( iDescription->GetLimitLength() <= textLength )
   233             	{
   253                 {
   234             	NotifyEventAsyncL( EESMRCmdSizeExceeded );
   254                 NotifyEventAsyncL( EESMRCmdSizeExceeded );
   235             	}            
   255                 }
   236             CleanupStack::PopAndDestroy( text );
   256             CleanupStack::PopAndDestroy( text );
   237             }
   257             }
   238         }
   258         }
   239 	}
   259     }
   240 
   260 
   241 // ---------------------------------------------------------------------------
   261 // ---------------------------------------------------------------------------
   242 // CESMRDescriptionField::CESMRDescriptionField
   262 // CESMRDescriptionField::CESMRDescriptionField
   243 // ---------------------------------------------------------------------------
   263 // ---------------------------------------------------------------------------
   244 //
   264 //
   245 CESMRDescriptionField::CESMRDescriptionField() :
   265 CESMRDescriptionField::CESMRDescriptionField()
   246     iSize( TSize( 0, 0 ))
   266     {
   247     {
   267     FUNC_LOG;
   248     FUNC_LOG;
   268     SetFieldId( EESMRFieldDescription );
   249     }
   269     SetFocusType( EESMRHighlightFocus );
   250 
       
   251 // ---------------------------------------------------------------------------
       
   252 // CESMRDescriptionField::ActivateL
       
   253 // ---------------------------------------------------------------------------
       
   254 //
       
   255 void CESMRDescriptionField::ActivateL()
       
   256     {
       
   257     FUNC_LOG;
       
   258     CCoeControl::ActivateL();
       
   259     TRect rect(TPoint(iDescription->Position()), iDescription->Size());
       
   260     TRect inner(rect);
       
   261     inner.Shrink( KFieldInnerShrink, KFieldInnerShrink );
       
   262     TRect outer(rect);
       
   263 
       
   264     delete iFrameBgContext;
       
   265     iFrameBgContext = NULL;
       
   266     iFrameBgContext = CAknsFrameBackgroundControlContext::NewL( KAknsIIDQsnFrInput, 
       
   267                                                                 outer, 
       
   268                                                                 inner, 
       
   269                                                                 EFalse );
       
   270 
       
   271     iFrameBgContext->SetParentContext( iBackground );
       
   272     iDescription->SetSkinBackgroundControlContextL( iFrameBgContext );
       
   273     }
       
   274 
       
   275 // ---------------------------------------------------------------------------
       
   276 // CESMRDescriptionField::PositionChanged()
       
   277 // ---------------------------------------------------------------------------
       
   278 //
       
   279 void CESMRDescriptionField::PositionChanged()
       
   280     {
       
   281     FUNC_LOG;
       
   282     CCoeControl::PositionChanged();
       
   283     if( iFrameBgContext )
       
   284         {
       
   285         TRect visibleRect = CalculateVisibleRect( iDescription->Rect() );
       
   286         iFrameBgContext->SetFrameRects( visibleRect, visibleRect );
       
   287         }
       
   288     }
   270     }
   289 
   271 
   290 // ---------------------------------------------------------------------------
   272 // ---------------------------------------------------------------------------
   291 // CESMRDescriptionField::ConstructL
   273 // CESMRDescriptionField::ConstructL
   292 // ---------------------------------------------------------------------------
   274 // ---------------------------------------------------------------------------
   293 //
   275 //
   294 void CESMRDescriptionField::ConstructL()
   276 void CESMRDescriptionField::ConstructL()
   295     {
   277     {
   296     FUNC_LOG;
   278     FUNC_LOG;
   297     SetFieldId( EESMRFieldDescription );
       
   298     SetExpandable( );
       
   299     iDescription = CESMREditor::NewL( this, 1, KTextLimit,
   279     iDescription = CESMREditor::NewL( this, 1, KTextLimit,
   300                                     CEikEdwin::EResizable |
   280                                     CEikEdwin::EResizable |
   301                                     CEikEdwin::EAvkonEditor );
   281                                     CEikEdwin::EAvkonEditor );
   302     iDescription->SetEdwinSizeObserver( this );
   282     iDescription->SetEdwinSizeObserver( this );
   303     iDescription->SetEdwinObserver( this );
   283     iDescription->SetEdwinObserver( this );
       
   284     CESMRField::ConstructL( iDescription );
   304 
   285 
   305     HBufC* buf = StringLoader::LoadLC( R_QTN_MEET_REQ_DETAILS_FIELD );
   286     HBufC* buf = StringLoader::LoadLC( R_QTN_MEET_REQ_DETAILS_FIELD );
   306     iDescription->SetDefaultTextL( buf ); // ownership transferred
   287     iDescription->SetDefaultTextL( buf ); // ownership transferred
   307     CleanupStack::Pop( buf );
   288     CleanupStack::Pop( buf );
   308 
   289 
   309     iBackground = AknsDrawUtils::ControlContext( this );
   290     // Setting background instead of theme skin
   310 
   291     NMRBitmapManager::TMRBitmapStruct bitmapStruct;
   311     CESMRField::ConstructL( iDescription );
   292     bitmapStruct = NMRBitmapManager::GetBitmapStruct( NMRBitmapManager::EMRBitmapInputCenter );
   312     }
   293 
   313 
   294     TRect initialisationRect( 0, 0, 0, 0 );
   314 // ---------------------------------------------------------------------------
   295     iBgControlContext = CAknsBasicBackgroundControlContext::NewL(
   315 // CESMRDescriptionField::GetMinimumVisibleVerticalArea
   296                 bitmapStruct.iItemId,
   316 // ---------------------------------------------------------------------------
   297                 initialisationRect,
   317 //
   298                 EFalse );
   318 void CESMRDescriptionField::GetMinimumVisibleVerticalArea(TInt& aUpper, TInt& aLower)
   299 
   319     {
   300     iDescription->SetSkinBackgroundControlContextL( iBgControlContext );
   320     FUNC_LOG;
   301     }
       
   302 
       
   303 // ---------------------------------------------------------------------------
       
   304 // CESMRDescriptionField::ListObserverSet
       
   305 // ---------------------------------------------------------------------------
       
   306 //
       
   307 void CESMRDescriptionField::ListObserverSet()
       
   308     {
       
   309     FUNC_LOG;
       
   310     iDescription->SetListObserver( iObserver );
       
   311     }
       
   312 
       
   313 // ---------------------------------------------------------------------------
       
   314 // CESMRDescriptionField::GetCursorLineVerticalPos
       
   315 // ---------------------------------------------------------------------------
       
   316 //
       
   317 void CESMRDescriptionField::GetCursorLineVerticalPos(TInt& aUpper, TInt& aLower)
       
   318     {
   321     aLower = iDescription->CurrentLineNumber() * iDescription->RowHeight();
   319     aLower = iDescription->CurrentLineNumber() * iDescription->RowHeight();
   322     aUpper = aLower - iDescription->RowHeight();
   320     aUpper = aLower - iDescription->RowHeight();
   323     }
   321     }
   324 
   322 
   325 // ---------------------------------------------------------------------------
   323 // ---------------------------------------------------------------------------
   326 // CESMRDescriptionField::ListObserverSet
       
   327 // ---------------------------------------------------------------------------
       
   328 //
       
   329 void CESMRDescriptionField::ListObserverSet()
       
   330     {
       
   331     FUNC_LOG;
       
   332     iDescription->SetListObserver( iObserver );
       
   333     }
       
   334 
       
   335 // ---------------------------------------------------------------------------
       
   336 // CESMRDescriptionField::StoreLinkL
   324 // CESMRDescriptionField::StoreLinkL
   337 // ---------------------------------------------------------------------------
   325 // ---------------------------------------------------------------------------
   338 //
   326 //
   339 void CESMRDescriptionField::StoreLinkL( MESMRCalEntry& aEntry )
   327 void CESMRDescriptionField::StoreLinkL( MESMRCalEntry& aEntry )
   340     {
   328     {
   341     FUNC_LOG;
   329     FUNC_LOG;
   342     TInt command( EESMRCmdDisableWaypointIcon );
       
   343     CESMRUrlParserPlugin* urlParser = CESMRUrlParserPlugin::NewL();
       
   344     CleanupStack::PushL( urlParser );
       
   345     TPtrC urlPointer;
   330     TPtrC urlPointer;
   346     TInt position;
   331     TInt position;
   347     position = urlParser->FindLocationUrl( aEntry.Entry().DescriptionL(), 
   332     position = UrlParserL().FindLocationUrl( aEntry.Entry().DescriptionL(),
   348                                            urlPointer );
   333                                            urlPointer );
   349     CleanupStack::PopAndDestroy( urlParser );
   334 
   350     if ( position >= KErrNone )
   335     if ( position >= KErrNone )
   351         {
   336         {
   352         command = EESMRCmdEnableWaypointIcon;
       
   353         HBufC* description =
   337         HBufC* description =
   354             HBufC::NewL( aEntry.Entry().DescriptionL().Length() );
   338             HBufC::NewL( aEntry.Entry().DescriptionL().Length() );
   355         CleanupStack::PushL( description );
   339         CleanupStack::PushL( description );
   356         TPtr descriptionPointer( description->Des() );
   340         TPtr descriptionPointer( description->Des() );
   357         descriptionPointer.Append( aEntry.Entry().DescriptionL() );
   341         descriptionPointer.Append( aEntry.Entry().DescriptionL() );
   361             {
   345             {
   362             iDescription->ClearSelectionAndSetTextL( *description );
   346             iDescription->ClearSelectionAndSetTextL( *description );
   363             }
   347             }
   364         else
   348         else
   365             {
   349             {
   366             iDescription->ClearSelectionAndSetTextL( iDescription->DefaultText() );
   350             iDescription->ClearSelectionAndSetTextL(
       
   351                     iDescription->DefaultText() );
   367             }
   352             }
   368         CleanupStack::PopAndDestroy( description );
   353         CleanupStack::PopAndDestroy( description );
   369 
   354 
   370         if ( iLocationLink )
   355         if ( iLocationLink )
   371             {
   356             {
   372             delete iLocationLink;
   357             delete iLocationLink;
   373             iLocationLink = NULL;
   358             iLocationLink = NULL;
   374             }
   359             }
   375         HBufC* showOnMapBuf =
   360         HBufC* showOnMapBuf =
   376             StringLoader::LoadLC( R_MEET_REQ_LINK_SHOW_ON_MAP );        
   361             StringLoader::LoadLC( R_MEET_REQ_LINK_SHOW_ON_MAP );
   377         iLocationLink = CESMRRichTextLink::NewL( position, 
   362         iLocationLink = CESMRRichTextLink::NewL( position,
   378                                      showOnMapBuf->Length(), 
   363                                      showOnMapBuf->Length(),
   379                                      urlPointer,
   364                                      urlPointer,
   380                                      CESMRRichTextLink::ETypeLocationUrl,
   365                                      CESMRRichTextLink::ETypeLocationUrl,
   381                                      CESMRRichTextLink::ETriggerKeyOk );
   366                                      CESMRRichTextLink::ETriggerKeyOk );
   382         CleanupStack::PopAndDestroy( showOnMapBuf );        
   367         CleanupStack::PopAndDestroy( showOnMapBuf );
   383         }
   368 
   384     
   369         StoreGeoValueL( aEntry.Entry(),
   385     NotifyEventL( command );
   370                         urlPointer );
       
   371         }
   386     }
   372     }
   387 
   373 
   388 // ---------------------------------------------------------------------------
   374 // ---------------------------------------------------------------------------
   389 // CESMRDescriptionField::AddLinkToTextL
   375 // CESMRDescriptionField::AddLinkToTextL
   390 // ---------------------------------------------------------------------------
   376 // ---------------------------------------------------------------------------
   394     FUNC_LOG;
   380     FUNC_LOG;
   395     if( iLocationLink )
   381     if( iLocationLink )
   396         {
   382         {
   397         TInt newTextLen = aBuf.Length() + iLocationLink->Value().Length() + 1;
   383         TInt newTextLen = aBuf.Length() + iLocationLink->Value().Length() + 1;
   398         HBufC* retBuf = HBufC::NewL( newTextLen );
   384         HBufC* retBuf = HBufC::NewL( newTextLen );
   399         
   385 
   400         retBuf->Des().Append( iLocationLink->Value() );
   386         retBuf->Des().Append( iLocationLink->Value() );
   401         _LIT( KParagraphSeparator, "\x2029" ); // unicode paragraph separator
   387         _LIT( KParagraphSeparator, "\x2029" ); // unicode paragraph separator
   402         // add the separator after url
   388         // add the separator after url
   403         retBuf->Des().Append( KParagraphSeparator );
   389         retBuf->Des().Append( KParagraphSeparator );
   404         retBuf->Des().Append( aBuf );
   390         retBuf->Des().Append( aBuf );
   420     FUNC_LOG;
   406     FUNC_LOG;
   421     if ( !iFeatures )
   407     if ( !iFeatures )
   422         {
   408         {
   423         iFeatures = CESMRFeatureSettings::NewL();
   409         iFeatures = CESMRFeatureSettings::NewL();
   424         }
   410         }
       
   411 
       
   412     return *iFeatures;
       
   413     }
       
   414 
       
   415 // ---------------------------------------------------------------------------
       
   416 // CESMRDescriptionField::ExecuteGenericCommandL
       
   417 // ---------------------------------------------------------------------------
       
   418 //
       
   419 TBool CESMRDescriptionField::ExecuteGenericCommandL(
       
   420         TInt aCommand )
       
   421     {
       
   422     FUNC_LOG;
       
   423     TBool isUsed( EFalse );
       
   424     if ( EESMRCmdSizeExceeded == aCommand )
       
   425         {
       
   426         CESMRGlobalNote::ExecuteL(
       
   427                 CESMRGlobalNote::EESMRCannotDisplayMuchMore );
       
   428 
       
   429         HBufC* text = iDescription->GetTextInHBufL();
       
   430         CleanupDeletePushL( text );
       
   431         if ( text )
       
   432             {
       
   433             TInt curPos = iDescription->CursorPos();
       
   434             if( curPos > iDescription->GetLimitLength() - 1 )
       
   435                 curPos = iDescription->GetLimitLength() - 1;
       
   436             HBufC* newText =
       
   437                 text->Des().Mid( 0,
       
   438                         iDescription->GetLimitLength() - 1 ).AllocLC();
       
   439 
       
   440             iDescription->SetTextL ( newText );
       
   441             CleanupStack::PopAndDestroy( newText );
       
   442             newText = NULL;
       
   443 
       
   444             iDescription->SetCursorPosL (curPos, EFalse );
       
   445             iDescription->HandleTextChangedL();
       
   446             iDescription->UpdateScrollBarsL();
       
   447             SetFocus(ETrue);
       
   448             }
       
   449         CleanupStack::PopAndDestroy( text );
       
   450         isUsed = ETrue;
       
   451         }
       
   452     else if ( EESMRCmdDisableWaypointIcon == aCommand )
       
   453         {
       
   454         isUsed = ETrue;
       
   455         
       
   456         // Clear location link
       
   457         delete iLocationLink;
       
   458         iLocationLink = NULL;
       
   459         }
   425     
   460     
   426     return *iFeatures;
   461     return isUsed;
   427     }
   462     }
   428 
   463 
   429 // ---------------------------------------------------------------------------
   464 // ---------------------------------------------------------------------------
   430 // CESMRDescriptionField::ExecuteGenericCommandL
   465 // CESMRDescriptionField::CountComponentControls
   431 // ---------------------------------------------------------------------------
   466 // ---------------------------------------------------------------------------
   432 //
   467 //
   433 void CESMRDescriptionField::ExecuteGenericCommandL( 
   468 TInt CESMRDescriptionField::CountComponentControls() const
   434 		TInt aCommand )
   469     {
   435 	{
   470     return KComponentCount;
   436     FUNC_LOG;
   471     }
   437 	if ( EESMRCmdSizeExceeded == aCommand )
   472 
   438 		{
   473 // ---------------------------------------------------------------------------
   439 		CESMRGlobalNote::ExecuteL ( 
   474 // CESMRDescriptionField::ComponentControl
   440 				CESMRGlobalNote::EESMRCannotDisplayMuchMore );
   475 // ---------------------------------------------------------------------------
   441 		
   476 //
   442 		HBufC* text = iDescription->GetTextInHBufL();
   477 CCoeControl* CESMRDescriptionField::ComponentControl( TInt aInd ) const
   443 		CleanupDeletePushL( text );
   478     {
   444 		if ( text )
   479     if( aInd == 0 )
   445 			{    
   480         {
   446 	    	TInt curPos = iDescription->CursorPos();    	
   481         return iDescription;
   447 	    	if( curPos > iDescription->GetLimitLength() - 1 )
   482         }
   448 	    		curPos = iDescription->GetLimitLength() - 1;
   483     return NULL;
   449 	    	HBufC* newText = 
   484     }
   450 	    		text->Des().Mid( 0, iDescription->GetLimitLength() - 1 ).AllocLC();    	
   485 
   451 	    	
   486 // ---------------------------------------------------------------------------
   452 	    	iDescription->SetTextL ( newText );
   487 // CESMRDescriptionField::SizeChanged
   453 	    	CleanupStack::PopAndDestroy( newText );
   488 // ---------------------------------------------------------------------------
   454 	    	newText = NULL;
   489 //
   455 
   490 void CESMRDescriptionField::SizeChanged()
   456 	    	iDescription->SetCursorPosL (curPos, EFalse );
   491     {
   457 	    	iDescription->HandleTextChangedL();
   492     TRect rect( Rect() );
   458 	    	iDescription->UpdateScrollBarsL();
   493 
   459 	    	SetFocus(ETrue);
   494     // Optimization: Layouting only when necessary
   460 			}
   495     if( iFieldRect != rect )
   461 		CleanupStack::PopAndDestroy( text );	
   496         {
   462 		}
   497         rect = NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 ).Rect();
   463 	}
   498 
   464 
   499         TAknLayoutText editorLayoutText = NMRLayoutManager::GetLayoutText(
       
   500                         rect,
       
   501                         NMRLayoutManager::EMRTextLayoutMultiRowTextEditor );
       
   502 
       
   503         TRect editorRect = editorLayoutText.TextRect();
       
   504 
       
   505         TRect bgRect( editorRect );
       
   506         // Move focus rect so that it's relative to field's position.
       
   507         bgRect.Move( -Position() );
       
   508         if( iSize.iHeight > 0 )
       
   509             {
       
   510             bgRect.SetHeight( iSize.iHeight );
       
   511             }
       
   512         SetFocusRect( bgRect );
       
   513 
       
   514         iDescription->SetRect(
       
   515                 TRect( editorRect.iTl,
       
   516                         TSize( editorRect.Width(), iSize.iHeight ) ) );
       
   517 
       
   518         // Set also correct font for description field
       
   519         TRAP_IGNORE( iDescription->SetFontL( editorLayoutText.Font() ) );
       
   520 
       
   521         iFieldRect = rect;
       
   522         }
       
   523     }
       
   524 
       
   525 // ---------------------------------------------------------------------------
       
   526 // CESMRDescriptionField::MinimumSize
       
   527 // ---------------------------------------------------------------------------
       
   528 //
       
   529 TSize CESMRDescriptionField::MinimumSize()
       
   530     {
       
   531     TRect rect( Parent()->Rect() );
       
   532     TRect listRect =
       
   533         NMRLayoutManager::GetLayoutRect(
       
   534                 rect,
       
   535                 NMRLayoutManager::EMRLayoutListArea ).Rect();
       
   536     TRect fieldRect =
       
   537         NMRLayoutManager::GetFieldLayoutRect( listRect, 1 ).Rect();
       
   538     TRect rowRect =
       
   539         NMRLayoutManager::GetFieldRowLayoutRect( fieldRect, 1 ).Rect();
       
   540     TRect viewerRect =
       
   541         NMRLayoutManager::GetLayoutText(
       
   542                 rowRect,
       
   543                 NMRLayoutManager::EMRTextLayoutMultiRowTextEditor ).TextRect();
       
   544 
       
   545     fieldRect.Resize( 0, iSize.iHeight - viewerRect.Height() );
       
   546 
       
   547     return fieldRect.Size();
       
   548     }
       
   549 
       
   550 // ---------------------------------------------------------------------------
       
   551 // CESMRRepeatUntilField::SetContainerWindowL
       
   552 // ---------------------------------------------------------------------------
       
   553 //
       
   554 void CESMRDescriptionField::SetContainerWindowL(
       
   555         const CCoeControl& aContainer )
       
   556     {
       
   557     CCoeControl::SetContainerWindowL( aContainer );
       
   558     iDescription->SetContainerWindowL( aContainer );
       
   559 
       
   560     iDescription->SetParent( this );
       
   561     }
       
   562 
       
   563 // ---------------------------------------------------------------------------
       
   564 // CESMRDescriptionField::StoreGeoValueL
       
   565 // ---------------------------------------------------------------------------
       
   566 //
       
   567 void CESMRDescriptionField::StoreGeoValueL(
       
   568         CCalEntry& aCalEntry,
       
   569         const TDesC& aLocationUrl )
       
   570     {
       
   571     TReal lat, lon;
       
   572     CCalGeoValue* geoVal = aCalEntry.GeoValueL();
       
   573 
       
   574     if ( !geoVal || ! geoVal->GetLatLong( lat, lon ) )
       
   575         {
       
   576         // GEO value not set. Convert URL
       
   577         geoVal = UrlParserL().CreateGeoValueLC( aLocationUrl );
       
   578         aCalEntry.SetGeoValueL( *geoVal );
       
   579         CleanupStack::Pop( geoVal );
       
   580 
       
   581         NotifyEventL( EESMRCmdEnableWaypointIcon );
       
   582         }
       
   583     }
       
   584 
       
   585 // ---------------------------------------------------------------------------
       
   586 // CESMRDescriptionField::UrlParserL
       
   587 // ---------------------------------------------------------------------------
       
   588 //
       
   589 CESMRUrlParserPlugin& CESMRDescriptionField::UrlParserL()
       
   590     {
       
   591     if ( !iUrlParser )
       
   592         {
       
   593         iUrlParser = CESMRUrlParserPlugin::NewL();
       
   594         }
       
   595 
       
   596     return *iUrlParser;
       
   597     }
   465 
   598 
   466 // EOF
   599 // EOF