meetingrequest/mrgui/mrfieldbuilderplugin/src/cesmrviewerrecurrencedatefield.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:  Recurrence date field for viewers
       
    15  *
       
    16 */
       
    17 
       
    18 #include "cesmrviewerrecurrencedatefield.h"
       
    19 #include "mesmrresponseobserver.h"
       
    20 #include "cesmrborderlayer.h"
       
    21 #include "mesmrlistobserver.h"
       
    22 #include "esmrfieldbuilderdef.h"
       
    23 #include "cesmrlayoutmgr.h"
       
    24 #include "cmrlabel.h"
       
    25 #include "nmrlayoutmanager.h"
       
    26 
       
    27 #include <eikenv.h>
       
    28 #include <avkon.rsg>
       
    29 #include <avkon.hrh>
       
    30 #include <StringLoader.h>
       
    31 #include <AknUtils.h>
       
    32 #include <esmrgui.rsg>
       
    33 #include <caltime.h>
       
    34 // DEBUG
       
    35 #include "emailtrace.h"
       
    36 
       
    37 using namespace ESMRLayout;
       
    38 
       
    39 namespace // codescanner::namespace
       
    40     {
       
    41     const TInt KComponentCount( 2 );
       
    42     const TInt KMargin (5);
       
    43     }
       
    44 // ======== MEMBER FUNCTIONS ========
       
    45 
       
    46 // -----------------------------------------------------------------------------
       
    47 // CESMRViewerRecurrenceDateField::NewL
       
    48 // -----------------------------------------------------------------------------
       
    49 //
       
    50 CESMRViewerRecurrenceDateField* CESMRViewerRecurrenceDateField::NewL()
       
    51     {
       
    52     FUNC_LOG;
       
    53     CESMRViewerRecurrenceDateField* self = new (ELeave) CESMRViewerRecurrenceDateField();
       
    54     CleanupStack::PushL( self );
       
    55     self->ConstructL();
       
    56     CleanupStack::Pop( self );
       
    57     return self;
       
    58     }
       
    59 
       
    60 // -----------------------------------------------------------------------------
       
    61 // CESMRViewerRecurrenceDateField::~CESMRViewerRecurrenceDateField
       
    62 // -----------------------------------------------------------------------------
       
    63 //
       
    64 CESMRViewerRecurrenceDateField::~CESMRViewerRecurrenceDateField()
       
    65     {
       
    66     FUNC_LOG;
       
    67     delete iRepeatTopic;
       
    68     delete iRepeatDate;
       
    69     }
       
    70 
       
    71 // -----------------------------------------------------------------------------
       
    72 // CESMRViewerRecurrenceDateField::CESMRViewerRecurrenceDateField
       
    73 // -----------------------------------------------------------------------------
       
    74 //
       
    75 CESMRViewerRecurrenceDateField::CESMRViewerRecurrenceDateField()
       
    76     {
       
    77     FUNC_LOG;
       
    78     SetFieldId( EESMRFieldRecurrenceDate );
       
    79     }
       
    80 
       
    81 // -----------------------------------------------------------------------------
       
    82 // CESMRViewerRecurrenceDateField::ConstructL
       
    83 // -----------------------------------------------------------------------------
       
    84 //
       
    85 void CESMRViewerRecurrenceDateField::ConstructL()
       
    86     {
       
    87     FUNC_LOG;
       
    88     iRepeatTopic = CMRLabel::NewL();
       
    89     iRepeatDate = CMRLabel::NewL();
       
    90 
       
    91     iRepeatTopic->SetTextL( KNullDesC );
       
    92     iRepeatDate->SetTextL( KNullDesC );
       
    93     }
       
    94 
       
    95 // -----------------------------------------------------------------------------
       
    96 // CESMRViewerRecurrenceDateField::InitializeL
       
    97 // -----------------------------------------------------------------------------
       
    98 //
       
    99 void CESMRViewerRecurrenceDateField::InitializeL()
       
   100     {
       
   101     FUNC_LOG;
       
   102     TAknLayoutText editorRect = 
       
   103     NMRLayoutManager::GetLayoutText( 
       
   104             Rect(), NMRLayoutManager::EMRTextLayoutMultiRowTextEditor );
       
   105     
       
   106     iRepeatTopic->SetFont( editorRect.Font() );
       
   107     iRepeatDate->SetFont( editorRect.Font() );
       
   108 
       
   109     AknLayoutUtils::OverrideControlColorL( *iRepeatTopic, EColorLabelText,
       
   110                                             KRgbBlack );
       
   111     AknLayoutUtils::OverrideControlColorL( *iRepeatDate, EColorLabelText,
       
   112                                             KRgbBlack );
       
   113     //this control cannot ever get keyboard focus
       
   114     SetFocusing(EFalse);
       
   115     }
       
   116 
       
   117 // -----------------------------------------------------------------------------
       
   118 // CESMRViewerRecurrenceDateField::SizeChanged
       
   119 // -----------------------------------------------------------------------------
       
   120 //
       
   121 void CESMRViewerRecurrenceDateField::SizeChanged()
       
   122     {
       
   123     FUNC_LOG;
       
   124     TRect rect( Rect() );
       
   125     // First row
       
   126     TAknLayoutRect row1LayoutRect =
       
   127         NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 );
       
   128     rect = row1LayoutRect.Rect();    
       
   129     
       
   130     TAknLayoutText topicRect = 
       
   131         NMRLayoutManager::GetLayoutText( 
       
   132                 rect, NMRLayoutManager::EMRTextLayoutMultiRowTextEditor ); 
       
   133     
       
   134     TRect rectWithMargin = topicRect.TextRect();
       
   135     rectWithMargin.iTl.iX += KMargin;
       
   136     iRepeatTopic->SetRect( rectWithMargin );
       
   137     
       
   138     rect = Rect();
       
   139     // Move the iY down the height of the topic field
       
   140     TInt movement = row1LayoutRect.Rect().Height();
       
   141     rect.Move( 0, movement );    
       
   142     
       
   143     // Second row
       
   144     TAknLayoutRect row2LayoutRect =
       
   145         NMRLayoutManager::GetFieldRowLayoutRect( rect, 2 );
       
   146     rect = row2LayoutRect.Rect();    
       
   147     
       
   148     TAknLayoutText dateRect = 
       
   149         NMRLayoutManager::GetLayoutText( 
       
   150                 rect, NMRLayoutManager::EMRTextLayoutMultiRowTextEditor );    
       
   151     
       
   152     rectWithMargin = dateRect.TextRect();
       
   153     rectWithMargin.iTl.iX += KMargin;
       
   154     iRepeatDate->SetRect( rectWithMargin );
       
   155     }
       
   156 
       
   157 // -----------------------------------------------------------------------------
       
   158 // CESMRViewerRecurrenceDateField::MinimumSize
       
   159 // -----------------------------------------------------------------------------
       
   160 //
       
   161 TSize CESMRViewerRecurrenceDateField::MinimumSize()
       
   162     {
       
   163     TInt height( 0 );
       
   164     // First row
       
   165     TAknLayoutRect row1LayoutRect =
       
   166         NMRLayoutManager::GetFieldRowLayoutRect( Rect(), 1 );
       
   167     height += row1LayoutRect.Rect().Height();
       
   168     // Second row
       
   169     TAknLayoutRect row2LayoutRect =
       
   170         NMRLayoutManager::GetFieldRowLayoutRect( Rect(), 2 );
       
   171     height += row2LayoutRect.Rect().Height();    
       
   172     
       
   173     TInt width( Parent()->Size().iWidth );
       
   174     return TSize( width, height );
       
   175     }
       
   176 
       
   177 // -----------------------------------------------------------------------------
       
   178 // CESMRViewerRecurrenceDateField::InternalizeL
       
   179 // -----------------------------------------------------------------------------
       
   180 //
       
   181 void CESMRViewerRecurrenceDateField::InternalizeL(
       
   182         MESMRCalEntry& aEntry )
       
   183     {
       
   184     FUNC_LOG;
       
   185     // Get recurrence
       
   186     TESMRRecurrenceValue recValue( ERecurrenceNot );
       
   187     TTime recTime( Time::NullTTime() );
       
   188     aEntry.GetRecurrenceL( recValue, recTime );
       
   189 
       
   190     // Recurrence time has to be shown in the viewer as local time
       
   191     TCalTime recurrenceTime;
       
   192     recurrenceTime.SetTimeUtcL( recTime );
       
   193     TTime localRecurrenceTime;
       
   194     localRecurrenceTime = recurrenceTime.TimeLocalL();
       
   195 
       
   196     if( aEntry.IsRecurrentEventL() &&
       
   197         recValue != ERecurrenceNot &&
       
   198         Time::NullTTime() != recTime )
       
   199         {
       
   200         HBufC* topicHolder =
       
   201                 StringLoader::LoadLC(
       
   202                         R_QTN_MEET_REQ_REPEAT_UNTIL,
       
   203                         iEikonEnv );
       
   204         // Set text for repeat topic (e.g. "Repeat until")
       
   205         iRepeatTopic->SetTextL( topicHolder->Des() );
       
   206         CleanupStack::PopAndDestroy( topicHolder );
       
   207 
       
   208         // Format date string
       
   209         HBufC* timeFormatString = iEikonEnv->AllocReadResourceLC(
       
   210                                         R_QTN_DATE_USUAL);
       
   211 
       
   212         TBuf< KDateStringLength > finalBuf;
       
   213         localRecurrenceTime.FormatL( finalBuf, *timeFormatString );
       
   214 
       
   215         // Set repeat until date value
       
   216         AknTextUtils::DisplayTextLanguageSpecificNumberConversion( finalBuf );
       
   217         iRepeatDate->SetTextL( finalBuf );
       
   218         CleanupStack::PopAndDestroy( timeFormatString );
       
   219         timeFormatString = NULL;
       
   220         }
       
   221     else
       
   222         {
       
   223         MakeVisible( EFalse );
       
   224         }
       
   225     }
       
   226 
       
   227 // -----------------------------------------------------------------------------
       
   228 // CESMRViewerRecurrenceDateField::CountComponentControls
       
   229 // -----------------------------------------------------------------------------
       
   230 //
       
   231 TInt CESMRViewerRecurrenceDateField::CountComponentControls() const
       
   232     {
       
   233     FUNC_LOG;
       
   234     return KComponentCount;
       
   235     }
       
   236 
       
   237 // -----------------------------------------------------------------------------
       
   238 // CESMRViewerRecurrenceDateField::ComponentControl
       
   239 // -----------------------------------------------------------------------------
       
   240 //
       
   241 CCoeControl* CESMRViewerRecurrenceDateField::ComponentControl( TInt aInd ) const
       
   242     {
       
   243     FUNC_LOG;
       
   244     CCoeControl* retVal = NULL;
       
   245     switch( aInd )
       
   246         {
       
   247         case 0:
       
   248             {
       
   249             retVal = iRepeatTopic;
       
   250             break;
       
   251             }
       
   252         case 1:
       
   253             {
       
   254             retVal = iRepeatDate;
       
   255             break;
       
   256             }
       
   257         default:;
       
   258         }
       
   259 
       
   260     return retVal;
       
   261     }
       
   262 
       
   263 // End of file
       
   264 
       
   265