phonebookengines/VirtualPhonebook/VPbkSimStoreImpl/src/CSharedViewArray.cpp
branchRCL_3
changeset 9 0d28c1c5b6dd
parent 0 e686773b3f54
equal deleted inserted replaced
8:5586b4d2ec3e 9:0d28c1c5b6dd
    65 CViewHandle* CSharedViewArray::CreateNewHandleL(
    65 CViewHandle* CSharedViewArray::CreateNewHandleL(
    66         const RVPbkSimFieldTypeArray& aSortOrder,
    66         const RVPbkSimFieldTypeArray& aSortOrder,
    67         TVPbkSimViewConstructionPolicy aConstructionPolicy, 
    67         TVPbkSimViewConstructionPolicy aConstructionPolicy, 
    68         MVPbkSimCntStore& aParentStore, const TDesC& aViewName )
    68         MVPbkSimCntStore& aParentStore, const TDesC& aViewName )
    69     {
    69     {
    70     CSharedViewOwner* viewOwner = FindOwner( aViewName );
    70     CSharedViewOwner* viewOwner = FindOwner( aSortOrder, aConstructionPolicy, aViewName );
    71     
    71     
    72     if ( !viewOwner )
    72     if ( !viewOwner )
    73         {
    73         {
    74         CVPbkSimContactView* sharedView = 
    74         CVPbkSimContactView* sharedView = 
    75                 CVPbkSimContactView::NewLC( aSortOrder, aConstructionPolicy,
    75                 CVPbkSimContactView::NewLC( aSortOrder, aConstructionPolicy,
    88 // CSharedViewArray::RemoveHandle
    88 // CSharedViewArray::RemoveHandle
    89 // -----------------------------------------------------------------------------
    89 // -----------------------------------------------------------------------------
    90 //        
    90 //        
    91 void CSharedViewArray::RemoveHandle( CViewHandle& aHandle )
    91 void CSharedViewArray::RemoveHandle( CViewHandle& aHandle )
    92     {
    92     {
    93     CSharedViewOwner* viewOwner = FindOwner( aHandle.SharedView().Name() );
    93     CSharedViewOwner* viewOwner = NULL;
       
    94     for ( TInt i=0; i<iSharedViews.Count()&&!viewOwner; i++ )
       
    95         {
       
    96        if ( &iSharedViews[i]->View() == &aHandle.SharedView() )
       
    97             {
       
    98             viewOwner = iSharedViews[i];
       
    99             }
       
   100         }
    94     if ( viewOwner )
   101     if ( viewOwner )
    95         {
   102         {
    96         viewOwner->RemoveHandle( aHandle );
   103         viewOwner->RemoveHandle( aHandle );
    97         if ( iDestructionPolicy == EDestroyViewIfNoHandles &&
   104         if ( iDestructionPolicy == EDestroyViewIfNoHandles &&
    98              !viewOwner->HasHandles() )
   105              !viewOwner->HasHandles() )
   106 
   113 
   107 // -----------------------------------------------------------------------------
   114 // -----------------------------------------------------------------------------
   108 // CSharedViewArray::FindOwner
   115 // CSharedViewArray::FindOwner
   109 // -----------------------------------------------------------------------------
   116 // -----------------------------------------------------------------------------
   110 //        
   117 //        
   111 CSharedViewOwner* CSharedViewArray::FindOwner( const TDesC& aViewName )
   118 CSharedViewOwner* CSharedViewArray::FindOwner( 
       
   119        const RVPbkSimFieldTypeArray& aSortOrder,
       
   120        TVPbkSimViewConstructionPolicy aConstructionPolicy,
       
   121        const TDesC& aViewName )
   112     {
   122     {
   113     CSharedViewOwner* viewOwner = NULL;
   123     CSharedViewOwner* viewOwner = NULL;
   114     const TInt count = iSharedViews.Count();
   124     const TInt count = iSharedViews.Count();
   115     for ( TInt i = 0; i < count && !viewOwner; ++i )
   125     for ( TInt i = 0; i < count && !viewOwner; ++i )
   116         {
   126         {
   117         if ( iSharedViews[i]->View().Name().CompareC( aViewName ) == 0 )
   127         if ( iSharedViews[i]->View().IsMatch( aSortOrder, aConstructionPolicy, aViewName ) )
   118             {
   128             {
   119             viewOwner = iSharedViews[i];
   129             viewOwner = iSharedViews[i];
   120             }
   130             }
   121         }
   131         }
   122     return viewOwner;
   132     return viewOwner;