|
1 /* |
|
2 * Copyright (c) 2002 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: |
|
15 * Sub view to a CContactViewBase |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDES |
|
21 #include "CPbkContactFindView.h" |
|
22 #include "CPbkContactFindViewImpl.h" |
|
23 #include "CPbkContactEngine.h" |
|
24 #include <PbkEngUtils.h> |
|
25 |
|
26 /// Unnamed namespace for local definitions |
|
27 namespace { |
|
28 |
|
29 // LOCAL DEBUG CODE |
|
30 #ifdef _DEBUG |
|
31 void Panic(TInt aReason) |
|
32 { |
|
33 _LIT(KPanicText, "CPbkContactFindView"); |
|
34 User::Panic(KPanicText, aReason); |
|
35 } |
|
36 #endif // _DEBUG |
|
37 |
|
38 } // namespace |
|
39 |
|
40 |
|
41 // ================= MEMBER FUNCTIONS ======================= |
|
42 |
|
43 EXPORT_C CPbkContactFindView* CPbkContactFindView::NewL |
|
44 (CPbkContactEngine& aEngine, |
|
45 CContactViewBase& aBaseView, |
|
46 MContactViewObserver& aObserver, |
|
47 MPbkFindPrimitives& aFindPrimitives) |
|
48 { |
|
49 CPbkContactFindView* self = |
|
50 new(ELeave) CPbkContactFindView(aEngine,aBaseView,aFindPrimitives); |
|
51 CleanupStack::PushL(self); |
|
52 self->ConstructL(aObserver); |
|
53 CleanupStack::Pop(self); |
|
54 return self; |
|
55 } |
|
56 |
|
57 EXPORT_C TBool CPbkContactFindView::SetFindTextL |
|
58 (const TDesC& aFindText, |
|
59 const CContactIdArray* aIncludeAlways/*=NULL*/) |
|
60 { |
|
61 return iCurrentState->SetFindTextL(aFindText, aIncludeAlways); |
|
62 } |
|
63 |
|
64 EXPORT_C const TDesC& CPbkContactFindView::FindText() const |
|
65 { |
|
66 return iCurrentState->FindText(); |
|
67 } |
|
68 |
|
69 EXPORT_C TBool CPbkContactFindView::ResetFind() |
|
70 { |
|
71 return iCurrentState->ResetFind(); |
|
72 } |
|
73 |
|
74 EXPORT_C TInt CPbkContactFindView::IndexOfFirstFindMatchL() const |
|
75 { |
|
76 return iCurrentState->IndexOfFirstFindMatchL(); |
|
77 } |
|
78 |
|
79 TContactItemId CPbkContactFindView::AtL(TInt aIndex) const |
|
80 { |
|
81 return iCurrentState->AtL(aIndex); |
|
82 } |
|
83 |
|
84 const CViewContact& CPbkContactFindView::ContactAtL(TInt aIndex) const |
|
85 { |
|
86 return iCurrentState->ContactAtL(aIndex); |
|
87 } |
|
88 |
|
89 TInt CPbkContactFindView::CountL() const |
|
90 { |
|
91 return iCurrentState->CountL(); |
|
92 } |
|
93 |
|
94 TInt CPbkContactFindView::FindL(TContactItemId aId) const |
|
95 { |
|
96 return iCurrentState->FindL(aId); |
|
97 } |
|
98 |
|
99 HBufC* CPbkContactFindView::AllFieldsLC |
|
100 (TInt aIndex,const TDesC& aSeparator) const |
|
101 { |
|
102 return iCurrentState->AllFieldsLC(aIndex,aSeparator); |
|
103 } |
|
104 |
|
105 TContactViewPreferences CPbkContactFindView::ContactViewPreferences() |
|
106 { |
|
107 // No need to delegate to iCurrentState because this call is always |
|
108 // delegated to iBaseView in all states. |
|
109 return iBaseView.ContactViewPreferences(); |
|
110 } |
|
111 |
|
112 const RContactViewSortOrder& CPbkContactFindView::SortOrderL() const |
|
113 { |
|
114 // No need to delegate to iCurrentState because this call is always |
|
115 // delegated to iBaseView in all states. |
|
116 return iBaseView.SortOrderL(); |
|
117 } |
|
118 |
|
119 TAny* CPbkContactFindView::CContactViewBase_Reserved_1 |
|
120 (TFunction aFunction, TAny* aParams) |
|
121 { |
|
122 return iCurrentState->CContactViewBase_Reserved_1(aFunction,aParams); |
|
123 } |
|
124 |
|
125 /** |
|
126 * Handles an event from iBaseView and synchronizes this view's state |
|
127 * accordingly. |
|
128 */ |
|
129 void CPbkContactFindView::HandleContactViewEvent |
|
130 (const CContactViewBase& aView, const TContactViewEvent& aEvent) |
|
131 { |
|
132 __ASSERT_DEBUG(&aView==&iBaseView, Panic(EPanicPreCond_HandleContactViewEvent)); |
|
133 |
|
134 // First handle event self |
|
135 TRAPD(err, HandleContactViewEventL(aEvent)); |
|
136 if (err != KErrNone) |
|
137 { |
|
138 NotifyObservers |
|
139 (TContactViewEvent(TContactViewEvent::ESortError,err,KNullContactId)); |
|
140 } |
|
141 |
|
142 // Let the current state handle the event |
|
143 iCurrentState->HandleContactViewEvent(aView,aEvent); |
|
144 } |
|
145 |
|
146 CPbkContactFindView::CPbkContactFindView |
|
147 (CPbkContactEngine& aEngine, |
|
148 CContactViewBase& aView, |
|
149 MPbkFindPrimitives& aFindPrimitives) : |
|
150 CContactViewBase(aEngine.Database()), |
|
151 iBaseView(aView), |
|
152 iNameFormatter(aEngine.ContactNameFormat()), |
|
153 iFindPrimitives(&aFindPrimitives) |
|
154 { |
|
155 // CBase::operator new(TLeave) will reset other members |
|
156 } |
|
157 |
|
158 void CPbkContactFindView::ConstructL |
|
159 (MContactViewObserver& aObserver) |
|
160 { |
|
161 CContactViewBase::ConstructL(); |
|
162 iCurrentState = MState::CreateInitialStateL(*this); |
|
163 OpenL(aObserver); |
|
164 iBaseView.OpenL(*this); |
|
165 iFindPrimitives->SetContactViewSortOrderL(SortOrderL()); |
|
166 } |
|
167 |
|
168 CPbkContactFindView::~CPbkContactFindView() |
|
169 { |
|
170 iBaseView.Close(*this); |
|
171 delete iCurrentState; |
|
172 } |
|
173 |
|
174 void CPbkContactFindView::HandleContactViewEventL |
|
175 (const TContactViewEvent& aEvent) |
|
176 { |
|
177 if (aEvent.iEventType == TContactViewEvent::ESortOrderChanged) |
|
178 { |
|
179 // Sort order change needs to ne notified to iFindPrimitives |
|
180 const RContactViewSortOrder& sortOrder = SortOrderL(); |
|
181 iFindPrimitives->SetContactViewSortOrderL(sortOrder); |
|
182 } |
|
183 } |
|
184 |
|
185 // End of File |