calendarui/editors/src/calenpriorityfield.cpp
changeset 0 f979ecb2b13e
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     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:  ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 // system includes
       
    19 #include <AknPopupField.h>
       
    20 #include <AknQueryValueText.h>
       
    21 #include <CalenDefaultEditorsData.rsg>
       
    22 
       
    23 // user includes
       
    24 #include "calenpriorityfield.h"
       
    25 #include "CalenDefaultEditors.hrh"
       
    26 #include "CalenDescription.h"
       
    27 #include "calennotedatautil.h"
       
    28 
       
    29 // debug
       
    30 #include "calendarui_debug.h"
       
    31 
       
    32 // -----------------------------------------------------------------------------
       
    33 // CCalenPriorityField::NewL
       
    34 // First phase constructor
       
    35 // -----------------------------------------------------------------------------
       
    36 //
       
    37 CCalenPriorityField* CCalenPriorityField::NewL( CCalenUnifiedEditor& aUnifiedEditor )
       
    38     {
       
    39     TRACE_ENTRY_POINT;
       
    40 
       
    41     CCalenPriorityField* self =
       
    42         new( ELeave ) CCalenPriorityField( aUnifiedEditor );
       
    43     CleanupStack::PushL( self );
       
    44     self->ConstructL();
       
    45     CleanupStack::Pop();
       
    46 
       
    47     TRACE_EXIT_POINT;
       
    48     return self;
       
    49     }
       
    50 
       
    51 // -----------------------------------------------------------------------------
       
    52 // CCalenPriorityField::CCalenPriorityField
       
    53 // C++ constructor
       
    54 // -----------------------------------------------------------------------------
       
    55 //
       
    56 CCalenPriorityField::CCalenPriorityField( CCalenUnifiedEditor& aUnifiedEditor )
       
    57     : iUnifiedEditor( aUnifiedEditor )
       
    58     {
       
    59     TRACE_ENTRY_POINT;
       
    60     TRACE_EXIT_POINT;
       
    61     }
       
    62 
       
    63 // -----------------------------------------------------------------------------
       
    64 // CCalenPriorityField::ConstructL
       
    65 // second phase constructor
       
    66 // -----------------------------------------------------------------------------
       
    67 //
       
    68 void CCalenPriorityField::ConstructL()
       
    69     {
       
    70     TRACE_ENTRY_POINT;
       
    71 
       
    72     // read resource for confideitiality popup list
       
    73     iPriorityArrayText = iUnifiedEditor.ControlEnv()->ReadDesCArrayResourceL(
       
    74             R_CALEN_EDITOR_PRIORITY_POPUP_ITEMS);
       
    75 
       
    76     // create textarray
       
    77     iPriorityArray = CAknQueryValueTextArray::NewL();
       
    78     iPriorityTextValues = CAknQueryValueText::NewL();
       
    79     iPriorityArray->SetArray( *iPriorityArrayText );
       
    80     iPriorityTextValues->SetArrayL( iPriorityArray );
       
    81 
       
    82     TRACE_EXIT_POINT;
       
    83     }
       
    84 
       
    85 // -----------------------------------------------------------------------------
       
    86 // CCalenPriorityField::~CCalenPriorityField
       
    87 // Destructor
       
    88 // -----------------------------------------------------------------------------
       
    89 //
       
    90 CCalenPriorityField::~CCalenPriorityField()
       
    91     {
       
    92     TRACE_ENTRY_POINT;
       
    93 
       
    94     delete iPriorityArrayText;
       
    95     delete iPriorityArray;
       
    96     delete iPriorityTextValues;
       
    97 
       
    98     TRACE_EXIT_POINT;
       
    99     }
       
   100 
       
   101 // -----------------------------------------------------------------------------
       
   102 // CCalenPriorityField::HandleControlStateChangedL
       
   103 // Handle Event type change
       
   104 // -----------------------------------------------------------------------------
       
   105 //
       
   106 void CCalenPriorityField::HandleControlStateChangeL( TInt aControlId )
       
   107     {
       
   108     TRACE_ENTRY_POINT;
       
   109 
       
   110     switch ( aControlId )
       
   111         {
       
   112         case ECalenEditorPriority:
       
   113             {
       
   114             NotifyPriorityChangeL();
       
   115             break;
       
   116             }
       
   117         default:
       
   118             {
       
   119             break;
       
   120             }
       
   121         }
       
   122 
       
   123     TRACE_EXIT_POINT;
       
   124     }
       
   125 
       
   126 // ---------------------------------------------------------
       
   127 // CCalenPriorityField::NotifyPriorityChangeL
       
   128 // This function is used when the top item of each form
       
   129 // ---------------------------------------------------------
       
   130 //
       
   131 void CCalenPriorityField::NotifyPriorityChangeL()
       
   132     {
       
   133     TRACE_ENTRY_POINT;
       
   134 
       
   135     // Nothing to do
       
   136     TRACE_EXIT_POINT;
       
   137     }
       
   138 
       
   139 // -----------------------------------------------------------------------------
       
   140 // CCalenPriorityField::ReadDataFromFormL
       
   141 // Read data from form
       
   142 // -----------------------------------------------------------------------------
       
   143 //
       
   144 void CCalenPriorityField::ReadDataFromFormL( TBool /*aContinueOnError*/ )
       
   145     {
       
   146     TRACE_ENTRY_POINT;
       
   147     
       
   148     TInt priority = iPriorityTextValues->CurrentValueIndex();
       
   149     iUnifiedEditor.Edited().SetPriorityL( static_cast<CCalenEntryUtil::TTodoPriority>( priority+1 ) );
       
   150     
       
   151     TRACE_EXIT_POINT;
       
   152     }
       
   153 
       
   154 // -----------------------------------------------------------------------------
       
   155 // CCalenPriorityField::SetDataToEditorL
       
   156 // Update form data
       
   157 // -----------------------------------------------------------------------------
       
   158 //
       
   159 void CCalenPriorityField::SetDataToEditorL()
       
   160     {
       
   161     TRACE_ENTRY_POINT;    
       
   162 
       
   163     // set priority item
       
   164     TInt priority = iUnifiedEditor.Edited().Priority();
       
   165     iPriorityTextValues->SetCurrentValueIndex( priority-1 );
       
   166     
       
   167     TRACE_EXIT_POINT;
       
   168     }
       
   169 
       
   170 // -----------------------------------------------------------------------------
       
   171 // CCalenPriorityField::InitPriorityFieldLayoutL
       
   172 // Updates fields just before the form is shown.
       
   173 // -----------------------------------------------------------------------------
       
   174 //
       
   175 void CCalenPriorityField::InitPriorityFieldLayoutL()
       
   176     {
       
   177     TRACE_ENTRY_POINT;
       
   178 
       
   179     CAknPopupField* pops =
       
   180         static_cast<CAknPopupField*>( iUnifiedEditor.Control( ECalenEditorPriority ) );
       
   181     pops->SetQueryValueL( iPriorityTextValues );
       
   182     
       
   183     // Set value to priority field in Editor
       
   184     SetDataToEditorL();
       
   185 
       
   186     TRACE_EXIT_POINT;
       
   187     }
       
   188 
       
   189 // -----------------------------------------------------------------------------
       
   190 // CCalenPriorityField::PrepareForFocusTransitionL
       
   191 // Prepare for focus change
       
   192 // -----------------------------------------------------------------------------
       
   193 //
       
   194 void CCalenPriorityField::PrepareForFocusTransitionL( TInt aFocusedId )
       
   195     {
       
   196     TRACE_ENTRY_POINT;
       
   197     
       
   198 
       
   199     switch( aFocusedId )
       
   200         {
       
   201         case ECalenEditorPriority:
       
   202             {
       
   203             TBool continueOnError = EFalse;
       
   204             ReadDataFromFormL( continueOnError );
       
   205             break;
       
   206             }
       
   207         default: 
       
   208             break;
       
   209         }
       
   210     TRACE_EXIT_POINT;
       
   211     }
       
   212 
       
   213 // End of File