emailuis/emailui/src/ncssubjectfield.cpp
branchRCL_3
changeset 10 f5907b1a1053
parent 8 e1b6206813b4
child 12 4ce476e64c59
--- a/emailuis/emailui/src/ncssubjectfield.cpp	Fri Feb 19 22:37:30 2010 +0200
+++ b/emailuis/emailui/src/ncssubjectfield.cpp	Fri Mar 12 15:41:14 2010 +0200
@@ -250,73 +250,49 @@
 void CNcsSubjectField::FocusChanged( TDrawNow aDrawNow )
 	{
     FUNC_LOG;
-	iDrawAfterFocusChange = aDrawNow;
-	DoHandleFocusChanged( this );
-	}
-
-// -----------------------------------------------------------------------------
-// CNcsSubjectField::HandleFocusChangedL()
-// -----------------------------------------------------------------------------
-//
-void CNcsSubjectField::HandleFocusChangedL()
-    {
-    FUNC_LOG;
-    if ( IsFocused() )
-        {
-        iTextEditor->SetFocus( ETrue );
-        iTextEditor->SetCursorPosL( iTextEditor->TextLength(), EFalse );
+	if ( IsFocused() )
+		{
+		iTextEditor->SetFocus( ETrue );
+		TRAP_IGNORE( iTextEditor->SetCursorPosL( iTextEditor->TextLength(), EFalse ) ); 
 
-        // make sure that control is visible on screen
-        if ( Rect().iTl.iY < 0 )
-            {
-            TPoint pt = TPoint( 0, 0 );
-            Reposition( pt, Rect().Width() );
-            iSizeObserver->UpdateFieldPosition( this );
-            }
-        else
-            {
-            TPoint pos = PositionRelativeToScreen();
-            pos.iY += Size().iHeight;
-            CWsScreenDevice* screenDev = ControlEnv()->ScreenDevice();
-            TPixelsAndRotation pix;
-            screenDev->GetDefaultScreenSizeAndRotation( pix );
-            const TInt h = pix.iPixelSize.iHeight;
-            if ( pos.iY >= h - h / 3 )
-                {
-                TPoint pt = TPoint( 0, h / 3 );
-                Reposition( pt, Rect().Width() );
-                iSizeObserver->UpdateFieldPosition( this );
-                }
-            }
+		// make sure that control is visible on screen
+		if ( Rect().iTl.iY < 0 )
+			{
+			TPoint pt = TPoint( 0, 0 );
+			Reposition( pt, Rect().Width() );
+			iSizeObserver->UpdateFieldPosition( this );
+			}
+		else
+			{
+			TPoint pos = PositionRelativeToScreen();
+			pos.iY += Size().iHeight;
+			CWsScreenDevice* screenDev = ControlEnv()->ScreenDevice();
+			TPixelsAndRotation pix;
+			screenDev->GetDefaultScreenSizeAndRotation( pix );
+			const TInt h = pix.iPixelSize.iHeight;
+			if ( pos.iY >= h - h / 3 )
+				{
+				TPoint pt = TPoint( 0, h / 3 );
+				Reposition( pt, Rect().Width() );
+				iSizeObserver->UpdateFieldPosition( this );
+				}
+			}
 
-        if ( iParentControl )
-            {
-            iParentControl->SetMskL();
-            }
-        }
-    else
-        {
-        iTextEditor->HandleTextChangedL();
-        iTextEditor->SetFocus( EFalse );
-        }
+		if ( iParentControl )
+			{
+			TRAP_IGNORE( iParentControl->SetMskL() );
+			}
+		}
+	else
+		{
+		iTextEditor->SetFocus( EFalse );
+		}
 
-    if ( iDrawAfterFocusChange )
-        {
-        DrawNow();
-        }
-    }
-
-// -----------------------------------------------------------------------------
-// CNcsSubjectField::DoHandleFocusChanged()
-// -----------------------------------------------------------------------------
-//
-TInt CNcsSubjectField::DoHandleFocusChanged( TAny* aSelfPtr )
-    {
-    FUNC_LOG;
-    CNcsSubjectField* self = static_cast<CNcsSubjectField*>( aSelfPtr );
-    TRAPD( err, self->HandleFocusChangedL() );
-    return err;
-    }
+	if ( aDrawNow )
+		{
+		DrawNow();
+		}
+	}
 
 // -----------------------------------------------------------------------------
 // CNcsSubjectField::MinimumHeight()
@@ -352,7 +328,15 @@
     FUNC_LOG;
     if ( &aSubject && aSubject.Length() > 0 )
     	{
-	    RMemReadStream inputStream( aSubject.Ptr(), aSubject.Size() );
+        // clear subject if necessary
+        TInt documentLength = iTextEditor->RichText()->DocumentLength();
+        if ( documentLength > 0 )
+            {
+            iTextEditor->RichText()->DeleteL( 0, documentLength );
+            iTextEditor->HandleTextChangedL();
+            }
+
+        RMemReadStream inputStream( aSubject.Ptr(), aSubject.Size() );
 	    CleanupClosePushL( inputStream );
 
 	  	iTextEditor->RichText()->ImportTextL( 0, inputStream, CPlainText::EOrganiseByParagraph );