calendarui/views/src/caleneventviewcontainer.cpp
branchRCL_3
changeset 59 aba12c885d83
parent 48 bf573002ff72
child 60 96907930389d
equal deleted inserted replaced
48:bf573002ff72 59:aba12c885d83
   117     : CCalenContainer( aView, aServices ),
   117     : CCalenContainer( aView, aServices ),
   118     					  iEntry(NULL),
   118     					  iEntry(NULL),
   119 						  iEmbeddedFileOpened(EFalse)
   119 						  iEmbeddedFileOpened(EFalse)
   120     {
   120     {
   121 	TRACE_ENTRY_POINT;
   121 	TRACE_ENTRY_POINT;
   122 	iNumOfLinesBeforeLocField = 0;
       
   123 	iLocaleChanged = EFalse;
   122 	iLocaleChanged = EFalse;
   124 	TRACE_EXIT_POINT;
   123 	TRACE_EXIT_POINT;
   125     }
   124     }
   126  
   125  
   127 // ----------------------------------------------------------------------------
   126 // ----------------------------------------------------------------------------
   667     // Insert the icon drawer into the Rich Text Editor.  This takes
   666     // Insert the icon drawer into the Rich Text Editor.  This takes
   668     // ownership of the icon drawer.
   667     // ownership of the icon drawer.
   669     // Insert at index 0 in the document to cause the icons to be drawn when
   668     // Insert at index 0 in the document to cause the icons to be drawn when
   670     // the first line is visible.  The icons will not be drawn at position 0,
   669     // the first line is visible.  The icons will not be drawn at position 0,
   671     // but this position must be on the screen for the icons to be drawn.
   670     // but this position must be on the screen for the icons to be drawn.
   672     iTextEditor->RichText()->InsertL( iTextEditor->RichText()->DocumentLength(), header );
   671     iTextEditor->RichText()->InsertL( 0, header );
   673 
   672 
   674     // Tell the text editor that it has been updated.  This will cause
   673     // Tell the text editor that it has been updated.  This will cause
   675     // a redraw.
   674     // a redraw.
   676     iTextEditor->HandleTextChangedL();
   675     iTextEditor->HandleTextChangedL();
   677 	}
   676 	}
   926             break;
   925             break;
   927         }
   926         }
   928 	if(IsEventHasMapLocationL())
   927 	if(IsEventHasMapLocationL())
   929         {
   928         {
   930         // Update iNumOfLinesBeforeLocField
   929         // Update iNumOfLinesBeforeLocField
   931         CalcNumOfLinesBeforeLocation();
       
   932         
   930         
   933         // Add map icon to the icon drawer
   931         // Add map icon to the icon drawer
   934         iconDrawer->AddIconL( MCalenServices::ECalenMapIcon );
   932         iconDrawer->AddIconL( MCalenServices::ECalenMapIcon );
   935                
   933                
   936         // Set the icon sizes
   934         // Set the icon sizes
   937         iconDrawer->SetIconSizesFromLayout(iNumOfLinesBeforeLocField);
   935         iconDrawer->SetIconSizesFromLayout();       
   938         }
   936         }
   939 	SetIconsL(iconDrawer);
   937 	SetIconsL(iconDrawer);
   940 
   938 
   941 	// Add Description
   939 	// Add Description
   942     AddDescriptionFieldL();
   940     AddDescriptionFieldL();
  1197             {
  1195             {
  1198             // nothing
  1196             // nothing
  1199             }
  1197             }
  1200         }
  1198         }
  1201     // Set the icon sizes
  1199     // Set the icon sizes
  1202     aIconDrawer.SetIconSizesFromLayout(iNumOfLinesBeforeLocField);
  1200     aIconDrawer.SetIconSizesFromLayout(); 
  1203 
  1201 
  1204     // Get the icon drawer width
  1202     // Get the icon drawer width
  1205     iIconDrawerWidthInPixels = aIconDrawer.WidthInPixels();
  1203     iIconDrawerWidthInPixels = aIconDrawer.WidthInPixels();
  1206 
  1204 
  1207     TRACE_EXIT_POINT;
  1205     TRACE_EXIT_POINT;
  2354 // Stores the necessary information in the context
  2352 // Stores the necessary information in the context
  2355 // and returns ETrue if event has geo coordinates else EFalse
  2353 // and returns ETrue if event has geo coordinates else EFalse
  2356 // ----------------------------------------------------------------------------
  2354 // ----------------------------------------------------------------------------
  2357 TBool CCalenEventViewContainer::IsEventHasMapLocationL()
  2355 TBool CCalenEventViewContainer::IsEventHasMapLocationL()
  2358 	{
  2356 	{
  2359 	CCalGeoValue* geoValue = iEntry->GeoValueL();
  2357     if(iEntry)
  2360 	if(geoValue)
  2358         {
  2361 		{
  2359         CCalGeoValue* geoValue = iEntry->GeoValueL();
  2362 		delete geoValue;
  2360         if(geoValue)
  2363 		return 	ETrue;
  2361             {
  2364 		}
  2362             delete geoValue; 
  2365 	else
  2363             return 	ETrue;
  2366 		{
  2364             }
  2367 		return 	EFalse;
  2365         else
  2368 		}
  2366             {
       
  2367             return 	EFalse;
       
  2368             }
       
  2369         }
       
  2370     else
       
  2371         {
       
  2372         return EFalse;
       
  2373         }
  2369 	}
  2374 	}
  2370 
  2375 
  2371 // ----------------------------------------------------------------------------
  2376 // ----------------------------------------------------------------------------
  2372 // CCalenEventViewContainer::IsEventHasNoLocationTextL
  2377 // CCalenEventViewContainer::IsEventHasNoLocationTextL
  2373 // Returns ETrue if event has location text else EFalse
  2378 // Returns ETrue if event has location text else EFalse
  2374 // ----------------------------------------------------------------------------
  2379 // ----------------------------------------------------------------------------
  2375 TBool CCalenEventViewContainer::IsEventHasNoLocationTextL()
  2380 TBool CCalenEventViewContainer::IsEventHasNoLocationTextL()
  2376 	{
  2381 	{
  2377 	TPtrC location = iEntry->LocationL();
  2382     if(iEntry)
  2378 	if(!location.Length())
  2383         {
  2379 		{
  2384         TPtrC location = iEntry->LocationL();
  2380 		return ETrue;
  2385         if(!location.Length())
  2381 		}
  2386             {
  2382 	else
  2387             return ETrue;
  2383 		{
  2388             }
  2384 		return EFalse;
  2389         else
  2385 		}
  2390             {
       
  2391             return EFalse;
       
  2392             }
       
  2393         }
       
  2394     else
       
  2395         {
       
  2396         return EFalse;
       
  2397         }
  2386 	}
  2398 	}
  2387 	
  2399 	
  2388 // ----------------------------------------------------------------------------
  2400 // ----------------------------------------------------------------------------
  2389 // CCalenEventView::OnLocaleChangedL
  2401 // CCalenEventView::OnLocaleChangedL
  2390 // (other items were commented in a header).
  2402 // (other items were commented in a header).
  2604         {
  2616         {
  2605         OpenViewerL(attachmentToBeOpened);
  2617         OpenViewerL(attachmentToBeOpened);
  2606         }
  2618         }
  2607     }
  2619     }
  2608 
  2620 
  2609 // ----------------------------------------------------------------------------
       
  2610 // CCalenEventViewContainer::CalcNumOfLinesBeforeLocation
       
  2611 // Calculates the number of line before locaiton field in the document of the rich text editor
       
  2612 // (other items were commented in a header).
       
  2613 // ----------------------------------------------------------------------------
       
  2614 //
       
  2615 void CCalenEventViewContainer::CalcNumOfLinesBeforeLocation()
       
  2616     {
       
  2617     TRACE_ENTRY_POINT;
       
  2618         
       
  2619         CCalGeoValue* geoValue = iEntry->GeoValueL();
       
  2620         if(geoValue)
       
  2621             {
       
  2622             // Get the count of lines before location field
       
  2623             // so that map icon is drwan exactly at the firlst line of location text on the event viewer
       
  2624             HBufC* visualText = NULL;
       
  2625             CArrayFixFlat<TInt>* lineWidths = new( ELeave )CArrayFixFlat<TInt>( 5 );
       
  2626             CleanupStack::PushL( lineWidths );
       
  2627             lineWidths->AppendL(iMaxWidth - iIconDrawerWidthInPixels);
       
  2628             // trim of enter keys entered at the end of the summary text,
       
  2629             TBuf<160> summary;
       
  2630             summary.Append(iEventViewData->Summary());
       
  2631             TChar ch = 0x2029; // For Enter key
       
  2632             TInt length = iEventViewData->Summary().Length();
       
  2633             TInt count = 0;
       
  2634             
       
  2635             while( length > 0 )
       
  2636                 {
       
  2637                 if(summary[--length] == ch)
       
  2638                     {
       
  2639                     count++;
       
  2640                     summary.Copy(summary.Left(length)); // trim off the enter key
       
  2641                     }
       
  2642                 }
       
  2643             
       
  2644             // Count the number of lines summary will occupy after squeezing enter keys at the end of the text
       
  2645             CArrayFixFlat<TPtrC>* textLines = new(ELeave)CArrayFixFlat<TPtrC>(5);
       
  2646             CleanupStack::PushL( textLines );
       
  2647             visualText = AknBidiTextUtils::ConvertToVisualAndWrapToArrayWholeTextL(summary , 
       
  2648                                                                                     *lineWidths, 
       
  2649                                                                                     *iHeadingFont,
       
  2650                                                                                     *textLines);
       
  2651             iNumOfLinesBeforeLocField += textLines->Count() + iTimeFieldLines; // Added for time and date field
       
  2652             if (iEventViewData->Summary() == KNullDesC) // If summary is NULL, then <Unnamed> will be added as first line, hence, increment it
       
  2653                 {
       
  2654                 iNumOfLinesBeforeLocField++;
       
  2655                 }
       
  2656             iNumOfLinesBeforeLocField += count; // Add the number of enter keys added at the end of the summary
       
  2657             iTimeFieldLines = 0; // Reset the value
       
  2658             CleanupStack::PopAndDestroy(textLines);
       
  2659             CleanupStack::PopAndDestroy(lineWidths);
       
  2660             delete visualText;
       
  2661             delete geoValue;    
       
  2662             }
       
  2663     }
       
  2664 	
       
  2665 // -----------------------------------------------------------------------------
  2621 // -----------------------------------------------------------------------------
  2666 // CCalenCommonUI::FindPossibleInstanceL
  2622 // CCalenCommonUI::FindPossibleInstanceL
  2667 // Finds an instance with the given instance id and instance view.
  2623 // Finds an instance with the given instance id and instance view.
  2668 // (other items were commented in a header).
  2624 // (other items were commented in a header).
  2669 // -----------------------------------------------------------------------------
  2625 // -----------------------------------------------------------------------------
  2794     {
  2750     {
  2795     TRACE_ENTRY_POINT;
  2751     TRACE_ENTRY_POINT;
  2796     BuildSearchBufferL();
  2752     BuildSearchBufferL();
  2797     MCalenToolbar* toolbar = iServices.ToolbarOrNull();
  2753     MCalenToolbar* toolbar = iServices.ToolbarOrNull();
  2798     CFindItemDialog* finder = CFindItemDialog::NewL( *iSearchBuf, CFindItemEngine::EFindItemSearchPhoneNumberBin);
  2754     CFindItemDialog* finder = CFindItemDialog::NewL( *iSearchBuf, CFindItemEngine::EFindItemSearchPhoneNumberBin);
       
  2755     finder->EnableSingleClick(ETrue);
  2799     toolbar->SetToolbarVisibilityL(EFalse);
  2756     toolbar->SetToolbarVisibilityL(EFalse);
  2800     finder->ExecuteLD();
  2757     finder->ExecuteLD();
  2801     toolbar->SetToolbarVisibilityL(ETrue);
  2758     toolbar->SetToolbarVisibilityL(ETrue);
  2802     
  2759     
  2803     TRACE_EXIT_POINT;
  2760     TRACE_EXIT_POINT;
  2813     {
  2770     {
  2814     TRACE_ENTRY_POINT;
  2771     TRACE_ENTRY_POINT;
  2815     BuildSearchBufferL();
  2772     BuildSearchBufferL();
  2816     MCalenToolbar* toolbar = iServices.ToolbarOrNull();
  2773     MCalenToolbar* toolbar = iServices.ToolbarOrNull();
  2817     CFindItemDialog* finder = CFindItemDialog::NewL( *iSearchBuf, CFindItemEngine::EFindItemSearchURLBin);
  2774     CFindItemDialog* finder = CFindItemDialog::NewL( *iSearchBuf, CFindItemEngine::EFindItemSearchURLBin);
       
  2775     finder->EnableSingleClick(ETrue);
  2818     toolbar->SetToolbarVisibilityL(EFalse);
  2776     toolbar->SetToolbarVisibilityL(EFalse);
  2819     finder->ExecuteLD();
  2777     finder->ExecuteLD();
  2820     toolbar->SetToolbarVisibilityL(ETrue);
  2778     toolbar->SetToolbarVisibilityL(ETrue);
  2821     TRACE_EXIT_POINT;
  2779     TRACE_EXIT_POINT;
  2822     }
  2780     }
  2831     {
  2789     {
  2832     TRACE_ENTRY_POINT;
  2790     TRACE_ENTRY_POINT;
  2833     BuildSearchBufferL();
  2791     BuildSearchBufferL();
  2834     MCalenToolbar* toolbar = iServices.ToolbarOrNull();
  2792     MCalenToolbar* toolbar = iServices.ToolbarOrNull();
  2835     CFindItemDialog* finder = CFindItemDialog::NewL( *iSearchBuf, CFindItemEngine::EFindItemSearchMailAddressBin);
  2793     CFindItemDialog* finder = CFindItemDialog::NewL( *iSearchBuf, CFindItemEngine::EFindItemSearchMailAddressBin);
       
  2794     finder->EnableSingleClick(ETrue);
  2836     toolbar->SetToolbarVisibilityL(EFalse);
  2795     toolbar->SetToolbarVisibilityL(EFalse);
  2837     finder->ExecuteLD();
  2796     finder->ExecuteLD();
  2838     toolbar->SetToolbarVisibilityL(ETrue);
  2797     toolbar->SetToolbarVisibilityL(ETrue);
  2839     TRACE_EXIT_POINT;
  2798     TRACE_EXIT_POINT;
  2840     }
  2799     }