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