uifw/AvKon/aknhlist/src/akntreeleaf.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2006, 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:  Implementation for CAknTreeLeaf class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "akntreeleaf.h"
       
    20 
       
    21 const TUint KDefaultLeafFlags = NULL;
       
    22 
       
    23 
       
    24 // ======== MEMBER FUNCTIONS ========
       
    25 
       
    26 // ---------------------------------------------------------------------------
       
    27 // Destructor.
       
    28 // ---------------------------------------------------------------------------
       
    29 //
       
    30 CAknTreeLeaf::~CAknTreeLeaf()
       
    31     {
       
    32     }
       
    33 
       
    34 
       
    35 // ---------------------------------------------------------------------------
       
    36 // From class CAknTreeItem.
       
    37 // ---------------------------------------------------------------------------
       
    38 //
       
    39 CAknTreeLeaf* CAknTreeLeaf::Leaf()
       
    40     {
       
    41     return this;
       
    42     }
       
    43 
       
    44 
       
    45 const CAknTreeLeaf* CAknTreeLeaf::Leaf() const
       
    46     {
       
    47     return this;
       
    48     }
       
    49 
       
    50 
       
    51 // ---------------------------------------------------------------------------
       
    52 // From class CAknTreeItem.
       
    53 // Checks whether the leaf is set marked.
       
    54 // ---------------------------------------------------------------------------
       
    55 //
       
    56 TBool CAknTreeLeaf::IsMarked() const
       
    57     {
       
    58     return ( iFlags & EMarked ) ? ETrue : EFalse;
       
    59     }
       
    60 
       
    61 
       
    62 // ---------------------------------------------------------------------------
       
    63 // From class CAknTreeItem.
       
    64 // Changes the state of the marked flag, if marking change is not disabled.
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 void CAknTreeLeaf::SetMarked( TBool aMarked )
       
    68     {
       
    69     if ( !( iFlags & EMarkingDisabled ) )
       
    70         {
       
    71         if ( aMarked )
       
    72             {
       
    73             iFlags |= EMarked;
       
    74             }
       
    75         else
       
    76             {
       
    77             iFlags &= ~EMarked;
       
    78             }
       
    79         }
       
    80     }
       
    81 
       
    82 
       
    83 // ---------------------------------------------------------------------------
       
    84 // From class CAknTreeItem.
       
    85 // Checks whether marking is enabled.
       
    86 // ---------------------------------------------------------------------------
       
    87 //
       
    88 TBool CAknTreeLeaf::IsMarkable() const
       
    89     {
       
    90     return ( iFlags & EMarkingDisabled ) ? EFalse : ETrue;
       
    91     }
       
    92 
       
    93 
       
    94 // ---------------------------------------------------------------------------
       
    95 // From class CAknTreeItem.
       
    96 // Changes the state of the marking enabled flag.
       
    97 // ---------------------------------------------------------------------------
       
    98 //
       
    99 void CAknTreeLeaf::SetMarkable( TBool aMarkable )
       
   100     {
       
   101     if ( aMarkable )
       
   102         {
       
   103         iFlags &= ~EMarkingDisabled;
       
   104         }
       
   105     else
       
   106         {
       
   107         iFlags |= EMarkingDisabled;
       
   108         }
       
   109     }
       
   110 
       
   111 
       
   112 // ---------------------------------------------------------------------------
       
   113 // From class CAknTreeItem.
       
   114 // Checks whether the leaf is set persistent.
       
   115 // ---------------------------------------------------------------------------
       
   116 //
       
   117 TBool CAknTreeLeaf::IsPersistent() const
       
   118     {
       
   119     return ( iFlags & EPersistent ) ? ETrue : EFalse;
       
   120     }
       
   121 
       
   122 
       
   123 // ---------------------------------------------------------------------------
       
   124 // From class CAknTreeItem.
       
   125 // Changes the state of the persistent flag.
       
   126 // ---------------------------------------------------------------------------
       
   127 //
       
   128 void CAknTreeLeaf::SetPersistent( TBool aPersistent )
       
   129     {
       
   130     if ( aPersistent )
       
   131         {
       
   132         iFlags |= EPersistent;
       
   133         }
       
   134     else
       
   135         {
       
   136         iFlags &= ~EPersistent;
       
   137         }
       
   138     }
       
   139 
       
   140 
       
   141 // ---------------------------------------------------------------------------
       
   142 // From class CAknTreeItem.
       
   143 // Implementation for pure virtual function returns always false, as a leaf
       
   144 // can not have any descendants.
       
   145 // ---------------------------------------------------------------------------
       
   146 //
       
   147 TBool CAknTreeLeaf::HasPersistentDescendants() const
       
   148     {
       
   149     return EFalse;
       
   150     }
       
   151 
       
   152 
       
   153 // ---------------------------------------------------------------------------
       
   154 // From class CAknTreeItem.
       
   155 // Checks whether the item can be removed from the tree when its parent node
       
   156 // is being collapsed.
       
   157 // ---------------------------------------------------------------------------
       
   158 //
       
   159 TBool CAknTreeLeaf::IsRemovableFromCollapsedNode() const
       
   160     {
       
   161     return !( IsMarked() || IsPersistent() );
       
   162     }
       
   163 
       
   164 
       
   165 // ---------------------------------------------------------------------------
       
   166 // Default C++ constructor.
       
   167 // ---------------------------------------------------------------------------
       
   168 //
       
   169 CAknTreeLeaf::CAknTreeLeaf()
       
   170     : iFlags( KDefaultLeafFlags )
       
   171     {
       
   172     }
       
   173 
       
   174 
       
   175 // ---------------------------------------------------------------------------
       
   176 // C++ constructor.
       
   177 // ---------------------------------------------------------------------------
       
   178 //
       
   179 CAknTreeLeaf::CAknTreeLeaf( TUint32 aFlags )
       
   180     : iFlags( aFlags )
       
   181     {
       
   182     }
       
   183 
       
   184 
       
   185 // ---------------------------------------------------------------------------
       
   186 // Returns flags set for the leaf.
       
   187 // ---------------------------------------------------------------------------
       
   188 //
       
   189 TUint32 CAknTreeLeaf::Flags() const
       
   190     {
       
   191     return iFlags;
       
   192     }
       
   193 
       
   194 
       
   195 // ---------------------------------------------------------------------------
       
   196 // Sets flags for the leaf.
       
   197 // ---------------------------------------------------------------------------
       
   198 //
       
   199 void CAknTreeLeaf::SetFlags( TUint32 aFlags )
       
   200     {
       
   201     iFlags = aFlags;
       
   202     }
       
   203