meetingrequest/mrgui/mrfieldbuilderpluginextension/src/cesmrtrackstatus.cpp
branchRCL_3
changeset 64 3533d4323edc
equal deleted inserted replaced
63:d189ee25cf9d 64:3533d4323edc
       
     1 /*
       
     2 * Copyright (c) 2009 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:  Holds the tracking status for MR attendee
       
    15  *
       
    16 */
       
    17 
       
    18 // CLASS HEADER
       
    19 
       
    20 #include "cesmrtrackstatus.h"
       
    21 
       
    22 #include "cesmrfield.h"
       
    23 #include "esmrdef.h"
       
    24 #include "mesmrlistobserver.h"
       
    25 #include "cesmrcontactmenuhandler.h"
       
    26 #include "esmrhelper.h"
       
    27 #include "nmrbitmapmanager.h"
       
    28 #include "cmrimage.h"
       
    29 
       
    30 #include <eiklabel.h>
       
    31 #include <eikimage.h>
       
    32 #include <calentry.h>
       
    33 #include <caluser.h>
       
    34 #include <eikenv.h>
       
    35 #include <StringLoader.h>
       
    36 #include <AknsUtils.h>
       
    37 #include <AknUtils.h>
       
    38 #include <AknsConstants.h>
       
    39 #include <AknBidiTextUtils.h>
       
    40 #include <esmrgui.rsg>
       
    41 #include <data_caging_path_literals.hrh>
       
    42 #include <e32cmn.h>
       
    43 
       
    44 
       
    45 // DEBUG
       
    46 #include "emailtrace.h"
       
    47 
       
    48 // ======== MEMBER FUNCTIONS ========
       
    49 
       
    50 // ---------------------------------------------------------------------------
       
    51 // CESMRTrackStatus::NewL()
       
    52 // ---------------------------------------------------------------------------
       
    53 //
       
    54 CESMRTrackStatus* CESMRTrackStatus::NewL()
       
    55     {
       
    56     FUNC_LOG;
       
    57     CESMRTrackStatus* self = new (ELeave) CESMRTrackStatus();
       
    58     CleanupStack::PushL( self );
       
    59     self->ConstructL();
       
    60     CleanupStack::Pop( self );
       
    61     return self;
       
    62     }
       
    63 
       
    64 // ---------------------------------------------------------------------------
       
    65 // CESMRTrackStatus::~CESMRTrackStatus()
       
    66 // ---------------------------------------------------------------------------
       
    67 //
       
    68 CESMRTrackStatus::~CESMRTrackStatus()
       
    69     {
       
    70     FUNC_LOG;
       
    71     if ( iMenuHandler )
       
    72         {
       
    73         iMenuHandler->Reset();
       
    74         }
       
    75     iESMRStatic.Close();
       
    76     delete iDefaultAddress;
       
    77     delete iAddress;
       
    78     delete iCommonName;
       
    79     delete iIcon;
       
    80     delete iActionMenuIcon;
       
    81     delete iActionMenuIconMask;
       
    82     }
       
    83 
       
    84 // ---------------------------------------------------------------------------
       
    85 // CESMRTrackStatus::CESMRTrackStatus()
       
    86 // ---------------------------------------------------------------------------
       
    87 //
       
    88 CESMRTrackStatus::CESMRTrackStatus()
       
    89     {
       
    90     FUNC_LOG;
       
    91     SetFieldId( EESMRTrackStatus );
       
    92     }
       
    93 
       
    94 // ---------------------------------------------------------------------------
       
    95 // CESMRTrackStatus::ConstructL()
       
    96 // ---------------------------------------------------------------------------
       
    97 //
       
    98 void CESMRTrackStatus::ConstructL()
       
    99     {
       
   100     FUNC_LOG;
       
   101     iIcon = CMRImage::NewL( NMRBitmapManager::EMRBitmapTrackingNone );
       
   102     iIcon->SetParent( this );
       
   103 
       
   104     iESMRStatic.ConnectL();
       
   105     iMenuHandler = &iESMRStatic.ContactMenuHandlerL();
       
   106     }
       
   107 
       
   108 // ---------------------------------------------------------------------------
       
   109 // CESMRTrackStatus::InternalizeL()
       
   110 // ---------------------------------------------------------------------------
       
   111 //
       
   112 void CESMRTrackStatus::InternalizeL( MESMRCalEntry& aEntry )
       
   113     {
       
   114     FUNC_LOG;
       
   115 
       
   116     RPointerArray<CCalAttendee> attendee = aEntry.Entry().AttendeesL();
       
   117     // The array is already in sorted order with ReqAttendee coming first and
       
   118     // OptAttendee  coming later.
       
   119     TInt currentIndex = iESMRStatic.CurrentFieldIndex();
       
   120     
       
   121     if(currentIndex >= attendee.Count())
       
   122         {
       
   123         User::Leave( KErrArgument );
       
   124         }
       
   125         
       
   126     TPtrC text;
       
   127     CCalAttendee::TCalStatus status = attendee[currentIndex]->StatusL();    
       
   128     if (attendee[currentIndex]->Address().Length() >0 )
       
   129         {
       
   130         if ( attendee[currentIndex]->CommonName().Length() > 0 )
       
   131             {
       
   132             text.Set( attendee[currentIndex]->CommonName() );
       
   133             iCommonName = text.AllocL();
       
   134             }
       
   135         else
       
   136             {
       
   137             text.Set( attendee[currentIndex]->Address() );
       
   138             }
       
   139         iAddress = attendee[currentIndex]->Address().AllocL();
       
   140         }
       
   141     
       
   142     NMRBitmapManager::TMRBitmapId bitmapId;
       
   143     
       
   144     switch( status )
       
   145         {
       
   146         case CCalAttendee::ENeedsAction:
       
   147             {
       
   148             bitmapId = NMRBitmapManager::EMRBitmapTrackingNone;
       
   149             break;
       
   150             }
       
   151         case CCalAttendee::ETentative:
       
   152             {
       
   153             bitmapId = NMRBitmapManager::EMRBitmapTrackingTentative;
       
   154             break;
       
   155             }
       
   156         case CCalAttendee::EAccepted:
       
   157         case CCalAttendee::EConfirmed:
       
   158             {
       
   159             bitmapId = NMRBitmapManager::EMRBitmapTrackingAccept;
       
   160             break;
       
   161             }
       
   162         case CCalAttendee::EDeclined:
       
   163             {
       
   164             bitmapId = NMRBitmapManager::EMRBitmapTrackingReject;
       
   165             break;
       
   166             }
       
   167         default:
       
   168             {
       
   169             bitmapId = NMRBitmapManager::EMRBitmapTrackingNone;
       
   170             break;
       
   171             }
       
   172         }
       
   173 
       
   174     iESMRStatic.SetCurrentFieldIndex(++currentIndex); // Move to next index
       
   175 
       
   176     delete iIcon;
       
   177     iIcon = NULL;
       
   178     iIcon = CMRImage::NewL( bitmapId );
       
   179     iIcon->SetParent( this );
       
   180     
       
   181     //store default list selection to contactmenuhandler
       
   182     iDefaultAddress = attendee[0]->Address().AllocL();
       
   183     iMenuHandler->SetValueL(*iDefaultAddress, CESMRContactMenuHandler::EValueTypeEmail);
       
   184 
       
   185     // This needs to be called so icon will be redrawn
       
   186     SizeChanged();
       
   187     }
       
   188 
       
   189 // ---------------------------------------------------------------------------
       
   190 // CESMRTrackStatus::OfferKeyEventL
       
   191 // ---------------------------------------------------------------------------
       
   192 //
       
   193 TKeyResponse CESMRTrackStatus::OfferKeyEventL(
       
   194         const TKeyEvent& aEvent,
       
   195         TEventCode /*aType*/ )
       
   196     {
       
   197     FUNC_LOG;
       
   198     TKeyResponse response( EKeyWasNotConsumed );
       
   199     
       
   200     if ( aEvent.iScanCode == EStdKeyRightArrow )
       
   201         {
       
   202         // Show right click menu (action menu)
       
   203 
       
   204         iMenuHandler->ShowActionMenuL();
       
   205         response = EKeyWasConsumed;
       
   206         }
       
   207 
       
   208     return response;
       
   209     }
       
   210 
       
   211 // ---------------------------------------------------------------------------
       
   212 // CESMRTrackStatus::SetOutlineFocusL
       
   213 // ---------------------------------------------------------------------------
       
   214 //
       
   215 void CESMRTrackStatus::SetOutlineFocusL(TBool aFocus )
       
   216     {
       
   217     FUNC_LOG;
       
   218     CESMRField::SetOutlineFocusL (aFocus );
       
   219     
       
   220     SetActionMenuIconL(aFocus);
       
   221     TRgb fontColor( 0, 0, 0 );
       
   222     if ( aFocus )
       
   223         {
       
   224         if( iAddress )
       
   225             {
       
   226             //no longer needed
       
   227             delete iDefaultAddress;
       
   228             iDefaultAddress = NULL;
       
   229             //give contact to actionmenuhandler
       
   230             iMenuHandler->SetValueL(*iAddress, CESMRContactMenuHandler::EValueTypeEmail);
       
   231             }
       
   232         }
       
   233     else
       
   234         {
       
   235         iMenuHandler->Reset();
       
   236         }
       
   237     }
       
   238 
       
   239 // ---------------------------------------------------------------------------
       
   240 // CESMRCheckbox::CountComponentControls
       
   241 // ---------------------------------------------------------------------------
       
   242 //
       
   243 TInt CESMRTrackStatus::CountComponentControls( ) const
       
   244     {
       
   245     FUNC_LOG;
       
   246     TInt count( 0 );
       
   247     if ( iIcon )
       
   248         {
       
   249         ++count;
       
   250         }
       
   251     return count;
       
   252     }
       
   253 
       
   254 // ---------------------------------------------------------------------------
       
   255 // CESMRTrackStatus::ComponentControl
       
   256 // ---------------------------------------------------------------------------
       
   257 //
       
   258 CCoeControl* CESMRTrackStatus::ComponentControl( TInt aInd ) const
       
   259     {
       
   260     FUNC_LOG;
       
   261     
       
   262     CCoeControl* control = NULL;
       
   263     
       
   264     if ( aInd == 2 )
       
   265         {
       
   266         control = iIcon;
       
   267         }
       
   268     
       
   269     ASSERT( control );
       
   270     
       
   271     return control;
       
   272     }
       
   273 
       
   274 // ---------------------------------------------------------------------------
       
   275 // CESMRCheckbox::SetIconL
       
   276 // ---------------------------------------------------------------------------
       
   277 //
       
   278 void CESMRTrackStatus::SetActionMenuIconL( TBool aFocused )
       
   279     {
       
   280     FUNC_LOG;
       
   281     delete iIcon;
       
   282     iIcon = NULL;
       
   283     delete iActionMenuIcon;
       
   284     iActionMenuIcon = NULL;
       
   285     delete iActionMenuIconMask;
       
   286     iActionMenuIconMask = NULL;
       
   287 
       
   288     if( aFocused )
       
   289         {
       
   290         User::LeaveIfError( 
       
   291                 NMRBitmapManager::GetSkinBasedBitmap( 
       
   292                         NMRBitmapManager::EMRBitmapRightClickArrow, 
       
   293                             iActionMenuIcon, iActionMenuIconMask, TSize(20, 20) ) );
       
   294         }
       
   295     }
       
   296 
       
   297 // ---------------------------------------------------------------------------
       
   298 // CESMRTrackStatus::SizeChanged
       
   299 // ---------------------------------------------------------------------------
       
   300 //
       
   301 void CESMRTrackStatus::SizeChanged( )
       
   302     {
       
   303     FUNC_LOG;
       
   304 
       
   305     if ( iIcon )
       
   306         {
       
   307         TRect rect = Rect ( );
       
   308         }
       
   309     }
       
   310 
       
   311 // -----------------------------------------------------------------------------
       
   312 // CESMRTrackStatus::ClipTextLC
       
   313 // -----------------------------------------------------------------------------
       
   314 //
       
   315 HBufC* CESMRTrackStatus::ClipTextLC( 
       
   316         const TDesC& aText, 
       
   317         const CFont& aFont, 
       
   318         TInt aWidth )
       
   319     {
       
   320     FUNC_LOG;
       
   321     HBufC* text = HBufC::NewLC( aText.Length() + KAknBidiExtraSpacePerLine );
       
   322     TPtr textPtr = text->Des();
       
   323     AknBidiTextUtils::ConvertToVisualAndClip( aText, textPtr, aFont, aWidth, aWidth );
       
   324     return text;
       
   325     }
       
   326 
       
   327 // End of file
       
   328