meetingrequest/mrgui/mrfieldbuilderplugin/src/cesmrviewerpriorityfield.cpp
changeset 0 8466d47a6819
child 16 4ce476e64c59
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     1 /*
       
     2 * Copyright (c) 2007-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:  Priority field for viewers
       
    15  *
       
    16 */
       
    17 
       
    18 #include "emailtrace.h"
       
    19 #include "cesmrviewerpriorityfield.h"
       
    20 
       
    21 #include <eiklabel.h>
       
    22 #include <calentry.h>
       
    23 #include <eikenv.h>
       
    24 #include <StringLoader.h>
       
    25 #include <AknsConstants.h>
       
    26 
       
    27 #include <esmrgui.rsg>
       
    28 #include "esmrdef.h"
       
    29 #include "mesmrlistobserver.h"
       
    30 
       
    31 // ======== MEMBER FUNCTIONS ========
       
    32 
       
    33 // ---------------------------------------------------------------------------
       
    34 // CESMRViewerPriorityField::NewL()
       
    35 // ---------------------------------------------------------------------------
       
    36 //
       
    37 CESMRViewerPriorityField* CESMRViewerPriorityField::NewL()
       
    38     {
       
    39     FUNC_LOG;
       
    40     CESMRViewerPriorityField* self = new (ELeave) CESMRViewerPriorityField();
       
    41     CleanupStack::PushL( self );
       
    42     self->ConstructL();
       
    43     CleanupStack::Pop( self );
       
    44     return self;
       
    45     }
       
    46 
       
    47 // ---------------------------------------------------------------------------
       
    48 // CESMRViewerPriorityField::~CESMRViewerPriorityField()
       
    49 // ---------------------------------------------------------------------------
       
    50 //
       
    51 CESMRViewerPriorityField::~CESMRViewerPriorityField()
       
    52     {
       
    53     FUNC_LOG;
       
    54     //do nothing
       
    55     }
       
    56 
       
    57 // ---------------------------------------------------------------------------
       
    58 // CESMRViewerPriorityField::CESMRViewerPriorityField()
       
    59 // ---------------------------------------------------------------------------
       
    60 //
       
    61 CESMRViewerPriorityField::CESMRViewerPriorityField()
       
    62     {
       
    63     FUNC_LOG;
       
    64     //do nothing
       
    65     }
       
    66 
       
    67 // ---------------------------------------------------------------------------
       
    68 // CESMRViewerPriorityField::ConstructL()
       
    69 // ---------------------------------------------------------------------------
       
    70 //
       
    71 void CESMRViewerPriorityField::ConstructL()
       
    72     {
       
    73     FUNC_LOG;
       
    74     // As a default set icon and text as it should be in priority NORMAL
       
    75     SetFieldId( EESMRFieldPriority );
       
    76     CESMRViewerLabelField::ConstructL( KAknsIIDQgnFsIndiPriorityNormal);
       
    77     HBufC* priorityText = StringLoader::LoadLC(
       
    78                         R_QTN_CALENDAR_MEETING_OPT_PRIORITY_NORMAL,
       
    79                         iEikonEnv );
       
    80     iLabel->SetTextL( *priorityText );
       
    81     CleanupStack::PopAndDestroy( priorityText );
       
    82     }
       
    83 
       
    84 // ---------------------------------------------------------------------------
       
    85 // CESMRViewerPriorityField::InternalizeL()
       
    86 // ---------------------------------------------------------------------------
       
    87 //
       
    88 void CESMRViewerPriorityField::InternalizeL( MESMRCalEntry& aEntry )
       
    89     {
       
    90     FUNC_LOG;
       
    91     // Get the priority
       
    92     TInt priority = aEntry.GetPriorityL();
       
    93 
       
    94     HBufC* priorityText;
       
    95     TInt resourceId(KErrNotFound);
       
    96     TAknsItemID priorityIconId;
       
    97 
       
    98     if ( aEntry.Type() == MESMRCalEntry::EESMRCalEntryTodo )
       
    99         {
       
   100         switch( priority )
       
   101             {
       
   102             case EFSCalenTodoPriorityLow:
       
   103                 {
       
   104                 resourceId = R_QTN_CALENDAR_MEETING_OPT_PRIORITY_LOW;
       
   105                 priorityIconId = KAknsIIDQgnFsIndiPriorityLow;
       
   106                 break;
       
   107                 }
       
   108             case EFSCalenTodoPriorityHigh:
       
   109                 {
       
   110                 resourceId = R_QTN_CALENDAR_MEETING_OPT_PRIORITY_HIGH;
       
   111                 priorityIconId = KAknsIIDQgnFsIndiPriorityHigh;
       
   112                 break;
       
   113                 }
       
   114             default:
       
   115                 {
       
   116                 // Do nothing, priority normal remains
       
   117                 break;
       
   118                 }
       
   119             }
       
   120 
       
   121         }
       
   122     else
       
   123         {
       
   124         switch( priority )
       
   125             {
       
   126             case EFSCalenMRPriorityLow:
       
   127                 {
       
   128                 resourceId = R_QTN_CALENDAR_MEETING_OPT_PRIORITY_LOW;
       
   129                 priorityIconId = KAknsIIDQgnFsIndiPriorityLow;
       
   130                 break;
       
   131                 }
       
   132             case EFSCalenMRPriorityHigh:
       
   133                 {
       
   134                 resourceId = R_QTN_CALENDAR_MEETING_OPT_PRIORITY_HIGH;
       
   135                 priorityIconId = KAknsIIDQgnFsIndiPriorityHigh;
       
   136                 break;
       
   137                 }
       
   138             default:
       
   139                 {
       
   140                 // Do nothing, priority normal remains
       
   141                 break;
       
   142                 }
       
   143             }
       
   144         }
       
   145 
       
   146     // if not changed, the default set in ConstructL will be used:
       
   147     if ( resourceId != KErrNotFound )
       
   148         {
       
   149         priorityText = StringLoader::LoadLC( resourceId,
       
   150                                              iEikonEnv );
       
   151         iLabel->SetTextL( *priorityText );
       
   152         CleanupStack::PopAndDestroy( priorityText );
       
   153 
       
   154         IconL( priorityIconId );
       
   155 
       
   156         // This needs to be called so icon will be redrawn
       
   157         SizeChanged();
       
   158         }
       
   159     }
       
   160 
       
   161 // EOF
       
   162