mobilemessaging/unieditor/application/src/UniEditorAddHeaderDialog.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2006,2007 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:   This is used when user wants to change the additional header fields.   
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 //  INCLUDES
       
    21 #include <aknlists.h>
       
    22 #include <UniEditor.rsg>
       
    23 #include "UniEditorAddHeaderDialog.h" 
       
    24 
       
    25 
       
    26 // -----------------------------------------------------------------------------
       
    27 // CUniEditorAddHeaderDialog::CUniEditorAddHeaderDialog
       
    28 // -----------------------------------------------------------------------------
       
    29 //
       
    30 CUniEditorAddHeaderDialog::CUniEditorAddHeaderDialog( 
       
    31                 CListBoxView::CSelectionIndexArray* aSelectionIndexArray ) :   
       
    32     CAknListQueryDialog( aSelectionIndexArray )
       
    33     {
       
    34     }
       
    35 
       
    36 // -----------------------------------------------------------------------------
       
    37 // CUniEditorAddHeaderDialog::~CUniEditorAddHeaderDialog
       
    38 // -----------------------------------------------------------------------------
       
    39 //
       
    40 CUniEditorAddHeaderDialog::~CUniEditorAddHeaderDialog()
       
    41     {
       
    42     }
       
    43 
       
    44 // -----------------------------------------------------------------------------
       
    45 // CUniEditorAddHeaderDialog::OfferKeyEventL
       
    46 // -----------------------------------------------------------------------------
       
    47 //
       
    48 TKeyResponse CUniEditorAddHeaderDialog::OfferKeyEventL( const TKeyEvent& aKeyEvent,
       
    49                                                         TEventCode aType )
       
    50     {
       
    51     if( aType == EEventKeyUp )
       
    52         {
       
    53         UpdateMskL();
       
    54         }
       
    55 
       
    56     return CAknListQueryDialog::OfferKeyEventL( aKeyEvent, aType );
       
    57     }
       
    58 
       
    59 // -----------------------------------------------------------------------------
       
    60 // CUniEditorAddHeaderDialog::OkToExitL
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 TBool CUniEditorAddHeaderDialog::OkToExitL( TInt aButtonId )
       
    64     {
       
    65     if( aButtonId == EAknSoftkeyMark || aButtonId == EAknSoftkeyUnmark)
       
    66         {
       
    67         // It seems something has been changed in Avkon so the next line is not needed anymore
       
    68         // ToggleL(); // But if this does not work in the future, just uncomment this line
       
    69         return EFalse;
       
    70         }
       
    71     else
       
    72         {
       
    73         return CAknListQueryDialog::OkToExitL( aButtonId );
       
    74         }
       
    75     }
       
    76 
       
    77 // -----------------------------------------------------------------------------
       
    78 // CUniEditorAddHeaderDialog::ProcessCommandL
       
    79 // -----------------------------------------------------------------------------
       
    80 //
       
    81 void CUniEditorAddHeaderDialog::ProcessCommandL( TInt /*aCommandId*/ )
       
    82     {
       
    83     }
       
    84 
       
    85 // -----------------------------------------------------------------------------
       
    86 // CUniEditorAddHeaderDialog::UpdateMskL
       
    87 // -----------------------------------------------------------------------------
       
    88 //
       
    89 void CUniEditorAddHeaderDialog::UpdateMskL()
       
    90     {
       
    91     TInt resId = 0;
       
    92     TBool selected = IsCurrentSelected();
       
    93 
       
    94     if( selected )
       
    95         { 
       
    96         // It's unmarkable
       
    97         resId = R_UNI_MSK_ADDHEADERS_BUTTON_UNMARK;
       
    98         }
       
    99     else
       
   100         { 
       
   101         // It's markable
       
   102         resId = R_UNI_MSK_ADDHEADERS_BUTTON_MARK;
       
   103         }
       
   104         
       
   105     CEikButtonGroupContainer& cba = ButtonGroupContainer();
       
   106     const TInt KMskPosition = 3;
       
   107     cba.SetCommandL( KMskPosition, resId );
       
   108     cba.DrawDeferred();
       
   109     }
       
   110 
       
   111 // -----------------------------------------------------------------------------
       
   112 // CUniEditorAddHeaderDialog::ToggleL
       
   113 // -----------------------------------------------------------------------------
       
   114 //
       
   115 void CUniEditorAddHeaderDialog::ToggleL()
       
   116     {
       
   117     TInt currentItem = View()->CurrentItemIndex();
       
   118     CEikListBox* listBox = ListBox();
       
   119     
       
   120     if( IsCurrentSelected() )
       
   121         {
       
   122         View()->DeselectItem( currentItem);
       
   123         }
       
   124     else
       
   125         {
       
   126         View()->SelectItemL( currentItem);    
       
   127         }
       
   128         
       
   129     listBox->HandleItemAdditionL();
       
   130     }
       
   131 
       
   132 // -----------------------------------------------------------------------------
       
   133 // CUniEditorAddHeaderDialog::IsCurrentSelected
       
   134 // -----------------------------------------------------------------------------
       
   135 //
       
   136 TBool CUniEditorAddHeaderDialog::IsCurrentSelected()
       
   137     {
       
   138     return View()->ItemIsSelected( View()->CurrentItemIndex() );
       
   139     }
       
   140 
       
   141 // -----------------------------------------------------------------------------
       
   142 // CUniEditorAddHeaderDialog::View
       
   143 // -----------------------------------------------------------------------------
       
   144 //
       
   145 CListBoxView* CUniEditorAddHeaderDialog::View()
       
   146     {
       
   147     return ListBox()->View();
       
   148     }
       
   149 
       
   150 // End of File