iaupdate/IAD/ui/src/iaupdatedeputils.cpp
changeset 0 ba25891c3a9e
child 44 329d304c1aa1
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2009 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:   This module contains the implementation of IAUpdateDepUtils class 
       
    15 *                member functions.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDES
       
    22 #include "iaupdatedeputils.h"
       
    23 #include "iaupdatebasenode.h"
       
    24 #include "iaupdateanynode.h"
       
    25 #include "iaupdatenode.h"
       
    26 
       
    27 
       
    28 // ---------------------------------------------------------------------------
       
    29 // IAUpdateDepUtils::GetDependenciesL
       
    30 // 
       
    31 // ---------------------------------------------------------------------------
       
    32 //
       
    33 void IAUpdateDepUtils::GetDependenciesL( const MIAUpdateNode& aNode,
       
    34                                          const RPointerArray<MIAUpdateAnyNode>& aAllNodes,  
       
    35                                          RPointerArray<MIAUpdateNode>& aDependencyNodes ) 
       
    36     {
       
    37     RPointerArray<MIAUpdateNode> dependencies;
       
    38     CleanupClosePushL( dependencies );
       
    39     // Include hidden nodes here. So, we can check the whole hierarchy
       
    40     // of dependencies. Maybe there are some hidden nodes in the middle of the
       
    41     // hierarchy. So, this way we can be sure that visible dependencies after
       
    42     // those hidden nodes are also counted here.
       
    43     // Notice, ownership of the nodes is not transferred here.
       
    44     aNode.GetDependenciesL( dependencies, ETrue );
       
    45     for ( TInt i = 0; i < dependencies.Count(); ++i )
       
    46         {
       
    47         MIAUpdateNode* dependencyNode( dependencies[ i ] );
       
    48         if ( dependencyNode != &aNode ) //skip if dependency is node itself
       
    49             {
       
    50             TInt nodeInd = aAllNodes.Find( dependencyNode );
       
    51             if ( nodeInd >= 0 ) // be sure that dependency is shown in UI
       
    52                 {
       
    53                 if ( !aAllNodes[ nodeInd ]->Base().IsSelected() )  
       
    54                     { // dependency is umarked 
       
    55                     if ( aDependencyNodes.Find( dependencyNode ) == KErrNotFound )//skip if dependency already in a list
       
    56                         {
       
    57                         aDependencyNodes.AppendL( dependencyNode );
       
    58                         GetDependenciesL( *dependencyNode, aAllNodes, aDependencyNodes );
       
    59                         }
       
    60                     }
       
    61                 }
       
    62             else if ( dependencyNode->Base().Hidden() )
       
    63                 {
       
    64                 // Hidden nodes are not included into the list but
       
    65                 // still their dependencies need to be checked.                
       
    66                 // Notice, that some nodes in the middle of the 
       
    67                 // dependency chain may be hidden. But, some of 
       
    68                 // their dependencies may still be visible. So, 
       
    69                 // those dependencies should be shown in the UI
       
    70                 // in a normal way.
       
    71                 GetDependenciesL( *dependencyNode, aAllNodes, aDependencyNodes );
       
    72                 }
       
    73             }
       
    74         }
       
    75     CleanupStack::PopAndDestroy( &dependencies );
       
    76     }
       
    77 
       
    78 // ---------------------------------------------------------------------------
       
    79 // IAUpdateDepUtils::GetDependantsL
       
    80 // 
       
    81 // ---------------------------------------------------------------------------
       
    82 //    
       
    83 void IAUpdateDepUtils::GetDependantsL( const MIAUpdateNode& aNode, 
       
    84                                        const RPointerArray<MIAUpdateAnyNode>& aAllNodes,  
       
    85                                        RPointerArray<MIAUpdateNode>& aDependantNodes ) 
       
    86     {
       
    87     RPointerArray<MIAUpdateNode> dependants;
       
    88     CleanupClosePushL( dependants );
       
    89     // Include hidden nodes here. So, we can check the whole hierarchy
       
    90     // of dependants. Maybe there are some hidden nodes in the middle of the
       
    91     // hierarchy. So, this way we can be sure that visible dependants after
       
    92     // those hidden nodes are also counted here.
       
    93     // Notice, ownership of the nodes is not transferred here.
       
    94     aNode.GetDependantsL( dependants, ETrue );
       
    95     for ( TInt i = 0; i < dependants.Count(); ++i )
       
    96         {
       
    97         MIAUpdateNode* dependantNode = dependants[ i ];
       
    98         if ( dependantNode != &aNode ) //skip if dependant is node itself
       
    99             {
       
   100             TInt nodeInd = aAllNodes.Find( dependantNode );
       
   101             if ( nodeInd >= 0 ) // be sure that dependant is shown in UI
       
   102                 {
       
   103                 if ( aAllNodes[ nodeInd ]->Base().IsSelected() )
       
   104                     { // dependant is marked 
       
   105                     if ( aDependantNodes.Find( dependantNode ) == KErrNotFound )//skip if dependant already in a list
       
   106                         {
       
   107                         aDependantNodes.AppendL( dependantNode );
       
   108                         GetDependantsL( *dependantNode, aAllNodes, aDependantNodes );
       
   109                         }
       
   110                     }
       
   111                 }
       
   112             else if ( dependantNode->Base().Hidden() )
       
   113                 {
       
   114                 // Hidden nodes are not included into the list but
       
   115                 // still their dependants need to be checked.                
       
   116                 // Notice, that some nodes in the middle of the 
       
   117                 // dependant chain may be hidden. But, some of 
       
   118                 // their dependants may still be visible. So, 
       
   119                 // those dependants should be shown in the UI
       
   120                 // in a normal way.
       
   121                 GetDependantsL( *dependantNode, aAllNodes, aDependantNodes );
       
   122                 }
       
   123             }
       
   124         }
       
   125     CleanupStack::PopAndDestroy( &dependants );
       
   126     }