emailcontacts/contactactionmenu/inc/cfsccontactactionmenumodelimpl.h
branchRCL_3
changeset 64 3533d4323edc
parent 0 8466d47a6819
equal deleted inserted replaced
63:d189ee25cf9d 64:3533d4323edc
       
     1 /*
       
     2 * Copyright (c) 2008 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:  Definition of class CFscContactActionMenuModelImpl.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_FSCCONTACTACTIONMENUMODELIMPL_H
       
    20 #define C_FSCCONTACTACTIONMENUMODELIMPL_H
       
    21 
       
    22 #include <e32base.h>
       
    23 //<cmail>
       
    24 #include "mfsccontactactionmenumodel.h"
       
    25 #include "cfsccontactactionmenuitem.h"
       
    26 //</cmail>
       
    27 
       
    28 // FORWARD DECLARATIONS
       
    29 class CFscContactActionService;
       
    30 
       
    31 /**
       
    32  *  Contact Action Menu Model implementation.
       
    33  *
       
    34  *  @since S60 3.1
       
    35  */
       
    36 class CFscContactActionMenuModelImpl : 
       
    37     public CBase,
       
    38     public MFscContactActionMenuModel
       
    39     {
       
    40 
       
    41 public: // Public constructor and destructor
       
    42 
       
    43     /**
       
    44      * Two-phased constructor.
       
    45      *
       
    46      * @param aService Pointer to Contact Action Service
       
    47      * @return New instance of the component  
       
    48      */
       
    49     static CFscContactActionMenuModelImpl* NewL( 
       
    50             CFscContactActionService& aService );
       
    51 
       
    52     /**
       
    53     * Destructor.
       
    54     */
       
    55     virtual ~CFscContactActionMenuModelImpl();
       
    56     
       
    57 public: // Public methods from base class
       
    58 
       
    59     /**
       
    60      * Factory method for creating a new menu item. 
       
    61      *   Item is not added to the menu.
       
    62      *   Ownership of new item is transferred and it is not added to 
       
    63      *   the menu automatically
       
    64      *
       
    65      * @param aMenuText Menu text
       
    66      * @param aIcon Icon. Icon ownership is not transferred
       
    67      * @param aPriority Priority of menu item
       
    68      * @param aStatic Is static
       
    69      *   Static items are ment to be kept in the menu longer than non-static. 
       
    70      *   Normal use case for static items are custom items set by Action Menu's 
       
    71      *   client. These special items are always in the menu so client does not 
       
    72      *   want to set them again after clearing other items from the menu. All CAS 
       
    73      *   based items are non-static and therefore they can easily be removed from 
       
    74      *   the menu without removing static items also. 
       
    75      * @param aUid Item Uid
       
    76      * @return New menu item
       
    77      */
       
    78     CFscContactActionMenuItem* NewMenuItemL( 
       
    79         const TDesC& aMenuText,
       
    80         const CGulIcon* aIcon,
       
    81         TInt aPriority,
       
    82         TBool aStatic,
       
    83         TUid aUid );
       
    84  
       
    85     /**
       
    86      * Add a single item
       
    87      *
       
    88      * @param aItem New item. Ownership of the item is transferred.
       
    89      * @return Index of added item
       
    90      */
       
    91     TInt AddItemL( CFscContactActionMenuItem* aItem );   
       
    92     
       
    93     /**
       
    94      * Add pre queried items to the list
       
    95      *   Previously set CAS items are removed before adding new items.
       
    96      */
       
    97     void AddPreQueriedCasItemsL();
       
    98  
       
    99     /**
       
   100      * Remove a single item from the menu
       
   101      *
       
   102      * @param aIndex Index of the item
       
   103      */
       
   104     void RemoveItemL( TInt aIndex );  
       
   105  
       
   106     /**
       
   107      * Remove all items from the menu
       
   108      *
       
   109      * @param aStaticAlso If ETrue also static items will be removed
       
   110      */
       
   111     void RemoveAll( TBool aStaticAlso = EFalse );  
       
   112  
       
   113     /**
       
   114      * Item getter
       
   115      *
       
   116      * @param aIndex Index of requested item
       
   117      * @return A pointer to requested menu item or NULL if item is not found.
       
   118      */
       
   119     CFscContactActionMenuItem& ItemL( TInt aIndex );  
       
   120  
       
   121     /**
       
   122      * Return number of items in the menu
       
   123      *
       
   124      * @return number of items in the menu
       
   125      */
       
   126     TInt ItemCount();
       
   127  
       
   128     /**
       
   129      * Visible item getter. 
       
   130      *   Visible items are not hidden or dimmed and they have an icon
       
   131      *
       
   132      * @param aIndex Index of requested item
       
   133      * @return A pointer to requested menu item or NULL if item is not found.
       
   134      */
       
   135     CFscContactActionMenuItem& VisibleItemL( TInt aIndex );  
       
   136  
       
   137     /**
       
   138      * Return number of visible items in the menu
       
   139      *   Visible items are not hidden or dimmed and they have an icon
       
   140      *
       
   141      * @return number of items in the menu
       
   142      */
       
   143     TInt VisibleItemCount();
       
   144     
       
   145 public: // public own methods
       
   146 
       
   147     /**
       
   148      * Get Contact Action Service pointer
       
   149      *
       
   150      * @return pointer to Contact Action Service
       
   151      */
       
   152     CFscContactActionService* Service();
       
   153     
       
   154 private: // private contrtuctors
       
   155 
       
   156     /**
       
   157      * Constructor.
       
   158      *
       
   159      * @param aService Pointer to Contact Action Service
       
   160      */
       
   161     CFscContactActionMenuModelImpl( CFscContactActionService& aService );
       
   162 
       
   163     /**
       
   164      * Second phase constructor.
       
   165      */
       
   166     void ConstructL();
       
   167     
       
   168 private: // private methods
       
   169 
       
   170     /**
       
   171      * Method sorts menu items into priority order
       
   172      */
       
   173     void SortMenuItems();
       
   174     
       
   175     /**
       
   176      * Method to check item's visibility
       
   177      *
       
   178      * @param aItem Item to be checked
       
   179      * @return ETrue if item is visible
       
   180      */
       
   181     TBool IsVisible( const CFscContactActionMenuItem& aItem );
       
   182     
       
   183     /**
       
   184      * Sorting methods used by sorting algorithm
       
   185      *
       
   186      * @param aItem1
       
   187      * @param aItem2
       
   188      * @return comparison result
       
   189      */
       
   190     static TInt PriorityCompare( 
       
   191         const CFscContactActionMenuItem& aItem1,
       
   192         const CFscContactActionMenuItem& aItem2 );
       
   193                                    
       
   194 private: // data
       
   195 
       
   196     /**
       
   197      * Instance of Contact Action Service
       
   198      */
       
   199     CFscContactActionService& iCas;
       
   200     
       
   201     /**
       
   202      * Menu item array
       
   203      */
       
   204     RPointerArray<CFscContactActionMenuItem> iMenuItems;
       
   205     
       
   206     };
       
   207 
       
   208 #endif // C_FSCCONTACTACTIONMENUMODELIMPL_H
       
   209