|
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 names list filtered state. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "CPbk2NamesListFilteredState.h" |
|
21 |
|
22 // Phonebook 2 |
|
23 #include "CPbk2ContactViewListBox.h" |
|
24 #include "MPbk2FilteredViewStack.h" |
|
25 #include "MPbk2UiControlEventSender.h" |
|
26 #include "CPbk2NamesListControl.h" |
|
27 #include "CPbk2FindStringSplitter.h" |
|
28 #include <MPbk2ControlObserver.h> |
|
29 #include <Pbk2MenuFilteringFlags.hrh> |
|
30 #include <MPbk2Command.h> |
|
31 #include "CPbk2AdaptiveSearchGridFiller.h" |
|
32 #include "CPbk2PredictiveSearchFilter.h" |
|
33 #include "TPbk2FindTextUtil.h" |
|
34 #include "PmuCommands.hrh" // For accessing EPmuCmdCascadingBackup |
|
35 #include "Pbk2USimUI.hrh" // For accessing EPsu2CmdCascadingSimMemory |
|
36 #include <Pbk2Commands.hrh> |
|
37 |
|
38 // System includes |
|
39 #include <eikmenup.h> |
|
40 #include <barsread.h> // TResourceReader |
|
41 #include <aknsfld.h> // CAknSearchField |
|
42 |
|
43 // Debugging headers |
|
44 #include <Pbk2Debug.h> |
|
45 |
|
46 /// Unnamed namespace for local definitions |
|
47 namespace { |
|
48 |
|
49 const TInt KNumberOfContacts = 0; |
|
50 const TInt KNumberOfControls = 2; // listbox and findbox |
|
51 |
|
52 #ifdef _DEBUG |
|
53 enum TPanicCode |
|
54 { |
|
55 EPanicLogic_FindTextL = 1, |
|
56 EPanicLogic_ComponentControl, |
|
57 EPreCond_UpdateFindResultL |
|
58 }; |
|
59 |
|
60 void Panic(TPanicCode aReason) |
|
61 { |
|
62 _LIT(KPanicText, "CPbk2NamesListFilteredState"); |
|
63 User::Panic(KPanicText, aReason); |
|
64 } |
|
65 |
|
66 #endif // _DEBUG |
|
67 |
|
68 } /// namespace |
|
69 |
|
70 |
|
71 // -------------------------------------------------------------------------- |
|
72 // CPbk2NamesListFilteredState::CPbk2NamesListFilteredState |
|
73 // -------------------------------------------------------------------------- |
|
74 // |
|
75 inline CPbk2NamesListFilteredState::CPbk2NamesListFilteredState( |
|
76 const CCoeControl* aParent, |
|
77 CPbk2ContactViewListBox& aListBox, |
|
78 MPbk2FilteredViewStack& aViewStack, |
|
79 CAknSearchField* aFindBox, |
|
80 MPbk2UiControlEventSender& aEventSender, |
|
81 MPbk2ContactNameFormatter& aNameFormatter, |
|
82 CPbk2PredictiveSearchFilter& aSearchFilter, |
|
83 RPointerArray<MPbk2UiControlCmdItem>& aCommandItems ) : |
|
84 iParent(*aParent), |
|
85 iListBox(aListBox), |
|
86 iViewStack(aViewStack), |
|
87 iFindBox(aFindBox), |
|
88 iEventSender( aEventSender ), |
|
89 iNameFormatter( aNameFormatter ), |
|
90 iSearchFilter( aSearchFilter ), |
|
91 iCommandItems( aCommandItems ) |
|
92 { |
|
93 } |
|
94 |
|
95 // -------------------------------------------------------------------------- |
|
96 // CPbk2NamesListFilteredState::~CPbk2NamesListFilteredState |
|
97 // -------------------------------------------------------------------------- |
|
98 // |
|
99 CPbk2NamesListFilteredState::~CPbk2NamesListFilteredState() |
|
100 { |
|
101 if (iCommand) |
|
102 { |
|
103 // inform the command that the control is deleted |
|
104 iCommand->ResetUiControl(*this); |
|
105 } |
|
106 delete iFindTextBuf; |
|
107 delete iStringArray; |
|
108 delete iStringSplitter; |
|
109 delete iAdaptiveSearchGridFiller; |
|
110 } |
|
111 |
|
112 // -------------------------------------------------------------------------- |
|
113 // CPbk2NamesListFilteredState::NewL |
|
114 // -------------------------------------------------------------------------- |
|
115 // |
|
116 CPbk2NamesListFilteredState* CPbk2NamesListFilteredState::NewLC |
|
117 ( const CCoeControl* aParent, CPbk2ContactViewListBox& aListBox, |
|
118 MPbk2FilteredViewStack& aViewStack, CAknSearchField* aFindBox, |
|
119 MPbk2UiControlEventSender& aEventSender, |
|
120 MPbk2ContactNameFormatter& aNameFormatter, |
|
121 CPbk2PredictiveSearchFilter& aSearchFilter, |
|
122 RPointerArray<MPbk2UiControlCmdItem>& aCommandItems ) |
|
123 { |
|
124 CPbk2NamesListFilteredState* self = |
|
125 new ( ELeave ) CPbk2NamesListFilteredState |
|
126 ( aParent, aListBox, aViewStack, aFindBox, aEventSender, aNameFormatter, aSearchFilter, aCommandItems ); |
|
127 CleanupStack::PushL(self); |
|
128 self->ConstructL(); |
|
129 return self; |
|
130 } |
|
131 |
|
132 // -------------------------------------------------------------------------- |
|
133 // CPbk2NamesListFilteredState::ConstructL |
|
134 // -------------------------------------------------------------------------- |
|
135 // |
|
136 void CPbk2NamesListFilteredState::ConstructL() |
|
137 { |
|
138 iStringSplitter = CPbk2FindStringSplitter::NewL( iNameFormatter ); |
|
139 if( iFindBox ) |
|
140 { |
|
141 iAdaptiveSearchGridFiller = CPbk2AdaptiveSearchGridFiller::NewL( *iFindBox, iNameFormatter ); |
|
142 } |
|
143 } |
|
144 |
|
145 // -------------------------------------------------------------------------- |
|
146 // CPbk2NamesListFilteredState::UnsubscribeCmdItemsVisibility |
|
147 // -------------------------------------------------------------------------- |
|
148 // |
|
149 void CPbk2NamesListFilteredState::UnsubscribeCmdItemsVisibility() const |
|
150 { |
|
151 for ( TInt i = 0; i < iCommandItems.Count(); ++i ) |
|
152 { |
|
153 iCommandItems[i]->SetVisibilityObserver( NULL ); |
|
154 } |
|
155 } |
|
156 |
|
157 // -------------------------------------------------------------------------- |
|
158 // CPbk2NamesListFilteredState::SubscribeCmdItemsVisibility |
|
159 // -------------------------------------------------------------------------- |
|
160 // |
|
161 void CPbk2NamesListFilteredState::SubscribeCmdItemsVisibility() |
|
162 { |
|
163 for ( TInt i = 0; i < iCommandItems.Count(); ++i ) |
|
164 { |
|
165 iCommandItems[i]->SetVisibilityObserver( this ); |
|
166 } |
|
167 } |
|
168 |
|
169 // -------------------------------------------------------------------------- |
|
170 // CPbk2NamesListFilteredState::ActivateStateL |
|
171 // -------------------------------------------------------------------------- |
|
172 // |
|
173 void CPbk2NamesListFilteredState::ActivateStateL() |
|
174 { |
|
175 AllowCommandsToShowThemselves( ETrue ); |
|
176 UpdateAdaptiveSearchGridL(); |
|
177 } |
|
178 |
|
179 // -------------------------------------------------------------------------- |
|
180 // CPbk2NamesListFilteredState::DeactivateState |
|
181 // -------------------------------------------------------------------------- |
|
182 // |
|
183 void CPbk2NamesListFilteredState::DeactivateState() |
|
184 { |
|
185 AllowCommandsToShowThemselves( EFalse ); |
|
186 |
|
187 // Stop creating adaptive search grid. |
|
188 if (iAdaptiveSearchGridFiller) |
|
189 { |
|
190 if (iAdaptiveSearchGridFiller->IsActive()) |
|
191 { |
|
192 iAdaptiveSearchGridFiller->StopFilling(); |
|
193 } |
|
194 } |
|
195 } |
|
196 |
|
197 // -------------------------------------------------------------------------- |
|
198 // CPbk2NamesListFilteredState::CountComponentControls |
|
199 // -------------------------------------------------------------------------- |
|
200 // |
|
201 TInt CPbk2NamesListFilteredState::CountComponentControls() const |
|
202 { |
|
203 TInt numberOfControls( KNumberOfControls ); |
|
204 if ( !iFindBox ) |
|
205 { |
|
206 --numberOfControls; |
|
207 } |
|
208 return numberOfControls; |
|
209 } |
|
210 |
|
211 // -------------------------------------------------------------------------- |
|
212 // CPbk2NamesListFilteredState::ComponentControl |
|
213 // -------------------------------------------------------------------------- |
|
214 // |
|
215 CCoeControl* CPbk2NamesListFilteredState::ComponentControl( TInt aIndex ) const |
|
216 { |
|
217 switch ( aIndex ) |
|
218 { |
|
219 case 0: |
|
220 { |
|
221 return &iListBox; |
|
222 } |
|
223 case 1: |
|
224 { |
|
225 return iFindBox; |
|
226 } |
|
227 default: |
|
228 { |
|
229 // Illegal state |
|
230 __ASSERT_DEBUG(EFalse, Panic(EPanicLogic_ComponentControl)); |
|
231 return NULL; |
|
232 } |
|
233 } |
|
234 } |
|
235 |
|
236 // -------------------------------------------------------------------------- |
|
237 // CPbk2NamesListFilteredState::SizeChanged |
|
238 // -------------------------------------------------------------------------- |
|
239 // |
|
240 void CPbk2NamesListFilteredState::SizeChanged() |
|
241 { |
|
242 const TRect rect(iParent.Rect()); |
|
243 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
244 ("CPbk2NamesListFilteredState::SizeChanged(0x%x), rect=(%d,%d,%d,%d)"), |
|
245 this, rect.iTl.iX, rect.iTl.iY, rect.iBr.iX, rect.iBr.iY); |
|
246 |
|
247 if ( iFindBox ) |
|
248 { |
|
249 AknLayoutUtils::LayoutControl(&iListBox, rect, |
|
250 AKN_LAYOUT_WINDOW_list_gen_pane(1)); |
|
251 |
|
252 AknLayoutUtils::LayoutControl( iFindBox, rect, |
|
253 AKN_LAYOUT_WINDOW_find_pane); |
|
254 |
|
255 if (iFindBox->IsVisible() && iListBox.IsVisible()) |
|
256 { |
|
257 iFindBox->SetLinePos(EABColumn); |
|
258 } |
|
259 } |
|
260 else |
|
261 { |
|
262 AknLayoutUtils::LayoutControl(&iListBox, rect, |
|
263 AKN_LAYOUT_WINDOW_list_gen_pane(0)); |
|
264 } |
|
265 } |
|
266 |
|
267 // -------------------------------------------------------------------------- |
|
268 // CPbk2NamesListFilteredState::MakeComponentsVisible |
|
269 // -------------------------------------------------------------------------- |
|
270 // |
|
271 void CPbk2NamesListFilteredState::MakeComponentsVisible(TBool aVisible) |
|
272 { |
|
273 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
274 ("CPbk2NamesListFilteredState::MakeComponentsVisible(0x%x,%d)"), |
|
275 this, aVisible); |
|
276 |
|
277 iListBox.MakeVisible(aVisible); |
|
278 if ( iFindBox ) |
|
279 { |
|
280 if ( (iFindBox->IsVisible()&&!aVisible) || |
|
281 (!iFindBox->IsVisible()&&aVisible) ) |
|
282 { |
|
283 iFindBox->MakeVisible(aVisible); |
|
284 } |
|
285 } |
|
286 } |
|
287 |
|
288 // -------------------------------------------------------------------------- |
|
289 // CPbk2NamesListFilteredState::ActivateL |
|
290 // -------------------------------------------------------------------------- |
|
291 // |
|
292 void CPbk2NamesListFilteredState::ActivateL() |
|
293 { |
|
294 if ( iFindBox ) |
|
295 { |
|
296 CEikEdwin& findEditor = iFindBox->Editor(); |
|
297 findEditor.SetCursorPosL(findEditor.TextLength(), EFalse); |
|
298 } |
|
299 } |
|
300 |
|
301 // -------------------------------------------------------------------------- |
|
302 // CPbk2NamesListFilteredState::Draw |
|
303 // -------------------------------------------------------------------------- |
|
304 // |
|
305 void CPbk2NamesListFilteredState::Draw |
|
306 (const TRect& aRect, CWindowGc& /*aGc*/) const |
|
307 { |
|
308 PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING( |
|
309 "CPbk2NamesListFilteredState::Draw(0x%x, TRect(%d,%d,%d,%d))"), |
|
310 this, aRect.iTl.iX, aRect.iTl.iY, aRect.iBr.iX, aRect.iBr.iY); |
|
311 } |
|
312 |
|
313 // -------------------------------------------------------------------------- |
|
314 // CPbk2NamesListFilteredState::OfferKeyEventL |
|
315 // -------------------------------------------------------------------------- |
|
316 // |
|
317 TKeyResponse CPbk2NamesListFilteredState::OfferKeyEventL |
|
318 ( const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
319 { |
|
320 TKeyResponse result( EKeyWasNotConsumed ); |
|
321 if ( iFindBox ) |
|
322 { |
|
323 //If the FindBox is locked then dont offer the event to the findbox |
|
324 if (!iSearchFilter.IsLocked()) |
|
325 { |
|
326 // Offer the key event first to findbox |
|
327 result = iFindBox->OfferKeyEventL( aKeyEvent, aType ); |
|
328 } |
|
329 else |
|
330 { |
|
331 //If FindPane is locked, then forward only the backspace key. |
|
332 if ( aKeyEvent.iCode == EKeyBackspace ) |
|
333 { |
|
334 // Offer the key event first to findbox |
|
335 result = iFindBox->OfferKeyEventL( aKeyEvent, aType ); |
|
336 } |
|
337 } |
|
338 } |
|
339 |
|
340 // And then offer the event to listbox if necessary |
|
341 if (result == EKeyWasNotConsumed) |
|
342 { |
|
343 result = iListBox.OfferKeyEventL(aKeyEvent, aType); |
|
344 } |
|
345 |
|
346 return result; |
|
347 } |
|
348 |
|
349 // -------------------------------------------------------------------------- |
|
350 // CPbk2NamesListFilteredState::HandlePointerEventL |
|
351 // -------------------------------------------------------------------------- |
|
352 // |
|
353 void CPbk2NamesListFilteredState::HandlePointerEventL |
|
354 ( const TPointerEvent& aPointerEvent ) |
|
355 { |
|
356 iSearchFieldPointed = EFalse; |
|
357 if ( iFindBox ) |
|
358 { |
|
359 if ( iFindBox->Rect().Contains( aPointerEvent.iPosition ) ) |
|
360 { |
|
361 iFindBox->HandlePointerEventL( aPointerEvent ); |
|
362 iSearchFieldPointed = ETrue; |
|
363 } |
|
364 } |
|
365 |
|
366 TInt previousItemIndex = iListBox.CurrentItemIndex(); |
|
367 iListBox.HandlePointerEventL( aPointerEvent ); |
|
368 |
|
369 // Handle focus change when dragging |
|
370 if ( previousItemIndex != iListBox.CurrentItemIndex() && |
|
371 aPointerEvent.iType == TPointerEvent::EDrag ) |
|
372 { |
|
373 HandleFocusChangeL(); |
|
374 } |
|
375 } |
|
376 |
|
377 // -------------------------------------------------------------------------- |
|
378 // CPbk2NamesListFilteredState::NamesListState |
|
379 // -------------------------------------------------------------------------- |
|
380 // |
|
381 TInt CPbk2NamesListFilteredState::NamesListState() const |
|
382 { |
|
383 return CPbk2NamesListControl::EStateFiltered; |
|
384 } |
|
385 |
|
386 // -------------------------------------------------------------------------- |
|
387 // CPbk2NamesListFilteredState::HandleContactViewEventL |
|
388 // -------------------------------------------------------------------------- |
|
389 // |
|
390 void CPbk2NamesListFilteredState::HandleContactViewEventL |
|
391 ( TInt aEvent, TInt aIndex ) |
|
392 { |
|
393 // need to calculate list index from contact |
|
394 // view index |
|
395 TInt listIndex = CommandItemCount() + aIndex; |
|
396 HandleListboxEventL(aEvent, listIndex, EFalse ); |
|
397 /// iListBox.HandleEventL( aEvent, aIndex ); |
|
398 } |
|
399 |
|
400 // -------------------------------------------------------------------------- |
|
401 // CPbk2NamesListFilteredState::HandleCommandEventL |
|
402 // -------------------------------------------------------------------------- |
|
403 // |
|
404 void CPbk2NamesListFilteredState::HandleCommandEventL |
|
405 (TInt aEvent, TInt /* aCommandIndex */) |
|
406 { |
|
407 HandleListboxEventL(aEvent, 0, ETrue ); |
|
408 } |
|
409 |
|
410 // -------------------------------------------------------------------------- |
|
411 // CPbk2NamesListFilteredState::HandleListboxEventL |
|
412 // -------------------------------------------------------------------------- |
|
413 // |
|
414 void CPbk2NamesListFilteredState::HandleListboxEventL |
|
415 (TInt aEvent, TInt aListboxIndex |
|
416 , TBool /*aMantainFocus*/) |
|
417 { |
|
418 iListBox.HandleEventL( aEvent, aListboxIndex ); |
|
419 iParent.DrawDeferred(); |
|
420 HandleFocusChangeL(); |
|
421 } |
|
422 |
|
423 // -------------------------------------------------------------------------- |
|
424 // CPbk2NamesListFilteredState::CoeControl |
|
425 // -------------------------------------------------------------------------- |
|
426 // |
|
427 CCoeControl& CPbk2NamesListFilteredState::CoeControl() |
|
428 { |
|
429 return const_cast<CCoeControl&>(iParent); |
|
430 } |
|
431 |
|
432 // -------------------------------------------------------------------------- |
|
433 // CPbk2NamesListFilteredState::HandleControlEventL |
|
434 // -------------------------------------------------------------------------- |
|
435 // |
|
436 void CPbk2NamesListFilteredState::HandleControlEventL( |
|
437 CCoeControl* aControl, |
|
438 MCoeControlObserver::TCoeEvent aEventType, TInt /*aParam*/ ) |
|
439 { |
|
440 if ( aEventType == MCoeControlObserver::EEventStateChanged ) |
|
441 { |
|
442 if ( aControl == iFindBox ) |
|
443 { |
|
444 UpdateFindResultL(); |
|
445 } |
|
446 } |
|
447 } |
|
448 |
|
449 // -------------------------------------------------------------------------- |
|
450 // CPbk2NamesListFilteredState::TopContactL |
|
451 // -------------------------------------------------------------------------- |
|
452 // |
|
453 const MVPbkViewContact* CPbk2NamesListFilteredState::TopContactL() |
|
454 { |
|
455 return NULL; |
|
456 } |
|
457 |
|
458 // -------------------------------------------------------------------------- |
|
459 // CPbk2NamesListFilteredState::ParentControl |
|
460 // -------------------------------------------------------------------------- |
|
461 // |
|
462 MPbk2ContactUiControl* CPbk2NamesListFilteredState::ParentControl() const |
|
463 { |
|
464 // Names list control does not have a parent control |
|
465 return NULL; |
|
466 } |
|
467 |
|
468 // -------------------------------------------------------------------------- |
|
469 // CPbk2NamesListFilteredState::NumberOfContacts |
|
470 // -------------------------------------------------------------------------- |
|
471 // |
|
472 TInt CPbk2NamesListFilteredState::NumberOfContacts() const |
|
473 { |
|
474 // The listbox can also have command items. |
|
475 TInt result = iListBox.NumberOfItems() - CommandItemCount(); |
|
476 if ( result < 0 ) |
|
477 { |
|
478 result = KNumberOfContacts; // No contacts |
|
479 } |
|
480 return result; |
|
481 } |
|
482 |
|
483 // -------------------------------------------------------------------------- |
|
484 // CPbk2NamesListFilteredState::FocusedContactL |
|
485 // -------------------------------------------------------------------------- |
|
486 // |
|
487 const MVPbkBaseContact* CPbk2NamesListFilteredState::FocusedContactL() const |
|
488 { |
|
489 return NULL; |
|
490 } |
|
491 |
|
492 // -------------------------------------------------------------------------- |
|
493 // CPbk2NamesListFilteredState::FocusedViewContactL |
|
494 // -------------------------------------------------------------------------- |
|
495 // |
|
496 const MVPbkViewContact* |
|
497 CPbk2NamesListFilteredState::FocusedViewContactL() const |
|
498 { |
|
499 return NULL; |
|
500 } |
|
501 |
|
502 // -------------------------------------------------------------------------- |
|
503 // CPbk2NamesListFilteredState::FocusedStoreContact |
|
504 // -------------------------------------------------------------------------- |
|
505 // |
|
506 const MVPbkStoreContact* |
|
507 CPbk2NamesListFilteredState::FocusedStoreContact() const |
|
508 { |
|
509 return NULL; |
|
510 } |
|
511 |
|
512 // -------------------------------------------------------------------------- |
|
513 // CPbk2NamesListFilteredState::SetFocusedContactL |
|
514 // -------------------------------------------------------------------------- |
|
515 // |
|
516 void CPbk2NamesListFilteredState::SetFocusedContactL |
|
517 ( const MVPbkBaseContact& /*aContact*/ ) |
|
518 { |
|
519 // Do nothing |
|
520 } |
|
521 |
|
522 // -------------------------------------------------------------------------- |
|
523 // CPbk2NamesListFilteredState::SetFocusedContactL |
|
524 // -------------------------------------------------------------------------- |
|
525 // |
|
526 void CPbk2NamesListFilteredState::SetFocusedContactL |
|
527 ( const MVPbkContactBookmark& /*aContactBookmark*/ ) |
|
528 { |
|
529 // Do nothing |
|
530 } |
|
531 |
|
532 // -------------------------------------------------------------------------- |
|
533 // CPbk2NamesListFilteredState::SetFocusedContactL |
|
534 // -------------------------------------------------------------------------- |
|
535 // |
|
536 void CPbk2NamesListFilteredState::SetFocusedContactL |
|
537 ( const MVPbkContactLink& /*aContactLink*/ ) |
|
538 { |
|
539 // Do nothing |
|
540 } |
|
541 |
|
542 // -------------------------------------------------------------------------- |
|
543 // CPbk2NamesListFilteredState::FocusedContactIndex |
|
544 // -------------------------------------------------------------------------- |
|
545 // |
|
546 TInt CPbk2NamesListFilteredState::FocusedContactIndex() const |
|
547 { |
|
548 // The result is a view index. There is an offset between listbox indexes |
|
549 // and view indexes. |
|
550 |
|
551 TInt viewIndex = KErrNotFound; |
|
552 const TInt currentListboxIndex = iListBox.CurrentItemIndex(); |
|
553 const TInt commandCount = CommandItemCount(); |
|
554 // Is the focus on a contact or on a command item? Check: |
|
555 if ( currentListboxIndex >= commandCount ) |
|
556 { |
|
557 // Yes, the focus is on a contact. |
|
558 // Need to map from listbox indexes to view indexes. |
|
559 viewIndex = currentListboxIndex - commandCount; |
|
560 } |
|
561 return viewIndex; |
|
562 } |
|
563 |
|
564 // -------------------------------------------------------------------------- |
|
565 // CPbk2NamesListFilteredState::SetFocusedContactIndex |
|
566 // -------------------------------------------------------------------------- |
|
567 // |
|
568 void CPbk2NamesListFilteredState::SetFocusedContactIndexL( TInt /*aIndex*/ ) |
|
569 { |
|
570 // Do nothing |
|
571 } |
|
572 |
|
573 // -------------------------------------------------------------------------- |
|
574 // CPbk2NamesListFilteredState::NumberOfContactFields |
|
575 // -------------------------------------------------------------------------- |
|
576 // |
|
577 TInt CPbk2NamesListFilteredState::NumberOfContactFields() const |
|
578 { |
|
579 return KErrNotSupported; |
|
580 } |
|
581 |
|
582 // -------------------------------------------------------------------------- |
|
583 // CPbk2NamesListFilteredState::FocusedField |
|
584 // -------------------------------------------------------------------------- |
|
585 // |
|
586 const MVPbkBaseContactField* |
|
587 CPbk2NamesListFilteredState::FocusedField() const |
|
588 { |
|
589 return NULL; |
|
590 } |
|
591 |
|
592 // -------------------------------------------------------------------------- |
|
593 // CPbk2NamesListFilteredState::FocusedFieldIndex |
|
594 // -------------------------------------------------------------------------- |
|
595 // |
|
596 TInt CPbk2NamesListFilteredState::FocusedFieldIndex() const |
|
597 { |
|
598 return KErrNotFound; |
|
599 } |
|
600 |
|
601 // -------------------------------------------------------------------------- |
|
602 // CPbk2NamesListFilteredState::SetFocusedFieldIndex |
|
603 // -------------------------------------------------------------------------- |
|
604 // |
|
605 void CPbk2NamesListFilteredState::SetFocusedFieldIndex( TInt /*aIndex*/ ) |
|
606 { |
|
607 // Do nothing |
|
608 } |
|
609 |
|
610 // -------------------------------------------------------------------------- |
|
611 // CPbk2NamesListFilteredState::ContactsMarked |
|
612 // -------------------------------------------------------------------------- |
|
613 // |
|
614 TBool CPbk2NamesListFilteredState::ContactsMarked() const |
|
615 { |
|
616 return EFalse; |
|
617 } |
|
618 |
|
619 // -------------------------------------------------------------------------- |
|
620 // CPbk2NamesListFilteredState::SelectedContactsL |
|
621 // -------------------------------------------------------------------------- |
|
622 // |
|
623 MVPbkContactLinkArray* CPbk2NamesListFilteredState::SelectedContactsL() const |
|
624 { |
|
625 return NULL; |
|
626 } |
|
627 |
|
628 // -------------------------------------------------------------------------- |
|
629 // CPbk2NamesListFilteredState::SelectedContactsOrFocusedContactL |
|
630 // -------------------------------------------------------------------------- |
|
631 // |
|
632 MVPbkContactLinkArray* CPbk2NamesListFilteredState:: |
|
633 SelectedContactsOrFocusedContactL() const |
|
634 { |
|
635 return NULL; |
|
636 } |
|
637 |
|
638 // -------------------------------------------------------------------------- |
|
639 // CPbk2NamesListFilteredState::SelectedContactsIteratorL |
|
640 // -------------------------------------------------------------------------- |
|
641 // |
|
642 MPbk2ContactLinkIterator* |
|
643 CPbk2NamesListFilteredState::SelectedContactsIteratorL() const |
|
644 { |
|
645 return NULL; |
|
646 } |
|
647 |
|
648 // -------------------------------------------------------------------------- |
|
649 // CPbk2NamesListFilteredState::SelectedContactStoresL |
|
650 // -------------------------------------------------------------------------- |
|
651 // |
|
652 CArrayPtr<MVPbkContactStore>* |
|
653 CPbk2NamesListFilteredState::SelectedContactStoresL() const |
|
654 { |
|
655 // This is not a state of the contact store control |
|
656 return NULL; |
|
657 } |
|
658 |
|
659 // -------------------------------------------------------------------------- |
|
660 // CPbk2NamesListFilteredState::ClearMarks |
|
661 // -------------------------------------------------------------------------- |
|
662 // |
|
663 void CPbk2NamesListFilteredState::ClearMarks() |
|
664 { |
|
665 // Do nothing |
|
666 } |
|
667 |
|
668 // -------------------------------------------------------------------------- |
|
669 // CPbk2NamesListFilteredState::SetSelectedContactL |
|
670 // -------------------------------------------------------------------------- |
|
671 // |
|
672 void CPbk2NamesListFilteredState::SetSelectedContactL( |
|
673 TInt /*aIndex*/, TBool /*aSelected*/) |
|
674 { |
|
675 // Do nothing |
|
676 } |
|
677 |
|
678 // -------------------------------------------------------------------------- |
|
679 // CPbk2NamesListFilteredState::SetSelectedContactL |
|
680 // -------------------------------------------------------------------------- |
|
681 // |
|
682 void CPbk2NamesListFilteredState::SetSelectedContactL( |
|
683 const MVPbkContactBookmark& /*aContactBookmark*/, |
|
684 TBool /*aSelected*/ ) |
|
685 { |
|
686 // Do nothing |
|
687 } |
|
688 |
|
689 // -------------------------------------------------------------------------- |
|
690 // CPbk2NamesListFilteredState::SetSelectedContactL |
|
691 // -------------------------------------------------------------------------- |
|
692 // |
|
693 void CPbk2NamesListFilteredState::SetSelectedContactL( |
|
694 const MVPbkContactLink& /*aContactLink*/, |
|
695 TBool /*aSelected*/ ) |
|
696 { |
|
697 // Do nothing |
|
698 } |
|
699 |
|
700 // -------------------------------------------------------------------------- |
|
701 // CPbk2NamesListFilteredState::CommandItemCount |
|
702 // -------------------------------------------------------------------------- |
|
703 // |
|
704 TInt CPbk2NamesListFilteredState::CommandItemCount() const |
|
705 { |
|
706 // Some of the commands might be disabled. Don't count those. |
|
707 TInt enabledCommandCount = 0; |
|
708 for ( TInt n = 0; n < iCommandItems.Count(); ++n ) |
|
709 { |
|
710 if ( iCommandItems[ n ]->IsEnabled() ) |
|
711 { |
|
712 enabledCommandCount++; |
|
713 } |
|
714 } |
|
715 return enabledCommandCount; |
|
716 } |
|
717 |
|
718 // -------------------------------------------------------------------------- |
|
719 // CPbk2NamesListFilteredState::CommandItemAt |
|
720 // -------------------------------------------------------------------------- |
|
721 // |
|
722 const MPbk2UiControlCmdItem& |
|
723 CPbk2NamesListFilteredState::CommandItemAt( TInt aIndex ) const |
|
724 { |
|
725 // Some of the commands might be disabled. Skip those. |
|
726 TInt enabledCount = 0; |
|
727 TInt indexOfResult = KErrNotFound; |
|
728 for ( TInt n = 0; n < iCommandItems.Count()&& indexOfResult == KErrNotFound; ++n ) |
|
729 |
|
730 { |
|
731 if ( iCommandItems[ n ]->IsEnabled() ) |
|
732 { |
|
733 enabledCount++; |
|
734 if ( enabledCount-1 == aIndex ) |
|
735 { |
|
736 indexOfResult = n; |
|
737 } |
|
738 } |
|
739 } |
|
740 return *iCommandItems[ indexOfResult ]; |
|
741 } |
|
742 |
|
743 // -------------------------------------------------------------------------- |
|
744 // CPbk2NamesListFilteredState::FocusedCommandItem |
|
745 // -------------------------------------------------------------------------- |
|
746 // |
|
747 const MPbk2UiControlCmdItem* |
|
748 CPbk2NamesListFilteredState::FocusedCommandItem() const |
|
749 { |
|
750 const MPbk2UiControlCmdItem* cmdItem = NULL; |
|
751 // Is the focus on a command item: |
|
752 TInt focusListIndex = iListBox.CurrentItemIndex(); |
|
753 const TInt commandItemCount = CommandItemCount(); |
|
754 if ( focusListIndex != KErrNotFound && focusListIndex < commandItemCount ) |
|
755 { |
|
756 // Yes it's a command item. |
|
757 cmdItem = &CommandItemAt(focusListIndex); |
|
758 } |
|
759 return cmdItem; |
|
760 } |
|
761 |
|
762 // -------------------------------------------------------------------------- |
|
763 // CPbk2NamesListFilteredState::DeleteCommandItemL |
|
764 // -------------------------------------------------------------------------- |
|
765 // |
|
766 void CPbk2NamesListFilteredState::DeleteCommandItemL( TInt /*aIndex*/ ) |
|
767 { |
|
768 // ownership & management of iCommandItems is wasted in names list |
|
769 // control. Do nothing here |
|
770 } |
|
771 |
|
772 // -------------------------------------------------------------------------- |
|
773 // CPbk2NamesListFilteredState::AddCommandItemL |
|
774 // -------------------------------------------------------------------------- |
|
775 // |
|
776 void CPbk2NamesListFilteredState::AddCommandItemL(MPbk2UiControlCmdItem* /*aCommand*/, TInt /*aIndex*/) |
|
777 { |
|
778 // ownership & management of iCommandItems is wasted in names list |
|
779 // control. Do nothing here |
|
780 } |
|
781 |
|
782 |
|
783 // -------------------------------------------------------------------------- |
|
784 // CPbk2NamesListFilteredState::DynInitMenuPaneL |
|
785 // -------------------------------------------------------------------------- |
|
786 // |
|
787 void CPbk2NamesListFilteredState::DynInitMenuPaneL( |
|
788 TInt aResourceId, CEikMenuPane* aMenuPane) const |
|
789 { |
|
790 AknSelectionService::HandleMarkableListDynInitMenuPane |
|
791 (aResourceId, aMenuPane, &iListBox); |
|
792 |
|
793 } |
|
794 |
|
795 // -------------------------------------------------------------------------- |
|
796 // CPbk2NamesListFilteredState::ProcessCommandL |
|
797 // -------------------------------------------------------------------------- |
|
798 // |
|
799 void CPbk2NamesListFilteredState::ProcessCommandL |
|
800 ( TInt /*aCommandId*/ ) const |
|
801 { |
|
802 // Do nothing |
|
803 } |
|
804 |
|
805 // -------------------------------------------------------------------------- |
|
806 // CPbk2NamesListFilteredState::UpdateAfterCommandExecution |
|
807 // -------------------------------------------------------------------------- |
|
808 // |
|
809 void CPbk2NamesListFilteredState::UpdateAfterCommandExecution() |
|
810 { |
|
811 if( iCommand ) |
|
812 { |
|
813 // reset command pointer, since command has finished |
|
814 iCommand->ResetUiControl( *this ); |
|
815 iCommand = NULL; |
|
816 } |
|
817 } |
|
818 |
|
819 // -------------------------------------------------------------------------- |
|
820 // CPbk2NamesListFilteredState::GetMenuFilteringFlagsL |
|
821 // -------------------------------------------------------------------------- |
|
822 // |
|
823 TInt CPbk2NamesListFilteredState::GetMenuFilteringFlagsL() const |
|
824 { |
|
825 // Filtered state is used when the search string does not match |
|
826 // to any of the contacts. |
|
827 return KPbk2ListContainsNoMarkedItems; |
|
828 } |
|
829 |
|
830 |
|
831 // -------------------------------------------------------------------------- |
|
832 // CPbk2NamesListFilteredState::ControlStateL |
|
833 // -------------------------------------------------------------------------- |
|
834 // |
|
835 CPbk2ViewState* CPbk2NamesListFilteredState::ControlStateL() const |
|
836 { |
|
837 // State objects do not handle control state changes |
|
838 return NULL; |
|
839 } |
|
840 |
|
841 // -------------------------------------------------------------------------- |
|
842 // CPbk2NamesListFilteredState::RestoreControlStateL |
|
843 // -------------------------------------------------------------------------- |
|
844 // |
|
845 void CPbk2NamesListFilteredState::RestoreControlStateL |
|
846 ( CPbk2ViewState* /*aState*/ ) |
|
847 { |
|
848 // State objects do not handle control state changes |
|
849 } |
|
850 |
|
851 // -------------------------------------------------------------------------- |
|
852 // CPbk2NamesListFilteredState::FindTextL |
|
853 // -------------------------------------------------------------------------- |
|
854 // |
|
855 const TDesC& CPbk2NamesListFilteredState::FindTextL() |
|
856 { |
|
857 if ( iFindBox ) |
|
858 { |
|
859 TPbk2FindTextUtil::EnsureFindTextBufSizeL( |
|
860 *iFindBox, |
|
861 &iFindTextBuf ); |
|
862 TPtr bufPtr = iFindTextBuf->Des(); |
|
863 iFindBox->GetSearchText(bufPtr); |
|
864 return *iFindTextBuf; |
|
865 } |
|
866 |
|
867 return KNullDesC; |
|
868 } |
|
869 |
|
870 |
|
871 // -------------------------------------------------------------------------- |
|
872 // CPbk2NamesListFilteredState::ResetFindL |
|
873 // -------------------------------------------------------------------------- |
|
874 // |
|
875 void CPbk2NamesListFilteredState::ResetFindL() |
|
876 { |
|
877 if ( iFindBox && iFindBox->TextLength() > 0 ) |
|
878 { |
|
879 iSearchFilter.ResetL(); |
|
880 iFindBox->ResetL(); |
|
881 iFindBox->DrawDeferred(); |
|
882 iViewStack.Reset(); |
|
883 } |
|
884 } |
|
885 |
|
886 // -------------------------------------------------------------------------- |
|
887 // CPbk2NamesListFilteredState::HideThumbnail |
|
888 // -------------------------------------------------------------------------- |
|
889 // |
|
890 void CPbk2NamesListFilteredState::HideThumbnail() |
|
891 { |
|
892 // Do nothing |
|
893 } |
|
894 |
|
895 // -------------------------------------------------------------------------- |
|
896 // CPbk2NamesListFilteredState::ShowThumbnail |
|
897 // -------------------------------------------------------------------------- |
|
898 // |
|
899 void CPbk2NamesListFilteredState::ShowThumbnail() |
|
900 { |
|
901 // Do nothing |
|
902 } |
|
903 |
|
904 // -------------------------------------------------------------------------- |
|
905 // CPbk2NamesListFilteredState::SetBlank |
|
906 // -------------------------------------------------------------------------- |
|
907 // |
|
908 void CPbk2NamesListFilteredState::SetBlank( TBool aBlank ) |
|
909 { |
|
910 if (!aBlank) |
|
911 { |
|
912 // Redraw |
|
913 iParent.DrawDeferred(); |
|
914 TRAPD( error, iListBox.UpdateScrollBarsL() ); |
|
915 if ( error != KErrNone ) |
|
916 { |
|
917 CCoeEnv::Static()->HandleError( error ); |
|
918 } |
|
919 } |
|
920 } |
|
921 |
|
922 // -------------------------------------------------------------------------- |
|
923 // CPbk2NamesListFilteredState::RegisterCommand |
|
924 // -------------------------------------------------------------------------- |
|
925 // |
|
926 void CPbk2NamesListFilteredState::RegisterCommand( |
|
927 MPbk2Command* aCommand) |
|
928 { |
|
929 iCommand = aCommand; |
|
930 } |
|
931 |
|
932 // -------------------------------------------------------------------------- |
|
933 // CPbk2NamesListFilteredState::SetTextL |
|
934 // -------------------------------------------------------------------------- |
|
935 // |
|
936 void CPbk2NamesListFilteredState::SetTextL( const TDesC& aText ) |
|
937 { |
|
938 iListBox.View()->SetListEmptyTextL( aText ); |
|
939 } |
|
940 |
|
941 // -------------------------------------------------------------------------- |
|
942 // CPbk2NamesListFilteredState::ContactUiControlExtension |
|
943 // -------------------------------------------------------------------------- |
|
944 // |
|
945 TAny* CPbk2NamesListFilteredState::ContactUiControlExtension(TUid aExtensionUid ) |
|
946 { |
|
947 if( aExtensionUid == KMPbk2ContactUiControlExtension2Uid ) |
|
948 { |
|
949 return static_cast<MPbk2ContactUiControl2*>( this ); |
|
950 } |
|
951 |
|
952 return NULL; |
|
953 } |
|
954 |
|
955 // -------------------------------------------------------------------------- |
|
956 // CPbk2NamesListFilteredState::UpdateFindResultL |
|
957 // -------------------------------------------------------------------------- |
|
958 // |
|
959 void CPbk2NamesListFilteredState::UpdateFindResultL() |
|
960 { |
|
961 TBuf <KSearchFieldLength> findPaneTxt( FindTextL() ); |
|
962 |
|
963 //First Forward the Find Pane text to the Search Filter before sending |
|
964 //the info to the viewstack |
|
965 if ( iSearchFilter.StartFindPaneInlineEditL( findPaneTxt ) ) |
|
966 { |
|
967 // If the control is in empty filtered state then the view stack must |
|
968 // contain at least one filtered view. Otherwise either the control |
|
969 // state is wrong or the stack state is not up to date. |
|
970 __ASSERT_DEBUG( iViewStack.Level() > 0, |
|
971 Panic( EPreCond_UpdateFindResultL ) ); |
|
972 |
|
973 // Extract the find text into array |
|
974 MDesCArray* temp = iStringSplitter->SplitTextIntoArrayL( findPaneTxt ); |
|
975 delete iStringArray; |
|
976 iStringArray = temp; |
|
977 |
|
978 iViewStack.UpdateFilterL( *iStringArray, NULL, EFalse ); |
|
979 } |
|
980 } |
|
981 |
|
982 // -------------------------------------------------------------------------- |
|
983 // CPbk2NamesListFilteredState::FocusedItemPointed |
|
984 // -------------------------------------------------------------------------- |
|
985 // |
|
986 TBool CPbk2NamesListFilteredState::FocusedItemPointed() |
|
987 { |
|
988 return iListBox.FocusedItemPointed(); |
|
989 } |
|
990 |
|
991 // -------------------------------------------------------------------------- |
|
992 // CPbk2NamesListFilteredState::FocusableItemPointed |
|
993 // -------------------------------------------------------------------------- |
|
994 // |
|
995 TBool CPbk2NamesListFilteredState::FocusableItemPointed() |
|
996 { |
|
997 return iListBox.FocusableItemPointed(); |
|
998 } |
|
999 |
|
1000 // -------------------------------------------------------------------------- |
|
1001 // CPbk2NamesListFilteredState::SearchFieldPointed |
|
1002 // -------------------------------------------------------------------------- |
|
1003 // |
|
1004 TBool CPbk2NamesListFilteredState::SearchFieldPointed() |
|
1005 { |
|
1006 return iSearchFieldPointed; |
|
1007 } |
|
1008 |
|
1009 // -------------------------------------------------------------------------- |
|
1010 // CPbk2NamesListFilteredState::TopViewChangedL |
|
1011 // -------------------------------------------------------------------------- |
|
1012 // |
|
1013 void CPbk2NamesListFilteredState::TopViewChangedL( |
|
1014 MVPbkContactViewBase& /*aOldView*/ ) |
|
1015 { |
|
1016 if ( iSearchFilter.IsPredictiveActivated() ) |
|
1017 { |
|
1018 iSearchFilter.CommitFindPaneTextL( iViewStack, iNameFormatter ); |
|
1019 } |
|
1020 } |
|
1021 |
|
1022 // -------------------------------------------------------------------------- |
|
1023 // CPbk2NamesListFilteredState::TopViewUpdatedL |
|
1024 // -------------------------------------------------------------------------- |
|
1025 // |
|
1026 void CPbk2NamesListFilteredState::TopViewUpdatedL() |
|
1027 { |
|
1028 // Do nothing |
|
1029 } |
|
1030 |
|
1031 // -------------------------------------------------------------------------- |
|
1032 // CPbk2NamesListFilteredState::BaseViewChangedL |
|
1033 // -------------------------------------------------------------------------- |
|
1034 // |
|
1035 void CPbk2NamesListFilteredState::BaseViewChangedL() |
|
1036 { |
|
1037 // Do nothing |
|
1038 } |
|
1039 |
|
1040 // -------------------------------------------------------------------------- |
|
1041 // CPbk2NamesListFilteredState::ViewStackError |
|
1042 // -------------------------------------------------------------------------- |
|
1043 // |
|
1044 void CPbk2NamesListFilteredState::ViewStackError( TInt /*aError*/ ) |
|
1045 { |
|
1046 // Do nothing |
|
1047 } |
|
1048 |
|
1049 // -------------------------------------------------------------------------- |
|
1050 // CPbk2NamesListFilteredState::ContactAddedToBaseView |
|
1051 // -------------------------------------------------------------------------- |
|
1052 // |
|
1053 void CPbk2NamesListFilteredState::ContactAddedToBaseView( |
|
1054 MVPbkContactViewBase& /*aBaseView*/, |
|
1055 TInt /*aIndex*/, |
|
1056 const MVPbkContactLink& /*aContactLink*/ ) |
|
1057 { |
|
1058 // Do nothing |
|
1059 } |
|
1060 |
|
1061 |
|
1062 // -------------------------------------------------------------------------- |
|
1063 // CPbk2NamesListFilteredState::HandleFocusChangeL |
|
1064 // -------------------------------------------------------------------------- |
|
1065 // |
|
1066 void CPbk2NamesListFilteredState::HandleFocusChangeL() |
|
1067 { |
|
1068 iEventSender.SendEventToObserversL( |
|
1069 TPbk2ControlEvent::TPbk2ControlEvent::EControlFocusChanged ); |
|
1070 } |
|
1071 |
|
1072 |
|
1073 void CPbk2NamesListFilteredState::UpdateAdaptiveSearchGridL() |
|
1074 { |
|
1075 if( ( !iAdaptiveSearchGridFiller ) || ( !iFindBox ) ) |
|
1076 { |
|
1077 return; |
|
1078 } |
|
1079 |
|
1080 CAknSearchField::TSearchFieldStyle searchStyle = iFindBox->SearchFieldStyle(); |
|
1081 if ( searchStyle != CAknSearchField::EAdaptiveSearch ) |
|
1082 { |
|
1083 delete iAdaptiveSearchGridFiller; |
|
1084 iAdaptiveSearchGridFiller = NULL; |
|
1085 return; |
|
1086 } |
|
1087 |
|
1088 iAdaptiveSearchGridFiller->StartFillingL( iViewStack.BaseView(), FindTextL(), ETrue ); |
|
1089 } |
|
1090 |
|
1091 // -------------------------------------------------------------------------- |
|
1092 // CPbk2NamesListFilteredState::IsContactAtListboxIndex |
|
1093 // Tells whether the listbox line contains a contact or not. |
|
1094 // Does not check that the aListboxIndex is within range of listbox. |
|
1095 // -------------------------------------------------------------------------- |
|
1096 // |
|
1097 TBool CPbk2NamesListFilteredState::IsContactAtListboxIndex( TInt aListboxIndex ) const |
|
1098 { |
|
1099 // There can be command items at the top of the list. |
|
1100 // The command items are not contacts. |
|
1101 const TInt enabledCommandCount = CommandItemCount(); |
|
1102 return aListboxIndex >= enabledCommandCount; |
|
1103 } |
|
1104 |
|
1105 // -------------------------------------------------------------------------- |
|
1106 // CPbk2NamesListFilteredState::AllowCommandsToShowThemselves |
|
1107 // -------------------------------------------------------------------------- |
|
1108 // |
|
1109 void CPbk2NamesListFilteredState::AllowCommandsToShowThemselves( TBool aVisible ) |
|
1110 { |
|
1111 if ( aVisible ) |
|
1112 { |
|
1113 // ownership not transferred |
|
1114 iListBox.SetListCommands( &iCommandItems ); |
|
1115 SubscribeCmdItemsVisibility(); |
|
1116 UpdateCommandEnabled( EPbk2CmdRcl, ETrue ); |
|
1117 UpdateCommandEnabled( EPbk2CmdAddFavourites, EFalse ); |
|
1118 UpdateCommandEnabled( EPbk2CmdOpenMyCard, EFalse ); |
|
1119 } |
|
1120 else |
|
1121 { |
|
1122 UnsubscribeCmdItemsVisibility(); |
|
1123 iListBox.SetListCommands( NULL ); |
|
1124 } |
|
1125 } |
|
1126 // -------------------------------------------------------------------------- |
|
1127 // CPbk2NamesListFilteredState::CmdItemVisibilityChanged |
|
1128 // -------------------------------------------------------------------------- |
|
1129 // |
|
1130 void CPbk2NamesListFilteredState::CmdItemVisibilityChanged( TInt aCmdItemId, TBool aVisible ) |
|
1131 { |
|
1132 TInt cmdItemIndex = FindCommand(aCmdItemId); |
|
1133 TInt cmdListBoxIndex = EnabledCommandCount(); |
|
1134 if( aVisible ) |
|
1135 { |
|
1136 cmdListBoxIndex--; |
|
1137 } |
|
1138 // Update the HiddenSelection property of the command items. |
|
1139 TListItemProperties prop( iListBox.ItemDrawer()->Properties(cmdListBoxIndex) ); |
|
1140 prop.SetHiddenSelection(aVisible); |
|
1141 TRAP_IGNORE( |
|
1142 iListBox.ItemDrawer()->SetPropertiesL(cmdListBoxIndex, prop); |
|
1143 |
|
1144 HandleCommandEventL( |
|
1145 (aVisible ? EItemAdded : EItemRemoved), |
|
1146 cmdItemIndex); |
|
1147 ); |
|
1148 } |
|
1149 |
|
1150 // -------------------------------------------------------------------------- |
|
1151 // CPbk2NamesListFilteredState::UpdateCommandEnabled |
|
1152 // -------------------------------------------------------------------------- |
|
1153 // |
|
1154 void CPbk2NamesListFilteredState::UpdateCommandEnabled( TInt aCommandId, TBool aEnabled ) |
|
1155 { |
|
1156 for ( TInt i = 0; i < iCommandItems.Count(); i++ ) |
|
1157 { |
|
1158 if ( iCommandItems[i]->CommandId() == aCommandId ) |
|
1159 { |
|
1160 iCommandItems[i]->SetEnabled( aEnabled ); |
|
1161 break; |
|
1162 } |
|
1163 } |
|
1164 } |
|
1165 // -------------------------------------------------------------------------- |
|
1166 // CPbk2NamesListFilteredState::IsCommandEnabled |
|
1167 // -------------------------------------------------------------------------- |
|
1168 // |
|
1169 TBool CPbk2NamesListFilteredState::IsCommandEnabled(TInt aCommandId) const |
|
1170 { |
|
1171 TBool res = EFalse; |
|
1172 for ( TInt i = 0; i < iCommandItems.Count(); i++ ) |
|
1173 { |
|
1174 if ( iCommandItems[i]->CommandId() == aCommandId ) |
|
1175 { |
|
1176 res = iCommandItems[i]->IsEnabled(); |
|
1177 break; |
|
1178 } |
|
1179 } |
|
1180 return res; |
|
1181 } |
|
1182 |
|
1183 // -------------------------------------------------------------------------- |
|
1184 // CPbk2NamesListFilteredState::FindCommand |
|
1185 // Search for a command in iCommandItems and returns its index |
|
1186 // -------------------------------------------------------------------------- |
|
1187 // |
|
1188 TInt CPbk2NamesListFilteredState::FindCommand(TInt aCommandId) const |
|
1189 { |
|
1190 TInt result = KErrNotFound; |
|
1191 for ( TInt i = 0; i < iCommandItems.Count(); ++i ) |
|
1192 { |
|
1193 if ( iCommandItems[i]->CommandId() == aCommandId ) |
|
1194 { |
|
1195 result = i; |
|
1196 break; |
|
1197 } |
|
1198 |
|
1199 } |
|
1200 return result; |
|
1201 } |
|
1202 |
|
1203 // -------------------------------------------------------------------------- |
|
1204 // CPbk2NamesListFilteredState::CalculateListboxIndex |
|
1205 // -------------------------------------------------------------------------- |
|
1206 // |
|
1207 TInt CPbk2NamesListFilteredState::CalculateListboxIndex(TInt aCommandIndex) const |
|
1208 { |
|
1209 TInt num(KErrNotFound); |
|
1210 for ( TInt i = 0; i < aCommandIndex; ++i ) |
|
1211 { |
|
1212 if(iCommandItems[i]->IsEnabled()) |
|
1213 { |
|
1214 ++num; |
|
1215 } |
|
1216 } |
|
1217 return num; |
|
1218 } |
|
1219 |
|
1220 // -------------------------------------------------------------------------- |
|
1221 // CPbk2NamesListFilteredState::UnmarkCommands |
|
1222 // -------------------------------------------------------------------------- |
|
1223 // |
|
1224 void CPbk2NamesListFilteredState::UnmarkCommands() const |
|
1225 { |
|
1226 for ( TInt i = 0; i < CommandItemCount(); i++ ) |
|
1227 { |
|
1228 iListBox.View()->DeselectItem( i ); |
|
1229 } |
|
1230 } |
|
1231 |
|
1232 // -------------------------------------------------------------------------- |
|
1233 // CPbk2NamesListFilteredState::EnabledCommandCount |
|
1234 // -------------------------------------------------------------------------- |
|
1235 // |
|
1236 TInt CPbk2NamesListFilteredState::EnabledCommandCount() const |
|
1237 { |
|
1238 TInt result = 0; |
|
1239 for ( TInt i = 0; i < iCommandItems.Count(); ++i ) |
|
1240 { |
|
1241 if(iCommandItems[i]->IsEnabled()) |
|
1242 { |
|
1243 result++; |
|
1244 } |
|
1245 } |
|
1246 return result; |
|
1247 } |
|
1248 |
|
1249 // End of File |