|
1 /* |
|
2 * Copyright (c) 2005-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: Phonebook 2 fetch dialog group page. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "CPbk2FetchDlgGroupPage.h" |
|
20 |
|
21 // Phonebook 2 |
|
22 #include "CPbk2FetchDlgGroupMarker.h" |
|
23 #include <CPbk2NamesListControl.h> |
|
24 #include <MPbk2FetchDlg.h> |
|
25 #include <MPbk2FetchDlgObserver.h> |
|
26 #include <CPbk2StoreConfiguration.h> |
|
27 #include <MPbk2Command.h> |
|
28 #include <Pbk2UIControls.hrh> |
|
29 #include <Pbk2UIControls.rsg> |
|
30 #include <CPbk2ViewState.h> |
|
31 |
|
32 // Virtual Phonebook |
|
33 #include <MVPbkContactViewBase.h> |
|
34 #include <CVPbkContactLinkArray.h> |
|
35 #include <MVPbkContactLink.h> |
|
36 #include <MVPbkBaseContact.h> |
|
37 #include <CVPbkContactManager.h> |
|
38 #include <CVPbkContactStoreUriArray.h> |
|
39 #include <MVPbkContactStore.h> |
|
40 #include <MVPbkContactStoreList.h> |
|
41 #include <MVPbkContactStoreProperties.h> |
|
42 #include <TVPbkContactStoreUriPtr.h> |
|
43 |
|
44 // System includes |
|
45 #include <calslbs.h> |
|
46 #include <aknlayout.cdl.h> |
|
47 #include <StringLoader.h> |
|
48 |
|
49 /// Unnamed namespace for local definitions |
|
50 namespace { |
|
51 |
|
52 // LOCAL CONSTANTS AND MACROS |
|
53 #ifdef _DEBUG |
|
54 enum TPanicCode |
|
55 { |
|
56 EPanicPreCond_HandleContactViewListControlEventL = 1 |
|
57 }; |
|
58 |
|
59 void Panic(TPanicCode aReason) |
|
60 { |
|
61 _LIT(KPanicText, "CPbk2FetchDlgGroupPage"); |
|
62 User::Panic(KPanicText, aReason); |
|
63 } |
|
64 #endif // _DEBUG |
|
65 |
|
66 } /// namespace |
|
67 |
|
68 |
|
69 // -------------------------------------------------------------------------- |
|
70 // CPbk2FetchDlgGroupPage::CPbk2FetchDlgGroupPage |
|
71 // -------------------------------------------------------------------------- |
|
72 // |
|
73 CPbk2FetchDlgGroupPage::CPbk2FetchDlgGroupPage |
|
74 ( MPbk2FetchDlg& aParentDlg, TInt aControlId, |
|
75 CVPbkContactManager& aContactManager ) : |
|
76 iParentDlg( aParentDlg ), |
|
77 iContactManager( aContactManager ), |
|
78 iControlId( aControlId ), |
|
79 iIsReady( EFalse ) |
|
80 { |
|
81 } |
|
82 |
|
83 // -------------------------------------------------------------------------- |
|
84 // CPbk2FetchDlgGroupPage::~CPbk2FetchDlgGroupPage |
|
85 // -------------------------------------------------------------------------- |
|
86 // |
|
87 CPbk2FetchDlgGroupPage::~CPbk2FetchDlgGroupPage() |
|
88 { |
|
89 delete iMarker; |
|
90 |
|
91 if (iContactView) |
|
92 { |
|
93 iContactView->RemoveObserver( *iControl ); |
|
94 } |
|
95 } |
|
96 |
|
97 // -------------------------------------------------------------------------- |
|
98 // CPbk2FetchDlgGroupPage::ConstructL |
|
99 // -------------------------------------------------------------------------- |
|
100 // |
|
101 inline void CPbk2FetchDlgGroupPage::ConstructL() |
|
102 { |
|
103 iControl = static_cast<CPbk2NamesListControl*> |
|
104 ( iParentDlg.FetchDlgControl( iControlId ) ); |
|
105 iContactView = &iParentDlg.FetchDlgViewL( iControlId ); |
|
106 |
|
107 iControl->AddObserverL( *this ); |
|
108 iContactView->AddObserverL( *iControl ); |
|
109 |
|
110 AknLayoutUtils::LayoutControl |
|
111 ( iControl, iParentDlg.FetchDlgClientRect(), |
|
112 AknLayout::list_gen_pane( 0 ) ); |
|
113 } |
|
114 |
|
115 // -------------------------------------------------------------------------- |
|
116 // CPbk2FetchDlgGroupPage::NewL |
|
117 // -------------------------------------------------------------------------- |
|
118 // |
|
119 CPbk2FetchDlgGroupPage* CPbk2FetchDlgGroupPage::NewL |
|
120 ( MPbk2FetchDlg& aParentDlg, TInt aControlId, |
|
121 CVPbkContactManager& aContactManager ) |
|
122 { |
|
123 CPbk2FetchDlgGroupPage* self = new ( ELeave ) CPbk2FetchDlgGroupPage |
|
124 ( aParentDlg, aControlId, aContactManager ); |
|
125 CleanupStack::PushL( self ); |
|
126 self->ConstructL(); |
|
127 CleanupStack::Pop( self ); |
|
128 return self; |
|
129 } |
|
130 |
|
131 // -------------------------------------------------------------------------- |
|
132 // CPbk2FetchDlgGroupPage::FetchDlgPageId |
|
133 // -------------------------------------------------------------------------- |
|
134 // |
|
135 TInt CPbk2FetchDlgGroupPage::FetchDlgPageId() const |
|
136 { |
|
137 return iControlId; |
|
138 } |
|
139 |
|
140 // -------------------------------------------------------------------------- |
|
141 // CPbk2FetchDlgGroupPage::ActivateFetchDlgPageL |
|
142 // -------------------------------------------------------------------------- |
|
143 // |
|
144 void CPbk2FetchDlgGroupPage::ActivateFetchDlgPageL() |
|
145 { |
|
146 } |
|
147 |
|
148 // -------------------------------------------------------------------------- |
|
149 // CPbk2FetchDlgGroupPage::DeactivateFetchDlgPage |
|
150 // -------------------------------------------------------------------------- |
|
151 // |
|
152 void CPbk2FetchDlgGroupPage::DeactivateFetchDlgPage() |
|
153 { |
|
154 } |
|
155 |
|
156 // -------------------------------------------------------------------------- |
|
157 // CPbk2FetchDlgGroupPage::FocusedContactL |
|
158 // -------------------------------------------------------------------------- |
|
159 // |
|
160 const MVPbkBaseContact* CPbk2FetchDlgGroupPage::FocusedContactL() const |
|
161 { |
|
162 return iControl->FocusedContactL(); |
|
163 } |
|
164 |
|
165 // -------------------------------------------------------------------------- |
|
166 // CPbk2FetchDlgGroupPage::Control |
|
167 // -------------------------------------------------------------------------- |
|
168 // |
|
169 MPbk2ContactUiControl& CPbk2FetchDlgGroupPage::Control() const |
|
170 { |
|
171 return *iControl; |
|
172 } |
|
173 |
|
174 // -------------------------------------------------------------------------- |
|
175 // CPbk2FetchDlgGroupPage::View |
|
176 // -------------------------------------------------------------------------- |
|
177 // |
|
178 MVPbkContactViewBase& CPbk2FetchDlgGroupPage::View() const |
|
179 { |
|
180 return iControl->View(); |
|
181 } |
|
182 |
|
183 // -------------------------------------------------------------------------- |
|
184 // CPbk2FetchDlgGroupPage::SetViewL |
|
185 // -------------------------------------------------------------------------- |
|
186 // |
|
187 void CPbk2FetchDlgGroupPage::SetViewL( MVPbkContactViewBase& aView ) |
|
188 { |
|
189 iControl->SetViewL( aView ); |
|
190 } |
|
191 |
|
192 // -------------------------------------------------------------------------- |
|
193 // CPbk2FetchDlgGroupPage::DlgPageReady |
|
194 // -------------------------------------------------------------------------- |
|
195 // |
|
196 TBool CPbk2FetchDlgGroupPage::DlgPageReady() const |
|
197 { |
|
198 return iIsReady; |
|
199 } |
|
200 |
|
201 // -------------------------------------------------------------------------- |
|
202 // CPbk2FetchDlgGroupPage::DlgPageEmpty |
|
203 // -------------------------------------------------------------------------- |
|
204 // |
|
205 TBool CPbk2FetchDlgGroupPage::DlgPageEmpty() const |
|
206 { |
|
207 return ( iControl->NumberOfContacts() == 0 ); |
|
208 } |
|
209 |
|
210 // -------------------------------------------------------------------------- |
|
211 // CPbk2FetchDlgGroupPage::SelectContactL |
|
212 // -------------------------------------------------------------------------- |
|
213 // |
|
214 void CPbk2FetchDlgGroupPage::SelectContactL |
|
215 ( const MVPbkContactLink& /*aContactLink*/, TBool /*aSelect*/ ) |
|
216 { |
|
217 if ( !iMarker ) |
|
218 { |
|
219 iMarker = CPbk2FetchDlgGroupMarker::NewL |
|
220 ( iContactManager, iParentDlg.FetchDlgSelection(), |
|
221 *iContactView, *iControl ); |
|
222 } |
|
223 |
|
224 iMarker->Cancel(); |
|
225 iMarker->MarkSelectedGroupsL(); |
|
226 } |
|
227 |
|
228 // -------------------------------------------------------------------------- |
|
229 // CPbk2FetchDlgGroupPage::HandleResourceChange |
|
230 // -------------------------------------------------------------------------- |
|
231 // |
|
232 void CPbk2FetchDlgGroupPage::HandleResourceChange( TInt aType ) |
|
233 { |
|
234 if ( aType == KEikDynamicLayoutVariantSwitch ) |
|
235 { |
|
236 AknLayoutUtils::LayoutControl |
|
237 ( iControl, iParentDlg.FetchDlgClientRect(), |
|
238 AKN_LAYOUT_WINDOW_list_gen_pane( 0 ) ); |
|
239 } |
|
240 } |
|
241 |
|
242 // -------------------------------------------------------------------------- |
|
243 // CPbk2FetchDlgGroupPage::HandleControlEventL |
|
244 // -------------------------------------------------------------------------- |
|
245 // |
|
246 void CPbk2FetchDlgGroupPage::HandleControlEventL |
|
247 ( MPbk2ContactUiControl& aControl, const TPbk2ControlEvent& aEvent ) |
|
248 { |
|
249 __ASSERT_DEBUG(&aControl==iControl, |
|
250 Panic(EPanicPreCond_HandleContactViewListControlEventL)); |
|
251 |
|
252 switch ( aEvent.iEventType ) |
|
253 { |
|
254 case TPbk2ControlEvent::EReady: |
|
255 { |
|
256 SetPagesReadyStateL( ETrue ); |
|
257 iControl->ShowThumbnail(); |
|
258 break; |
|
259 } |
|
260 |
|
261 case TPbk2ControlEvent::EUnavailable: |
|
262 { |
|
263 SetPagesReadyStateL( EFalse ); |
|
264 break; |
|
265 } |
|
266 |
|
267 case TPbk2ControlEvent::EContactSelected: |
|
268 { |
|
269 HandleContactSelectionL |
|
270 ( aControl.FocusedContactL(), aEvent.iInt, ETrue ); |
|
271 break; |
|
272 } |
|
273 |
|
274 case TPbk2ControlEvent::EContactUnselected: |
|
275 { |
|
276 HandleContactSelectionL |
|
277 ( aControl.FocusedContactL(), aEvent.iInt, EFalse ); |
|
278 break; |
|
279 } |
|
280 |
|
281 case TPbk2ControlEvent::EItemAdded: |
|
282 { |
|
283 // Notify parent dialog that this page's contents has changed |
|
284 iParentDlg.FetchDlgPageChangedL( *this ); |
|
285 break; |
|
286 } |
|
287 |
|
288 case TPbk2ControlEvent::EItemRemoved: |
|
289 { |
|
290 // Notify parent dialog that this page's contents has changed |
|
291 iParentDlg.FetchDlgPageChangedL( *this ); |
|
292 break; |
|
293 } |
|
294 |
|
295 case TPbk2ControlEvent::EContactSetChanged: |
|
296 { |
|
297 // Notify parent dialog that this page's contents has changed |
|
298 iParentDlg.FetchDlgPageChangedL( *this ); |
|
299 break; |
|
300 } |
|
301 |
|
302 case TPbk2ControlEvent::EControlStateChanged: |
|
303 { |
|
304 UpdateListEmptyTextL( aEvent.iInt ); |
|
305 iControl->DrawDeferred(); |
|
306 break; |
|
307 } |
|
308 |
|
309 case TPbk2ControlEvent::EContactUnselectedAll: // FALLTHROUGH |
|
310 default: |
|
311 { |
|
312 // Do nothing |
|
313 break; |
|
314 }; |
|
315 } |
|
316 |
|
317 // Forward event to parent dialog |
|
318 iParentDlg.HandleControlEventL( aControl, aEvent ); |
|
319 } |
|
320 |
|
321 // -------------------------------------------------------------------------- |
|
322 // CPbk2FetchDlgGroupPage::HandleContactSelectionL |
|
323 // -------------------------------------------------------------------------- |
|
324 // |
|
325 void CPbk2FetchDlgGroupPage::HandleContactSelectionL |
|
326 ( const MVPbkBaseContact* aContact, TInt /*aIndex*/, |
|
327 TBool aSelected ) |
|
328 { |
|
329 if ( aContact ) |
|
330 { |
|
331 MVPbkContactLink* link = aContact->CreateLinkLC(); |
|
332 iParentDlg.SelectContactL( *link, aSelected ); |
|
333 CleanupStack::PopAndDestroy(); |
|
334 } |
|
335 } |
|
336 |
|
337 // -------------------------------------------------------------------------- |
|
338 // CPbk2FetchDlgGroupPage::SetPagesReadyStateL |
|
339 // -------------------------------------------------------------------------- |
|
340 // |
|
341 void CPbk2FetchDlgGroupPage::SetPagesReadyStateL( TBool aReadyState ) |
|
342 { |
|
343 iIsReady = aReadyState; |
|
344 iParentDlg.FetchDlgPageChangedL( *this ); // call this to update CBAs |
|
345 } |
|
346 |
|
347 // -------------------------------------------------------------------------- |
|
348 // CPbk2FetchDlgGroupPage::UpdateListEmptyTextL |
|
349 // -------------------------------------------------------------------------- |
|
350 // |
|
351 void CPbk2FetchDlgGroupPage::UpdateListEmptyTextL( TInt aListState ) |
|
352 { |
|
353 HBufC* text = ListEmptyTextLC( aListState ); |
|
354 |
|
355 if ( text ) |
|
356 { |
|
357 iControl->SetTextL( *text ); |
|
358 CleanupStack::PopAndDestroy(); // text |
|
359 } |
|
360 } |
|
361 |
|
362 // -------------------------------------------------------------------------- |
|
363 // CPbk2FetchDlgGroupPage::ListEmptyTextLC |
|
364 // -------------------------------------------------------------------------- |
|
365 // |
|
366 HBufC* CPbk2FetchDlgGroupPage::ListEmptyTextLC( TInt aListState ) |
|
367 { |
|
368 HBufC* text = NULL; |
|
369 |
|
370 switch ( aListState ) |
|
371 { |
|
372 case CPbk2NamesListControl::EStateEmpty: // FALLTHROUGH |
|
373 case CPbk2NamesListControl::EStateNotReady: |
|
374 { |
|
375 text = StringLoader::LoadLC( R_QTN_PHOB_NO_GROUPS_IN_FETCH ); |
|
376 break; |
|
377 } |
|
378 |
|
379 case CPbk2NamesListControl::EStateReady: // FALLTHROUGH |
|
380 case CPbk2NamesListControl::EStateFiltered: |
|
381 { |
|
382 text = StringLoader::LoadLC( R_PBK2_FIND_NO_MATCHES ); |
|
383 break; |
|
384 } |
|
385 |
|
386 default: |
|
387 { |
|
388 text = KNullDesC().AllocLC(); |
|
389 break; |
|
390 } |
|
391 } |
|
392 return text; |
|
393 } |
|
394 |
|
395 // End of File |