calendarui/views/src/caleneventviewcontainer.cpp
branchRCL_3
changeset 36 9c5b1510919f
parent 21 9711e452b5e9
child 48 bf573002ff72
equal deleted inserted replaced
30:d68a4b5d5885 36:9c5b1510919f
   115 //
   115 //
   116 CCalenEventViewContainer::CCalenEventViewContainer(CCalenNativeView* aView,
   116 CCalenEventViewContainer::CCalenEventViewContainer(CCalenNativeView* aView,
   117                               MCalenServices& aServices  )
   117                               MCalenServices& aServices  )
   118     : CCalenContainer( aView, aServices ),
   118     : CCalenContainer( aView, aServices ),
   119     					  iEntry(NULL),
   119     					  iEntry(NULL),
   120     					  iAutomaticHlValue(ETrue),
   120 						  iEmbeddedFileOpened(EFalse)
   121     					  iAutomaticHlInitialized(EFalse),
       
   122     					  iEmbeddedFileOpened(EFalse)
       
   123     {
   121     {
   124 	TRACE_ENTRY_POINT;
   122 	TRACE_ENTRY_POINT;
   125 	iNumOfLinesBeforeLocField = 0;
   123 	iNumOfLinesBeforeLocField = 0;
   126 	iLocaleChanged = EFalse;
   124 	iLocaleChanged = EFalse;
   127 	TRACE_EXIT_POINT;
   125 	TRACE_EXIT_POINT;
   149 	delete iTextEditor;
   147 	delete iTextEditor;
   150 	delete iBgContext;
   148 	delete iBgContext;
   151     delete iTimeFormat;
   149     delete iTimeFormat;
   152     delete iDateFormat;
   150     delete iDateFormat;
   153     delete iDocHandler;
   151     delete iDocHandler;
   154     delete iAutoFinder;
       
   155     delete iFindMenu;
   152     delete iFindMenu;
   156     
   153     
   157     if( iNotifier )
   154     if( iNotifier )
   158         {
   155         {
   159         iNotifier->StopListening();
   156         iNotifier->StopListening();
   187     iBgContext = CAknsBasicBackgroundControlContext::NewL( KAknsIIDQsnBgAreaMain,
   184     iBgContext = CAknsBasicBackgroundControlContext::NewL( KAknsIIDQsnBgAreaMain,
   188                                                            Rect(),
   185                                                            Rect(),
   189                                                            ETrue );
   186                                                            ETrue );
   190     
   187     
   191     iDocHandler = CDocumentHandler::NewL( iEikonEnv->Process() );
   188     iDocHandler = CDocumentHandler::NewL( iEikonEnv->Process() );
   192     iAutoFinder = CItemFinder::NewL();
   189     
   193     iFindMenu = CFindItemMenu::NewL( EFindItemMenuPlaceHolder );
   190     iFindMenu = CFindItemMenu::NewL( EFindItemMenuPlaceHolder );
   194     iFindMenu->AttachItemFinderMenuL(0);
   191     iFindMenu->AttachItemFinderMenuL(0);
       
   192    
   195     
   193     
   196     iParaFormat = CParaFormat::NewL();
   194     iParaFormat = CParaFormat::NewL();
   197 
   195 
   198 	
   196 	
   199 	iTextEditor = new (ELeave) CEikRichTextEditor;
   197 	iTextEditor = new (ELeave) CEikRichTextEditor;
   204 	
   202 	
   205     iLabel = new (ELeave) CEikLabel;
   203     iLabel = new (ELeave) CEikLabel;
   206     iLabel->SetContainerWindowL(*this);
   204     iLabel->SetContainerWindowL(*this);
   207     iLabel->SetTextL(_L(""));
   205     iLabel->SetTextL(_L(""));
   208     iLabel->SetRect(Rect());
   206     iLabel->SetRect(Rect());
   209     
   207         
   210     ReadAutoHlCenRepValueAndSetNotifyL();
       
   211     
       
   212     CCalenEventView* eventView = static_cast<CCalenEventView*>( iView );
       
   213     if( !( eventView->IsAlarmActiveInViewer() ) )
       
   214         {
       
   215         SetAutomaticHighlightL(iAutomaticHlValue);
       
   216         }
       
   217     
       
   218     iDocHandler->SetExitObserver( this );
   208     iDocHandler->SetExitObserver( this );
       
   209     iTextEditor->EnableKineticScrollingL(ETrue);
   219 	TRACE_EXIT_POINT;
   210 	TRACE_EXIT_POINT;
   220 	}
   211 	}
   221 
   212 
   222 // ----------------------------------------------------------------------------
   213 // ----------------------------------------------------------------------------
   223 // CCalenEventViewContainer::UpdateSize
   214 // CCalenEventViewContainer::UpdateSize
   252 // ----------------------------------------------------------------------------
   243 // ----------------------------------------------------------------------------
   253 //
   244 //
   254 void CCalenEventViewContainer::CompletePopulationL()
   245 void CCalenEventViewContainer::CompletePopulationL()
   255 	{
   246 	{
   256     TRACE_ENTRY_POINT;
   247     TRACE_ENTRY_POINT;
   257     if(iTextEditor && iTextEditor->Text()->DocumentLength() > 0 && iAutoFinder &&
   248     
   258     iSelectedText.iCursorPos == 0 && iSelectedText.iAnchorPos == 0)
       
   259         {
       
   260         iAutoFinder->SetEditor((CEikRichTextEditor**)&iTextEditor);
       
   261         }
       
   262         
       
   263     iTextEditor->SetFocus(ETrue);
   249     iTextEditor->SetFocus(ETrue);
   264     ActivateL();
   250     ActivateL();
   265     AddToStackAndMakeVisibleL();
   251     AddToStackAndMakeVisibleL();
   266     DrawDeferred();
   252     DrawDeferred();
   267     if(iSelectedText.iCursorPos > 0 || iSelectedText.iAnchorPos > 0)
   253     if(iSelectedText.iCursorPos > 0 || iSelectedText.iAnchorPos > 0)
   404         {
   390         {
   405         switch (aKeyEvent.iCode)
   391         switch (aKeyEvent.iCode)
   406             {
   392             {
   407             case EKeyUpArrow:
   393             case EKeyUpArrow:
   408                 {
   394                 {
   409                  iAutoFinder->NextItemOrScrollL( CItemFinder::ENextUp );
       
   410                 // Scroll the text view up by one line
   395                 // Scroll the text view up by one line
   411                 iTextEditor->MakeVisible(EFalse);
   396                 iTextEditor->MakeVisible(EFalse);
   412                 TInt scrollLines = KScrollViewerUp;
   397                 TInt scrollLines = KScrollViewerUp;
   413                 iTextEditor->TextView()->ScrollDisplayLinesL(scrollLines);
   398                 iTextEditor->TextView()->ScrollDisplayLinesL(scrollLines);
   414                 iTextEditor->UpdateScrollBarsL();
   399                 iTextEditor->UpdateScrollBarsL();
   419                 }
   404                 }
   420                 break;
   405                 break;
   421 
   406 
   422             case EKeyDownArrow:
   407             case EKeyDownArrow:
   423                 {
   408                 {
   424                 iAutoFinder->NextItemOrScrollL( CItemFinder::ENextDown );
       
   425                 // Scroll the text view down by one line
   409                 // Scroll the text view down by one line
   426                 iTextEditor->MakeVisible(EFalse);
   410                 iTextEditor->MakeVisible(EFalse);
   427                 TInt scrollLines = KScrollViewerDown;
   411                 TInt scrollLines = KScrollViewerDown;
   428                 iTextEditor->TextView()->ScrollDisplayLinesL(scrollLines);
   412                 iTextEditor->TextView()->ScrollDisplayLinesL(scrollLines);
   429                 iTextEditor->UpdateScrollBarsL();
   413                 iTextEditor->UpdateScrollBarsL();
   445             	// Calendar relaunched from cmd line - close viewer
   429             	// Calendar relaunched from cmd line - close viewer
   446                 iView->HandleCommandL(EAknSoftkeyBack);
   430                 iView->HandleCommandL(EAknSoftkeyBack);
   447                 keyResponse = EKeyWasConsumed;
   431                 keyResponse = EKeyWasConsumed;
   448             	}
   432             	}
   449                 break;
   433                 break;
   450             case EKeyPhoneSend:
       
   451              	{
       
   452              	HandleNumberCallL();
       
   453                 break;
       
   454               }
       
   455             case EKeyBackspace:  /* fall through... */
   434             case EKeyBackspace:  /* fall through... */
   456             case EKeyDelete:
   435             case EKeyDelete:
   457             	{            
   436             	{            
   458                 CCalenEventView* eventView = static_cast<CCalenEventView*>( iView );
   437                 CCalenEventView* eventView = static_cast<CCalenEventView*>( iView );
   459             	if( !( eventView->IsAlarmActiveInViewer() ) )
   438             	if( !( eventView->IsAlarmActiveInViewer() ) )
   513     return keyResponse;
   492     return keyResponse;
   514 
   493 
   515  
   494  
   516     }
   495     }
   517 
   496 
   518 // ----------------------------------------------------------------------------
       
   519 // CCalenEventViewContainer::HandleNumberCallL
       
   520 // ----------------------------------------------------------------------------
       
   521 //
       
   522 void CCalenEventViewContainer::HandleNumberCallL()
       
   523 	{
       
   524 	TRACE_ENTRY_POINT;
       
   525 	
       
   526 	const CItemFinder::CFindItemExt& findItem = iAutoFinder->CurrentItemExt(); 
       
   527      
       
   528      if(findItem.iItemType != CItemFinder::EPhoneNumber)
       
   529         {
       
   530          return;
       
   531         }
       
   532      
       
   533      iFindMenu->HandleCallL( findItem.iItemDescriptor->Des() );  
       
   534 	
       
   535 	TRACE_EXIT_POINT;
       
   536 	}
       
   537 
   497 
   538 // ----------------------------------------------------------------------------
   498 // ----------------------------------------------------------------------------
   539 // CCalenEventViewContainer::HandlePointerEventL
   499 // CCalenEventViewContainer::HandlePointerEventL
   540 // Process pointer event.
   500 // Process pointer event.
   541 // (other items were commented in a header).
   501 // (other items were commented in a header).
   547     
   507     
   548     if(!AknLayoutUtils::PenEnabled())
   508     if(!AknLayoutUtils::PenEnabled())
   549 	 {
   509 	 {
   550 	 	return;
   510 	 	return;
   551 	 }
   511 	 }
   552    
   512     CCalenContainer::HandlePointerEventL( aPointerEvent );
   553     CCalenEventView* eventView = static_cast<CCalenEventView*>( iView );
   513     
   554     if( !( eventView->IsAlarmActiveInViewer() ) )
       
   555         {
       
   556     if(iTextEditor->Rect().Contains(aPointerEvent.iPosition))
   514     if(iTextEditor->Rect().Contains(aPointerEvent.iPosition))
   557     	{
   515     	{
   558     	switch(aPointerEvent.iType)
   516     	switch(aPointerEvent.iType)
   559     		{
   517     		{
   560     		case TPointerEvent::EButton1Down:
   518     		case TPointerEvent::EButton1Down:
   561     			{
   519     			{
   562     			iTextEditor->SetFocus(ETrue);
   520     			iTextEditor->SetFocus(ETrue);
   563     			
   521     			CCalenEventView* eventView = static_cast<CCalenEventView*>( iView );
       
   522     			if(!( eventView->IsAlarmActiveInViewer() ) )
       
   523     			    {
   564     			// TODO: Uncomment this when enabling attachment support
   524     			// TODO: Uncomment this when enabling attachment support
   565     			if(iEventViewData && !iEmbeddedFileOpened)
   525                     if(iEventViewData && !iEmbeddedFileOpened)
   566     			    {
   526                         {
   567     		
   527                         if(iEventViewData->AttachmentCount())
   568     			    if(iEventViewData->AttachmentCount())
   528                             {
   569     			        {
   529                             CTextView *textView = iTextEditor->TextView();
   570     			        CTextView *textView = iTextEditor->TextView();
   530                         
   571                     
   531                             TTmPosInfo2 *posInfo = new(ELeave) TTmPosInfo2;
   572     			        TTmPosInfo2 *posInfo = new(ELeave) TTmPosInfo2;
   532                             textView->FindXyPosL(aPointerEvent.iPosition,*posInfo);
   573     			        textView->FindXyPosL(aPointerEvent.iPosition,*posInfo);
   533                         
   574                     
   534                             // Check if it is tapped on any attachment name, if yes then open that attachment
   575     			        // Check if it is tapped on any attachment name, if yes then open that attachment
   535                             CheckAndOpenTappedAttachment(posInfo);
   576     			        CheckAndOpenTappedAttachment(posInfo);
   536                             delete posInfo;
   577     			        delete posInfo;
   537                             }
   578     			        }
   538                         }
   579     			    }
   539     			    }
   580     			break;
   540     				break;
   581     			}
   541     			}
   582     		case TPointerEvent::EDrag:
   542     		case TPointerEvent::EDrag:
   583     			{
   543     			{
   584     			iTextEditor->SetFocus(ETrue);
   544     			iTextEditor->SetFocus(ETrue);
   585     			break;
   545     			break;
   587     		case TPointerEvent::EButton1Up:
   547     		case TPointerEvent::EButton1Up:
   588     			{
   548     			{
   589     			iTextEditor->SetFocus(ETrue);
   549     			iTextEditor->SetFocus(ETrue);
   590     			TInt curPos = iTextEditor->CursorPos();	
   550     			TInt curPos = iTextEditor->CursorPos();	
   591 		        TRect rect = iTextEditor->Rect();  
   551 		        TRect rect = iTextEditor->Rect();  
   592 		       	if ( !iAutoFinder->ItemWasTappedL( aPointerEvent.iPosition - rect.iTl ) )
   552 		       	
   593 		         	{
       
   594 				 	//	return;
       
   595 				 	} 
       
   596     			break;	
   553     			break;	
   597     			}
   554     			}
   598     		default:
   555     		default:
   599     			{
   556     			{
   600     			break;	
   557     			break;	
   601     			}	
   558     			}	
   602     		}
   559     		}
   603        	iTextEditor->HandlePointerEventL(aPointerEvent);
   560      }
   604        	}    
       
   605       }
       
   606        	
   561        	
   607     TRACE_EXIT_POINT;
   562     TRACE_EXIT_POINT;
   608     }
   563     }
   609     
   564     
   610 // ----------------------------------------------------------------------------
   565 // ----------------------------------------------------------------------------
  2335 	TRACE_ENTRY_POINT;
  2290 	TRACE_ENTRY_POINT;
  2336 	TRACE_EXIT_POINT;
  2291 	TRACE_EXIT_POINT;
  2337 	return iEventViewData;	
  2292 	return iEventViewData;	
  2338 	}
  2293 	}
  2339 
  2294 
  2340 // -----------------------------------------------------------------------------
  2295 
  2341 // CCalenEventViewContainer::ReadAutoHlCenRepValueAndSetNotifyL
  2296 // -----------------------------------------------------------------------------
  2342 // 
  2297 // CCalenEventViewContainer::HandleNotifyError
  2343 // -----------------------------------------------------------------------------
  2298 // From MCenRepNotifyHandlerCallback
  2344 //
  2299 // -----------------------------------------------------------------------------
  2345 void CCalenEventViewContainer::ReadAutoHlCenRepValueAndSetNotifyL()
  2300 //	
  2346 	{
       
  2347 	TRACE_ENTRY_POINT;
       
  2348 	
       
  2349 	if ( iAutomaticHlInitialized )
       
  2350 	     return;
       
  2351 	
       
  2352     // Create the session
       
  2353     iCenRepSession = CRepository::NewL( KCRUidCommonUi );
       
  2354     
       
  2355     if( iCenRepSession )
       
  2356         {
       
  2357         // Get the value of AutomaticHighlight key
       
  2358         iCenRepSession->Get( KCuiAutomaticHighlight, iAutomaticHlValue );
       
  2359         // Create the notifer
       
  2360         iNotifier = 
       
  2361             CCenRepNotifyHandler::NewL( 
       
  2362                 *this, *iCenRepSession, CCenRepNotifyHandler::EIntKey,
       
  2363                 KCuiAutomaticHighlight );
       
  2364         // Start listening
       
  2365         iNotifier->StartListeningL();       
       
  2366         }
       
  2367     
       
  2368     iAutomaticHlInitialized = ETrue; // Done once per viewer
       
  2369 	
       
  2370 	TRACE_EXIT_POINT;
       
  2371 	}
       
  2372 
       
  2373 // -----------------------------------------------------------------------------
       
  2374 // CCalenEventViewContainer::HandleNotifyInt
       
  2375 // Handles the incoming notifications of key changes
       
  2376 // -----------------------------------------------------------------------------
       
  2377 //		
       
  2378 void CCalenEventViewContainer::HandleNotifyInt( TUint32 /*aId*/, TInt aNewValue )
       
  2379 	{
       
  2380 	TRACE_ENTRY_POINT;
       
  2381 	
       
  2382 	// Notifies changes on KCuiAutomaticHighlight
       
  2383     TRAPD(error,SetAutomaticHighlightL( aNewValue ));
       
  2384 	if ( error != KErrNone )
       
  2385 		{
       
  2386 		 User::Panic(_L("CCalenEventViewContainer"),error);
       
  2387 		}
       
  2388 	TRACE_EXIT_POINT;
       
  2389 	}
       
  2390 
       
  2391 
       
  2392 void CCalenEventViewContainer::HandleNotifyError( TUint32 /*aId*/,TInt /*aError*/,
  2301 void CCalenEventViewContainer::HandleNotifyError( TUint32 /*aId*/,TInt /*aError*/,
  2393 												CCenRepNotifyHandler* /*aHandler*/ )
  2302 												CCenRepNotifyHandler* /*aHandler*/ )
  2394 	{
  2303 	{
  2395 	TRACE_ENTRY_POINT;
  2304 	TRACE_ENTRY_POINT;
  2396 	
  2305 	
  2405     iCenRepSession = NULL;
  2314     iCenRepSession = NULL;
  2406 	
  2315 	
  2407 	TRACE_EXIT_POINT;
  2316 	TRACE_EXIT_POINT;
  2408 	}
  2317 	}
  2409 
  2318 
  2410 // -----------------------------------------------------------------------------
  2319 
  2411 // CCalenEventViewContainer::SetAutomaticHighlightL
  2320 
  2412 // -----------------------------------------------------------------------------
  2321 
  2413 //	
       
  2414 void CCalenEventViewContainer::SetAutomaticHighlightL( const TBool aSwitchON )
       
  2415 	{
       
  2416 	TRACE_ENTRY_POINT;
       
  2417 	
       
  2418 	if ( iAutoFinder )
       
  2419         {
       
  2420         // content highlight
       
  2421         if ( aSwitchON )
       
  2422             { // switch ON
       
  2423             iAutoFinder->SetFindModeL( 
       
  2424                 CItemFinder::EPhoneNumber |
       
  2425                 CItemFinder::EUrlAddress |
       
  2426                 CItemFinder::EEmailAddress );
       
  2427                
       
  2428             }
       
  2429         else
       
  2430             { // switch OFF
       
  2431             iAutoFinder->SetFindModeL( 
       
  2432                 CItemFinder::ENoneSelected );
       
  2433                 
       
  2434             }
       
  2435         }
       
  2436         
       
  2437 	TRACE_EXIT_POINT;
       
  2438 	}
       
  2439 	
       
  2440 // -----------------------------------------------------------------------------
       
  2441 // CCalenEventViewContainer::GetItemFinder
       
  2442 // -----------------------------------------------------------------------------
       
  2443 //
       
  2444 CItemFinder* CCalenEventViewContainer::GetItemFinder()
       
  2445 	{
       
  2446 	TRACE_ENTRY_POINT;
       
  2447 	TRACE_EXIT_POINT;
       
  2448 	
       
  2449 	return iAutoFinder;
       
  2450 	}
       
  2451 // -----------------------------------------------------------------------------
  2322 // -----------------------------------------------------------------------------
  2452 // CCalenEventViewContainer::GetFindItemMenu
  2323 // CCalenEventViewContainer::GetFindItemMenu
  2453 // -----------------------------------------------------------------------------
  2324 // -----------------------------------------------------------------------------
  2454 //
  2325 //
  2455 CFindItemMenu* CCalenEventViewContainer::GetFindItemMenu()
  2326 CFindItemMenu* CCalenEventViewContainer::GetFindItemMenu()
  3000             break;
  2871             break;
  3001         }
  2872         }
  3002     TRACE_EXIT_POINT
  2873     TRACE_EXIT_POINT
  3003     }  
  2874     }  
  3004 
  2875 
       
  2876 // -----------------------------------------------------------------------------
       
  2877 // OnCmdFindPhoneNumL
       
  2878 // Find phone numbers in the form.
       
  2879 // (other items were commented in a header).
       
  2880 // -----------------------------------------------------------------------------
       
  2881 //
       
  2882 void CCalenEventViewContainer::OnCmdFindPhoneNumL()
       
  2883     {
       
  2884     TRACE_ENTRY_POINT;
       
  2885     BuildSearchBufferL();
       
  2886     MCalenToolbar* toolbar = iServices.ToolbarOrNull();
       
  2887     CFindItemDialog* finder = CFindItemDialog::NewL( *iSearchBuf, CFindItemEngine::EFindItemSearchPhoneNumberBin);
       
  2888     toolbar->SetToolbarVisibilityL(EFalse);
       
  2889     finder->ExecuteLD();
       
  2890     toolbar->SetToolbarVisibilityL(ETrue);
       
  2891     
       
  2892     TRACE_EXIT_POINT;
       
  2893     }
       
  2894 
       
  2895 // -----------------------------------------------------------------------------
       
  2896 // OnCmdFindUrlL
       
  2897 // Find urls in the form.
       
  2898 // (other items were commented in a header).
       
  2899 // -----------------------------------------------------------------------------
       
  2900 //
       
  2901 void CCalenEventViewContainer::OnCmdFindUrlL()
       
  2902     {
       
  2903     TRACE_ENTRY_POINT;
       
  2904     BuildSearchBufferL();
       
  2905     MCalenToolbar* toolbar = iServices.ToolbarOrNull();
       
  2906     CFindItemDialog* finder = CFindItemDialog::NewL( *iSearchBuf, CFindItemEngine::EFindItemSearchURLBin);
       
  2907     toolbar->SetToolbarVisibilityL(EFalse);
       
  2908     finder->ExecuteLD();
       
  2909     toolbar->SetToolbarVisibilityL(ETrue);
       
  2910     TRACE_EXIT_POINT;
       
  2911     }
       
  2912 
       
  2913 // -----------------------------------------------------------------------------
       
  2914 // OnCmdFindEmailL
       
  2915 // Find email addresses in the form.
       
  2916 // (other items were commented in a header).
       
  2917 // -----------------------------------------------------------------------------
       
  2918 //
       
  2919 void CCalenEventViewContainer::OnCmdFindEmailL()
       
  2920     {
       
  2921     TRACE_ENTRY_POINT;
       
  2922     BuildSearchBufferL();
       
  2923     MCalenToolbar* toolbar = iServices.ToolbarOrNull();
       
  2924     CFindItemDialog* finder = CFindItemDialog::NewL( *iSearchBuf, CFindItemEngine::EFindItemSearchMailAddressBin);
       
  2925     toolbar->SetToolbarVisibilityL(EFalse);
       
  2926     finder->ExecuteLD();
       
  2927     toolbar->SetToolbarVisibilityL(ETrue);
       
  2928     TRACE_EXIT_POINT;
       
  2929     }
  3005 
  2930 
  3006 // end of file
  2931 // end of file
  3007 
  2932