phonebookengines/VirtualPhonebook/VPbkCntModel/src/CGroupView.cpp
branchRCL_3
changeset 20 f4a778e096c2
parent 0 e686773b3f54
equal deleted inserted replaced
19:5b6f26637ad3 20:f4a778e096c2
       
     1 /*
       
     2 * Copyright (c) 2004-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:  Virtual Phonebook group view
       
    15 *
       
    16 */
       
    17  
       
    18 
       
    19 #include "CGroupView.h"
       
    20 
       
    21 // System includes
       
    22 #include <cntitem.h>
       
    23 
       
    24 // From VPbkEng
       
    25 #include <MVPbkContactViewObserver.h>
       
    26 #include <MVPbkFieldType.h>
       
    27 #include <VPbkError.h>
       
    28 #include <CVPbkSortOrder.h>
       
    29 #include <CVPbkAsyncCallback.h>
       
    30 #include "NamedRemoteViewViewDefinitionStoreUtility.h"
       
    31 
       
    32 // From VPbkCntModel
       
    33 #include "VPbkCntModelRemoteViewPreferences.h"
       
    34 #include "CContactStore.h"
       
    35 #include "CFieldFactory.h"
       
    36 #include "CContact.h"
       
    37 #include "CFieldTypeList.h"
       
    38 #include "CContactLink.h"
       
    39 
       
    40 namespace VPbkCntModel {
       
    41 
       
    42 inline CGroupView::CGroupView(
       
    43         CContactStore& aParentStore) :
       
    44     CViewBase(aParentStore)
       
    45     {
       
    46     }
       
    47 
       
    48 void CGroupView::ConstructL(
       
    49         const CVPbkContactViewDefinition& aViewDefinition,
       
    50         MVPbkContactViewObserver& aObserver, 
       
    51         const MVPbkFieldTypeList& aSortOrder)
       
    52     {
       
    53     CViewBase::ConstructL(aViewDefinition, aObserver, aSortOrder);
       
    54     }
       
    55 
       
    56 CGroupView* CGroupView::NewLC(
       
    57         const CVPbkContactViewDefinition& aViewDefinition,
       
    58         MVPbkContactViewObserver& aObserver,
       
    59         CContactStore& aParentStore, 
       
    60         const MVPbkFieldTypeList& aSortOrder)
       
    61     {
       
    62     CGroupView* self = new(ELeave) CGroupView(aParentStore);
       
    63     CleanupStack::PushL(self);
       
    64     self->ConstructL(aViewDefinition, aObserver, aSortOrder);
       
    65     return self;
       
    66     }
       
    67 
       
    68 CGroupView::~CGroupView()
       
    69     {
       
    70     }
       
    71 
       
    72 TVPbkContactViewType CGroupView::Type() const
       
    73     {
       
    74     return EVPbkGroupsView;
       
    75     }
       
    76 
       
    77 void CGroupView::DoInitializeViewL(
       
    78         const CVPbkContactViewDefinition& aViewDefinition,
       
    79         RContactViewSortOrder& aViewSortOrder)
       
    80     {
       
    81     if ( RemoteViewDefinition( aViewDefinition ) )
       
    82         {
       
    83         iRemoteView = CContactNamedRemoteView::NewL( 
       
    84                 *this, RemoteViewName( aViewDefinition ), 
       
    85                 Store().NativeDatabase(), aViewSortOrder, 
       
    86                 KVPbkDefaultGroupsViewPrefs );
       
    87                 
       
    88         iView = iRemoteView;
       
    89         }
       
    90     else
       
    91         {
       
    92         iView = CContactLocalView::NewL( *this, Store().NativeDatabase(), 
       
    93                 aViewSortOrder, KVPbkDefaultGroupsViewPrefs );
       
    94         }
       
    95     }
       
    96 
       
    97 void CGroupView::DoTeardownView()
       
    98     {
       
    99     }
       
   100     
       
   101 TBool CGroupView::DoChangeSortOrderL(
       
   102         const CVPbkContactViewDefinition& aViewDefinition,
       
   103         RContactViewSortOrder& aSortOrder)
       
   104     {
       
   105     TBool canBeChanged = ETrue;
       
   106     if ( iRemoteView )
       
   107         {
       
   108         if ( RemoteViewName( aViewDefinition ).Compare( 
       
   109                 KVPbkAllGroupsViewName ) == 0 )
       
   110             {
       
   111             // Set Contacts Model default view setting only if client
       
   112             // is using KVPbkAllGroupsViewName shared view.
       
   113             NamedRemoteViewViewDefinitionStoreUtility::
       
   114                 SetNamedRemoteViewViewDefinitionL(
       
   115                     KVPbkAllGroupsViewName, aSortOrder, 
       
   116                     KVPbkDefaultGroupsViewPrefs);
       
   117             }
       
   118         iRemoteView->ChangeSortOrderL( aSortOrder );
       
   119         }
       
   120     else
       
   121         {
       
   122         // CContactLocalView doesn't support ChangeSortOrderL
       
   123         canBeChanged = EFalse;
       
   124         }
       
   125         
       
   126     return canBeChanged;
       
   127     }
       
   128 
       
   129 } // namespace VPbkCntModel
       
   130 
       
   131 // End of File