emailuis/uicomponents/inc/fstreeitem.h
branchRCL_3
changeset 25 3533d4323edc
parent 0 8466d47a6819
equal deleted inserted replaced
24:d189ee25cf9d 25:3533d4323edc
       
     1 /*
       
     2 * Copyright (c) 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:  Data item classes used by tree list component
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_FSTREEITEM_H
       
    20 #define C_FSTREEITEM_H
       
    21 
       
    22 #include <e32cmn.h>
       
    23 #include <e32base.h>
       
    24 
       
    25 #include "fstreelistconstants.h"
       
    26 
       
    27 class CFsTreeItem;
       
    28 
       
    29 /** Array of pointers to the tree items */
       
    30 typedef RPointerArray<CFsTreeItem> RFsTreeItemList;
       
    31 
       
    32 class CFsTreeNode;
       
    33 class MFsTreeItemData;
       
    34 class MFsTreeItemVisualizer;
       
    35 
       
    36 
       
    37 /**
       
    38  *  CFsTreeItem is a class representing leaf in tree data structure
       
    39  *
       
    40  *  @code
       
    41  *
       
    42  *  @endcode
       
    43  *
       
    44  *  @lib
       
    45  */
       
    46 NONSHARABLE_CLASS( CFsTreeItem ) : public CBase
       
    47     {
       
    48 public: // Construction
       
    49 
       
    50     /**
       
    51      * Two-phased constructor
       
    52      *
       
    53      * @param aParent Reference to the parent node (cannot be NULL!)
       
    54      * @param aData Reference to the item data instance
       
    55      * @param aVisualizer Reference to the item visualizer instance
       
    56      */
       
    57     IMPORT_C static CFsTreeItem* NewL( CFsTreeNode& aParent, MFsTreeItemData& aData,
       
    58             MFsTreeItemVisualizer& aVisualizer);
       
    59 
       
    60     /**
       
    61      * Two-phased constructor
       
    62      *
       
    63      * @param aParent Reference to the parent node (cannot be NULL!)
       
    64      * @param aData Reference to the item data class
       
    65      * @param aVisualizer Reference to the item visualizer class
       
    66      */
       
    67     IMPORT_C static CFsTreeItem* NewLC( CFsTreeNode& aParent, MFsTreeItemData& aData,
       
    68             MFsTreeItemVisualizer& aVisualizer);
       
    69 
       
    70 public: // Item content
       
    71 
       
    72     /**
       
    73      * Gets reference to the item visualizer
       
    74      *
       
    75      * @return Reference to the item visualizer
       
    76      */
       
    77     MFsTreeItemVisualizer* ItemVisualizer() const;
       
    78 
       
    79     /**
       
    80      * Gets refrence to the item data
       
    81      *
       
    82      * @return Reference to the item data
       
    83      */
       
    84     MFsTreeItemData& ItemData() const;
       
    85 
       
    86     /**
       
    87      * Sets visualizer for the item
       
    88      *
       
    89      * @param aVisualizer Reference to the item visualizer
       
    90      */
       
    91     void SetItemVisualizer( MFsTreeItemVisualizer& aVisualizer );
       
    92 
       
    93     /**
       
    94      * Sets data for the item
       
    95      *
       
    96      * @param aData Reference to the item data
       
    97      */
       
    98     void SetItemData( MFsTreeItemData& aData );
       
    99 
       
   100 
       
   101     /**
       
   102      * C++ destructor
       
   103      */
       
   104     ~CFsTreeItem();
       
   105 
       
   106 public: // Hierchy management
       
   107 
       
   108     /**
       
   109      * Checks if tree item is a node
       
   110      *
       
   111      * @return EFalse
       
   112      */
       
   113     virtual TBool IsNode() const;
       
   114 
       
   115     /**
       
   116      * Return pointer to node object. Returned value is @c NULL, if the item
       
   117      * is not derived from @c CFsTreeNode.
       
   118      *
       
   119      * @return @c CFsTreeNode pointer, if the item is a node.
       
   120      */
       
   121     virtual CFsTreeNode* Node();
       
   122 
       
   123     /**
       
   124      * Gets the parent node of the item
       
   125      *
       
   126      * @return Pointer to the parent node of the item
       
   127      */
       
   128     CFsTreeNode* Parent() const;
       
   129 
       
   130     /**
       
   131      * Sets the parent node of the item
       
   132      *
       
   133      * @param aParent Pointer to the parent node
       
   134      */
       
   135     void SetParent( CFsTreeNode& aParent );
       
   136 
       
   137     /**
       
   138      * Returns the level of the item in the tree. The returned value matches
       
   139      * the number of parents in the items parent chain.
       
   140      *
       
   141      * @return The level of the item in the tree.
       
   142      */
       
   143     TUint Level() const;
       
   144 
       
   145     /**
       
   146      * Returns recursively the number of all children under the node
       
   147      * (NOTE: this method is overriden in class CFsTreeNode)
       
   148      * @return Always 0
       
   149      */
       
   150     virtual TUint CountChildrenRecursively() const;
       
   151 
       
   152 protected: //Construction
       
   153 
       
   154     /**
       
   155      * C++ constructor
       
   156      */
       
   157     CFsTreeItem( CFsTreeNode* aParent, MFsTreeItemData& aData,
       
   158             MFsTreeItemVisualizer& aVisualizer );
       
   159 
       
   160     /**
       
   161      * Second phase constructor
       
   162      *
       
   163      */
       
   164     void ConstructL( );
       
   165 
       
   166 protected: //Data
       
   167 
       
   168     /**
       
   169      * Item's parent node
       
   170      * Not own
       
   171      */
       
   172     CFsTreeNode* iParent;
       
   173 
       
   174     /**
       
   175      * Item's data
       
   176      * Not own
       
   177      */
       
   178     MFsTreeItemData* iData;
       
   179 
       
   180     /**
       
   181      * Item's visualizer
       
   182      * Not own
       
   183      */
       
   184     MFsTreeItemVisualizer* iVisualizer;
       
   185 
       
   186     };
       
   187 
       
   188 #endif // C_FSTREEITEM_H
       
   189