|
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 contact info list box. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "CPbk2ContactInfoListBox.h" |
|
21 |
|
22 // Phonebook 2 |
|
23 #include "CPbk2ContactInfoDataSwapper.h" |
|
24 #include "CPbk2IconArray.h" |
|
25 #include "CPbk2FieldListBoxModel.h" |
|
26 #include <CPbk2PresentationContactField.h> |
|
27 #include <CPbk2PresentationContactFieldCollection.h> |
|
28 #include <Pbk2UIControls.rsg> |
|
29 #include <CPbk2UIExtensionManager.h> |
|
30 #include <MPbk2UIExtensionIconSupport.h> |
|
31 #include <Pbk2Profile.h> |
|
32 |
|
33 // Virtual Phonebook |
|
34 #include <CVPbkContactManager.h> |
|
35 #include <CVPbkFieldTypeSelector.h> |
|
36 #include <MVPbkFieldType.h> |
|
37 #include <CVPbkDefaultAttribute.h> |
|
38 #include <VPbkUtils.h> |
|
39 #include <CVPbkVoiceTagAttribute.h> |
|
40 #include <MVPbkContactOperationBase.h> |
|
41 #include <MVPbkContactStoreProperties.h> |
|
42 #include <MVPbkStoreContact.h> |
|
43 #include <MVPbkContactStore.h> |
|
44 |
|
45 // System includes |
|
46 #include <barsread.h> |
|
47 #include <eikclbd.h> |
|
48 #include <eikfrlb.h> |
|
49 #include <StringLoader.h> |
|
50 |
|
51 // Debugging headers |
|
52 #include <Pbk2Debug.h> |
|
53 |
|
54 /// Unnamed namespace for local definitions |
|
55 namespace { |
|
56 |
|
57 /** |
|
58 * Returns CPbk2IconArray icon array from the given list box. |
|
59 * |
|
60 * @param aListBox List box. |
|
61 * @return Phonebook 2 icon array. |
|
62 */ |
|
63 inline CPbk2IconArray* IconArray( |
|
64 const CEikFormattedCellListBox& aListBox ) |
|
65 { |
|
66 return static_cast<CPbk2IconArray*>( |
|
67 aListBox.ItemDrawer()->ColumnData()->IconArray() ); |
|
68 } |
|
69 |
|
70 /** |
|
71 * Sets aIconArray as aListBox'es icon array. |
|
72 * |
|
73 * @param aListBox List box. |
|
74 * @param aIconArray Phonebook 2 icon array. |
|
75 */ |
|
76 inline void SetIconArray( |
|
77 CEikFormattedCellListBox& aListBox, |
|
78 CPbk2IconArray* aIconArray ) |
|
79 { |
|
80 aListBox.ItemDrawer()->ColumnData()->SetIconArray( aIconArray ); |
|
81 } |
|
82 |
|
83 |
|
84 #ifdef _DEBUG |
|
85 |
|
86 enum TPanicCode |
|
87 { |
|
88 EPanicPostCond_DoUpdateL = 1 |
|
89 }; |
|
90 |
|
91 void Panic( TInt aReason ) |
|
92 { |
|
93 _LIT( KPanicText, "CPbk2ContactInfoListBox" ); |
|
94 User::Panic( KPanicText, aReason ); |
|
95 } |
|
96 |
|
97 #endif // _DEBUG |
|
98 |
|
99 } /// namespace |
|
100 |
|
101 // MODULE DATA STRUCTURES |
|
102 |
|
103 /** |
|
104 * Listbox item drawer. |
|
105 */ |
|
106 NONSHARABLE_CLASS( CPbk2ContactInfoListBox::CItemDrawer ) : |
|
107 public CFormattedCellListBoxItemDrawer |
|
108 { |
|
109 public: // Construction and destruction |
|
110 |
|
111 /** |
|
112 * Creates a new instance of this class. |
|
113 * |
|
114 * @param aTextListBoxModel The model whose items will be drawn. |
|
115 * @param aFont The font with which the items |
|
116 * will be drawn. |
|
117 * @param aFormattedCellData The column list box data. |
|
118 * @param aManager Virtual Phonebook contact manager. |
|
119 * @return A new instance of this class. |
|
120 */ |
|
121 static CPbk2ContactInfoListBox::CItemDrawer* NewL( |
|
122 MTextListBoxModel* aTextListBoxModel, |
|
123 const CFont* aFont, |
|
124 CFormattedCellListBoxData* aFormattedCellData, |
|
125 CVPbkContactManager& aManager ); |
|
126 |
|
127 /** |
|
128 * Destructor. |
|
129 */ |
|
130 ~CItemDrawer(); |
|
131 |
|
132 public: // Interface |
|
133 |
|
134 /** |
|
135 * Sets contact field collection. |
|
136 * |
|
137 * @param aFields The field collection to set. |
|
138 */ |
|
139 inline void SetFields( |
|
140 const CPbk2PresentationContactFieldCollection& aFields ); |
|
141 |
|
142 private: // From CFormattedCellListBoxItemDrawer |
|
143 TListItemProperties Properties( |
|
144 TInt aItemIndex ) const; |
|
145 |
|
146 private: // Implementation |
|
147 CItemDrawer( |
|
148 MTextListBoxModel* aTextListBoxModel, |
|
149 const CFont* aFont, |
|
150 CFormattedCellListBoxData* aFormattedCellData, |
|
151 CVPbkContactManager& aManager ); |
|
152 void ConstructL(); |
|
153 |
|
154 private: // Data |
|
155 /// Ref: Array of fields |
|
156 const CPbk2PresentationContactFieldCollection* iFields; |
|
157 /// Ref: Virtual Phonebook contact manager |
|
158 CVPbkContactManager& iManager; |
|
159 /// Own: Field type selector |
|
160 CVPbkFieldTypeSelector* iPhoneNumberFieldSelector; |
|
161 }; |
|
162 |
|
163 // -------------------------------------------------------------------------- |
|
164 // CPbk2ContactInfoListBox::CItemDrawer::CItemDrawer |
|
165 // -------------------------------------------------------------------------- |
|
166 // |
|
167 inline CPbk2ContactInfoListBox::CItemDrawer::CItemDrawer( |
|
168 MTextListBoxModel* aTextListBoxModel, const CFont* aFont, |
|
169 CFormattedCellListBoxData* aFormattedCellData, |
|
170 CVPbkContactManager& aManager ) : |
|
171 CFormattedCellListBoxItemDrawer( aTextListBoxModel, aFont, |
|
172 aFormattedCellData ), iManager( aManager ) |
|
173 { |
|
174 } |
|
175 |
|
176 // -------------------------------------------------------------------------- |
|
177 // CPbk2ContactInfoListBox::CItemDrawer::~CItemDrawer |
|
178 // -------------------------------------------------------------------------- |
|
179 // |
|
180 CPbk2ContactInfoListBox::CItemDrawer::~CItemDrawer() |
|
181 { |
|
182 delete iPhoneNumberFieldSelector; |
|
183 } |
|
184 |
|
185 // -------------------------------------------------------------------------- |
|
186 // CPbk2ContactInfoListBox::CItemDrawer::NewL |
|
187 // -------------------------------------------------------------------------- |
|
188 // |
|
189 CPbk2ContactInfoListBox::CItemDrawer* |
|
190 CPbk2ContactInfoListBox::CItemDrawer::NewL( |
|
191 MTextListBoxModel* aTextListBoxModel, |
|
192 const CFont* aFont, |
|
193 CFormattedCellListBoxData* aFormattedCellData, |
|
194 CVPbkContactManager& aManager ) |
|
195 { |
|
196 CPbk2ContactInfoListBox::CItemDrawer* self = |
|
197 new (ELeave) CPbk2ContactInfoListBox::CItemDrawer( |
|
198 aTextListBoxModel, aFont, aFormattedCellData, aManager ); |
|
199 CleanupStack::PushL( self ); |
|
200 self->ConstructL(); |
|
201 CleanupStack::Pop( self ); |
|
202 return self; |
|
203 } |
|
204 |
|
205 // -------------------------------------------------------------------------- |
|
206 // CPbk2ContactInfoListBox::CItemDrawer::ConstructL |
|
207 // -------------------------------------------------------------------------- |
|
208 // |
|
209 void CPbk2ContactInfoListBox::CItemDrawer::ConstructL() |
|
210 { |
|
211 TResourceReader resReader; |
|
212 CCoeEnv::Static()->CreateResourceReaderLC( |
|
213 resReader, R_PHONEBOOK2_PHONENUMBER_SELECTOR ); |
|
214 |
|
215 iPhoneNumberFieldSelector = CVPbkFieldTypeSelector::NewL |
|
216 ( resReader, iManager.FieldTypes() ); |
|
217 |
|
218 CleanupStack::PopAndDestroy(); // resReader |
|
219 } |
|
220 |
|
221 // -------------------------------------------------------------------------- |
|
222 // CPbk2ContactInfoListBox::CItemDrawer::SetFields |
|
223 // -------------------------------------------------------------------------- |
|
224 // |
|
225 inline void CPbk2ContactInfoListBox::CItemDrawer::SetFields( |
|
226 const CPbk2PresentationContactFieldCollection& aFields ) |
|
227 { |
|
228 iFields = &aFields; |
|
229 } |
|
230 |
|
231 // -------------------------------------------------------------------------- |
|
232 // CPbk2ContactInfoListBox::CItemDrawer::Properties |
|
233 // -------------------------------------------------------------------------- |
|
234 // |
|
235 TListItemProperties CPbk2ContactInfoListBox::CItemDrawer::Properties( |
|
236 TInt aItemIndex ) const |
|
237 { |
|
238 TListItemProperties result = |
|
239 CFormattedCellListBoxItemDrawer::Properties( aItemIndex ); |
|
240 |
|
241 if ( iFields && ( iFields->FieldCount() > aItemIndex ) ) |
|
242 { |
|
243 const CPbk2PresentationContactField* field = |
|
244 &iFields->At( aItemIndex ); |
|
245 |
|
246 // Get the field type |
|
247 const MVPbkFieldType* fieldType = |
|
248 VPbkUtils::MatchFieldType( iManager.FieldTypes(), *field ); |
|
249 |
|
250 // If leave occurs, the field prompt will be not underlined. |
|
251 TRAP_IGNORE( |
|
252 { |
|
253 CVPbkDefaultAttribute* attr = |
|
254 CVPbkDefaultAttribute::NewL( EVPbkDefaultTypePhoneNumber ); |
|
255 CleanupStack::PushL( attr ); |
|
256 if ( iPhoneNumberFieldSelector->IsFieldTypeIncluded( *fieldType ) |
|
257 && iManager.ContactAttributeManagerL().HasFieldAttributeL |
|
258 ( *attr, field->StoreField() ) ) |
|
259 { |
|
260 // Default phone number field prompt is underlined |
|
261 result.SetUnderlined( ETrue ); |
|
262 } |
|
263 CleanupStack::PopAndDestroy( attr ); |
|
264 }); // TRAP_IGNORE |
|
265 } |
|
266 |
|
267 return result; |
|
268 } |
|
269 |
|
270 // -------------------------------------------------------------------------- |
|
271 // CPbk2ContactInfoListBox::CPbk2ContactInfoListBox |
|
272 // -------------------------------------------------------------------------- |
|
273 // |
|
274 inline CPbk2ContactInfoListBox::CPbk2ContactInfoListBox( |
|
275 CVPbkContactManager& aManager ) : |
|
276 iManager( aManager ) |
|
277 { |
|
278 } |
|
279 |
|
280 // -------------------------------------------------------------------------- |
|
281 // CPbk2ContactInfoListBox::~CPbk2ContactInfoListBox |
|
282 // -------------------------------------------------------------------------- |
|
283 // |
|
284 CPbk2ContactInfoListBox::~CPbk2ContactInfoListBox() |
|
285 { |
|
286 delete iVoiceTagFindOperation; |
|
287 delete iResourceData.iFindEmptyText; |
|
288 delete iModel; |
|
289 delete iFieldAnalyzer; |
|
290 } |
|
291 |
|
292 // -------------------------------------------------------------------------- |
|
293 // CPbk2ContactInfoListBox::NewL |
|
294 // -------------------------------------------------------------------------- |
|
295 // |
|
296 CPbk2ContactInfoListBox* CPbk2ContactInfoListBox::NewL( |
|
297 CCoeControl& aContainer, |
|
298 TInt aResourceId, |
|
299 CVPbkContactManager& aManager ) |
|
300 { |
|
301 CPbk2ContactInfoListBox* self = |
|
302 new (ELeave) CPbk2ContactInfoListBox( aManager ); |
|
303 CleanupStack::PushL( self ); |
|
304 self->ConstructL( aContainer, aResourceId ); |
|
305 CleanupStack::Pop( self ); |
|
306 return self; |
|
307 } |
|
308 |
|
309 // -------------------------------------------------------------------------- |
|
310 // CPbk2ContactInfoListBox::ConstructL |
|
311 // -------------------------------------------------------------------------- |
|
312 // |
|
313 inline void CPbk2ContactInfoListBox::ConstructL( |
|
314 CCoeControl& aContainer, TInt aResourceId ) |
|
315 { |
|
316 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
317 ("CPbk2ContactInfoListBox::ConstructL")); |
|
318 |
|
319 iFieldAnalyzer = CPbk2FieldAnalyzer::NewL( iManager ); |
|
320 |
|
321 TResourceReader reader; |
|
322 CCoeEnv::Static()->CreateResourceReaderLC( reader, aResourceId ); |
|
323 |
|
324 iResourceData.iFlags = reader.ReadUint32(); // flags |
|
325 |
|
326 SetContainerWindowL( aContainer ); |
|
327 |
|
328 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
329 ("CPbk2ContactInfoListBox::ConstructL about to resource construct")); |
|
330 |
|
331 // Let Avkon read it's share of the resources |
|
332 ConstructFromResourceL( reader ); |
|
333 |
|
334 View()->SetListEmptyTextL( KNullDesC ); |
|
335 |
|
336 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
337 ("CPbk2ContactInfoListBox::ConstructL about to create icon array")); |
|
338 |
|
339 // Set icon array |
|
340 const TInt iconArrayRes = reader.ReadInt32(); |
|
341 TResourceReader iconArrayreader; |
|
342 CCoeEnv::Static()->CreateResourceReaderLC |
|
343 ( iconArrayreader, iconArrayRes ); |
|
344 CPbk2IconArray* iconArray = CPbk2IconArray::NewL( iconArrayreader ); |
|
345 CleanupStack::PushL( iconArray ); |
|
346 |
|
347 // Add icons from UI extensions |
|
348 CPbk2UIExtensionManager* extManager = |
|
349 CPbk2UIExtensionManager::InstanceL(); |
|
350 extManager->PushL(); |
|
351 extManager->IconSupportL().AppendExtensionIconsL( *iconArray ); |
|
352 CleanupStack::PopAndDestroy(); // extManager |
|
353 CleanupStack::Pop( iconArray ); |
|
354 CleanupStack::PopAndDestroy(); // iconArrayreader |
|
355 SetIconArray( *this, iconArray ); |
|
356 |
|
357 CleanupStack::PopAndDestroy(); // reader |
|
358 |
|
359 CreateScrollBarFrameL( ETrue ); |
|
360 ScrollBarFrame()->SetScrollBarVisibilityL( |
|
361 CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto ); |
|
362 |
|
363 // Take ownership of the default listbox model |
|
364 iModel = Model()->ItemTextArray(); |
|
365 Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
366 |
|
367 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
368 ("CPbk2ContactInfoListBox::ConstructL end")); |
|
369 } |
|
370 |
|
371 // -------------------------------------------------------------------------- |
|
372 // CPbk2ContactInfoListBox::PrepareForUpdateL |
|
373 // -------------------------------------------------------------------------- |
|
374 // |
|
375 void CPbk2ContactInfoListBox::PrepareForUpdateL( |
|
376 CPbk2ContactInfoDataSwapper& aDataSwapper, |
|
377 const CPbk2PresentationContactFieldCollection& aFieldCollection, |
|
378 MPbk2FieldPropertyArray& aFieldProperties, |
|
379 const CPbk2ContactFieldDynamicProperties* aDynamicProperties ) |
|
380 { |
|
381 // cancel voice tag operation |
|
382 if (iVoiceTagFindOperation) |
|
383 { |
|
384 delete iVoiceTagFindOperation; |
|
385 iVoiceTagFindOperation = NULL; |
|
386 } |
|
387 |
|
388 // Create a new list box model based on the |
|
389 // new field collection |
|
390 PBK2_PROFILE_START(Pbk2Profile::EContactInfoListBoxPrepareForUpdateLCreateListBoxModel); |
|
391 CPbk2FieldListBoxModel* model = CreateListBoxModelL( |
|
392 iManager, aFieldCollection, aFieldProperties, aDynamicProperties ); |
|
393 PBK2_PROFILE_END(Pbk2Profile::EContactInfoListBoxPrepareForUpdateLCreateListBoxModel); |
|
394 |
|
395 // Store the members which are to be swapped |
|
396 PBK2_PROFILE_START(Pbk2Profile::EContactInfoListBoxPrepareForUpdateLStoreListBoxState); |
|
397 aDataSwapper.StoreListBoxState( *this ); |
|
398 aDataSwapper.iListBoxModel = model; |
|
399 aDataSwapper.iFieldCollection = &aFieldCollection; |
|
400 PBK2_PROFILE_END(Pbk2Profile::EContactInfoListBoxPrepareForUpdateLStoreListBoxState); |
|
401 } |
|
402 |
|
403 // -------------------------------------------------------------------------- |
|
404 // CPbk2ContactInfoListBox::DoUpdateL |
|
405 // -------------------------------------------------------------------------- |
|
406 // |
|
407 void CPbk2ContactInfoListBox::DoUpdateL( |
|
408 CPbk2ContactInfoDataSwapper& aDataSwapper, |
|
409 MVPbkStoreContact& aContact ) |
|
410 { |
|
411 // Change state |
|
412 aDataSwapper.ResetListBoxState(); |
|
413 aDataSwapper.Swap( iFieldCollection, aDataSwapper.iFieldCollection ); |
|
414 aDataSwapper.Swap( iModel, aDataSwapper.iListBoxModel ); |
|
415 |
|
416 // Redraw |
|
417 ItemDrawer()->SetFields( *iFieldCollection ); |
|
418 Model()->SetItemTextArray( iModel ); |
|
419 Reset(); |
|
420 // The leaving methods have to be executed last |
|
421 UpdateScrollBarsL(); |
|
422 |
|
423 // create asynchronous voice tag retriever |
|
424 TRAP_IGNORE(DoCreateVoiceTagRetrieverL(aContact)); |
|
425 |
|
426 __ASSERT_DEBUG(iModel, Panic(EPanicPostCond_DoUpdateL)); |
|
427 __ASSERT_DEBUG(Model()->ItemTextArray() == iModel, |
|
428 Panic(EPanicPostCond_DoUpdateL)); |
|
429 } |
|
430 |
|
431 // -------------------------------------------------------------------------- |
|
432 // CPbk2ContactInfoListBox::NumberOfItems |
|
433 // -------------------------------------------------------------------------- |
|
434 // |
|
435 TInt CPbk2ContactInfoListBox::NumberOfItems() const |
|
436 { |
|
437 return 0; |
|
438 } |
|
439 |
|
440 // -------------------------------------------------------------------------- |
|
441 // CPbk2ContactInfoListBox::ContactsMarked |
|
442 // -------------------------------------------------------------------------- |
|
443 // |
|
444 TBool CPbk2ContactInfoListBox::ContactsMarked() const |
|
445 { |
|
446 return EFalse; |
|
447 } |
|
448 |
|
449 // -------------------------------------------------------------------------- |
|
450 // CPbk2ContactInfoListBox::CurrentItemIndex |
|
451 // -------------------------------------------------------------------------- |
|
452 // |
|
453 TInt CPbk2ContactInfoListBox::CurrentItemIndex() const |
|
454 { |
|
455 return CAknFormDoubleGraphicStyleListBox::CurrentItemIndex(); |
|
456 } |
|
457 |
|
458 // -------------------------------------------------------------------------- |
|
459 // CPbk2ContactInfoListBox::DoHandleResourceChangeL |
|
460 // -------------------------------------------------------------------------- |
|
461 // |
|
462 void CPbk2ContactInfoListBox::DoHandleResourceChangeL |
|
463 ( const TInt aType ) const |
|
464 { |
|
465 if ( aType == KAknsMessageSkinChange || |
|
466 aType == KEikDynamicLayoutVariantSwitch ) |
|
467 { |
|
468 CPbk2IconArray* iconArray = IconArray( *this ); |
|
469 if ( iconArray ) |
|
470 { |
|
471 // Refresh core Phonebook2 icons |
|
472 iconArray->RefreshL(); |
|
473 CPbk2UIExtensionManager* extManager = |
|
474 CPbk2UIExtensionManager::InstanceL(); |
|
475 extManager->PushL(); |
|
476 // Refresh extension icons |
|
477 extManager->IconSupportL().RefreshL( *iconArray ); |
|
478 CleanupStack::PopAndDestroy(); // extManager |
|
479 } |
|
480 } |
|
481 } |
|
482 |
|
483 // -------------------------------------------------------------------------- |
|
484 // CPbk2ContactInfoListBox::Flags |
|
485 // -------------------------------------------------------------------------- |
|
486 // |
|
487 TUint CPbk2ContactInfoListBox::Flags() const |
|
488 { |
|
489 return iResourceData.iFlags; |
|
490 } |
|
491 |
|
492 // -------------------------------------------------------------------------- |
|
493 // CPbk2ContactInfoListBox::SetScrollEventObserver |
|
494 // -------------------------------------------------------------------------- |
|
495 // |
|
496 void CPbk2ContactInfoListBox::SetScrollEventObserver(MEikScrollBarObserver* aObserver) |
|
497 { |
|
498 iScrollEventObserver = aObserver; |
|
499 } |
|
500 |
|
501 // -------------------------------------------------------------------------- |
|
502 // CPbk2ContactInfoListBox::ItemDrawer |
|
503 // -------------------------------------------------------------------------- |
|
504 // |
|
505 inline CPbk2ContactInfoListBox::CItemDrawer* |
|
506 CPbk2ContactInfoListBox::ItemDrawer() const |
|
507 { |
|
508 return static_cast<CPbk2ContactInfoListBox::CItemDrawer*>( |
|
509 CAknFormDoubleGraphicStyleListBox::ItemDrawer() ); |
|
510 } |
|
511 |
|
512 // -------------------------------------------------------------------------- |
|
513 // CPbk2ContactInfoListBox::CreateItemDrawerL |
|
514 // -------------------------------------------------------------------------- |
|
515 // |
|
516 void CPbk2ContactInfoListBox::CreateItemDrawerL() |
|
517 { |
|
518 CFormattedCellListBoxData* formattedData = |
|
519 CFormattedCellListBoxData::NewL(); |
|
520 CleanupStack::PushL( formattedData ); |
|
521 iItemDrawer = CPbk2ContactInfoListBox::CItemDrawer::NewL( |
|
522 Model(), iEikonEnv->NormalFont(), formattedData, iManager ); |
|
523 CleanupStack::Pop( formattedData ); |
|
524 } |
|
525 |
|
526 // -------------------------------------------------------------------------- |
|
527 // CPbk2ContactInfoListBox::HandlePointerEventL |
|
528 // -------------------------------------------------------------------------- |
|
529 // |
|
530 void CPbk2ContactInfoListBox::HandlePointerEventL( |
|
531 const TPointerEvent& aPointerEvent ) |
|
532 { |
|
533 TInt oldIndex = CurrentItemIndex(); |
|
534 |
|
535 // Base class handles the pointer event |
|
536 CAknFormDoubleGraphicStyleListBox::HandlePointerEventL( |
|
537 aPointerEvent ); |
|
538 |
|
539 switch( aPointerEvent.iType ) |
|
540 { |
|
541 case TPointerEvent::EButton1Down: |
|
542 { |
|
543 TInt pointedItemIndex; |
|
544 iFocusableItemPointed = View()->XYPosToItemIndex( |
|
545 aPointerEvent.iPosition, pointedItemIndex ); |
|
546 iFocusedItemPointed = iFocusableItemPointed && |
|
547 ( pointedItemIndex == oldIndex ); |
|
548 break; |
|
549 } |
|
550 default: |
|
551 { |
|
552 // Do nothing |
|
553 break; |
|
554 } |
|
555 } |
|
556 } |
|
557 |
|
558 // -------------------------------------------------------------------------- |
|
559 // CPbk2ContactInfoListBox::HandleScrollEventL |
|
560 // -------------------------------------------------------------------------- |
|
561 // |
|
562 void CPbk2ContactInfoListBox::HandleScrollEventL( CEikScrollBar* aScrollBar, |
|
563 TEikScrollEvent aEventType ) |
|
564 { |
|
565 CAknFormDoubleGraphicStyleListBox::HandleScrollEventL( aScrollBar, aEventType ); |
|
566 if( iScrollEventObserver ) |
|
567 { |
|
568 iScrollEventObserver->HandleScrollEventL( aScrollBar, aEventType ); |
|
569 } |
|
570 } |
|
571 |
|
572 // -------------------------------------------------------------------------- |
|
573 // CPbk2ContactInfoListBox::ClipFromBeginning |
|
574 // -------------------------------------------------------------------------- |
|
575 // |
|
576 TBool CPbk2ContactInfoListBox::ClipFromBeginning |
|
577 ( TDes& aBuffer, TInt aItemIndex, TInt aSubCellNumber ) |
|
578 { |
|
579 return AknTextUtils::ClipToFit |
|
580 ( aBuffer, AknTextUtils::EClipFromBeginning, this, aItemIndex, |
|
581 aSubCellNumber ); |
|
582 } |
|
583 |
|
584 // -------------------------------------------------------------------------- |
|
585 // CPbk2ContactInfoListBox::FocusedItemPointed |
|
586 // -------------------------------------------------------------------------- |
|
587 // |
|
588 TBool CPbk2ContactInfoListBox::FocusedItemPointed() |
|
589 { |
|
590 return iFocusedItemPointed; |
|
591 } |
|
592 |
|
593 // -------------------------------------------------------------------------- |
|
594 // CPbk2ContactInfoListBox::FocusableItemPointed |
|
595 // -------------------------------------------------------------------------- |
|
596 // |
|
597 TBool CPbk2ContactInfoListBox::FocusableItemPointed() |
|
598 { |
|
599 return iFocusableItemPointed; |
|
600 } |
|
601 |
|
602 // -------------------------------------------------------------------------- |
|
603 // CPbk2ContactInfoListBox::SearchFieldPointed |
|
604 // -------------------------------------------------------------------------- |
|
605 // |
|
606 TBool CPbk2ContactInfoListBox::SearchFieldPointed() |
|
607 { |
|
608 return EFalse; // no search field |
|
609 } |
|
610 |
|
611 // -------------------------------------------------------------------------- |
|
612 // CPbk2ContactInfoListBox::AttributePresenceOperationComplete |
|
613 // -------------------------------------------------------------------------- |
|
614 // |
|
615 void CPbk2ContactInfoListBox::AttributePresenceOperationComplete( |
|
616 MVPbkContactOperationBase& aOperation, |
|
617 MVPbkStoreContactFieldCollection* aResult) |
|
618 { |
|
619 if (&aOperation == iVoiceTagFindOperation) |
|
620 { |
|
621 // Save voice tag results to field analyser |
|
622 iFieldAnalyzer->SetVoiceTagFields(aResult); |
|
623 TRAP_IGNORE(DoRefreshListBoxContentL(aResult)); |
|
624 |
|
625 delete iVoiceTagFindOperation; |
|
626 iVoiceTagFindOperation = NULL; |
|
627 } |
|
628 } |
|
629 |
|
630 // -------------------------------------------------------------------------- |
|
631 // CPbk2ContactInfoListBox::AttributePresenceOperationFailed |
|
632 // -------------------------------------------------------------------------- |
|
633 // |
|
634 void CPbk2ContactInfoListBox::AttributePresenceOperationFailed( |
|
635 MVPbkContactOperationBase& aOperation, |
|
636 TInt /*aError*/) |
|
637 { |
|
638 if (&aOperation == iVoiceTagFindOperation) |
|
639 { |
|
640 delete iVoiceTagFindOperation; |
|
641 iVoiceTagFindOperation = NULL; |
|
642 } |
|
643 } |
|
644 |
|
645 // -------------------------------------------------------------------------- |
|
646 // CPbk2ContactInfoListBox::CreateListBoxModelL |
|
647 // -------------------------------------------------------------------------- |
|
648 // |
|
649 CPbk2FieldListBoxModel* CPbk2ContactInfoListBox::CreateListBoxModelL( |
|
650 const CVPbkContactManager& aContactManager, |
|
651 const CPbk2PresentationContactFieldCollection& aFieldCollection, |
|
652 MPbk2FieldPropertyArray& aFieldProperties, |
|
653 const CPbk2ContactFieldDynamicProperties* aDynamicProperties ) |
|
654 { |
|
655 PBK2_PROFILE_START(Pbk2Profile::EContactInfoListBoxCreateListBoxModelLTimeFormat); |
|
656 HBufC* timeFormat = iCoeEnv->AllocReadResourceLC( R_QTN_DATE_USUAL ); |
|
657 PBK2_PROFILE_END(Pbk2Profile::EContactInfoListBoxCreateListBoxModelLTimeFormat); |
|
658 |
|
659 PBK2_PROFILE_START(Pbk2Profile::EContactInfoListBoxCreateListBoxModelLCreateListBoxModel); |
|
660 CPbk2FieldListBoxModel::TParams params( |
|
661 aFieldCollection, aContactManager, aFieldProperties, *timeFormat, |
|
662 *IconArray( *this ), iFieldAnalyzer, aDynamicProperties, EFalse); |
|
663 CPbk2FieldListBoxModel* model = CPbk2FieldListBoxModel::NewL( params ); |
|
664 PBK2_PROFILE_END(Pbk2Profile::EContactInfoListBoxCreateListBoxModelLCreateListBoxModel); |
|
665 |
|
666 PBK2_PROFILE_START(Pbk2Profile::EContactInfoListBoxCreateListBoxModelLFormatFields); |
|
667 model->FormatFieldsL(); |
|
668 PBK2_PROFILE_END(Pbk2Profile::EContactInfoListBoxCreateListBoxModelLFormatFields); |
|
669 |
|
670 CleanupStack::PopAndDestroy(); // timeFormat |
|
671 PBK2_PROFILE_START(Pbk2Profile::EContactInfoListBoxCreateListBoxModelLSetClipper); |
|
672 model->SetClipper( *this ); |
|
673 PBK2_PROFILE_END(Pbk2Profile::EContactInfoListBoxCreateListBoxModelLSetClipper); |
|
674 return model; |
|
675 } |
|
676 |
|
677 // -------------------------------------------------------------------------- |
|
678 // CPbk2ContactInfoListBox::DoCreateVoiceTagRetrieverL |
|
679 // -------------------------------------------------------------------------- |
|
680 // |
|
681 void CPbk2ContactInfoListBox::DoCreateVoiceTagRetrieverL( |
|
682 MVPbkStoreContact& aContact) |
|
683 { |
|
684 const MVPbkContactStoreProperties& properties = |
|
685 iFieldCollection->ParentStoreContact().ParentStore().StoreProperties(); |
|
686 |
|
687 if ( properties.SupportsVoiceTags() ) |
|
688 { |
|
689 if (iVoiceTagFindOperation) |
|
690 { |
|
691 delete iVoiceTagFindOperation; |
|
692 iVoiceTagFindOperation = NULL; |
|
693 } |
|
694 // initiate a asynchronous voice tag retrieval |
|
695 iVoiceTagFindOperation = iManager.ContactAttributeManagerL().FindFieldsWithAttributeL( |
|
696 CVPbkVoiceTagAttribute::Uid(), aContact, *this ); |
|
697 } |
|
698 } |
|
699 |
|
700 // -------------------------------------------------------------------------- |
|
701 // CPbk2ContactInfoListBox::DoRefreshListBoxContentL |
|
702 // -------------------------------------------------------------------------- |
|
703 // |
|
704 void CPbk2ContactInfoListBox::DoRefreshListBoxContentL( |
|
705 MVPbkStoreContactFieldCollection* aResult) |
|
706 { |
|
707 // Format fields in the list box model and draw control |
|
708 static_cast<CPbk2FieldListBoxModel*>(iModel)->FormatFieldsL(); |
|
709 // convert store contact field collection to presentation fields |
|
710 // from the presentation fields we can acquire the information which |
|
711 // list box rows need to be redrawn |
|
712 const TInt count = aResult->FieldCount(); |
|
713 for (TInt i = 0; i < count; ++i) |
|
714 { |
|
715 MVPbkStoreContactField& storeField = aResult->FieldAt(i); |
|
716 const TInt redrawIndex = iFieldCollection->FindFieldIndex( |
|
717 storeField); |
|
718 View()->DrawItem(redrawIndex); |
|
719 } |
|
720 } |
|
721 |
|
722 // End of File |