|
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 members view |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "CGroupMembersView.h" |
|
20 |
|
21 // System includes |
|
22 #include <cntitem.h> |
|
23 #include <cntview.h> |
|
24 |
|
25 // From VPbkEng |
|
26 #include <MVPbkContactViewObserver.h> |
|
27 #include <MVPbkFieldType.h> |
|
28 #include <MVPbkContactStoreProperties.h> |
|
29 #include <VPbkError.h> |
|
30 #include <CVPbkSortOrder.h> |
|
31 #include <CVPbkAsyncCallback.h> |
|
32 #include <CVPbkContactViewDefinition.h> |
|
33 |
|
34 // From VPbkCntModel |
|
35 #include "CContactStore.h" |
|
36 #include "CFieldFactory.h" |
|
37 #include "CContact.h" |
|
38 #include "CFieldTypeList.h" |
|
39 #include "CContactLink.h" |
|
40 #include "CContactView.h" |
|
41 |
|
42 namespace VPbkCntModel { |
|
43 |
|
44 CGroupMembersView::CGroupMembersView( |
|
45 CContactStore& aParentStore, |
|
46 TContactItemId aGroupId ) : |
|
47 CViewBase( aParentStore ), |
|
48 iGroupId( aGroupId ) |
|
49 { |
|
50 } |
|
51 |
|
52 void CGroupMembersView::ConstructL( |
|
53 MVPbkContactViewObserver& aObserver, |
|
54 const MVPbkFieldTypeList& aSortOrder ) |
|
55 { |
|
56 // For showing a group members it needs a contact view that contains |
|
57 // all the contacts |
|
58 // First create a handle to the "All Contacts" remote view. |
|
59 CVPbkContactViewDefinition* viewDefinition = |
|
60 CVPbkContactViewDefinition::NewLC(); |
|
61 viewDefinition->SetUriL( Store().StoreProperties().Uri().UriDes() ); |
|
62 viewDefinition->SetType( EVPbkContactsView ); |
|
63 viewDefinition->SetSharing( EVPbkSharedView ); |
|
64 |
|
65 CViewBase* tempView = CContactView::NewLC( *viewDefinition, *this, Store(), |
|
66 aSortOrder ); |
|
67 CleanupStack::Pop(); |
|
68 iBaseView = tempView; |
|
69 tempView = NULL; |
|
70 |
|
71 // Group members view is a local view built on iBaseView. |
|
72 // aSortOrder will be ignored because the sort order is defined |
|
73 // by iBaseView. |
|
74 viewDefinition->SetSharing( EVPbkLocalView ); |
|
75 CViewBase::ConstructL( *viewDefinition, aObserver, aSortOrder ); |
|
76 CleanupStack::PopAndDestroy( viewDefinition ); |
|
77 } |
|
78 |
|
79 CGroupMembersView* CGroupMembersView::NewLC( |
|
80 CContactStore& aParentStore, |
|
81 TContactItemId aGroupId, |
|
82 MVPbkContactViewObserver& aObserver, |
|
83 const MVPbkFieldTypeList& aSortOrder ) |
|
84 { |
|
85 CGroupMembersView* self = new ( ELeave ) CGroupMembersView( |
|
86 aParentStore, aGroupId ); |
|
87 CleanupStack::PushL( self ); |
|
88 self->ConstructL( aObserver, aSortOrder ); |
|
89 return self; |
|
90 } |
|
91 |
|
92 CGroupMembersView::~CGroupMembersView() |
|
93 { |
|
94 delete iBaseView; |
|
95 } |
|
96 |
|
97 TVPbkContactViewType CGroupMembersView::Type() const |
|
98 { |
|
99 return EVPbkContactsView; |
|
100 } |
|
101 |
|
102 void CGroupMembersView::DoInitializeViewL( |
|
103 const CVPbkContactViewDefinition& /*aViewDefinition*/, |
|
104 RContactViewSortOrder& /*aViewSortOrder*/ ) |
|
105 { |
|
106 iView = CContactGroupView::NewL( |
|
107 Store().NativeDatabase(), |
|
108 iBaseView->NativeView(), |
|
109 *this, |
|
110 iGroupId, |
|
111 CContactGroupView::EShowContactsInGroup ); |
|
112 } |
|
113 |
|
114 void CGroupMembersView::DoTeardownView() |
|
115 { |
|
116 } |
|
117 |
|
118 TBool CGroupMembersView::DoChangeSortOrderL( |
|
119 const CVPbkContactViewDefinition& /*aViewDefinition*/, |
|
120 RContactViewSortOrder& aSortOrder ) |
|
121 { |
|
122 // CContactGroupView doesn't support ChangeSortOrderL, but it's |
|
123 // built on iBaseView so the order must be changed from iBaseView. |
|
124 MVPbkFieldTypeList* newSortOrder = CFieldTypeList::NewLC( |
|
125 aSortOrder, Store().FieldTypeMap() ); |
|
126 iBaseView->ChangeSortOrderL( *newSortOrder ); |
|
127 CleanupStack::PopAndDestroy(); // newSortOrder |
|
128 return ETrue; |
|
129 } |
|
130 |
|
131 } // namespace VPbkCntModel |
|
132 |
|
133 // End of File |