emailuis/uicomponents/inc/fstreenode.h
changeset 0 8466d47a6819
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     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_FSTREENODE_H
       
    20 #define C_FSTREENODE_H
       
    21 
       
    22 #include "fstreeitem.h"
       
    23 
       
    24 class MFsTreeNodeVisualizer;
       
    25 
       
    26 /** Default item index in children array */
       
    27 const TInt KFsTreeChildIndexLast = -1;
       
    28 
       
    29 /**
       
    30  *  CFsTreeNode is a class representing node in tree data structure
       
    31  *
       
    32  *  @code
       
    33  *
       
    34  *  @endcode
       
    35  *
       
    36  *  @lib
       
    37  */
       
    38 NONSHARABLE_CLASS( CFsTreeNode ) : public CFsTreeItem
       
    39     {
       
    40 
       
    41 public: // Construction
       
    42 
       
    43     /**
       
    44      * Two-phased constructor
       
    45      *
       
    46      * @param aParent Pointer to the parent node (cannot be NULL!)
       
    47      * @param aData Reference to the item data instance
       
    48      * @param aVisualizer Reference to the item visualizer instance
       
    49      */
       
    50     IMPORT_C static CFsTreeNode* NewL( CFsTreeNode& aParent, MFsTreeItemData& aData,
       
    51             MFsTreeNodeVisualizer& aVisualizer );
       
    52 
       
    53     /**
       
    54      * C++ destructor
       
    55      */
       
    56     virtual ~CFsTreeNode();
       
    57 
       
    58 public: //node content
       
    59 
       
    60     /**
       
    61      * Returns reference to the node's visualizer
       
    62      *
       
    63      * @return Reference to the node's visualizer
       
    64      */
       
    65     MFsTreeNodeVisualizer* NodeVisualizer() const;
       
    66 
       
    67 public: // Hierarchy management
       
    68 
       
    69     /**
       
    70      * Inserts new child item on given position
       
    71      *
       
    72      * @param aItem  Pointer to the item that is to be inserted.
       
    73      * @param aIndex Index (position) of a child, if omitted item is added as
       
    74      *               last child.
       
    75      *
       
    76      * @return KErrNone, if the insertion is successful, otherwise one of the
       
    77      *         system wide error codes.
       
    78      */
       
    79     TInt InsertChild( CFsTreeItem* aItem,
       
    80             const TInt aIndex = KFsTreeChildIndexLast );
       
    81 
       
    82     /**
       
    83      * Removes a child
       
    84      *
       
    85      * @param aIndex Index of the child to be removed
       
    86      *
       
    87      * @return Address of the removed item. NULL if index is out of range.
       
    88      */
       
    89     CFsTreeItem* RemoveChild( const TInt aIndex );
       
    90 
       
    91     /**
       
    92      * Gets child with given index (position)
       
    93      *
       
    94      * @param aIndex Index of a child
       
    95      *
       
    96      * @return Pointer to the child tree item, NULL if the index is out of
       
    97      *         range.
       
    98      */
       
    99     CFsTreeItem* Child( const TInt aIndex ) const;
       
   100 
       
   101     /**
       
   102      * Gets an index of desired child tree item
       
   103      *
       
   104      * @param aItem Pointer to the child tree item
       
   105      *
       
   106      * @return Index (position) of the child, KErrNotFound is returned if item
       
   107      *         is not not found
       
   108      */
       
   109     TInt Index( const CFsTreeItem* aItem ) const;
       
   110 
       
   111     /**
       
   112      * Returns the number of children for the node
       
   113      *
       
   114      * @return Number of children
       
   115      */
       
   116     TUint CountChildren() const;
       
   117 
       
   118     /**
       
   119      * Returns recursively the number of all children under the node
       
   120      * @return Number of children
       
   121      */
       
   122     TUint CountChildrenRecursively() const;
       
   123 
       
   124     /**
       
   125      * Checks if tree item is a node
       
   126      *
       
   127      * @returns ETrue
       
   128      */
       
   129     virtual TBool IsNode() const;
       
   130 
       
   131     /**
       
   132      * Return pointer to node object. Returned value is @c NULL, if the item
       
   133      * is not derived from @c CFsTreeNode.
       
   134      *
       
   135      * @return @c CFsTreeNode pointer, if the item is a node.
       
   136      */
       
   137     virtual CFsTreeNode* Node();
       
   138 
       
   139 protected: // Construction
       
   140 
       
   141     /**
       
   142      * C++ constructor
       
   143      *
       
   144      * @param aParent Pointer to the parent node
       
   145      * @param aData Reference to the item data instance
       
   146      * @param aVisualizer Reference to the item visualizer instance
       
   147      */
       
   148     CFsTreeNode( CFsTreeNode* aParent, MFsTreeItemData& aData,
       
   149             MFsTreeNodeVisualizer& aVisualizer );
       
   150 
       
   151     /**
       
   152      * Second phase constructor
       
   153      *
       
   154      */
       
   155     void ConstructL( );
       
   156 
       
   157 protected:
       
   158 
       
   159     /**
       
   160      * Array of pointers to node's children
       
   161      */
       
   162     RFsTreeItemList iChildren;
       
   163 
       
   164     };
       
   165 
       
   166 #endif // C_FSTREENODE_H
       
   167