|
1 /* |
|
2 * Copyright (c) 2002-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 own numbers control. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "CPsu2OwnNumberControl.h" |
|
20 |
|
21 // From Phonebook 2 |
|
22 #include "CPsu2OwnNumberListBoxModel.h" |
|
23 #include "Pbk2USIMUIUID.h" |
|
24 #include <Pbk2USimUIRes.rsg> |
|
25 #include <Pbk2USimUI.hrh> |
|
26 #include <CPbk2IconInfoContainer.h> |
|
27 #include <CPbk2IconFactory.h> |
|
28 #include <TPbk2IconId.h> |
|
29 |
|
30 // From VirtualPhonebook |
|
31 #include <MVPbkViewContact.h> |
|
32 #include <MVPbkContactViewBase.h> |
|
33 |
|
34 // System includes |
|
35 #include <aknlists.h> |
|
36 #include <barsread.h> |
|
37 #include <AknIconArray.h> |
|
38 |
|
39 // -------------------------------------------------------------------------- |
|
40 // CPsu2OwnNumberControl::CPsu2OwnNumberControl |
|
41 // -------------------------------------------------------------------------- |
|
42 // |
|
43 CPsu2OwnNumberControl::CPsu2OwnNumberControl( |
|
44 MVPbkContactViewBase& aView ): |
|
45 iBaseView( &aView ) |
|
46 { |
|
47 } |
|
48 |
|
49 // -------------------------------------------------------------------------- |
|
50 // CPsu2OwnNumberControl::~CPsu2OwnNumberControl |
|
51 // -------------------------------------------------------------------------- |
|
52 // |
|
53 CPsu2OwnNumberControl::~CPsu2OwnNumberControl() |
|
54 { |
|
55 delete iListBox; |
|
56 } |
|
57 |
|
58 // -------------------------------------------------------------------------- |
|
59 // CPsu2OwnNumberControl::ConstructL |
|
60 // -------------------------------------------------------------------------- |
|
61 // |
|
62 void CPsu2OwnNumberControl::ConstructL |
|
63 ( MVPbkContactViewBase& aView, CCoeControl* aContainer ) |
|
64 { |
|
65 SetContainerWindowL(*aContainer); |
|
66 iListBox = new (ELeave) CAknDoubleGraphicStyleListBox; |
|
67 iListBox->ConstructL( this, 0 ); |
|
68 |
|
69 CPsu2OwnNumberListBoxModel* model = |
|
70 CPsu2OwnNumberListBoxModel::NewL( |
|
71 aView, |
|
72 *aContainer ); |
|
73 iListBox->Model()->SetItemTextArray(model); |
|
74 iListBox->Model()->SetOwnershipType(ELbmOwnsItemArray); |
|
75 |
|
76 iListBox->CreateScrollBarFrameL(ETrue); |
|
77 iListBox->ScrollBarFrame()->SetScrollBarVisibilityL |
|
78 ( CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto ); |
|
79 iListBox->SetContainerWindowL(*this ); |
|
80 |
|
81 CPbk2IconInfoContainer* iconInfoContainer = |
|
82 CPbk2IconInfoContainer::NewL(R_PSU2_OWN_NUMBER_ICON_INFO_ARRAY); |
|
83 CleanupStack::PushL(iconInfoContainer); |
|
84 CPbk2IconFactory* factory = CPbk2IconFactory::NewLC( *iconInfoContainer ); |
|
85 // Set icon array, use granularity of 1 |
|
86 CAknIconArray* iconArray = new(ELeave) CAknIconArray(1); |
|
87 CleanupStack::PushL(iconArray); |
|
88 // The only icon in the own number list is a phone icon |
|
89 TPbk2IconId phoneIconId( TUid::Uid(KPbk2USIMExtensionImplementationUID), |
|
90 EPsu2qgn_prop_nrtyp_phone ); |
|
91 CGulIcon* icon = factory->CreateIconLC( phoneIconId ); |
|
92 iconArray->AppendL( icon ); |
|
93 CleanupStack::Pop(2); // icon, iconArray |
|
94 iListBox->ItemDrawer()->ColumnData()->SetIconArray(iconArray); |
|
95 |
|
96 CleanupStack::PopAndDestroy( 2 ); // factory, iconInfoContainer |
|
97 } |
|
98 |
|
99 // -------------------------------------------------------------------------- |
|
100 // CPsu2OwnNumberControl::NewL |
|
101 // -------------------------------------------------------------------------- |
|
102 // |
|
103 CPsu2OwnNumberControl* CPsu2OwnNumberControl::NewL |
|
104 ( MVPbkContactViewBase& aView, CCoeControl* aContainer ) |
|
105 { |
|
106 CPsu2OwnNumberControl* self = new(ELeave)CPsu2OwnNumberControl( aView ); |
|
107 CleanupStack::PushL( self ); |
|
108 self->ConstructL( aView, aContainer ); |
|
109 CleanupStack::Pop( self ); |
|
110 return self; |
|
111 } |
|
112 |
|
113 // -------------------------------------------------------------------------- |
|
114 // CPsu2OwnNumberControl::OfferKeyEventL |
|
115 // -------------------------------------------------------------------------- |
|
116 // |
|
117 TKeyResponse CPsu2OwnNumberControl::OfferKeyEventL |
|
118 (const TKeyEvent& aKeyEvent,TEventCode aType) |
|
119 { |
|
120 // Forward all key events to the list box |
|
121 TKeyResponse response = iListBox->OfferKeyEventL(aKeyEvent,aType); |
|
122 |
|
123 // Ignore Send Key up and down events to prevent Dialer appearance |
|
124 // on top of Phonebook application. |
|
125 if ( response == EKeyWasNotConsumed ) |
|
126 { |
|
127 if ( ( aType == EEventKeyDown || aType == EEventKeyUp ) |
|
128 && aKeyEvent.iScanCode == EStdKeyYes ) |
|
129 { |
|
130 response = EKeyWasConsumed; |
|
131 } |
|
132 } |
|
133 return response; |
|
134 } |
|
135 |
|
136 // -------------------------------------------------------------------------- |
|
137 // CPsu2OwnNumberControl::SizeChanged |
|
138 // -------------------------------------------------------------------------- |
|
139 // |
|
140 void CPsu2OwnNumberControl::SizeChanged() |
|
141 { |
|
142 iListBox->SetRect(Rect()); |
|
143 } |
|
144 |
|
145 // -------------------------------------------------------------------------- |
|
146 // CPsu2OwnNumberControl::CountComponentControls |
|
147 // -------------------------------------------------------------------------- |
|
148 // |
|
149 TInt CPsu2OwnNumberControl::CountComponentControls() const |
|
150 { |
|
151 return (iListBox ? 1 : 0); |
|
152 } |
|
153 |
|
154 // -------------------------------------------------------------------------- |
|
155 // CPsu2OwnNumberControl::ComponentControl |
|
156 // -------------------------------------------------------------------------- |
|
157 // |
|
158 CCoeControl* CPsu2OwnNumberControl::ComponentControl |
|
159 ( TInt /*aIndex*/ ) const |
|
160 { |
|
161 // Return the one and only child control |
|
162 return iListBox; |
|
163 } |
|
164 |
|
165 // -------------------------------------------------------------------------- |
|
166 // CPsu2OwnNumberControl::FocusChanged |
|
167 // -------------------------------------------------------------------------- |
|
168 // |
|
169 void CPsu2OwnNumberControl::FocusChanged( TDrawNow aDrawNow ) |
|
170 { |
|
171 iListBox->SetFocus( IsFocused(), aDrawNow ); |
|
172 } |
|
173 |
|
174 // -------------------------------------------------------------------------- |
|
175 // CPsu2OwnNumberControl::ParentControl |
|
176 // -------------------------------------------------------------------------- |
|
177 // |
|
178 MPbk2ContactUiControl* CPsu2OwnNumberControl::ParentControl() const |
|
179 { |
|
180 // Do nothing |
|
181 return NULL; |
|
182 } |
|
183 // -------------------------------------------------------------------------- |
|
184 // CPsu2OwnNumberControl::NumberOfContacts |
|
185 // -------------------------------------------------------------------------- |
|
186 // |
|
187 TInt CPsu2OwnNumberControl::NumberOfContacts() const |
|
188 { |
|
189 return iListBox->Model()->NumberOfItems(); |
|
190 } |
|
191 |
|
192 // -------------------------------------------------------------------------- |
|
193 // CPsu2OwnNumberControl::FocusedContactL |
|
194 // -------------------------------------------------------------------------- |
|
195 // |
|
196 const MVPbkBaseContact* CPsu2OwnNumberControl::FocusedContactL() const |
|
197 { |
|
198 return FocusedViewContactL(); |
|
199 } |
|
200 |
|
201 // -------------------------------------------------------------------------- |
|
202 // CPsu2OwnNumberControl::FocusedViewContactL |
|
203 // -------------------------------------------------------------------------- |
|
204 // |
|
205 const MVPbkViewContact* CPsu2OwnNumberControl::FocusedViewContactL() const |
|
206 { |
|
207 const MVPbkViewContact* contact = NULL; |
|
208 |
|
209 const TInt focusIndex = iListBox->CurrentItemIndex(); |
|
210 if ( focusIndex >= 0 ) |
|
211 { |
|
212 contact = &iBaseView->ContactAtL( focusIndex ); |
|
213 } |
|
214 |
|
215 return contact; |
|
216 } |
|
217 |
|
218 // -------------------------------------------------------------------------- |
|
219 // CPsu2OwnNumberControl::FocusedStoreContact |
|
220 // -------------------------------------------------------------------------- |
|
221 // |
|
222 const MVPbkStoreContact* CPsu2OwnNumberControl::FocusedStoreContact() const |
|
223 { |
|
224 return NULL; |
|
225 } |
|
226 |
|
227 // -------------------------------------------------------------------------- |
|
228 // CPsu2OwnNumberControl::SetFocusedContactL |
|
229 // -------------------------------------------------------------------------- |
|
230 // |
|
231 void CPsu2OwnNumberControl::SetFocusedContactL( |
|
232 const MVPbkBaseContact& /*aContact*/ ) |
|
233 { |
|
234 // Do nothing |
|
235 } |
|
236 |
|
237 // -------------------------------------------------------------------------- |
|
238 // CPsu2OwnNumberControl::SetFocusedContactL |
|
239 // -------------------------------------------------------------------------- |
|
240 // |
|
241 void CPsu2OwnNumberControl::SetFocusedContactL( |
|
242 const MVPbkContactBookmark& /*aContactBookmark*/ ) |
|
243 { |
|
244 // Do nothing |
|
245 } |
|
246 |
|
247 // -------------------------------------------------------------------------- |
|
248 // CPsu2OwnNumberControl::SetFocusedContactL |
|
249 // -------------------------------------------------------------------------- |
|
250 // |
|
251 void CPsu2OwnNumberControl::SetFocusedContactL( |
|
252 const MVPbkContactLink& /*aContactLink*/ ) |
|
253 { |
|
254 // Do nothing |
|
255 } |
|
256 |
|
257 // -------------------------------------------------------------------------- |
|
258 // CPsu2OwnNumberControl::FocusedContactIndex |
|
259 // -------------------------------------------------------------------------- |
|
260 // |
|
261 TInt CPsu2OwnNumberControl::FocusedContactIndex() const |
|
262 { |
|
263 return iListBox->CurrentItemIndex(); |
|
264 } |
|
265 |
|
266 // -------------------------------------------------------------------------- |
|
267 // CPsu2OwnNumberControl::SetFocusedContactIndexL |
|
268 // -------------------------------------------------------------------------- |
|
269 // |
|
270 void CPsu2OwnNumberControl::SetFocusedContactIndexL( |
|
271 TInt /*aIndex*/ ) |
|
272 { |
|
273 // Do nothing |
|
274 } |
|
275 |
|
276 // -------------------------------------------------------------------------- |
|
277 // CPsu2OwnNumberControl::NumberOfContactFields |
|
278 // -------------------------------------------------------------------------- |
|
279 // |
|
280 TInt CPsu2OwnNumberControl::NumberOfContactFields() const |
|
281 { |
|
282 // Do nothing |
|
283 return KErrNone; |
|
284 } |
|
285 |
|
286 // -------------------------------------------------------------------------- |
|
287 // CPsu2OwnNumberControl::FocusedField |
|
288 // -------------------------------------------------------------------------- |
|
289 // |
|
290 const MVPbkBaseContactField* CPsu2OwnNumberControl::FocusedField() const |
|
291 { |
|
292 // Do nothing |
|
293 return NULL; |
|
294 } |
|
295 |
|
296 // -------------------------------------------------------------------------- |
|
297 // CPsu2OwnNumberControl::FocusedFieldIndex |
|
298 // -------------------------------------------------------------------------- |
|
299 // |
|
300 TInt CPsu2OwnNumberControl::FocusedFieldIndex() const |
|
301 { |
|
302 // Do nothing |
|
303 return KErrNotFound; |
|
304 } |
|
305 |
|
306 // -------------------------------------------------------------------------- |
|
307 // CPsu2OwnNumberControl::SetFocusedFieldIndex |
|
308 // -------------------------------------------------------------------------- |
|
309 // |
|
310 void CPsu2OwnNumberControl::SetFocusedFieldIndex( |
|
311 TInt /*aIndex*/ ) |
|
312 { |
|
313 // Do nothing |
|
314 } |
|
315 |
|
316 // -------------------------------------------------------------------------- |
|
317 // CPsu2OwnNumberControl::ContactsMarked |
|
318 // -------------------------------------------------------------------------- |
|
319 // |
|
320 TBool CPsu2OwnNumberControl::ContactsMarked() const |
|
321 { |
|
322 // Do nothing |
|
323 return EFalse; |
|
324 } |
|
325 |
|
326 // -------------------------------------------------------------------------- |
|
327 // CPsu2OwnNumberControl::SelectedContactsL |
|
328 // -------------------------------------------------------------------------- |
|
329 // |
|
330 MVPbkContactLinkArray* CPsu2OwnNumberControl::SelectedContactsL() const |
|
331 { |
|
332 // Do nothing |
|
333 return NULL; |
|
334 } |
|
335 |
|
336 // -------------------------------------------------------------------------- |
|
337 // CPsu2OwnNumberControl::SelectedContactsOrFocusedContactL |
|
338 // -------------------------------------------------------------------------- |
|
339 // |
|
340 MVPbkContactLinkArray* |
|
341 CPsu2OwnNumberControl::SelectedContactsOrFocusedContactL() const |
|
342 { |
|
343 // Do nothing |
|
344 return NULL; |
|
345 } |
|
346 |
|
347 // -------------------------------------------------------------------------- |
|
348 // CPsu2OwnNumberControl::SelectedContactsIteratorL |
|
349 // -------------------------------------------------------------------------- |
|
350 // |
|
351 MPbk2ContactLinkIterator* |
|
352 CPsu2OwnNumberControl::SelectedContactsIteratorL() const |
|
353 { |
|
354 // Do nothing |
|
355 return NULL; |
|
356 } |
|
357 |
|
358 // -------------------------------------------------------------------------- |
|
359 // CPsu2OwnNumberControl::SelectedContactStoresL |
|
360 // -------------------------------------------------------------------------- |
|
361 // |
|
362 CArrayPtr<MVPbkContactStore>* |
|
363 CPsu2OwnNumberControl::SelectedContactStoresL() const |
|
364 { |
|
365 // Do nothing |
|
366 return NULL; |
|
367 } |
|
368 |
|
369 // -------------------------------------------------------------------------- |
|
370 // CPsu2OwnNumberControl::ClearMarks |
|
371 // -------------------------------------------------------------------------- |
|
372 // |
|
373 void CPsu2OwnNumberControl::ClearMarks() |
|
374 { |
|
375 // Do nothing |
|
376 } |
|
377 |
|
378 // -------------------------------------------------------------------------- |
|
379 // CPsu2OwnNumberControl::SetSelectedContactL |
|
380 // -------------------------------------------------------------------------- |
|
381 // |
|
382 void CPsu2OwnNumberControl::SetSelectedContactL( |
|
383 TInt /*aIndex*/, |
|
384 TBool /*aSelected*/ ) |
|
385 { |
|
386 // Do nothing |
|
387 } |
|
388 |
|
389 // -------------------------------------------------------------------------- |
|
390 // CPsu2OwnNumberControl::SetSelectedContactL |
|
391 // -------------------------------------------------------------------------- |
|
392 // |
|
393 void CPsu2OwnNumberControl::SetSelectedContactL( |
|
394 const MVPbkContactBookmark& /*aContactBookmark*/, |
|
395 TBool /*aSelected*/ ) |
|
396 { |
|
397 // Do nothing |
|
398 } |
|
399 |
|
400 // -------------------------------------------------------------------------- |
|
401 // CPsu2OwnNumberControl::SetSelectedContactL |
|
402 // -------------------------------------------------------------------------- |
|
403 // |
|
404 void CPsu2OwnNumberControl::SetSelectedContactL( |
|
405 const MVPbkContactLink& /*aContactLink*/, |
|
406 TBool /*aSelected*/ ) |
|
407 { |
|
408 // Do nothing |
|
409 } |
|
410 |
|
411 TInt CPsu2OwnNumberControl::CommandItemCount() const |
|
412 { |
|
413 return 0; // No command items in this control. |
|
414 } |
|
415 |
|
416 const MPbk2UiControlCmdItem& CPsu2OwnNumberControl::CommandItemAt( |
|
417 TInt /*aIndex*/ ) const |
|
418 { |
|
419 // No UI list command items are supported by this control. |
|
420 MPbk2UiControlCmdItem* item = NULL; // For the compiler |
|
421 return *item; // For the compiler |
|
422 } |
|
423 |
|
424 const MPbk2UiControlCmdItem* CPsu2OwnNumberControl::FocusedCommandItem() const |
|
425 { |
|
426 return NULL; |
|
427 } |
|
428 |
|
429 void CPsu2OwnNumberControl::DeleteCommandItemL( TInt /*aIndex*/ ) |
|
430 { |
|
431 // Do nothing |
|
432 } |
|
433 |
|
434 void CPsu2OwnNumberControl::AddCommandItemL(MPbk2UiControlCmdItem* /*aCommand*/, TInt /*aIndex*/) |
|
435 { |
|
436 //Do nothing, since there shouldn't be any command items in this state. |
|
437 } |
|
438 |
|
439 // -------------------------------------------------------------------------- |
|
440 // CPsu2OwnNumberControl::DynInitMenuPaneL |
|
441 // -------------------------------------------------------------------------- |
|
442 // |
|
443 void CPsu2OwnNumberControl::DynInitMenuPaneL( |
|
444 TInt /*aResourceId*/, |
|
445 CEikMenuPane* /*aMenuPane*/ ) const |
|
446 { |
|
447 // Do nothing |
|
448 } |
|
449 |
|
450 // -------------------------------------------------------------------------- |
|
451 // CPsu2OwnNumberControl::ProcessCommandL |
|
452 // -------------------------------------------------------------------------- |
|
453 // |
|
454 void CPsu2OwnNumberControl::ProcessCommandL( TInt /*aCommandId*/ ) const |
|
455 { |
|
456 // Do nothing |
|
457 } |
|
458 |
|
459 // -------------------------------------------------------------------------- |
|
460 // CPsu2OwnNumberControl::UpdateAfterCommandExecution |
|
461 // -------------------------------------------------------------------------- |
|
462 // |
|
463 void CPsu2OwnNumberControl::UpdateAfterCommandExecution() |
|
464 { |
|
465 // Do nothing |
|
466 } |
|
467 |
|
468 // -------------------------------------------------------------------------- |
|
469 // CPsu2OwnNumberControl::GetMenuFilteringFlagsL |
|
470 // -------------------------------------------------------------------------- |
|
471 // |
|
472 TInt CPsu2OwnNumberControl::GetMenuFilteringFlagsL() const |
|
473 { |
|
474 // Do nothing |
|
475 return 0; |
|
476 } |
|
477 |
|
478 // -------------------------------------------------------------------------- |
|
479 // CPsu2OwnNumberControl::ControlStateL |
|
480 // -------------------------------------------------------------------------- |
|
481 // |
|
482 CPbk2ViewState* CPsu2OwnNumberControl::ControlStateL() const |
|
483 { |
|
484 // Do nothing |
|
485 return NULL; |
|
486 } |
|
487 |
|
488 // -------------------------------------------------------------------------- |
|
489 // CPsu2OwnNumberControl::RestoreControlStateL |
|
490 // -------------------------------------------------------------------------- |
|
491 // |
|
492 void CPsu2OwnNumberControl::RestoreControlStateL( |
|
493 CPbk2ViewState* /*aState*/ ) |
|
494 { |
|
495 // Do nothing |
|
496 } |
|
497 |
|
498 // -------------------------------------------------------------------------- |
|
499 // CPsu2OwnNumberControl::FindTextL |
|
500 // -------------------------------------------------------------------------- |
|
501 // |
|
502 const TDesC& CPsu2OwnNumberControl::FindTextL() |
|
503 { |
|
504 // No find box in this control |
|
505 return KNullDesC; |
|
506 } |
|
507 |
|
508 // -------------------------------------------------------------------------- |
|
509 // CPsu2OwnNumberControl::ResetFindL |
|
510 // -------------------------------------------------------------------------- |
|
511 // |
|
512 void CPsu2OwnNumberControl::ResetFindL() |
|
513 { |
|
514 // Do nothing |
|
515 } |
|
516 |
|
517 // -------------------------------------------------------------------------- |
|
518 // CPsu2OwnNumberControl::ShowThumbnail |
|
519 // -------------------------------------------------------------------------- |
|
520 // |
|
521 void CPsu2OwnNumberControl::ShowThumbnail() |
|
522 { |
|
523 // Do nothing |
|
524 } |
|
525 |
|
526 // -------------------------------------------------------------------------- |
|
527 // CPsu2OwnNumberControl::HideThumbnail |
|
528 // -------------------------------------------------------------------------- |
|
529 // |
|
530 void CPsu2OwnNumberControl::HideThumbnail() |
|
531 { |
|
532 // Do nothing |
|
533 } |
|
534 |
|
535 // -------------------------------------------------------------------------- |
|
536 // CPsu2OwnNumberControl::SetBlank |
|
537 // -------------------------------------------------------------------------- |
|
538 // |
|
539 void CPsu2OwnNumberControl::SetBlank( |
|
540 TBool /*aBlank*/ ) |
|
541 { |
|
542 // Do nothing |
|
543 } |
|
544 |
|
545 // -------------------------------------------------------------------------- |
|
546 // CPsu2OwnNumberControl::RegisterCommand |
|
547 // -------------------------------------------------------------------------- |
|
548 // |
|
549 void CPsu2OwnNumberControl::RegisterCommand( |
|
550 MPbk2Command* /*aCommand*/ ) |
|
551 { |
|
552 // Do nothing |
|
553 } |
|
554 |
|
555 // -------------------------------------------------------------------------- |
|
556 // CPsu2OwnNumberControl::SetTextL |
|
557 // -------------------------------------------------------------------------- |
|
558 // |
|
559 void CPsu2OwnNumberControl::SetTextL( const TDesC& aText ) |
|
560 { |
|
561 iListBox->View()->SetListEmptyTextL( aText ); |
|
562 } |
|
563 |
|
564 // -------------------------------------------------------------------------- |
|
565 // CPsu2OwnNumberControl::ContactUiControlExtension |
|
566 // -------------------------------------------------------------------------- |
|
567 // |
|
568 TAny* CPsu2OwnNumberControl::ContactUiControlExtension(TUid aExtensionUid ) |
|
569 { |
|
570 if( aExtensionUid == KMPbk2ContactUiControlExtension2Uid ) |
|
571 { |
|
572 return static_cast<MPbk2ContactUiControl2*>( this ); |
|
573 } |
|
574 |
|
575 return NULL; |
|
576 } |
|
577 |
|
578 // End of File |