calendarui/views/src/calenpreviewentry.cpp
changeset 0 f979ecb2b13e
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 /*
       
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Storage for single line of data in preview.
       
    15  *
       
    16 */
       
    17 
       
    18 //debug
       
    19 #include "calendarui_debug.h"
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include "calenpreviewentry.h"
       
    23 
       
    24 
       
    25 #include "calenpreviewlabelobserver.h"
       
    26 #include "calenpreviewentryobserver.h"
       
    27 #include "calenpreviewlabel.h"
       
    28 
       
    29 #include <calendateutils.h>
       
    30 #include "calenpreviewlayoutmanager.h"
       
    31 
       
    32 #include <StringLoader.h>
       
    33 #include <AknBidiTextUtils.h>
       
    34 #include <PUAcodes.hrh>
       
    35 
       
    36 #include <Calendar.rsg>
       
    37 #include "calendar.hrh"
       
    38 
       
    39 const TInt KMaxTimePrefixLength = 22 + KAknBidiExtraSpacePerLine;
       
    40 const TUint KSpecialHyphen = KPuaCodeShortHyphen;
       
    41 const TUint KSpecialSpace = KPuaCodeShortSpace;
       
    42 
       
    43 /**
       
    44  * KReplaceWhitespaceChars contains some characters that should be replaced by
       
    45  *  space in Calendar popup, day view etc. 
       
    46  * Following characters are replaced with space 
       
    47  * \x0009 horizontal tab
       
    48  * \x000a new line 
       
    49  * \x000b line tabulation (vertical
       
    50  * \x000c form feed
       
    51  * \x000d carriage return
       
    52  * \x2028 line separator
       
    53  * \x2029 paragraph separator
       
    54  */
       
    55 _LIT( KReplaceWhitespaceChars, "\x0009\x000A\x000B\x000C\x000D\x2028\x2029" );
       
    56 
       
    57 // ---------------------------------------------------------------------------
       
    58 // ?classname::?member_function
       
    59 // ?implementation_description
       
    60 // (other items were commented in a header).
       
    61 // ---------------------------------------------------------------------------
       
    62 //
       
    63 CCalenPreviewEntry::CCalenPreviewEntry() : 
       
    64     iStart(NULL), iHyphen(NULL), iEnd(NULL), iSummary(NULL), 
       
    65     iLocation(NULL), iDescription(NULL),iText(NULL), iTextLines(NULL),
       
    66     iLines(0), iEventType(CCalEntry::EAppt)
       
    67     {
       
    68     TRACE_ENTRY_POINT;
       
    69     TRACE_EXIT_POINT;
       
    70     }
       
    71 
       
    72 // ---------------------------------------------------------------------------
       
    73 // ?classname::?member_function
       
    74 // ?implementation_description
       
    75 // (other items were commented in a header).
       
    76 // ---------------------------------------------------------------------------
       
    77 //
       
    78 CCalenPreviewEntry::~CCalenPreviewEntry()
       
    79     {
       
    80     TRACE_ENTRY_POINT;
       
    81     iLabels.Reset();
       
    82     if(iTextLines)
       
    83         iTextLines->Reset();
       
    84     delete iTextLines;
       
    85     delete iText;
       
    86     TRACE_EXIT_POINT;
       
    87     }
       
    88 
       
    89 // ---------------------------------------------------------------------------
       
    90 // ?classname::?member_function
       
    91 // ?implementation_description
       
    92 // (other items were commented in a header).
       
    93 // ---------------------------------------------------------------------------
       
    94 //
       
    95 CCalEntry::TType CCalenPreviewEntry::EventType() const
       
    96     {
       
    97     TRACE_ENTRY_POINT;
       
    98     TRACE_EXIT_POINT;
       
    99     return iEventType;
       
   100     }
       
   101 
       
   102 // ---------------------------------------------------------------------------
       
   103 // ?classname::?member_function
       
   104 // ?implementation_description
       
   105 // (other items were commented in a header).
       
   106 // ---------------------------------------------------------------------------
       
   107 //
       
   108 CCalenPreviewEntry::TPreviewEntryType CCalenPreviewEntry::EntryType() const
       
   109     {
       
   110     TRACE_ENTRY_POINT;
       
   111     TRACE_EXIT_POINT;
       
   112     return iEntryType;
       
   113     }
       
   114 // ---------------------------------------------------------------------------
       
   115 // ?classname::?member_function
       
   116 // ?implementation_description
       
   117 // (other items were commented in a header).
       
   118 // ---------------------------------------------------------------------------
       
   119 //
       
   120 void CCalenPreviewEntry::SetHyphenL()
       
   121     {
       
   122     TRACE_ENTRY_POINT;
       
   123     iHyphen = HBufC::NewL( 1 );
       
   124     TPtr bufPtr = iHyphen->Des();
       
   125     bufPtr.Append(TChar(KSpecialHyphen));
       
   126     TRACE_EXIT_POINT;
       
   127     }
       
   128 
       
   129 // ---------------------------------------------------------------------------
       
   130 // ?classname::?member_function
       
   131 // ?implementation_description
       
   132 // (other items were commented in a header).
       
   133 // ---------------------------------------------------------------------------
       
   134 //
       
   135 HBufC* CCalenPreviewEntry::FullTextL()
       
   136     {
       
   137     TRACE_ENTRY_POINT;
       
   138 
       
   139     if(iText)
       
   140         {
       
   141         TRACE_EXIT_POINT;
       
   142         return NULL;
       
   143         }
       
   144 
       
   145     TBuf<1> space; 
       
   146     space.Append(TChar(KSpecialSpace));
       
   147 
       
   148     HBufC* text = HBufC::NewL(CalculateTextLengthL() + 
       
   149                               KAknBidiExtraSpacePerLine * iLines);
       
   150 
       
   151     CleanupStack::PushL( text );
       
   152     
       
   153     TPtr ptr = text->Des();
       
   154     if(iStart && iStart->Length())
       
   155         ptr.Append(iStart->Des());
       
   156     
       
   157     if(iHyphen)
       
   158         ptr.Append(iHyphen->Des());
       
   159     else
       
   160     	ptr.Append(space);
       
   161     
       
   162     if(iEnd && iEnd->Length() && iLines > 1)
       
   163         {
       
   164         ptr.Append(iEnd->Des());
       
   165         ptr.Append(space);
       
   166         }
       
   167     
       
   168     if(iSummary && iSummary->Length())
       
   169         ptr.Append(iSummary->Des());
       
   170     
       
   171     HBufC* separator = StringLoader::LoadLC( R_CALEN_PREVIEW_SEPARATOR );
       
   172 
       
   173     if(iLocation && iLocation->Length())
       
   174         {
       
   175         if(iSummary && iSummary->Length())
       
   176             ptr.Append(separator->Des());
       
   177         ptr.Append(iLocation->Des());
       
   178         }
       
   179     if(iDescription && iDescription->Length())
       
   180         {
       
   181         if( (iSummary && iSummary->Length()) || 
       
   182             (iLocation && iLocation->Length()) )
       
   183             ptr.Append(separator->Des());
       
   184         ptr.Append(iDescription->Des());
       
   185         }
       
   186     
       
   187     if((iSummary && !iSummary->Length())
       
   188     	&& (iLocation && !iLocation->Length())
       
   189         && (iDescription && !iDescription->Length()))
       
   190     	{
       
   191     	HBufC* emptytext = StringLoader::LoadLC( R_CALEN_QTN_CALE_NO_SUBJECT );
       
   192         	
       
   193     	ptr.Append(emptytext->Des());
       
   194     
       
   195         CleanupStack::PopAndDestroy(emptytext);
       
   196     	}
       
   197 		
       
   198     CleanupStack::PopAndDestroy( separator );
       
   199     CleanupStack::Pop( text );
       
   200     TRACE_EXIT_POINT;
       
   201     return text;
       
   202     }
       
   203 
       
   204 // ---------------------------------------------------------------------------
       
   205 // ?classname::?member_function
       
   206 // ?implementation_description
       
   207 // (other items were commented in a header).
       
   208 // ---------------------------------------------------------------------------
       
   209 //
       
   210 void CCalenPreviewEntry::DoLineUsageL(TInt aMaxRows)
       
   211     {
       
   212     TRACE_ENTRY_POINT;
       
   213     // textLines contain 
       
   214     if(aMaxRows > 1)
       
   215         {
       
   216         CArrayFixFlat<TPtrC>* textLines = new(ELeave)CArrayFixFlat<TPtrC>(
       
   217             aMaxRows);
       
   218         CleanupStack::PushL( textLines );
       
   219         
       
   220         HBufC* visualText = NULL;
       
   221         
       
   222         CArrayFixFlat<TInt>* lineWidths = new( ELeave )CArrayFixFlat<TInt>( 2 );
       
   223         CleanupStack::PushL( lineWidths );
       
   224 
       
   225         switch (iEntryType)
       
   226             {
       
   227             case ECalenPreviewEntryNormal:
       
   228                 lineWidths->AppendL( iLayoutManager->FirstLineWidth() );
       
   229                 lineWidths->AppendL( iLayoutManager->MiddleLineWidth() );
       
   230                 break;
       
   231             case ECalenPreviewEntryPlugin:
       
   232                 lineWidths->AppendL( iLayoutManager->PluginLineWidth() );
       
   233                 break;
       
   234             case ECalenPreviewEntryEmpty:
       
   235             default:
       
   236                 lineWidths->AppendL( iLayoutManager->EmptyLineWidth() );
       
   237                 break;
       
   238             }
       
   239         HBufC* text = FullTextL();
       
   240         
       
   241         CleanupStack::PushL( text );
       
   242         
       
   243         visualText = 
       
   244             AknBidiTextUtils::ConvertToVisualAndWrapToArrayWholeTextL(
       
   245                 text->Des(),
       
   246                 *lineWidths,
       
   247                 *iLayoutManager->LineFont(),
       
   248                 *textLines);
       
   249 
       
   250         iLines = Min(iLines, textLines->Count());
       
   251                 
       
   252         CleanupStack::PopAndDestroy( text );
       
   253         CleanupStack::PopAndDestroy( lineWidths );
       
   254         CleanupStack::PopAndDestroy( textLines );
       
   255         delete visualText;
       
   256         }
       
   257     else
       
   258         {
       
   259         iLines = 1;
       
   260         }
       
   261     TRACE_EXIT_POINT;
       
   262     }
       
   263 // ---------------------------------------------------------------------------
       
   264 // ?classname::?member_function
       
   265 // ?implementation_description
       
   266 // (other items were commented in a header).
       
   267 // ---------------------------------------------------------------------------
       
   268 //
       
   269 void CCalenPreviewEntry::FormatTextL(TBool aShortLine)
       
   270     {
       
   271     TRACE_ENTRY_POINT;
       
   272     
       
   273     if(!iLayoutManager)
       
   274         {
       
   275         TRACE_EXIT_POINT;
       
   276         return;
       
   277         }
       
   278 
       
   279     HBufC* text = FullTextL();
       
   280     CleanupStack::PushL( text );
       
   281 
       
   282     delete iStart;       iStart = NULL;
       
   283     delete iHyphen;      iHyphen = NULL;
       
   284     delete iEnd;         iEnd = NULL;
       
   285     delete iSummary;     iSummary = NULL;
       
   286     delete iLocation;    iLocation = NULL;
       
   287     delete iDescription; iDescription = NULL;
       
   288 
       
   289     CArrayFixFlat<TInt>* lineWidths = new( ELeave )CArrayFixFlat<TInt>( 
       
   290         iLines );
       
   291     CleanupStack::PushL( lineWidths );
       
   292     
       
   293     iTextLines = new(ELeave)CArrayFixFlat<TPtrC>(iLines);
       
   294 
       
   295     if( aShortLine )
       
   296         lineWidths->AppendL( iLayoutManager->LastLineWidth() );
       
   297     else
       
   298         {
       
   299         if(iEntryType == ECalenPreviewEntryNormal)
       
   300             {
       
   301             lineWidths->AppendL( iLayoutManager->FirstLineWidth() );
       
   302             for(TInt i = 1; i < iLines; i++)
       
   303                 lineWidths->AppendL( iLayoutManager->MiddleLineWidth() );
       
   304             }
       
   305         else if(iEntryType == ECalenPreviewEntryEmpty)
       
   306             {
       
   307             lineWidths->AppendL( iLayoutManager->EmptyLineWidth() );
       
   308             for(TInt i = 1; i < iLines; i++)
       
   309                 lineWidths->AppendL( iLayoutManager->EmptyLineWidth() );
       
   310             }
       
   311         else
       
   312             {
       
   313             lineWidths->AppendL( iLayoutManager->PluginLineWidth() );
       
   314             for(TInt i = 1; i < iLines; i++)
       
   315                 lineWidths->AppendL( iLayoutManager->PluginLineWidth() );
       
   316             }
       
   317         }
       
   318     
       
   319     TPtr truncatedText = text->Des();
       
   320     const TBool KUseEllipsis = ETrue; 
       
   321 
       
   322     AknBidiTextUtils::ConvertToVisualAndWrapToArrayL(
       
   323         truncatedText,
       
   324         *lineWidths,
       
   325         *iLayoutManager->LineFont(),
       
   326         *iTextLines,
       
   327         KUseEllipsis);
       
   328     CleanupStack::PopAndDestroy( lineWidths );
       
   329     CleanupStack::Pop( text );
       
   330 	
       
   331     iText = text;
       
   332     TRACE_EXIT_POINT;
       
   333     }
       
   334 
       
   335 // ---------------------------------------------------------------------------
       
   336 // ?classname::?member_function
       
   337 // ?implementation_description
       
   338 // (other items were commented in a header).
       
   339 // ---------------------------------------------------------------------------
       
   340 //
       
   341 TInt CCalenPreviewEntry::CalculateTextLengthL()
       
   342     {
       
   343     TRACE_ENTRY_POINT;
       
   344 
       
   345     TBuf<1> space; 
       
   346     space.Append(TChar(KSpecialSpace));
       
   347 
       
   348     HBufC* separator = StringLoader::LoadLC( R_CALEN_PREVIEW_SEPARATOR );
       
   349 
       
   350     TInt result(0);
       
   351     if(iStart)
       
   352         result += iStart->Length();
       
   353     if(iHyphen)
       
   354         result += iHyphen->Length();
       
   355     else
       
   356     	result += space.Length(); 
       
   357     
       
   358     if(iEnd)
       
   359         {
       
   360         result += iEnd->Length();
       
   361         result += space.Length(); 
       
   362         }
       
   363     if(iSummary)
       
   364         {
       
   365         result += iSummary->Length();
       
   366         }
       
   367     if(iLocation)
       
   368         {
       
   369     	result += iLocation->Length();
       
   370         result += separator->Length();
       
   371         }
       
   372     if(iDescription)
       
   373         {
       
   374         result += iDescription->Length();
       
   375         result += separator->Length();
       
   376         }
       
   377     
       
   378     if((iSummary && !iSummary->Length())
       
   379     	&& (iLocation && !iLocation->Length())
       
   380         && (iDescription && !iDescription->Length()))
       
   381     	{
       
   382     	HBufC* emptytext = StringLoader::LoadLC( R_CALEN_QTN_CALE_NO_SUBJECT );
       
   383         	
       
   384     	result += emptytext->Length();
       
   385     
       
   386         CleanupStack::PopAndDestroy(emptytext);
       
   387     	}
       
   388     
       
   389     CleanupStack::PopAndDestroy( separator );
       
   390     TRACE_EXIT_POINT;
       
   391     return result;
       
   392     }
       
   393 
       
   394 // ---------------------------------------------------------------------------
       
   395 // ?classname::?member_function
       
   396 // ?implementation_description
       
   397 // (other items were commented in a header).
       
   398 // ---------------------------------------------------------------------------
       
   399 //
       
   400 TPtrC CCalenPreviewEntry::GetLine(TInt aIndex)
       
   401     {
       
   402     TRACE_ENTRY_POINT;
       
   403     TRACE_EXIT_POINT;
       
   404     return iTextLines->At(aIndex);
       
   405     }
       
   406 
       
   407 // ---------------------------------------------------------------------------
       
   408 // ?classname::?member_function
       
   409 // ?implementation_description
       
   410 // (other items were commented in a header).
       
   411 // ---------------------------------------------------------------------------
       
   412 //
       
   413 TInt CCalenPreviewEntry::LineCount()
       
   414     {
       
   415     TRACE_ENTRY_POINT;
       
   416     TRACE_EXIT_POINT;
       
   417     return iLines;
       
   418     }
       
   419 
       
   420 // ---------------------------------------------------------------------------
       
   421 // ?classname::?member_function
       
   422 // ?implementation_description
       
   423 // (other items were commented in a header).
       
   424 // ---------------------------------------------------------------------------
       
   425 //
       
   426 TBool CCalenPreviewEntry::RemoveLine()
       
   427     {
       
   428     TRACE_ENTRY_POINT;
       
   429     TBool ret(EFalse);
       
   430     if(iLines > 1)
       
   431         {
       
   432         iLines--;
       
   433         ret = ETrue;
       
   434         }
       
   435     TRACE_EXIT_POINT;
       
   436     return ret;
       
   437     }
       
   438 
       
   439 // ---------------------------------------------------------------------------
       
   440 // ?classname::?member_function
       
   441 // ?implementation_description
       
   442 // (other items were commented in a header).
       
   443 // ---------------------------------------------------------------------------
       
   444 //
       
   445 CCalenPreviewEntry* CCalenPreviewEntry::NewL(
       
   446     CCalInstance* aInstance,
       
   447     CCalenPreviewLayoutManager* aLayoutManager, 
       
   448     const TTime& aDay,
       
   449     TInt aMaxRows,TUint32 aColor)
       
   450     {
       
   451     TRACE_ENTRY_POINT;
       
   452 
       
   453     CCalenPreviewEntry* self = new (ELeave) CCalenPreviewEntry;
       
   454 
       
   455     CleanupStack::PushL( self );
       
   456     self->ConstructL(aInstance, aLayoutManager, aDay, aMaxRows,aColor);
       
   457     CleanupStack::Pop( self );    
       
   458 
       
   459     TRACE_EXIT_POINT;
       
   460     return self;
       
   461     }
       
   462 
       
   463 // ---------------------------------------------------------------------------
       
   464 // ?classname::?member_function
       
   465 // ?implementation_description
       
   466 // (other items were commented in a header).
       
   467 // ---------------------------------------------------------------------------
       
   468 //
       
   469 CCalenPreviewEntry* CCalenPreviewEntry::NewL(
       
   470     CCalenPreviewLayoutManager* aLayoutManager,
       
   471     TPreviewEntryType aEntryType,TUint32 aColor)
       
   472     {
       
   473     TRACE_ENTRY_POINT;
       
   474     CCalenPreviewEntry* self = new (ELeave) CCalenPreviewEntry;
       
   475     CleanupStack::PushL( self );
       
   476     self->ConstructL(aLayoutManager, aEntryType,aColor);
       
   477     CleanupStack::Pop( self );    
       
   478     TRACE_EXIT_POINT;
       
   479     return self;
       
   480     }
       
   481 
       
   482 // ---------------------------------------------------------------------------
       
   483 // ?classname::?member_function
       
   484 // ?implementation_description
       
   485 // (other items were commented in a header).
       
   486 // ---------------------------------------------------------------------------
       
   487 //
       
   488 void CCalenPreviewEntry::ConstructL(CCalenPreviewLayoutManager* aLayoutManager,
       
   489                                     TPreviewEntryType aEntryType,TUint32 aColor)
       
   490     {
       
   491     TRACE_ENTRY_POINT;
       
   492     iColor= aColor;
       
   493     iLayoutManager = aLayoutManager;
       
   494     iLines = 2;
       
   495     iEntryType = aEntryType;
       
   496     FormatEmptyTextL();
       
   497     DoLineUsageL(iLines);
       
   498     TRACE_EXIT_POINT;
       
   499     }
       
   500 // ---------------------------------------------------------------------------
       
   501 // ?classname::?member_function
       
   502 // ?implementation_description
       
   503 // (other items were commented in a header).
       
   504 // ---------------------------------------------------------------------------
       
   505 //
       
   506 void CCalenPreviewEntry::ConstructL(CCalInstance* aInstance,
       
   507                                     CCalenPreviewLayoutManager* aLayoutManager,
       
   508                                     const TTime& aDay, 
       
   509                                     TInt aMaxRows,
       
   510                                     TUint32 aColor)
       
   511     {
       
   512     TRACE_ENTRY_POINT;
       
   513     iColor= aColor;
       
   514     iEntryType =  ECalenPreviewEntryNormal;
       
   515     iEventType = aInstance->Entry().EntryTypeL();
       
   516 
       
   517     iInstanceId = TCalenInstanceId::CreateL( *aInstance );
       
   518     iLayoutManager = aLayoutManager;
       
   519     TInt maxLen(aMaxRows * KMaxColumnDataLength);
       
   520 
       
   521     iLines = aMaxRows;
       
   522 
       
   523     if(aInstance->Entry().EntryTypeL() == CCalEntry::EAppt)
       
   524         {
       
   525         FormatTimeL(aInstance, aDay, maxLen);
       
   526         }
       
   527 
       
   528     FormatSummaryL(aInstance, maxLen);
       
   529     FormatLocationL(aInstance, maxLen);
       
   530     FormatDescriptionL(aInstance, maxLen);
       
   531     DoLineUsageL(aMaxRows);
       
   532     TRACE_EXIT_POINT;
       
   533     }
       
   534 
       
   535 // ---------------------------------------------------------------------------
       
   536 // ?classname::?member_function
       
   537 // ?implementation_description
       
   538 // (other items were commented in a header).
       
   539 // ---------------------------------------------------------------------------
       
   540 //
       
   541 void CCalenPreviewEntry::AddObservedLabelL(CCalenPreviewLabel *aLabel)
       
   542     {
       
   543     TRACE_ENTRY_POINT;
       
   544     iLabels.AppendL(aLabel);
       
   545     TRACE_EXIT_POINT;
       
   546     }
       
   547 
       
   548 // ---------------------------------------------------------------------------
       
   549 // ?classname::?member_function
       
   550 // ?implementation_description
       
   551 // (other items were commented in a header).
       
   552 // ---------------------------------------------------------------------------
       
   553 //
       
   554 TBool CCalenPreviewEntry::Contains(TPoint aPoint)
       
   555     {
       
   556     TRACE_ENTRY_POINT;
       
   557     TBool result(EFalse);
       
   558     if(aPoint.iX > iLabels[0]->Rect().iTl.iX &&
       
   559        aPoint.iY > iLabels[0]->Rect().iTl.iY &&
       
   560        aPoint.iX < iLabels[iLabels.Count()-1]->Rect().iBr.iX &&
       
   561        aPoint.iY < iLabels[iLabels.Count()-1]->Rect().iBr.iY && 
       
   562        iEntryType != ECalenPreviewEntryEmpty)
       
   563         result = ETrue;
       
   564     TRACE_EXIT_POINT;
       
   565     return result;
       
   566     }
       
   567 
       
   568 // ---------------------------------------------------------------------------
       
   569 // ?classname::?member_function
       
   570 // ?implementation_description
       
   571 // (other items were commented in a header).
       
   572 // ---------------------------------------------------------------------------
       
   573 //
       
   574 void CCalenPreviewEntry::HandleLabelPointerEventL(const TPointerEvent& 
       
   575                                                   aPointerEvent)
       
   576     {
       
   577     TRACE_ENTRY_POINT;
       
   578     if(AknLayoutUtils::PenEnabled())
       
   579         {
       
   580         switch(aPointerEvent.iType)
       
   581             {
       
   582             case TPointerEvent::EButton1Down:
       
   583                 for(TInt i = 0; i < iLabels.Count(); i++)
       
   584                     {
       
   585                     iLabels[i]->HandleVisualisationL(
       
   586                         CCalenPreviewLabel::EAddVisualisation);
       
   587                     }
       
   588                 if(iObserver)
       
   589                     iObserver->HandlePreviewEntryEventL(iInstanceId, 
       
   590                                                         aPointerEvent.iType);
       
   591                 break;
       
   592             case TPointerEvent::EButton1Up:
       
   593                 for(TInt i = 0; i < iLabels.Count(); i++)
       
   594                     {
       
   595                     iLabels[i]->HandleVisualisationL(
       
   596                         CCalenPreviewLabel::ERemoveVisualisation);
       
   597                     }
       
   598                 if(iObserver)
       
   599                     iObserver->HandlePreviewEntryEventL(iInstanceId, 
       
   600                                                         aPointerEvent.iType);
       
   601                 break;
       
   602             case TPointerEvent::EDrag:
       
   603                 if(Contains(aPointerEvent.iPosition))
       
   604                     {
       
   605                     if(iObserver)
       
   606                         iObserver->HandlePreviewEntryEventL(iInstanceId, 
       
   607                                                             aPointerEvent.iType);
       
   608                     for(TInt i = 0; i < iLabels.Count(); i++)
       
   609                         {
       
   610                         iLabels[i]->HandleVisualisationL(
       
   611                             CCalenPreviewLabel::EAddVisualisation);
       
   612                         }
       
   613                     }
       
   614                 break;
       
   615                 }
       
   616         }
       
   617     TRACE_EXIT_POINT;
       
   618     }
       
   619 
       
   620 // ---------------------------------------------------------------------------
       
   621 // ?classname::?member_function
       
   622 // ?implementation_description
       
   623 // (other items were commented in a header).
       
   624 // ---------------------------------------------------------------------------
       
   625 //
       
   626 void CCalenPreviewEntry::SetEntryObserver(
       
   627     MCalenPreviewEntryObserver* aObserver)
       
   628     {
       
   629     TRACE_ENTRY_POINT;
       
   630     iObserver = aObserver;
       
   631     TRACE_EXIT_POINT;
       
   632     }
       
   633 
       
   634 // ---------------------------------------------------------------------------
       
   635 // ?classname::?member_function
       
   636 // ?implementation_description
       
   637 // (other items were commented in a header).
       
   638 // ---------------------------------------------------------------------------
       
   639 //
       
   640 void CCalenPreviewEntry::FormatTimeL(CCalInstance* aInstance,
       
   641                                      const TTime& aDay,
       
   642                                      TInt& aMaxLen)
       
   643     {
       
   644     TRACE_ENTRY_POINT;
       
   645     
       
   646     CCalEntry& apptEntry = aInstance->Entry();
       
   647     TTimeIntervalMinutes duration;
       
   648     apptEntry.EndTimeL().TimeLocalL().MinutesFrom(
       
   649         apptEntry.StartTimeL().TimeLocalL(), duration );
       
   650     
       
   651     TTime startTime = aInstance->Time().TimeLocalL();
       
   652     TTime endTime = startTime + duration;
       
   653 
       
   654     // Format time 
       
   655     HBufC* timeFormat = StringLoader::LoadLC( R_QTN_TIME_USUAL_WITH_ZERO );
       
   656     TTime displayTime = CalenDateUtils::DisplayTimeOnDay(startTime, aDay);
       
   657     HBufC* startBuf = HBufC::NewLC( KMaxTimePrefixLength );
       
   658     TPtr startPtr = startBuf->Des();
       
   659     displayTime.FormatL( startPtr, *timeFormat );
       
   660     AknTextUtils::DisplayTextLanguageSpecificNumberConversion( startPtr );
       
   661 
       
   662     iStart = startBuf;
       
   663     aMaxLen -= startBuf->Length();
       
   664 
       
   665     TBuf<1> hyphen;
       
   666     hyphen.Append(TChar(KSpecialHyphen));
       
   667 
       
   668     if( startTime != endTime )
       
   669         {
       
   670         SetHyphenL();
       
   671         aMaxLen -= 1;
       
   672 
       
   673         TTime end(TInt64(0));
       
   674 
       
   675         TTimeIntervalDays days(aDay.DaysFrom(TTime(TInt64(0))));
       
   676         TTimeIntervalDays endDays(endTime.DaysFrom(TTime(TInt64(0))));
       
   677         
       
   678         // Set end time to 23:59, if event continues to next day 
       
   679         if (endDays != days)
       
   680             {
       
   681             TDateTime endDate = endTime.DateTime();
       
   682             endDate.SetHour(ECalenMaxHour);
       
   683             endDate.SetMinute(ECalenMaxMinute);
       
   684             endTime = endDate;
       
   685             }
       
   686 
       
   687         HBufC* endBuf = HBufC::NewLC( KMaxTimePrefixLength );
       
   688         TPtr endPtr = endBuf->Des();
       
   689         endTime.FormatL( endPtr, *timeFormat );
       
   690         AknTextUtils::DisplayTextLanguageSpecificNumberConversion( endPtr );
       
   691         iEnd = endBuf;
       
   692         aMaxLen -= endBuf->Length();
       
   693         CleanupStack::Pop( endBuf );
       
   694         }
       
   695 
       
   696     CleanupStack::Pop( startBuf );
       
   697     CleanupStack::PopAndDestroy( timeFormat );
       
   698 
       
   699     TRACE_EXIT_POINT;
       
   700     }
       
   701 
       
   702 // ---------------------------------------------------------------------------
       
   703 // ?classname::?member_function
       
   704 // ?implementation_description
       
   705 // (other items were commented in a header).
       
   706 // ---------------------------------------------------------------------------
       
   707 //
       
   708 void CCalenPreviewEntry::FormatSummaryL(CCalInstance* aInstance,
       
   709                                         TInt& aMaxLen)
       
   710     {
       
   711     TRACE_ENTRY_POINT;
       
   712     
       
   713     CCalEntry& apptEntry = aInstance->Entry();
       
   714     HBufC* textBuf = HBufC::NewL(aMaxLen);
       
   715     CleanupStack::PushL( textBuf );
       
   716     
       
   717     TPtr textPtr = textBuf->Des();
       
   718     
       
   719     const TDesC& summary = apptEntry.SummaryL();
       
   720     
       
   721     textPtr.Append( summary.Left( aMaxLen ) );
       
   722     AknTextUtils::ReplaceCharacters(textPtr, KReplaceWhitespaceChars, TChar(' '));
       
   723     textPtr.TrimAll();
       
   724     
       
   725     iSummary = textBuf;
       
   726     aMaxLen -= textBuf->Length();
       
   727     
       
   728     CleanupStack::Pop(textBuf);
       
   729 
       
   730     TRACE_EXIT_POINT;
       
   731     }
       
   732 // ---------------------------------------------------------------------------
       
   733 // ?classname::?member_function
       
   734 // ?implementation_description
       
   735 // (other items were commented in a header).
       
   736 // ---------------------------------------------------------------------------
       
   737 //
       
   738 void CCalenPreviewEntry::FormatLocationL(CCalInstance* aInstance,
       
   739                                          TInt& aMaxLen)
       
   740     {
       
   741     TRACE_ENTRY_POINT;
       
   742     
       
   743     CCalEntry& apptEntry = aInstance->Entry();
       
   744     HBufC* textBuf = HBufC::NewL(aMaxLen);
       
   745     CleanupStack::PushL( textBuf );
       
   746     
       
   747     TPtr textPtr = textBuf->Des();
       
   748     
       
   749     const TDesC& location = apptEntry.LocationL();
       
   750     
       
   751     textPtr.Append( location.Left( aMaxLen ) );
       
   752     AknTextUtils::ReplaceCharacters(textPtr, KReplaceWhitespaceChars, TChar(' '));
       
   753     textPtr.TrimAll();
       
   754     
       
   755     iLocation = textBuf;
       
   756     aMaxLen -= textBuf->Length();
       
   757     
       
   758     CleanupStack::Pop(textBuf);
       
   759 
       
   760     TRACE_EXIT_POINT;
       
   761     }
       
   762 
       
   763 // ---------------------------------------------------------------------------
       
   764 // ?classname::?member_function
       
   765 // ?implementation_description
       
   766 // (other items were commented in a header).
       
   767 // ---------------------------------------------------------------------------
       
   768 //
       
   769 void CCalenPreviewEntry::FormatDescriptionL(CCalInstance* aInstance,
       
   770                                             TInt& aMaxLen)
       
   771     {
       
   772     TRACE_ENTRY_POINT;
       
   773     
       
   774     CCalEntry& apptEntry = aInstance->Entry();
       
   775     HBufC* textBuf = HBufC::NewL(aMaxLen);
       
   776     CleanupStack::PushL( textBuf );
       
   777     
       
   778     TPtr textPtr = textBuf->Des();
       
   779     
       
   780     const TDesC& description = apptEntry.DescriptionL();
       
   781     
       
   782     textPtr.Append( description.Left( aMaxLen ) );
       
   783     AknTextUtils::ReplaceCharacters(textPtr, KReplaceWhitespaceChars, TChar(' '));
       
   784     textPtr.TrimAll();
       
   785 
       
   786     iDescription = textBuf;
       
   787     aMaxLen -= textBuf->Length();
       
   788     
       
   789     CleanupStack::Pop(textBuf);
       
   790 
       
   791     TRACE_EXIT_POINT;
       
   792     }
       
   793 
       
   794 // ---------------------------------------------------------------------------
       
   795 // ?classname::?member_function
       
   796 // ?implementation_description
       
   797 // (other items were commented in a header).
       
   798 // ---------------------------------------------------------------------------
       
   799 //
       
   800 void CCalenPreviewEntry::FormatEmptyTextL()
       
   801     {
       
   802     TRACE_ENTRY_POINT;
       
   803     
       
   804     HBufC* emptyText = StringLoader::LoadLC(R_CALEN_QTN_CALE_NO_EVENTS);
       
   805     iDescription = emptyText;
       
   806     CleanupStack::Pop(emptyText);
       
   807 
       
   808     TRACE_EXIT_POINT;
       
   809     }
       
   810 
       
   811 
       
   812 //  End of File