emailuis/uicomponents/inc/fstreeiterator.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:  Iterator class for traversing the tree structure.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef T_FSTREEITERATOR_H
       
    20 #define T_FSTREEITERATOR_H
       
    21 
       
    22 
       
    23 #include <e32def.h>
       
    24 
       
    25 #include "fstreelistconstants.h"
       
    26 
       
    27 
       
    28 class CFsTree;
       
    29 class CFsTreeItem;
       
    30 class CFsTreeNode;
       
    31 
       
    32 
       
    33 const TUint KFsTreeIteratorNullFlag = 0x00;
       
    34 
       
    35 /**  Flag indicating that the content of collapsed nodes is not to be
       
    36      included in the iteration sequence. */
       
    37 const TUint KFsTreeIteratorSkipCollapsedFlag = 0x01;
       
    38 
       
    39 const TUint KFsTreeIteratorSkipHiddenFlag = 0x02;
       
    40 
       
    41 
       
    42 NONSHARABLE_CLASS( TFsTreeIterator )
       
    43     {
       
    44 
       
    45     //friend class CFsTree;
       
    46 
       
    47 public:
       
    48 
       
    49     /**
       
    50      * Copy constructor.
       
    51      *
       
    52      * @param aIterator Copied iterator.
       
    53      */
       
    54     
       
    55     TFsTreeIterator( const TFsTreeIterator& aIterator );
       
    56     
       
    57     /**
       
    58      * C++ constructor.
       
    59      *
       
    60      * @param aRoot Root node for the iterated tree (or subtree).
       
    61      */
       
    62     TFsTreeIterator( CFsTreeNode* aRoot, CFsTree* aTree,
       
    63                    CFsTreeItem* aCurrent,
       
    64                    const TUint aFlags = KFsTreeIteratorNullFlag);
       
    65         
       
    66     /**
       
    67      * Assignment operator.
       
    68      *
       
    69      * @param aIterator Iterator.
       
    70      */
       
    71     TFsTreeIterator& operator=( const TFsTreeIterator& aIterator );
       
    72     
       
    73     /**
       
    74      * Returns whether the iterator has next tree item.
       
    75      *
       
    76      * @return @c ETrue, if there is a next item.
       
    77      */
       
    78     TBool HasNext();
       
    79 
       
    80     /**
       
    81      * Returns an identifier to the next tree item. The returned value is @c 
       
    82      * KFsTreeNoneID,
       
    83      * when there is no more items. This changes also the iterator to point
       
    84      * to the returned item.
       
    85      *
       
    86      * @return Identifier of the next tree item.
       
    87      */
       
    88     TFsTreeItemId Next();
       
    89     
       
    90     /**
       
    91      * Returns whether the iterator has previous tree item.
       
    92      *
       
    93      * @return @c ETrue, if there is a previous item.
       
    94      */
       
    95     TBool HasPrevious();
       
    96 
       
    97     /**
       
    98      * Returns an identifier to the previous tree item. The returned value is
       
    99      * @c KFsTreeNoneID, if there is no previous tree item. This changes also 
       
   100      * the iterator to point to the returned item. 
       
   101      *
       
   102      * @return Identifier to the previous tree item.
       
   103      */
       
   104     TFsTreeItemId Previous();
       
   105     
       
   106     /**
       
   107      * Returns an identifier to the current tree item. The returned value is
       
   108      * @c KFsTreeNoneID, if there is no current tree item.
       
   109      *
       
   110      * @return Identifier to the current tree item.
       
   111      */
       
   112     TFsTreeItemId Current() const;
       
   113 
       
   114     /**
       
   115      * Return an identifier to the first item in the sequence.
       
   116      *
       
   117      * @return An identifier of the first item.
       
   118      */
       
   119     TFsTreeItemId First();
       
   120     
       
   121     /**
       
   122      * Returns an identifier to the last item in the sequence.
       
   123      *
       
   124      * @return An identifier of the last item.
       
   125      */ 
       
   126     TFsTreeItemId Last();
       
   127 
       
   128 private:
       
   129 
       
   130     /**
       
   131      * Returns pointer to the next tree item.
       
   132      *
       
   133      * @return Pointer to the next tree item. @c NULL, if the next item is not
       
   134      *      found.
       
   135      */
       
   136     CFsTreeItem* FindNext();
       
   137     
       
   138     /**
       
   139      * Returns pointer ot the previous tree item.
       
   140      *
       
   141      * @return Pointer to the previous tree item. @c NULL, if previous item is
       
   142      *      not found.
       
   143      */
       
   144     CFsTreeItem* FindPrevious();
       
   145 
       
   146 private: // data
       
   147 
       
   148     /**
       
   149      * Tree to iterate in.
       
   150      */
       
   151     CFsTree* iTree;
       
   152 
       
   153     /**
       
   154      * Current item.
       
   155      */
       
   156     CFsTreeItem* iCurrent;
       
   157 
       
   158     /**
       
   159      * Root of the tree.
       
   160      */
       
   161     CFsTreeNode* iRoot;
       
   162 
       
   163     /**
       
   164      * Next item. Contains a pointer to the cached next item.
       
   165      */
       
   166     CFsTreeItem* iNext;
       
   167 
       
   168     /**
       
   169      * Previous item. Contains a pointer to the cached previous item.
       
   170      */
       
   171     CFsTreeItem* iPrevious;
       
   172 
       
   173     /**
       
   174      * Flags for the iterator.
       
   175      */
       
   176     TUint iFlags;
       
   177       
       
   178     };
       
   179  
       
   180 #endif // T_FSTREEITERATOR_H