contacts_plat/virtual_phonebook_engine_api/inc/CVPbkSortOrder.h
branchRCL_3
changeset 63 f4a778e096c2
child 64 c1e8ba0c2b16
equal deleted inserted replaced
62:5b6f26637ad3 63:f4a778e096c2
       
     1 /*
       
     2 * Copyright (c) 2002-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:  Virtual Phonebook sort order that is needed in view creation.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CVPBKSORTORDER_H
       
    20 #define CVPBKSORTORDER_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>
       
    24 #include <MVPbkFieldType.h>
       
    25 
       
    26 // FORWARD DECLARATIONS
       
    27 class TResourceReader;
       
    28 
       
    29 /**
       
    30  * Virtual Phonebook sort order.
       
    31  * This class can be used to create a sort order, which is needed
       
    32  * when creating Virtual Phonebook views. The sort order determines
       
    33  * how the view is sorted by setting a field type priority list.
       
    34  */
       
    35 class CVPbkSortOrder : 
       
    36         public CBase,
       
    37         public MVPbkFieldTypeList
       
    38     {
       
    39     public:
       
    40         /**
       
    41          * Constructs new sort order from a 
       
    42          * VPBK_FIELD_TYPE_MAPPING_LIST resource.
       
    43          *
       
    44          * @param aReader   Resource reader pointing to a 
       
    45          *                  VPBK_FIELD_TYPE_MAPPING_LIST resource.
       
    46          * @param aMasterFieldTypeList  Master field type list types from 
       
    47          *                              the resource are mapped against.
       
    48          * @exception   KErrNotFound if a matching field type is not 
       
    49          *              found from aFieldTypeList.
       
    50          */
       
    51         IMPORT_C static CVPbkSortOrder* NewL(
       
    52                 TResourceReader& aReader, 
       
    53                 const MVPbkFieldTypeList& aMasterFieldTypeList);
       
    54 
       
    55         /**
       
    56          * Creates a new sort order from an existing one.
       
    57          *
       
    58          * @param aSortOrder    The sort order to duplicate.
       
    59          */
       
    60         IMPORT_C static CVPbkSortOrder* NewL(
       
    61                 const MVPbkFieldTypeList& aSortOrder);
       
    62 
       
    63         /**
       
    64          * Destructor.
       
    65          */
       
    66         ~CVPbkSortOrder();
       
    67 
       
    68     public: // Interface
       
    69         /**
       
    70          * Reserves aSortOrderLength items for the sort order length.
       
    71          * This quarantees that following Set() call will not leave because of
       
    72          * memory allocation failure. If more than aSortOrderLength items are
       
    73          * provided in following Set() calls, rest of the field types are ignored.
       
    74          *
       
    75          * @param aSortOrderLength  Number of field types to reserve space for.
       
    76          * @exception Panics if aSortOrderLength <= 0
       
    77          */
       
    78         IMPORT_C void SetReserveL(TInt aSortOrderLength);
       
    79 
       
    80         /**
       
    81          * Sets new fields types for this sort order from the list.
       
    82          * This will not leave because SetReserveL has to be called in advance to
       
    83          * reserve space for sort order field types.
       
    84          *
       
    85          * @param aSortOrder    Priority ordered list of field types 
       
    86          *                      used as the sort order.
       
    87          * @precond SetReserveL called with a proper sort order length.
       
    88          */
       
    89         IMPORT_C void Set(const MVPbkFieldTypeList& aSortOrder);
       
    90 
       
    91     public: // From MVPbkFieldTypeList
       
    92         TInt FieldTypeCount() const;
       
    93         const MVPbkFieldType& FieldTypeAt(TInt aIndex) const;
       
    94         TBool ContainsSame(const MVPbkFieldType& aFieldType) const;
       
    95         TInt MaxMatchPriority() const;
       
    96         const MVPbkFieldType* FindMatch(const TVPbkFieldVersitProperty& aMatchProperty,
       
    97                 TInt aMatchPriority) const;
       
    98         const MVPbkFieldType* FindMatch(
       
    99                 TVPbkNonVersitFieldType aNonVersitType) const;
       
   100         const MVPbkFieldType* Find(TInt aFieldTypeResId) const;
       
   101 
       
   102     private: // Implementation
       
   103         CVPbkSortOrder();
       
   104         void ConstructL(TResourceReader& aReader, 
       
   105                 const MVPbkFieldTypeList& aMasterFieldTypeList);
       
   106         void ConstructL(const MVPbkFieldTypeList& aSortOrder);
       
   107 
       
   108     private:
       
   109         ///Own: Maximum sort order length
       
   110         TInt iMaxSortOrderLength;
       
   111         ///Ref: Sort order array
       
   112         RPointerArray<MVPbkFieldType> iSortOrder;
       
   113         ///Own: Max match priority
       
   114         TInt iMaxMatchPriority;
       
   115     };
       
   116 
       
   117 #endif // CVPBKSORTORDER_H
       
   118 
       
   119 // End of file