author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 14 Sep 2010 20:54:53 +0300 | |
branch | RCL_3 |
changeset 21 | 9da50d567e3c |
parent 20 | f4a778e096c2 |
permissions | -rw-r--r-- |
20 | 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 ready state. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
// INCLUDE FILES |
|
20 |
#include "CPbk2NamesListReadyState.h" |
|
21 |
||
22 |
// Phonebook 2 |
|
23 |
#include "CPbk2AdaptiveSearchGridFiller.h" |
|
24 |
#include "CPbk2ThumbnailLoader.h" |
|
25 |
#include "CPbk2ContactViewListBox.h" |
|
26 |
#include "CPbk2ContactViewIterator.h" |
|
27 |
#include "MPbk2UiControlEventSender.h" |
|
28 |
#include "CPbk2FindDelay.h" |
|
29 |
#include "CPbk2NamesListControl.h" |
|
30 |
#include "CPbk2FindStringSplitter.h" |
|
31 |
#include <CPbk2ViewState.h> |
|
32 |
#include <MPbk2ControlObserver.h> |
|
33 |
#include <Pbk2MenuFilteringFlags.hrh> |
|
34 |
#include <MPbk2ApplicationServices.h> |
|
35 |
#include <MPbk2AppUi.h> |
|
36 |
#include "TPbk2FindTextUtil.h" |
|
37 |
#include <CPbk2AppViewBase.h> |
|
38 |
||
39 |
#include "PmuCommands.hrh" // For accessing EPmuCmdCascadingBackup |
|
40 |
#include "Pbk2USimUI.hrh" // For accessing EPsu2CmdCascadingSimMemory |
|
41 |
#include <Pbk2InternalUID.h> |
|
42 |
#include <pbk2doublelistboxcmditemextension.h> |
|
43 |
||
44 |
// Virtual Phonebook |
|
45 |
#include <MVPbkContactViewBase.h> |
|
46 |
#include <MVPbkViewContact.h> |
|
47 |
#include <MVPbkContactLink.h> |
|
48 |
#include <MVPbkContactBookmark.h> |
|
49 |
#include <CVPbkContactLinkArray.h> |
|
50 |
#include <CVPbkContactFindPolicy.h> |
|
51 |
#include <CVPbkContactManager.h> |
|
52 |
||
53 |
// System includes |
|
54 |
#include <akntoolbar.h> |
|
55 |
#include <AknsDrawUtils.h> |
|
56 |
#include <barsread.h> |
|
57 |
#include <aknsfld.h> |
|
58 |
#include <badesca.h> |
|
59 |
#include <aknViewAppUi.h> |
|
60 |
#include <aknappui.h> |
|
61 |
#include <eikmenub.h> |
|
62 |
#include <eikdialg.h> |
|
63 |
||
64 |
// Debugging headers |
|
65 |
#include <Pbk2Debug.h> |
|
66 |
#include "CPbk2PredictiveSearchFilter.h" |
|
67 |
#include "cpbk2predictiveviewstack.h" |
|
68 |
||
69 |
||
70 |
/// Unnamed namespace for local definitions |
|
71 |
namespace { |
|
72 |
||
73 |
// LOCAL CONSTANTS AND MACROS |
|
74 |
const TInt KNumberOfControls = 2; // listbox and findbox |
|
75 |
const TInt KFindDelayTime = 700000; // microseconds |
|
76 |
const TInt KFindDelayThresholdContacts = 1000; // amount of contacts to |
|
77 |
// activate find delay |
|
78 |
||
79 |
#ifdef _DEBUG |
|
80 |
enum TPanicCode |
|
81 |
{ |
|
82 |
EPanicLogic_ComponentControl = 1, |
|
83 |
EPanicLogic_FindTextL, |
|
84 |
EPanicLogic_PreConds_SetCurrentItemIndexAndDraw, |
|
85 |
EPanicLogic_Command_index_out_of_bounds |
|
86 |
}; |
|
87 |
||
88 |
void Panic(TPanicCode aReason) |
|
89 |
{ |
|
90 |
_LIT(KPanicText, "CPbk2NamesListReadyState"); |
|
91 |
User::Panic(KPanicText, aReason); |
|
92 |
} |
|
93 |
#endif // _DEBUG |
|
94 |
||
95 |
||
96 |
NONSHARABLE_CLASS(TCleanupEnableListBoxViewRedraw) |
|
97 |
{ |
|
98 |
public: // Interface |
|
99 |
||
100 |
/** |
|
101 |
* Constructor. |
|
102 |
* |
|
103 |
* @param aListBoxView The list box view |
|
104 |
*/ |
|
105 |
inline TCleanupEnableListBoxViewRedraw( CListBoxView& aListBoxView ) |
|
106 |
: iCleanupItem( CleanupOp, &aListBoxView ) |
|
107 |
{ |
|
108 |
} |
|
109 |
||
110 |
/** |
|
111 |
* Returns the cleanup item. |
|
112 |
*/ |
|
113 |
inline operator TCleanupItem() const |
|
114 |
{ |
|
115 |
return iCleanupItem; |
|
116 |
} |
|
117 |
||
118 |
private: // Implementation |
|
119 |
static void CleanupOp( |
|
120 |
TAny* aPtr ); |
|
121 |
||
122 |
private: // Data |
|
123 |
/// Own: Cleanup item |
|
124 |
TCleanupItem iCleanupItem; |
|
125 |
}; |
|
126 |
||
127 |
// -------------------------------------------------------------------------- |
|
128 |
// TCleanupEnableListBoxViewRedraw::CleanupOp |
|
129 |
// -------------------------------------------------------------------------- |
|
130 |
// |
|
131 |
void TCleanupEnableListBoxViewRedraw::CleanupOp( TAny* aPtr ) |
|
132 |
{ |
|
133 |
static_cast<CListBoxView*>(aPtr)->SetDisableRedraw(EFalse); |
|
134 |
} |
|
135 |
||
136 |
||
137 |
/** |
|
138 |
* Resolves the next index of the listbox according the key event. |
|
139 |
* If key event is UP, the index is decreased from current index. |
|
140 |
* If key event is DOWN, the index is increased from current index. |
|
141 |
* If current index is last & event is DOWN, the new index is set to first. |
|
142 |
* If current index is first & event is UP, the new index is set to last. |
|
143 |
* |
|
144 |
* @param aKeyEvent Key event. |
|
145 |
* @param aListBox List box. |
|
146 |
* @return Next index of the list item. |
|
147 |
*/ |
|
148 |
TInt NextFocusIndex |
|
149 |
( const TKeyEvent& aKeyEvent, CEikListBox& aListBox ) |
|
150 |
{ |
|
151 |
TInt result( KErrNotFound ); |
|
152 |
const TInt KFirstItemIndex( 0 ); |
|
153 |
TInt itemCount( aListBox.Model()->NumberOfItems() ); |
|
154 |
const TInt KLastItemIndex( itemCount - 1 ); |
|
155 |
TInt currentItemIndex( aListBox.CurrentItemIndex() ); |
|
156 |
if ( aKeyEvent.iCode == EKeyDownArrow ) |
|
157 |
{ |
|
158 |
result = currentItemIndex + 1; |
|
159 |
if ( result > KLastItemIndex ) |
|
160 |
{ |
|
161 |
// Set to first |
|
162 |
result = KFirstItemIndex; |
|
163 |
} |
|
164 |
} |
|
165 |
else if ( aKeyEvent.iCode == EKeyUpArrow ) |
|
166 |
{ |
|
167 |
result = currentItemIndex - 1; |
|
168 |
if ( result < KFirstItemIndex ) |
|
169 |
{ |
|
170 |
// Set to last |
|
171 |
result = KLastItemIndex; |
|
172 |
} |
|
173 |
} |
|
174 |
else |
|
175 |
{ |
|
176 |
result = currentItemIndex; |
|
177 |
} |
|
178 |
return result; |
|
179 |
} |
|
180 |
||
181 |
} /// namespace |
|
182 |
||
183 |
// -------------------------------------------------------------------------- |
|
184 |
// CPbk2NamesListReadyState::CPbk2NamesListReadyState |
|
185 |
// -------------------------------------------------------------------------- |
|
186 |
// |
|
187 |
inline CPbk2NamesListReadyState::CPbk2NamesListReadyState( |
|
188 |
const CCoeControl& aParent, |
|
189 |
CPbk2ContactViewListBox& aListBox, |
|
190 |
MPbk2FilteredViewStack& aViewStack, |
|
191 |
CAknSearchField* aFindBox, |
|
192 |
CPbk2ThumbnailLoader& aThumbnailLoader, |
|
193 |
MPbk2UiControlEventSender& aEventSender, |
|
194 |
MPbk2ContactNameFormatter& aNameFormatter, |
|
195 |
RPointerArray<MPbk2UiControlCmdItem>& aCommandItems, |
|
196 |
CPbk2PredictiveSearchFilter& aSearchFilter ) : |
|
197 |
iParent( aParent ), |
|
198 |
iListBox( aListBox ), |
|
199 |
iViewStack( aViewStack ), |
|
200 |
iFindBox( aFindBox ), |
|
201 |
iThumbnailLoader( aThumbnailLoader ), |
|
202 |
iEventSender( aEventSender ), |
|
203 |
iNameFormatter( aNameFormatter ), |
|
204 |
iCommandItems( aCommandItems ), |
|
205 |
iSearchFilter(aSearchFilter) |
|
206 |
{ |
|
207 |
} |
|
208 |
||
209 |
// -------------------------------------------------------------------------- |
|
210 |
// CPbk2NamesListReadyState::~CPbk2NamesListReadyState |
|
211 |
// -------------------------------------------------------------------------- |
|
212 |
// |
|
213 |
CPbk2NamesListReadyState::~CPbk2NamesListReadyState() |
|
214 |
{ |
|
215 |
UnsubscribeCmdItemsVisibility(); |
|
216 |
iListBox.SetListCommands( NULL ); |
|
217 |
||
218 |
delete iAdaptiveSearchGridFiller; |
|
219 |
delete iFindPolicy; |
|
220 |
delete iFindDelay; |
|
221 |
delete iFindTextBuf; |
|
222 |
iSelectedItems.Close(); |
|
223 |
delete iStringArray; |
|
224 |
delete iStringSplitter; |
|
225 |
iIteratorIndexes.Close(); |
|
226 |
} |
|
227 |
||
228 |
// -------------------------------------------------------------------------- |
|
229 |
// CPbk2NamesListReadyState::NewL |
|
230 |
// -------------------------------------------------------------------------- |
|
231 |
// |
|
232 |
CPbk2NamesListReadyState* CPbk2NamesListReadyState::NewLC |
|
233 |
( const CCoeControl* aParent, CPbk2ContactViewListBox& aListBox, |
|
234 |
MPbk2FilteredViewStack& aViewStack, CAknSearchField* aFindBox, |
|
235 |
CPbk2ThumbnailLoader& aThumbnailLoader, |
|
236 |
MPbk2UiControlEventSender& aEventSender, |
|
237 |
MPbk2ContactNameFormatter& aNameFormatter, |
|
238 |
RPointerArray<MPbk2UiControlCmdItem>& aCommandItems, |
|
239 |
CPbk2PredictiveSearchFilter& aSearchFilter ) |
|
240 |
{ |
|
241 |
CPbk2NamesListReadyState* self = new (ELeave) CPbk2NamesListReadyState( |
|
242 |
*aParent, aListBox, aViewStack, aFindBox, aThumbnailLoader, |
|
243 |
aEventSender, aNameFormatter, aCommandItems, aSearchFilter ); |
|
244 |
CleanupStack::PushL(self); |
|
245 |
self->ConstructL(); |
|
246 |
return self; |
|
247 |
} |
|
248 |
||
249 |
// -------------------------------------------------------------------------- |
|
250 |
// CPbk2NamesListReadyState::ConstructL |
|
251 |
// -------------------------------------------------------------------------- |
|
252 |
// |
|
253 |
inline void CPbk2NamesListReadyState::ConstructL() |
|
254 |
{ |
|
255 |
if ( iFindBox ) |
|
256 |
{ |
|
257 |
if (!iFindBox->IsFocused() && iParent.IsFocused() ) |
|
258 |
{ |
|
259 |
iFindBox->SetFocus(ETrue); |
|
260 |
} |
|
261 |
iFindBox->ResetL(); |
|
262 |
} |
|
263 |
||
264 |
iFindDelay = CPbk2FindDelay::NewL( *this ); |
|
265 |
||
266 |
// Create contact find policy |
|
267 |
CVPbkContactManager& manager = |
|
268 |
Phonebook2::Pbk2AppUi()->ApplicationServices().ContactManager(); |
|
269 |
CVPbkContactFindPolicy::TParam param = |
|
270 |
CVPbkContactFindPolicy::TParam( |
|
271 |
manager.FieldTypes(), |
|
272 |
manager.FsSession() ); |
|
273 |
iFindPolicy = CVPbkContactFindPolicy::NewL( param ); |
|
274 |
||
275 |
if( iFindBox ) |
|
276 |
{ |
|
277 |
iFindBox->AddAdaptiveSearchTextObserverL( this ); |
|
278 |
iAdaptiveSearchGridFiller = CPbk2AdaptiveSearchGridFiller::NewL( *iFindBox, iNameFormatter ); |
|
279 |
} |
|
280 |
} |
|
281 |
||
282 |
void CPbk2NamesListReadyState::UnsubscribeCmdItemsVisibility() const |
|
283 |
{ |
|
284 |
for ( TInt i = 0; i < iCommandItems.Count(); ++i ) |
|
285 |
{ |
|
286 |
iCommandItems[i]->SetVisibilityObserver( NULL ); |
|
287 |
} |
|
288 |
} |
|
289 |
||
290 |
void CPbk2NamesListReadyState::SubscribeCmdItemsVisibility() |
|
291 |
{ |
|
292 |
for ( TInt i = 0; i < iCommandItems.Count(); ++i ) |
|
293 |
{ |
|
294 |
iCommandItems[i]->SetVisibilityObserver( this ); |
|
295 |
} |
|
296 |
} |
|
297 |
||
298 |
// -------------------------------------------------------------------------- |
|
299 |
// CPbk2NamesListReadyState::ActivateStateL |
|
300 |
// -------------------------------------------------------------------------- |
|
301 |
// |
|
302 |
void CPbk2NamesListReadyState::ActivateStateL() |
|
303 |
{ |
|
304 |
PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
305 |
("CPbk2NamesListReadyState::ActivateStateL(0x%x)"), this ); |
|
306 |
||
307 |
AllowCommandsToShowThemselves( ETrue ); |
|
308 |
UpdateAdaptiveSearchGridL( EFalse ); |
|
309 |
} |
|
310 |
||
311 |
// -------------------------------------------------------------------------- |
|
312 |
// CPbk2NamesListReadyState::DeactivateState |
|
313 |
// -------------------------------------------------------------------------- |
|
314 |
// |
|
315 |
void CPbk2NamesListReadyState::DeactivateState() |
|
316 |
{ |
|
317 |
PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
318 |
("CPbk2NamesListReadyState::DeactivateState(0x%x)"), this ); |
|
319 |
||
320 |
AllowCommandsToShowThemselves( EFalse ); |
|
321 |
HideThumbnail(); |
|
322 |
// Stop creating adaptive search grid. |
|
323 |
if (iAdaptiveSearchGridFiller) |
|
324 |
{ |
|
325 |
if (iAdaptiveSearchGridFiller->IsActive()) |
|
326 |
{ |
|
327 |
iAdaptiveSearchGridFiller->StopFilling(); |
|
328 |
} |
|
329 |
} |
|
330 |
} |
|
331 |
||
332 |
// -------------------------------------------------------------------------- |
|
333 |
// CPbk2NamesListReadyState::CountComponentControls |
|
334 |
// -------------------------------------------------------------------------- |
|
335 |
// |
|
336 |
TInt CPbk2NamesListReadyState::CountComponentControls() const |
|
337 |
{ |
|
338 |
TInt numberOfControls( KNumberOfControls ); |
|
339 |
if ( !iFindBox ) |
|
340 |
{ |
|
341 |
--numberOfControls; |
|
342 |
} |
|
343 |
return numberOfControls; |
|
344 |
} |
|
345 |
||
346 |
// -------------------------------------------------------------------------- |
|
347 |
// CPbk2NamesListReadyState::ComponentControl |
|
348 |
// -------------------------------------------------------------------------- |
|
349 |
// |
|
350 |
CCoeControl* CPbk2NamesListReadyState::ComponentControl(TInt aIndex) const |
|
351 |
{ |
|
352 |
switch (aIndex) |
|
353 |
{ |
|
354 |
case 0: |
|
355 |
{ |
|
356 |
return &iListBox; |
|
357 |
} |
|
358 |
case 1: |
|
359 |
{ |
|
360 |
return iFindBox; |
|
361 |
} |
|
362 |
default: |
|
363 |
{ |
|
364 |
// Illegal state |
|
365 |
__ASSERT_DEBUG(EFalse, Panic(EPanicLogic_ComponentControl)); |
|
366 |
return NULL; |
|
367 |
} |
|
368 |
} |
|
369 |
} |
|
370 |
||
371 |
// -------------------------------------------------------------------------- |
|
372 |
// CPbk2NamesListReadyState::SizeChanged |
|
373 |
// -------------------------------------------------------------------------- |
|
374 |
// |
|
375 |
void CPbk2NamesListReadyState::SizeChanged() |
|
376 |
{ |
|
377 |
const TRect rect(iParent.Rect()); |
|
378 |
PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
379 |
("CPbk2NamesListReadyState::SizeChanged(0x%x), rect=(%d,%d,%d,%d)"), |
|
380 |
this, rect.iTl.iX, rect.iTl.iY, rect.iBr.iX, rect.iBr.iY); |
|
381 |
||
382 |
if ( iFindBox ) |
|
383 |
{ |
|
384 |
AknLayoutUtils::LayoutControl(&iListBox, rect, |
|
385 |
AKN_LAYOUT_WINDOW_list_gen_pane(1)); |
|
386 |
||
387 |
AknLayoutUtils::LayoutControl( iFindBox, rect, |
|
388 |
AKN_LAYOUT_WINDOW_find_pane ); |
|
389 |
if (iFindBox->IsVisible() && iListBox.IsVisible()) |
|
390 |
{ |
|
391 |
iFindBox->SetLinePos(EABColumn); |
|
392 |
} |
|
393 |
} |
|
394 |
else |
|
395 |
{ |
|
396 |
AknLayoutUtils::LayoutControl(&iListBox, rect, |
|
397 |
AKN_LAYOUT_WINDOW_list_gen_pane(0)); |
|
398 |
} |
|
399 |
} |
|
400 |
||
401 |
// -------------------------------------------------------------------------- |
|
402 |
// CPbk2NamesListReadyState::MakeComponentsVisible |
|
403 |
// -------------------------------------------------------------------------- |
|
404 |
// |
|
405 |
void CPbk2NamesListReadyState::MakeComponentsVisible(TBool aVisible) |
|
406 |
{ |
|
407 |
PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
408 |
("CPbk2NamesListReadyState::MakeComponentsVisible(0x%x,%d)"), |
|
409 |
this, aVisible); |
|
410 |
||
411 |
iListBox.MakeVisible(aVisible); |
|
412 |
||
413 |
CEikScrollBar *scrollBar = iListBox.ScrollBarFrame()->GetScrollBarHandle |
|
414 |
(CEikScrollBar::EVertical); |
|
415 |
if ( scrollBar ) |
|
416 |
{ |
|
417 |
scrollBar->MakeVisible(aVisible); |
|
418 |
} |
|
419 |
||
420 |
if ( iFindBox ) |
|
421 |
{ |
|
422 |
if ( (iFindBox->IsVisible()&&!aVisible) || (!iFindBox->IsVisible()&&aVisible) ) |
|
423 |
{ |
|
424 |
iFindBox->MakeVisible(aVisible); |
|
425 |
} |
|
426 |
} |
|
427 |
||
428 |
// Have to call to make sure that scrollbar is updated when state of |
|
429 |
// control is changing. |
|
430 |
TRAP_IGNORE( iListBox.UpdateScrollBarsL() ); |
|
431 |
||
432 |
// Change visible state |
|
433 |
iVisible = aVisible; |
|
434 |
} |
|
435 |
||
436 |
// -------------------------------------------------------------------------- |
|
437 |
// CPbk2NamesListReadyState::ActivateL |
|
438 |
// -------------------------------------------------------------------------- |
|
439 |
// |
|
440 |
void CPbk2NamesListReadyState::ActivateL() |
|
441 |
{ |
|
442 |
PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
443 |
("CPbk2NamesListReadyState::ActivateL(0x%x)"), this ); |
|
444 |
||
445 |
if ( iFindBox ) |
|
446 |
{ |
|
447 |
// Adjust find box cursor |
|
448 |
CEikEdwin& findEditor = iFindBox->Editor(); |
|
449 |
findEditor.SetCursorPosL(findEditor.TextLength(), EFalse); |
|
450 |
} |
|
451 |
} |
|
452 |
||
453 |
// -------------------------------------------------------------------------- |
|
454 |
// CPbk2NamesListReadyState::Draw |
|
455 |
// -------------------------------------------------------------------------- |
|
456 |
// |
|
457 |
void CPbk2NamesListReadyState::Draw |
|
458 |
( const TRect& aRect, CWindowGc& aGc ) const |
|
459 |
{ |
|
460 |
PBK2_DEBUG_PRINT( PBK2_DEBUG_STRING( |
|
461 |
"CPbk2NamesListReadyState::Draw(0x%x, TRect(%d,%d,%d,%d))" ), |
|
462 |
this, aRect.iTl.iX, aRect.iTl.iY, aRect.iBr.iX, aRect.iBr.iY ); |
|
463 |
||
464 |
if ( !iVisible ) |
|
465 |
{ |
|
466 |
// If control is not visible (blanked) draw a blank background |
|
467 |
MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
468 |
MAknsControlContext* cc = |
|
469 |
AknsDrawUtils::ControlContext( &iListBox ); |
|
470 |
||
471 |
if ( !AknsDrawUtils::Background( skin, cc, &iListBox, aGc, aRect ) ) |
|
472 |
{ |
|
473 |
// Blank background if no skin present |
|
474 |
aGc.SetPenStyle( CGraphicsContext::ENullPen ); |
|
475 |
aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
476 |
aGc.DrawRect( aRect ); |
|
477 |
} |
|
478 |
} |
|
479 |
} |
|
480 |
||
481 |
// -------------------------------------------------------------------------- |
|
482 |
// CPbk2NamesListReadyState::DialogMenuBar |
|
483 |
// -------------------------------------------------------------------------- |
|
484 |
// |
|
485 |
CEikMenuBar* CPbk2NamesListReadyState::DialogMenuBar(CAknAppUi* aAppUi) |
|
486 |
{ |
|
487 |
CEikMenuBar* menuBar = NULL; |
|
488 |
||
489 |
// Check for an active dialog and fetch its menu bar |
|
490 |
if (aAppUi->IsDisplayingMenuOrDialog()) |
|
491 |
{ |
|
492 |
CCoeControl* ctrl = aAppUi->TopFocusedControl(); |
|
493 |
if (ctrl) |
|
494 |
{ |
|
495 |
CEikDialog* dialog = ctrl->MopGetObjectNoChaining(dialog); |
|
496 |
if (dialog) |
|
497 |
{ |
|
498 |
dialog->MopGetObject(menuBar); |
|
499 |
} |
|
500 |
} |
|
501 |
} |
|
502 |
return menuBar; |
|
503 |
} |
|
504 |
||
505 |
// -------------------------------------------------------------------------- |
|
506 |
// CPbk2NamesListReadyState::ViewMenuBar |
|
507 |
// -------------------------------------------------------------------------- |
|
508 |
// |
|
509 |
CEikMenuBar* CPbk2NamesListReadyState::ViewMenuBar(CAknAppUi* aAppUi) |
|
510 |
{ |
|
511 |
CEikMenuBar* menuBar = NULL; |
|
512 |
||
513 |
// Check for an active view |
|
514 |
TVwsViewId uid; |
|
515 |
if (aAppUi->GetActiveViewId(uid) == KErrNone) |
|
516 |
{ |
|
517 |
if ( uid.iAppUid != uid.iViewUid ) |
|
518 |
{ |
|
519 |
CAknView* view = |
|
520 |
static_cast<CAknViewAppUi*> (aAppUi)->View(uid.iViewUid); |
|
521 |
if ( view ) |
|
522 |
{ |
|
523 |
menuBar = view->MenuBar(); |
|
524 |
} |
|
525 |
} |
|
526 |
} |
|
527 |
return menuBar; |
|
528 |
} |
|
529 |
||
530 |
// -------------------------------------------------------------------------- |
|
531 |
// CPbk2NamesListReadyState::MenuBar |
|
532 |
// -------------------------------------------------------------------------- |
|
533 |
// |
|
534 |
CEikMenuBar* CPbk2NamesListReadyState::MenuBar(CAknAppUi* aAppUi) |
|
535 |
{ |
|
536 |
// Try fetching a menu bar from currently displayed dialog |
|
537 |
CEikMenuBar* menuBar = DialogMenuBar( aAppUi ); |
|
538 |
||
539 |
if ( !menuBar ) // Menu bar was not dialog based |
|
540 |
{ |
|
541 |
// Try fetching a menu bar from an active view |
|
542 |
menuBar = ViewMenuBar(aAppUi); |
|
543 |
} |
|
544 |
||
545 |
if ( !menuBar ) // Menu bar was not view based |
|
546 |
{ |
|
547 |
// Finally, try fetching a menu bar from AppUi |
|
548 |
menuBar = CEikonEnv::Static()->AppUiFactory()->MenuBar(); |
|
549 |
} |
|
550 |
return menuBar; |
|
551 |
} |
|
552 |
||
553 |
// -------------------------------------------------------------------------- |
|
554 |
// CPbk2NamesListReadyState::OfferKeyEventL |
|
555 |
// -------------------------------------------------------------------------- |
|
556 |
// |
|
557 |
TKeyResponse CPbk2NamesListReadyState::OfferKeyEventL |
|
558 |
(const TKeyEvent& aKeyEvent, TEventCode aType) |
|
559 |
{ |
|
560 |
// Remember current index and selection before |
|
561 |
// listbox has handled the event. |
|
562 |
TInt oldItemIndex( iListBox.CurrentItemIndex() ); |
|
563 |
TBool oldItemMarkedBefore |
|
564 |
( iListBox.View()->ItemIsSelected( oldItemIndex ) ); |
|
565 |
||
566 |
// Remember next index based on key event (UP, DOWN) |
|
567 |
// and selection before listbox has handled the event. |
|
568 |
TInt newItemIndex( NextFocusIndex( aKeyEvent, iListBox ) ); |
|
569 |
TBool newItemMarkedBefore |
|
570 |
( iListBox.View()->ItemIsSelected( newItemIndex ) ); |
|
571 |
||
572 |
TKeyResponse result( EKeyWasNotConsumed ); |
|
573 |
if ( iFindBox ) |
|
574 |
{ |
|
575 |
//If the FindBox is locked then dont offer the event to the findbox |
|
576 |
if (!iSearchFilter.IsLocked()) |
|
577 |
{ |
|
578 |
// use the "C" key to delete the Adaptive search character must |
|
579 |
// change the focus to Adaptive search pane |
|
580 |
if ( aKeyEvent.iCode == EKeyBackspace && iAdaptiveSearchGridFiller ) |
|
581 |
{ |
|
582 |
iAdaptiveSearchGridFiller->SetFocusToAdaptiveSearchGrid(); |
|
583 |
} |
|
584 |
||
585 |
// Offer the key event first to findbox |
|
586 |
result = iFindBox->OfferKeyEventL( aKeyEvent, aType ); |
|
587 |
||
588 |
CPbk2PredictiveViewStack& predictiveViewStack = static_cast<CPbk2PredictiveViewStack&>( iViewStack ); |
|
589 |
||
590 |
TInt contactItemIndex = newItemIndex - CommandItemCount(); |
|
591 |
||
592 |
if ( contactItemIndex >= 0 && oldItemIndex != newItemIndex && iSearchFilter.IsPredictiveActivated() && iViewStack.Level() && |
|
593 |
!predictiveViewStack.IsNonMatchingMarkedContact( contactItemIndex ) ) |
|
594 |
{ |
|
595 |
iSearchFilter.CommitFindPaneTextL( iViewStack, iNameFormatter, contactItemIndex ); |
|
596 |
} |
|
597 |
||
598 |
} |
|
599 |
else |
|
600 |
{ |
|
601 |
//If FindPane is locked, then forward only the backspace key. |
|
602 |
if ( aKeyEvent.iCode == EKeyBackspace ) |
|
603 |
{ |
|
604 |
// Offer the key event first to findbox |
|
605 |
result = iFindBox->OfferKeyEventL( aKeyEvent, aType ); |
|
606 |
} |
|
607 |
} |
|
608 |
} |
|
609 |
||
610 |
// And then offer the event to listbox if necessary |
|
611 |
if ( result == EKeyWasNotConsumed ) |
|
612 |
{ |
|
613 |
// Use hash key to mark and unmark list item |
|
614 |
if ( (aKeyEvent.iScanCode == EStdKeyHash) |
|
615 |
&& MenuBar( iAvkonAppUi )->ItemSpecificCommandsEnabled() ) |
|
616 |
{ |
|
617 |
if ( aType == EEventKeyUp ) |
|
618 |
{ |
|
619 |
if ( newItemMarkedBefore ) |
|
620 |
{ |
|
621 |
iListBox.View()->DeselectItem( newItemIndex ); |
|
622 |
} |
|
623 |
else |
|
624 |
{ |
|
625 |
iListBox.View()->SelectItemL( newItemIndex ); |
|
626 |
} |
|
627 |
} |
|
628 |
result = EKeyWasConsumed; |
|
629 |
} |
|
630 |
else |
|
631 |
{ |
|
632 |
result = iListBox.OfferKeyEventL( aKeyEvent, aType ); |
|
633 |
} |
|
634 |
} |
|
635 |
else |
|
636 |
{ |
|
637 |
// Find box consumed the key event, abort abort |
|
638 |
return result; |
|
639 |
} |
|
640 |
||
641 |
// If listbox handles the event, test if the selections have changed. |
|
642 |
if ( result == EKeyWasConsumed ) |
|
643 |
{ |
|
644 |
// If newItemIndex is found (it is not KErrNotFound) and |
|
645 |
// if newItemIndex is not the same as oldItemIndex |
|
646 |
if ( newItemIndex != KErrNotFound |
|
647 |
&& newItemIndex != oldItemIndex ) |
|
648 |
{ |
|
649 |
// Check if the new item index has marked afterwards. |
|
650 |
TBool newItemMarkedAfter |
|
651 |
( iListBox.View()->ItemIsSelected( newItemIndex ) ); |
|
652 |
||
653 |
// If new item selection has changed, send event. |
|
654 |
if ( newItemMarkedBefore != newItemMarkedAfter ) |
|
655 |
{ |
|
656 |
// Send event about changed state |
|
657 |
TPbk2ControlEvent |
|
658 |
event( TPbk2ControlEvent::EContactSelected ); |
|
659 |
event.iInt = newItemIndex; |
|
660 |
if ( !newItemMarkedAfter ) |
|
661 |
{ |
|
662 |
event.iEventType = |
|
663 |
TPbk2ControlEvent::EContactUnselected; |
|
664 |
} |
|
665 |
iEventSender.SendEventToObserversL( event ); |
|
666 |
||
667 |
//if commands marked, unmark it back |
|
668 |
if ( !IsContactAtListboxIndex( newItemIndex ) && newItemMarkedAfter ) |
|
669 |
{ |
|
670 |
UnmarkCommands(); |
|
671 |
event.iEventType = TPbk2ControlEvent::EContactUnselected; |
|
672 |
iEventSender.SendEventToObserversL( event ); |
|
673 |
} |
|
674 |
} |
|
675 |
} |
|
676 |
||
677 |
// Check if old item's selection has changed and send event. |
|
678 |
TBool oldItemMarkedAfter |
|
679 |
( iListBox.View()->ItemIsSelected( oldItemIndex ) ); |
|
680 |
if ( oldItemMarkedBefore != oldItemMarkedAfter ) |
|
681 |
{ |
|
682 |
// Send event about changed state |
|
683 |
TPbk2ControlEvent |
|
684 |
event( TPbk2ControlEvent::EContactSelected ); |
|
685 |
event.iInt = oldItemIndex; |
|
686 |
if ( !oldItemMarkedAfter ) |
|
687 |
{ |
|
688 |
event.iEventType = |
|
689 |
TPbk2ControlEvent::EContactUnselected; |
|
690 |
} |
|
691 |
iEventSender.SendEventToObserversL( event ); |
|
692 |
||
693 |
//if commands marked, unmark it back |
|
694 |
if ( !IsContactAtListboxIndex( oldItemIndex ) && oldItemMarkedAfter ) |
|
695 |
{ |
|
696 |
UnmarkCommands(); |
|
697 |
event.iEventType = TPbk2ControlEvent::EContactUnselected; |
|
698 |
iEventSender.SendEventToObserversL( event ); |
|
699 |
} |
|
700 |
} |
|
701 |
} |
|
702 |
||
703 |
return result; |
|
704 |
} |
|
705 |
||
706 |
// -------------------------------------------------------------------------- |
|
707 |
// CPbk2NamesListReadyState::HandlePointerEventL |
|
708 |
// Event sending differs from OfferKeyEventL's solution on purpose. |
|
709 |
// -------------------------------------------------------------------------- |
|
710 |
// |
|
711 |
void CPbk2NamesListReadyState::HandlePointerEventL |
|
712 |
( const TPointerEvent& aPointerEvent ) |
|
713 |
{ |
|
714 |
iSearchFieldPointed = EFalse; |
|
715 |
if ( iFindBox ) |
|
716 |
{ |
|
717 |
if ( iFindBox->Rect().Contains( aPointerEvent.iPosition ) ) |
|
718 |
{ |
|
719 |
iFindBox->HandlePointerEventL( aPointerEvent ); |
|
720 |
iSearchFieldPointed = ETrue; |
|
721 |
} |
|
722 |
} |
|
723 |
||
724 |
TInt previousItemIndex = iListBox.CurrentItemIndex(); |
|
725 |
iListBox.HandlePointerEventL( aPointerEvent ); |
|
726 |
||
727 |
// Handle focus change when dragging |
|
728 |
if ( previousItemIndex != iListBox.CurrentItemIndex() && |
|
729 |
aPointerEvent.iType == TPointerEvent::EDrag ) |
|
730 |
{ |
|
731 |
HandleFocusChangeL(); |
|
732 |
} |
|
733 |
||
734 |
if ( !iSearchFieldPointed && FocusableItemPointed() && |
|
735 |
aPointerEvent.iType == TPointerEvent::EButton1Up ) |
|
736 |
{ |
|
737 |
// Send selection events based on marking |
|
738 |
TInt focusIndex = iListBox.CurrentItemIndex(); |
|
739 |
TInt commands = CommandItemCount(); |
|
740 |
const TBool markedAfter = iListBox.View()->ItemIsSelected( focusIndex ); |
|
741 |
||
742 |
TPbk2ControlEvent event( TPbk2ControlEvent::EContactSelected ); |
|
743 |
event.iInt = focusIndex; |
|
744 |
if ( !markedAfter ) |
|
745 |
{ |
|
746 |
event.iEventType = TPbk2ControlEvent::EContactUnselected; |
|
747 |
} |
|
748 |
else if ( focusIndex < commands) |
|
749 |
{ |
|
750 |
UnmarkCommands(); |
|
751 |
} |
|
752 |
iEventSender.SendEventToObserversL( event ); |
|
753 |
||
754 |
} |
|
755 |
||
756 |
TInt currentIndex = iListBox.CurrentItemIndex(); |
|
757 |
CPbk2PredictiveViewStack& predictiveViewStack = static_cast<CPbk2PredictiveViewStack&>( iViewStack ); |
|
758 |
||
759 |
TInt contactItemIndex = currentIndex - CommandItemCount(); |
|
760 |
if ( contactItemIndex >= 0 && iFindBox && iSearchFilter.IsPredictiveActivated() && iViewStack.Level() && |
|
761 |
!predictiveViewStack.IsNonMatchingMarkedContact( contactItemIndex ) ) |
|
762 |
{ |
|
763 |
iSearchFilter.CommitFindPaneTextL( iViewStack, iNameFormatter, contactItemIndex ); |
|
764 |
} |
|
765 |
||
766 |
} |
|
767 |
||
768 |
// -------------------------------------------------------------------------- |
|
769 |
// CPbk2NamesListReadyState::NamesListState |
|
770 |
// -------------------------------------------------------------------------- |
|
771 |
// |
|
772 |
TInt CPbk2NamesListReadyState::NamesListState() const |
|
773 |
{ |
|
774 |
return CPbk2NamesListControl::EStateReady; |
|
775 |
} |
|
776 |
||
777 |
// -------------------------------------------------------------------------- |
|
778 |
// CPbk2NamesListReadyState::HandleContactViewEventL |
|
779 |
// -------------------------------------------------------------------------- |
|
780 |
// |
|
781 |
void CPbk2NamesListReadyState::HandleContactViewEventL |
|
782 |
(TInt aEvent, TInt aIndex) |
|
783 |
{ |
|
784 |
// need to calculate list index from contact |
|
785 |
// view index |
|
786 |
TInt listIndex = CommandItemCount() + aIndex; |
|
787 |
HandleListboxEventL(aEvent, listIndex, EFalse ); |
|
788 |
||
789 |
TInt currentFocusIndex = iListBox.CurrentItemIndex(); |
|
790 |
TBool marked = iListBox.View()->ItemIsSelected( currentFocusIndex ); |
|
791 |
||
792 |
//update findpane according to the new focused contact after delete operation. |
|
793 |
//Do nothing if the next focused contact is marked because it would not be found. |
|
794 |
if ( aEvent == MPbk2NamesListState::EItemRemoved |
|
795 |
&& iSearchFilter.IsPredictiveActivated() |
|
796 |
&& iViewStack.Level() |
|
797 |
&& iFindBox |
|
798 |
&& iFindBox->TextLength() != 0 |
|
799 |
&& !marked) |
|
800 |
{ |
|
801 |
iSearchFilter.CommitFindPaneTextL( iViewStack, iNameFormatter, currentFocusIndex ); |
|
802 |
} |
|
803 |
} |
|
804 |
||
805 |
// -------------------------------------------------------------------------- |
|
806 |
// CPbk2NamesListReadyState::HandleCommandEventL |
|
807 |
// -------------------------------------------------------------------------- |
|
808 |
// |
|
809 |
void CPbk2NamesListReadyState::HandleCommandEventL |
|
810 |
(TInt aEvent, TInt /* aCommandIndex*/ ) |
|
811 |
{ |
|
812 |
HandleListboxEventL(aEvent, 0, ETrue ); |
|
813 |
} |
|
814 |
||
815 |
// -------------------------------------------------------------------------- |
|
816 |
// CPbk2NamesListReadyState::HandleListboxEventL |
|
817 |
// -------------------------------------------------------------------------- |
|
818 |
// |
|
819 |
void CPbk2NamesListReadyState::HandleListboxEventL |
|
820 |
(TInt aEvent, TInt aListboxIndex, TBool aMantainFocus ) |
|
821 |
{ |
|
822 |
switch (aEvent) |
|
823 |
{ |
|
824 |
case EItemAdded: |
|
825 |
{ |
|
826 |
//contact added, grid might not have all necessary characters. |
|
827 |
//this could be optimized, we could just check the added contact and |
|
828 |
//update map if the performance is not enough |
|
829 |
UpdateAdaptiveSearchGridL( ETrue ); |
|
830 |
||
831 |
// Inform find box and list box |
|
832 |
UpdateFindBoxL(); |
|
833 |
||
834 |
TInt topIndex = iListBox.TopItemIndex(); |
|
835 |
iListBox.HandleEventL(aEvent, aListboxIndex); |
|
836 |
||
837 |
// Maintain focus |
|
838 |
// TODO: similar focus handling code in case item delete in iListBox.HandleEventL |
|
839 |
// to consider to move this focus code there as well |
|
840 |
if (aListboxIndex >= 0 && aListboxIndex < iListBox.NumberOfItems() ) |
|
841 |
{ |
|
842 |
if ( aMantainFocus ) |
|
843 |
{ |
|
844 |
//keep focused item and top item if its not 0 |
|
845 |
if ( aListboxIndex <= iListBox.CurrentItemIndex() && |
|
846 |
( iListBox.CurrentItemIndex() + 1 ) < iListBox.NumberOfItems() ) |
|
847 |
{ |
|
848 |
iListBox.SetCurrentItemIndex( |
|
849 |
iListBox.CurrentItemIndex() + 1 ); |
|
850 |
if ( topIndex > 0 && ( topIndex + 1 ) < iListBox.NumberOfItems() ) |
|
851 |
{ |
|
852 |
iListBox.SetTopItemIndex( topIndex + 1 ); |
|
853 |
} |
|
854 |
} |
|
855 |
} |
|
856 |
else |
|
857 |
{ |
|
858 |
//change focus to the added item |
|
859 |
if ( aListboxIndex != iListBox.CurrentItemIndex() ) |
|
860 |
{ |
|
861 |
iListBox.SetCurrentItemIndex( aListboxIndex ); |
|
862 |
} |
|
863 |
} |
|
864 |
} |
|
865 |
||
866 |
iParent.DrawDeferred(); |
|
867 |
HandleFocusChangeL(); |
|
868 |
break; |
|
869 |
} |
|
870 |
case EItemRemoved: |
|
871 |
{ |
|
872 |
//contact removed, grids might have unecessary characters |
|
873 |
UpdateAdaptiveSearchGridL( ETrue ); |
|
874 |
||
875 |
// Inform find box and list box |
|
876 |
UpdateFindBoxL(); |
|
877 |
iListBox.HandleEventL(aEvent, aListboxIndex); |
|
878 |
||
879 |
// Maintain focus |
|
880 |
if (aListboxIndex >= 0 && aListboxIndex < iListBox.NumberOfItems() ) |
|
881 |
{ |
|
882 |
if ( aMantainFocus ) |
|
883 |
{ |
|
884 |
//no op |
|
885 |
} |
|
886 |
else |
|
887 |
{ |
|
888 |
//change focus |
|
889 |
if ( aListboxIndex != iListBox.CurrentItemIndex() ) |
|
890 |
{ |
|
891 |
iListBox.SetCurrentItemIndex( aListboxIndex ); |
|
892 |
} |
|
893 |
} |
|
894 |
} |
|
895 |
||
896 |
iParent.DrawDeferred(); |
|
897 |
HandleFocusChangeL(); |
|
898 |
break; |
|
899 |
} |
|
900 |
case EContactViewUpdated: |
|
901 |
{ |
|
902 |
UpdateAdaptiveSearchGridL( ETrue ); |
|
903 |
break; |
|
904 |
} |
|
905 |
default: |
|
906 |
{ |
|
907 |
// Do nothing |
|
908 |
break; |
|
909 |
} |
|
910 |
} |
|
911 |
} |
|
912 |
||
913 |
// -------------------------------------------------------------------------- |
|
914 |
// CPbk2NamesListReadyState::CoeControl |
|
915 |
// -------------------------------------------------------------------------- |
|
916 |
// |
|
917 |
CCoeControl& CPbk2NamesListReadyState::CoeControl() |
|
918 |
{ |
|
919 |
CCoeControl* tmp = NULL; |
|
920 |
return *static_cast<CCoeControl*>(tmp); |
|
921 |
} |
|
922 |
||
923 |
// -------------------------------------------------------------------------- |
|
924 |
// CPbk2NamesListReadyState::HandleControlEventL |
|
925 |
// -------------------------------------------------------------------------- |
|
926 |
// |
|
927 |
void CPbk2NamesListReadyState::HandleControlEventL( CCoeControl* aControl, |
|
928 |
MCoeControlObserver::TCoeEvent aEventType, TInt aParam ) |
|
929 |
{ |
|
930 |
if ( aEventType == MCoeControlObserver::EEventStateChanged ) |
|
931 |
{ |
|
932 |
// Find box |
|
933 |
if ( aControl == iFindBox ) |
|
934 |
{ |
|
935 |
if( aParam ) |
|
936 |
{ |
|
937 |
//means the search came from adaptive search grid |
|
938 |
if( iAdaptiveSearchGridFiller ) |
|
939 |
{ |
|
940 |
iAdaptiveSearchGridFiller->InvalidateAdaptiveSearchGrid(); |
|
941 |
} |
|
942 |
} |
|
943 |
||
944 |
if ( iFindDelay->IsActive() ) |
|
945 |
{ |
|
946 |
iFindDelay->Cancel(); |
|
947 |
} |
|
948 |
//if aParam is ETrue, it means that event came from adaptive search, which means |
|
949 |
//we do not want to delay filtering |
|
950 |
if ( ( !aParam ) && |
|
951 |
( iFindDelay ) && |
|
952 |
( NumberOfContacts() >= KFindDelayThresholdContacts ) ) |
|
953 |
{ |
|
954 |
iFindDelay->After( TTimeIntervalMicroSeconds32( KFindDelayTime ) ); |
|
955 |
} |
|
956 |
else |
|
957 |
{ |
|
958 |
UpdateFindResultL(); |
|
959 |
} |
|
960 |
} |
|
961 |
// List |
|
962 |
else if ( aControl == &iListBox ) |
|
963 |
{ |
|
964 |
HandleFocusChangeL(); |
|
965 |
} |
|
966 |
} |
|
967 |
} |
|
968 |
||
969 |
// -------------------------------------------------------------------------- |
|
970 |
// CPbk2NamesListReadyState::TopContactL |
|
971 |
// -------------------------------------------------------------------------- |
|
972 |
// |
|
973 |
const MVPbkViewContact* CPbk2NamesListReadyState::TopContactL() |
|
974 |
{ |
|
975 |
const MVPbkViewContact* contact = NULL; |
|
976 |
||
977 |
// There is an offset between listbox indexes and view indexes. |
|
978 |
const TInt topListboxIndex = iListBox.TopItemIndex(); |
|
979 |
const TInt enabledCommandCount = CommandItemCount(); |
|
980 |
// Check whether the index is valid. Also check whether the top |
|
981 |
// really is a contact. |
|
982 |
if ( topListboxIndex >= 0 && topListboxIndex >= enabledCommandCount ) |
|
983 |
{ |
|
984 |
// Map from listbox index to view index |
|
985 |
contact = &iViewStack.ContactAtL( |
|
986 |
topListboxIndex - enabledCommandCount ); |
|
987 |
} |
|
988 |
return contact; |
|
989 |
} |
|
990 |
||
991 |
// -------------------------------------------------------------------------- |
|
992 |
// CPbk2NamesListReadyState::ParentControl |
|
993 |
// -------------------------------------------------------------------------- |
|
994 |
// |
|
995 |
MPbk2ContactUiControl* CPbk2NamesListReadyState::ParentControl() const |
|
996 |
{ |
|
997 |
// Names list control does not have a parent control |
|
998 |
return NULL; |
|
999 |
} |
|
1000 |
||
1001 |
// -------------------------------------------------------------------------- |
|
1002 |
// CPbk2NamesListReadyState::NumberOfContacts |
|
1003 |
// -------------------------------------------------------------------------- |
|
1004 |
// |
|
1005 |
TInt CPbk2NamesListReadyState::NumberOfContacts() const |
|
1006 |
{ |
|
1007 |
// The listbox can also have command items. |
|
1008 |
TInt result = iListBox.NumberOfItems() - CommandItemCount(); |
|
1009 |
if ( result < 0 ) |
|
1010 |
{ |
|
1011 |
result = 0; // No contacts |
|
1012 |
} |
|
1013 |
return result; |
|
1014 |
} |
|
1015 |
||
1016 |
// -------------------------------------------------------------------------- |
|
1017 |
// CPbk2NamesListReadyState::FocusedContactL |
|
1018 |
// -------------------------------------------------------------------------- |
|
1019 |
// |
|
1020 |
const MVPbkBaseContact* CPbk2NamesListReadyState::FocusedContactL() const |
|
1021 |
{ |
|
1022 |
return FocusedViewContactL(); |
|
1023 |
} |
|
1024 |
||
1025 |
// -------------------------------------------------------------------------- |
|
1026 |
// CPbk2NamesListReadyState::FocusedViewContactL |
|
1027 |
// -------------------------------------------------------------------------- |
|
1028 |
// |
|
1029 |
const MVPbkViewContact* CPbk2NamesListReadyState::FocusedViewContactL() const |
|
1030 |
{ |
|
1031 |
const MVPbkViewContact* contact = NULL; |
|
1032 |
||
1033 |
// There is an offset between listbox indexes and view indexes. |
|
1034 |
const TInt focusListboxIndex = iListBox.CurrentItemIndex(); |
|
1035 |
const TInt enabledCommandCount = CommandItemCount(); |
|
1036 |
// Is the focus on a contact. Check... |
|
1037 |
if (focusListboxIndex >= 0 && focusListboxIndex >= enabledCommandCount ) |
|
1038 |
{ |
|
1039 |
// Yes, the focus is on a contact. |
|
1040 |
// Map from listbox index to view index |
|
1041 |
contact = &iViewStack.ContactAtL( |
|
1042 |
focusListboxIndex - enabledCommandCount ); |
|
1043 |
} |
|
1044 |
return contact; |
|
1045 |
} |
|
1046 |
||
1047 |
// -------------------------------------------------------------------------- |
|
1048 |
// CPbk2NamesListReadyState::FocusedStoreContact |
|
1049 |
// -------------------------------------------------------------------------- |
|
1050 |
// |
|
1051 |
const MVPbkStoreContact* CPbk2NamesListReadyState::FocusedStoreContact() const |
|
1052 |
{ |
|
1053 |
return NULL; |
|
1054 |
} |
|
1055 |
||
1056 |
// -------------------------------------------------------------------------- |
|
1057 |
// CPbk2NamesListReadyState::SetFocusedContactL |
|
1058 |
// -------------------------------------------------------------------------- |
|
1059 |
// |
|
1060 |
void CPbk2NamesListReadyState::SetFocusedContactL |
|
1061 |
( const MVPbkBaseContact& aContact ) |
|
1062 |
{ |
|
1063 |
SetFocusedContactL( KErrNotSupported, &aContact ); |
|
1064 |
} |
|
1065 |
||
1066 |
// -------------------------------------------------------------------------- |
|
1067 |
// CPbk2NamesListReadyState::SetFocusedContactL |
|
1068 |
// -------------------------------------------------------------------------- |
|
1069 |
// |
|
1070 |
void CPbk2NamesListReadyState::SetFocusedContactL |
|
1071 |
( const MVPbkContactBookmark& aContactBookmark ) |
|
1072 |
{ |
|
1073 |
TInt viewIndex = iViewStack.IndexOfBookmarkL( aContactBookmark ); |
|
1074 |
SetFocusedContactL( viewIndex, NULL ); |
|
1075 |
} |
|
1076 |
||
1077 |
// -------------------------------------------------------------------------- |
|
1078 |
// CPbk2NamesListReadyState::SetFocusedContactL |
|
1079 |
// -------------------------------------------------------------------------- |
|
1080 |
// |
|
1081 |
void CPbk2NamesListReadyState::SetFocusedContactL |
|
1082 |
( const MVPbkContactLink& aContactLink ) |
|
1083 |
{ |
|
1084 |
TInt viewIndex = iViewStack.IndexOfLinkL( aContactLink ); |
|
1085 |
SetFocusedContactL( viewIndex, NULL ); |
|
1086 |
} |
|
1087 |
||
1088 |
// -------------------------------------------------------------------------- |
|
1089 |
// CPbk2NamesListReadyState::FocusedContactIndex |
|
1090 |
// -------------------------------------------------------------------------- |
|
1091 |
// |
|
1092 |
TInt CPbk2NamesListReadyState::FocusedContactIndex() const |
|
1093 |
{ |
|
1094 |
// The result is a view index. There is an offset between listbox indexes |
|
1095 |
// and view indexes. |
|
1096 |
||
1097 |
TInt viewIndex = KErrNotFound; |
|
1098 |
const TInt currentListboxIndex = iListBox.CurrentItemIndex(); |
|
1099 |
const TInt commandCount = CommandItemCount(); |
|
1100 |
// Is the focus on a contact or on a command item? Check: |
|
1101 |
if ( currentListboxIndex >= commandCount ) |
|
1102 |
{ |
|
1103 |
// Yes, the focus is on a contact. |
|
1104 |
// Need to map from listbox indexes to view indexes. |
|
1105 |
viewIndex = currentListboxIndex - commandCount; |
|
1106 |
} |
|
1107 |
return viewIndex; |
|
1108 |
} |
|
1109 |
||
1110 |
// -------------------------------------------------------------------------- |
|
1111 |
// CPbk2NamesListReadyState::SetFocusedContactIndex |
|
1112 |
// -------------------------------------------------------------------------- |
|
1113 |
// |
|
1114 |
void CPbk2NamesListReadyState::SetFocusedContactIndexL( TInt aIndex ) |
|
1115 |
{ |
|
1116 |
// The aIndex is a view index. There is an offset between listbox indexes |
|
1117 |
// and view indexes. |
|
1118 |
||
1119 |
if ( aIndex < 0 ) |
|
1120 |
{ |
|
1121 |
aIndex = 0; |
|
1122 |
} |
|
1123 |
const TInt enabledCommandCount = CommandItemCount(); |
|
1124 |
if ( aIndex > iListBox.BottomItemIndex() - enabledCommandCount ) |
|
1125 |
{ |
|
1126 |
aIndex = iListBox.BottomItemIndex() - enabledCommandCount; |
|
1127 |
} |
|
1128 |
||
1129 |
SetFocusedContactL( aIndex, NULL ); |
|
1130 |
} |
|
1131 |
||
1132 |
// -------------------------------------------------------------------------- |
|
1133 |
// CPbk2NamesListReadyState::NumberOfContactFields |
|
1134 |
// -------------------------------------------------------------------------- |
|
1135 |
// |
|
1136 |
TInt CPbk2NamesListReadyState::NumberOfContactFields() const |
|
1137 |
{ |
|
1138 |
return KErrNotSupported; |
|
1139 |
} |
|
1140 |
||
1141 |
// -------------------------------------------------------------------------- |
|
1142 |
// CPbk2NamesListReadyState::FocusedField |
|
1143 |
// -------------------------------------------------------------------------- |
|
1144 |
// |
|
1145 |
const MVPbkBaseContactField* CPbk2NamesListReadyState::FocusedField() const |
|
1146 |
{ |
|
1147 |
// There is no field level focus |
|
1148 |
return NULL; |
|
1149 |
} |
|
1150 |
||
1151 |
// -------------------------------------------------------------------------- |
|
1152 |
// CPbk2NamesListReadyState::FocusedFieldIndex |
|
1153 |
// -------------------------------------------------------------------------- |
|
1154 |
// |
|
1155 |
TInt CPbk2NamesListReadyState::FocusedFieldIndex() const |
|
1156 |
{ |
|
1157 |
// There is no field level focus |
|
1158 |
return KErrNotFound; |
|
1159 |
} |
|
1160 |
||
1161 |
// -------------------------------------------------------------------------- |
|
1162 |
// CPbk2NamesListReadyState::SetFocusedFieldIndex |
|
1163 |
// -------------------------------------------------------------------------- |
|
1164 |
// |
|
1165 |
void CPbk2NamesListReadyState::SetFocusedFieldIndex( TInt /*aIndex*/ ) |
|
1166 |
{ |
|
1167 |
// Do nothing |
|
1168 |
} |
|
1169 |
||
1170 |
// -------------------------------------------------------------------------- |
|
1171 |
// CPbk2NamesListReadyState::ContactsMarked |
|
1172 |
// -------------------------------------------------------------------------- |
|
1173 |
// |
|
1174 |
TBool CPbk2NamesListReadyState::ContactsMarked() const |
|
1175 |
{ |
|
1176 |
return iListBox.ContactsMarked(); |
|
1177 |
} |
|
1178 |
||
1179 |
// -------------------------------------------------------------------------- |
|
1180 |
// CPbk2NamesListReadyState::SelectedContactsL |
|
1181 |
// -------------------------------------------------------------------------- |
|
1182 |
// |
|
1183 |
MVPbkContactLinkArray* |
|
1184 |
CPbk2NamesListReadyState::SelectedContactsL() const |
|
1185 |
{ |
|
1186 |
// Get listbox selection indexes, a reference only |
|
1187 |
const CListBoxView::CSelectionIndexArray* selArray = |
|
1188 |
iListBox.SelectionIndexes(); |
|
1189 |
||
1190 |
||
1191 |
TInt count = 1; // initialize to one, because if there are |
|
1192 |
// no selections we operate with one focused contact |
|
1193 |
if (selArray) |
|
1194 |
{ |
|
1195 |
count = selArray->Count(); |
|
1196 |
} |
|
1197 |
||
1198 |
CVPbkContactLinkArray* linkArray = NULL; |
|
1199 |
||
1200 |
if (count > 0) |
|
1201 |
{ |
|
1202 |
linkArray = CVPbkContactLinkArray::NewLC(); |
|
1203 |
||
1204 |
// Loop through the selections and construct a link for |
|
1205 |
// each of the contacts |
|
1206 |
const TInt commandItemCount = CommandItemCount(); |
|
1207 |
for (TInt i=0; i<count; ++i) |
|
1208 |
{ |
|
1209 |
const TInt singleSelection = selArray->At(i); |
|
1210 |
if ( IsContactAtListboxIndex( singleSelection ) ) |
|
1211 |
{ |
|
1212 |
// Take the view contact from the view, the ownership |
|
1213 |
// stays at the view |
|
1214 |
const MVPbkViewContact* contact = |
|
1215 |
&iViewStack.ContactAtL( singleSelection - commandItemCount ); |
|
1216 |
MVPbkContactLink* link = contact->CreateLinkLC(); |
|
1217 |
if (link) |
|
1218 |
{ |
|
1219 |
linkArray->AppendL(link); |
|
1220 |
CleanupStack::Pop(); // the array takes ownership of the link |
|
1221 |
} |
|
1222 |
} |
|
1223 |
} |
|
1224 |
||
1225 |
CleanupStack::Pop(linkArray); |
|
1226 |
} |
|
1227 |
||
1228 |
return linkArray; |
|
1229 |
} |
|
1230 |
||
1231 |
// -------------------------------------------------------------------------- |
|
1232 |
// CPbk2NamesListReadyState::SelectedContactsOrFocusedContactL |
|
1233 |
// -------------------------------------------------------------------------- |
|
1234 |
// |
|
1235 |
MVPbkContactLinkArray* |
|
1236 |
CPbk2NamesListReadyState::SelectedContactsOrFocusedContactL() const |
|
1237 |
{ |
|
1238 |
MVPbkContactLinkArray* result = NULL; |
|
1239 |
result = SelectedContactsL(); |
|
1240 |
||
1241 |
if ( !result ) |
|
1242 |
{ |
|
1243 |
CVPbkContactLinkArray* array = CVPbkContactLinkArray::NewLC(); |
|
1244 |
const MVPbkBaseContact* focusedContact = FocusedContactL(); |
|
1245 |
if ( focusedContact ) |
|
1246 |
{ |
|
1247 |
MVPbkContactLink* link = focusedContact->CreateLinkLC(); |
|
1248 |
CleanupStack::Pop(); // link |
|
1249 |
array->AppendL( link ); |
|
1250 |
} |
|
1251 |
else |
|
1252 |
{ |
|
1253 |
// there was no focused contact, check if this is the my card |
|
1254 |
AppendMyCardLinkIfExistL( *array ); |
|
1255 |
} |
|
1256 |
CleanupStack::Pop(); // array |
|
1257 |
result = array; |
|
1258 |
} |
|
1259 |
||
1260 |
return result; |
|
1261 |
} |
|
1262 |
||
1263 |
// -------------------------------------------------------------------------- |
|
1264 |
// CPbk2NamesListReadyState::AppendMyCardLinkIfExistL |
|
1265 |
// -------------------------------------------------------------------------- |
|
1266 |
// |
|
1267 |
void CPbk2NamesListReadyState::AppendMyCardLinkIfExistL( CVPbkContactLinkArray& aArray ) const |
|
1268 |
{ |
|
1269 |
TInt currentItem = iListBox.CurrentItemIndex(); |
|
1270 |
// if focused index is command item |
|
1271 |
if( currentItem < CommandItemCount() ) |
|
1272 |
{ |
|
1273 |
// check if the command is my card ( this search is copied from CommandItemAt - function to avoid const cast) |
|
1274 |
// Some of the commands might be disabled. Skip those. |
|
1275 |
TInt enabledCount = 0; |
|
1276 |
TInt indexOfResult = KErrNotFound; |
|
1277 |
for ( TInt n = 0; n < iCommandItems.Count() && indexOfResult == KErrNotFound; ++n ) |
|
1278 |
{ |
|
1279 |
if ( iCommandItems[ n ]->IsEnabled() ) |
|
1280 |
{ |
|
1281 |
enabledCount++; |
|
1282 |
if ( enabledCount-1 == currentItem ) |
|
1283 |
{ |
|
1284 |
indexOfResult = n; |
|
1285 |
} |
|
1286 |
} |
|
1287 |
} |
|
1288 |
MPbk2UiControlCmdItem* item = iCommandItems[ indexOfResult ]; |
|
1289 |
// check if the command item was a my card |
|
1290 |
if( item->CommandId() == EPbk2CmdOpenMyCard ) |
|
1291 |
{ |
|
1292 |
// get extension point and my card link |
|
1293 |
TAny* object = item->ControlCmdItemExtension( TUid::Uid( KPbk2ControlCmdItemExtensionUID ) ); |
|
1294 |
if( object ) |
|
1295 |
{ |
|
1296 |
MPbk2DoubleListboxCmdItemExtension* extension = |
|
1297 |
static_cast<MPbk2DoubleListboxCmdItemExtension*>( object ); |
|
1298 |
// if extension exists |
|
1299 |
if( extension ) |
|
1300 |
{ |
|
1301 |
const MVPbkContactLink* link = extension->Link(); |
|
1302 |
// if link exists, add it to the array |
|
1303 |
if( link ) |
|
1304 |
{ |
|
1305 |
aArray.AppendL( link->CloneLC() ); |
|
1306 |
CleanupStack::Pop(); |
|
1307 |
} |
|
1308 |
} |
|
1309 |
} |
|
1310 |
} |
|
1311 |
} |
|
1312 |
} |
|
1313 |
||
1314 |
||
1315 |
// -------------------------------------------------------------------------- |
|
1316 |
// CPbk2NamesListReadyState::SelectedContactsIteratorL |
|
1317 |
// -------------------------------------------------------------------------- |
|
1318 |
// |
|
1319 |
MPbk2ContactLinkIterator* |
|
1320 |
CPbk2NamesListReadyState::SelectedContactsIteratorL() const |
|
1321 |
{ |
|
1322 |
// Get listbox selection indexes, a reference only |
|
1323 |
const CListBoxView::CSelectionIndexArray* selArray = |
|
1324 |
iListBox.SelectionIndexes(); |
|
1325 |
||
1326 |
TInt count = 0; |
|
1327 |
if ( selArray ) |
|
1328 |
{ |
|
1329 |
count = selArray->Count(); |
|
1330 |
} |
|
1331 |
||
1332 |
MPbk2ContactLinkIterator* iterator = NULL; |
|
1333 |
||
1334 |
if ( count > 0 ) |
|
1335 |
{ |
|
1336 |
// Need to map the listbox indexes to view indexes. |
|
1337 |
// Also need to filter out cmd items. |
|
1338 |
iIteratorIndexes.Reset(); |
|
1339 |
const TInt commandItemCount = CommandItemCount(); |
|
1340 |
const TInt selectionCount = selArray->Count(); |
|
1341 |
for ( TInt n = 0; n < selectionCount; ++n ) |
|
1342 |
{ |
|
1343 |
const TInt listboxIndex = selArray->At( n ); |
|
1344 |
if ( listboxIndex >= commandItemCount) |
|
1345 |
{ |
|
1346 |
// It is a contact. |
|
1347 |
// Do a mapping from listbox index to view index |
|
1348 |
iIteratorIndexes.AppendL( listboxIndex - commandItemCount ); |
|
1349 |
} |
|
1350 |
} |
|
1351 |
iterator = CPbk2ContactViewIterator::NewLC |
|
1352 |
( iViewStack, iIteratorIndexes.Array() ); |
|
1353 |
CleanupStack::Pop(); // iterator |
|
1354 |
} |
|
1355 |
||
1356 |
return iterator; |
|
1357 |
} |
|
1358 |
||
1359 |
// -------------------------------------------------------------------------- |
|
1360 |
// CPbk2NamesListReadyState::SelectedContactStoresL |
|
1361 |
// -------------------------------------------------------------------------- |
|
1362 |
// |
|
1363 |
CArrayPtr<MVPbkContactStore>* |
|
1364 |
CPbk2NamesListReadyState::SelectedContactStoresL() const |
|
1365 |
{ |
|
1366 |
// This is not a state of the contact store control |
|
1367 |
return NULL; |
|
1368 |
} |
|
1369 |
||
1370 |
// -------------------------------------------------------------------------- |
|
1371 |
// CPbk2NamesListReadyState::ClearMarks |
|
1372 |
// -------------------------------------------------------------------------- |
|
1373 |
// |
|
1374 |
void CPbk2NamesListReadyState::ClearMarks() |
|
1375 |
{ |
|
1376 |
iListBox.View()->ClearSelection(); |
|
1377 |
} |
|
1378 |
||
1379 |
// -------------------------------------------------------------------------- |
|
1380 |
// CPbk2NamesListReadyState::SetSelectedContactL |
|
1381 |
// -------------------------------------------------------------------------- |
|
1382 |
// |
|
1383 |
void CPbk2NamesListReadyState::SetSelectedContactL |
|
1384 |
( TInt aIndex, TBool aSelected ) |
|
1385 |
{ |
|
1386 |
if ( aSelected ) |
|
1387 |
{ |
|
1388 |
iListBox.View()->SelectItemL( aIndex ); |
|
1389 |
} |
|
1390 |
else |
|
1391 |
{ |
|
1392 |
iListBox.View()->DeselectItem( aIndex ); |
|
1393 |
} |
|
1394 |
} |
|
1395 |
||
1396 |
// -------------------------------------------------------------------------- |
|
1397 |
// CPbk2NamesListReadyState::SetSelectedContactL |
|
1398 |
// -------------------------------------------------------------------------- |
|
1399 |
// |
|
1400 |
void CPbk2NamesListReadyState::SetSelectedContactL( |
|
1401 |
const MVPbkContactBookmark& aContactBookmark, |
|
1402 |
TBool aSelected ) |
|
1403 |
{ |
|
1404 |
TInt cmdItemCount = CommandItemCount(); |
|
1405 |
TInt index = iViewStack.IndexOfBookmarkL( aContactBookmark ); |
|
1406 |
if ( index != KErrNotFound ) |
|
1407 |
{ |
|
1408 |
SetSelectedContactL( cmdItemCount+index, aSelected ); |
|
1409 |
} |
|
1410 |
} |
|
1411 |
||
1412 |
// -------------------------------------------------------------------------- |
|
1413 |
// CPbk2NamesListReadyState::SetSelectedContactL |
|
1414 |
// -------------------------------------------------------------------------- |
|
1415 |
// |
|
1416 |
void CPbk2NamesListReadyState::SetSelectedContactL( |
|
1417 |
const MVPbkContactLink& aContactLink, |
|
1418 |
TBool aSelected ) |
|
1419 |
{ |
|
1420 |
TInt cmdItemCount = CommandItemCount(); |
|
1421 |
TInt index = iViewStack.IndexOfLinkL( aContactLink ); |
|
1422 |
if ( index != KErrNotFound ) |
|
1423 |
{ |
|
1424 |
SetSelectedContactL( index+cmdItemCount, aSelected ); |
|
1425 |
} |
|
1426 |
} |
|
1427 |
||
1428 |
||
1429 |
TInt CPbk2NamesListReadyState::CommandItemCount() const |
|
1430 |
{ |
|
1431 |
// Some of the commands might be disabled. Don't count those. |
|
1432 |
TInt enabledCommandCount = 0; |
|
1433 |
for ( TInt n = 0; n < iCommandItems.Count(); ++n ) |
|
1434 |
{ |
|
1435 |
if ( iCommandItems[ n ]->IsEnabled() ) |
|
1436 |
{ |
|
1437 |
enabledCommandCount++; |
|
1438 |
} |
|
1439 |
} |
|
1440 |
return enabledCommandCount; |
|
1441 |
} |
|
1442 |
||
1443 |
const MPbk2UiControlCmdItem& |
|
1444 |
CPbk2NamesListReadyState::CommandItemAt( TInt aIndex ) const |
|
1445 |
{ |
|
1446 |
// Some of the commands might be disabled. Skip those. |
|
1447 |
TInt enabledCount = 0; |
|
1448 |
TInt indexOfResult = KErrNotFound; |
|
1449 |
||
1450 |
for ( TInt n = 0; n < iCommandItems.Count()&& indexOfResult == KErrNotFound; ++n ) |
|
1451 |
{ |
|
1452 |
if ( iCommandItems[ n ]->IsEnabled() ) |
|
1453 |
{ |
|
1454 |
enabledCount++; |
|
1455 |
if ( enabledCount-1 == aIndex ) |
|
1456 |
{ |
|
1457 |
indexOfResult = n; |
|
1458 |
} |
|
1459 |
} |
|
1460 |
} |
|
1461 |
||
1462 |
return *iCommandItems[ indexOfResult ]; |
|
1463 |
} |
|
1464 |
||
1465 |
const MPbk2UiControlCmdItem* |
|
1466 |
CPbk2NamesListReadyState::FocusedCommandItem() const |
|
1467 |
{ |
|
1468 |
const MPbk2UiControlCmdItem* cmdItem = NULL; |
|
1469 |
// Is the focus on a command item: |
|
1470 |
TInt focusListIndex = iListBox.CurrentItemIndex(); |
|
1471 |
const TInt commandItemCount = CommandItemCount(); |
|
1472 |
if ( focusListIndex != KErrNotFound && focusListIndex < commandItemCount ) |
|
1473 |
{ |
|
1474 |
// Yes it's a command item. |
|
1475 |
cmdItem = &CommandItemAt(focusListIndex); |
|
1476 |
} |
|
1477 |
return cmdItem; |
|
1478 |
} |
|
1479 |
||
1480 |
void CPbk2NamesListReadyState::DeleteCommandItemL( TInt /*aIndex*/ ) |
|
1481 |
{ |
|
1482 |
// ownership & management of iCommandItems is wasted in names list |
|
1483 |
// control. Do nothing here |
|
1484 |
} |
|
1485 |
||
1486 |
void CPbk2NamesListReadyState::AddCommandItemL(MPbk2UiControlCmdItem* /*aCommand*/, TInt /*aIndex*/) |
|
1487 |
{ |
|
1488 |
// ownership & management of iCommandItems is wasted in names list |
|
1489 |
// control. Do nothing here |
|
1490 |
} |
|
1491 |
||
1492 |
// -------------------------------------------------------------------------- |
|
1493 |
// CPbk2NamesListReadyState::DynInitMenuPaneL |
|
1494 |
// -------------------------------------------------------------------------- |
|
1495 |
// |
|
1496 |
void CPbk2NamesListReadyState::DynInitMenuPaneL( |
|
1497 |
TInt aResourceId, CEikMenuPane* aMenuPane) const |
|
1498 |
{ |
|
1499 |
TInt commandItemCount = CommandItemCount(); |
|
1500 |
||
1501 |
// Stores the position of the searched menu item. |
|
1502 |
// This position is not needed or used anywhere |
|
1503 |
TInt pos; |
|
1504 |
||
1505 |
if ((iListBox.SelectionIndexes()->Count() + commandItemCount ) |
|
1506 |
== iListBox.Model()->NumberOfItems()) |
|
1507 |
{ |
|
1508 |
if (aMenuPane->MenuItemExists( EAknCmdMarkingModeEnter, pos ) ) |
|
1509 |
{ |
|
1510 |
aMenuPane->SetItemDimmed( EAknCmdMarkingModeEnter, ETrue ); |
|
1511 |
} |
|
1512 |
} |
|
1513 |
||
1514 |
} |
|
1515 |
||
1516 |
// -------------------------------------------------------------------------- |
|
1517 |
// CPbk2NamesListReadyState::ProcessCommandL |
|
1518 |
// -------------------------------------------------------------------------- |
|
1519 |
// |
|
1520 |
void CPbk2NamesListReadyState::ProcessCommandL |
|
1521 |
(TInt aCommandId) const |
|
1522 |
{ |
|
1523 |
AknSelectionService::HandleMarkableListProcessCommandL |
|
1524 |
(aCommandId, &iListBox); |
|
1525 |
||
1526 |
// Send event |
|
1527 |
TPbk2ControlEvent event( TPbk2ControlEvent::EContactSelected ); |
|
1528 |
event.iInt = iListBox.CurrentItemIndex(); |
|
1529 |
||
1530 |
switch( aCommandId ) |
|
1531 |
{ |
|
1532 |
case EAknCmdMark: |
|
1533 |
case EAknMarkAll: |
|
1534 |
{ |
|
1535 |
// Send event about changed state |
|
1536 |
iEventSender.SendEventToObserversL( event ); |
|
1537 |
// commands should stay unmarked |
|
1538 |
UnmarkCommands(); |
|
1539 |
break; |
|
1540 |
} |
|
1541 |
||
1542 |
case EAknCmdUnmark: |
|
1543 |
{ |
|
1544 |
event.iEventType = TPbk2ControlEvent::EContactUnselected; |
|
1545 |
iEventSender.SendEventToObserversL( event ); |
|
1546 |
break; |
|
1547 |
} |
|
1548 |
||
1549 |
case EAknUnmarkAll: |
|
1550 |
{ |
|
1551 |
// Send event about changed state |
|
1552 |
event.iEventType = TPbk2ControlEvent::EContactUnselectedAll; |
|
1553 |
iEventSender.SendEventToObserversL( event ); |
|
1554 |
break; |
|
1555 |
} |
|
1556 |
||
1557 |
default:; |
|
1558 |
} |
|
1559 |
} |
|
1560 |
||
1561 |
// -------------------------------------------------------------------------- |
|
1562 |
// CPbk2NamesListReadyState::UpdateAfterCommandExecution |
|
1563 |
// -------------------------------------------------------------------------- |
|
1564 |
// |
|
1565 |
void CPbk2NamesListReadyState::UpdateAfterCommandExecution() |
|
1566 |
{ |
|
1567 |
// Do nothing |
|
1568 |
} |
|
1569 |
||
1570 |
// -------------------------------------------------------------------------- |
|
1571 |
// CPbk2NamesListReadyState::GetMenuFilteringFlagsL |
|
1572 |
// -------------------------------------------------------------------------- |
|
1573 |
// |
|
1574 |
TInt CPbk2NamesListReadyState::GetMenuFilteringFlagsL() const |
|
1575 |
{ |
|
1576 |
TInt ret = KPbk2ListContainsItems; |
|
1577 |
if (ContactsMarked()) |
|
1578 |
{ |
|
1579 |
ret |= KPbk2ListContainsMarkedItems; |
|
1580 |
} |
|
1581 |
else |
|
1582 |
{ |
|
1583 |
ret |= KPbk2ListContainsNoMarkedItems; |
|
1584 |
} |
|
1585 |
return ret; |
|
1586 |
} |
|
1587 |
||
1588 |
// -------------------------------------------------------------------------- |
|
1589 |
// CPbk2NamesListReadyState::ControlStateL |
|
1590 |
// -------------------------------------------------------------------------- |
|
1591 |
// |
|
1592 |
CPbk2ViewState* CPbk2NamesListReadyState::ControlStateL() const |
|
1593 |
{ |
|
1594 |
// State objects do not handle control state changes |
|
1595 |
return NULL; |
|
1596 |
} |
|
1597 |
||
1598 |
// -------------------------------------------------------------------------- |
|
1599 |
// CPbk2NamesListReadyState::SetFocusedContactL |
|
1600 |
// -------------------------------------------------------------------------- |
|
1601 |
// |
|
1602 |
void CPbk2NamesListReadyState::SetFocusedContactL( TInt aIndex, |
|
1603 |
const MVPbkBaseContact* aContact ) |
|
1604 |
{ |
|
1605 |
// The aIndex is a view index. There is an offset between listbox indexes |
|
1606 |
// and view indexes. |
|
1607 |
||
1608 |
TInt viewIndex = KErrNotReady; |
|
1609 |
||
1610 |
if ( aContact ) |
|
1611 |
{ |
|
1612 |
MVPbkContactBookmark* bookmark = aContact->CreateBookmarkLC(); |
|
1613 |
TInt contactIndex = iViewStack.IndexOfBookmarkL( *bookmark ); |
|
1614 |
CleanupStack::PopAndDestroy(); // bookmark |
|
1615 |
||
1616 |
if ( contactIndex >= 0 && |
|
1617 |
contactIndex < iViewStack.ContactCountL() ) |
|
1618 |
{ |
|
1619 |
viewIndex = contactIndex; |
|
1620 |
} |
|
1621 |
} |
|
1622 |
||
1623 |
if ( viewIndex == KErrNotReady ) |
|
1624 |
{ |
|
1625 |
if ( aIndex >= 0 && |
|
1626 |
aIndex < iViewStack.ContactCountL() ) |
|
1627 |
{ |
|
1628 |
viewIndex = aIndex; |
|
1629 |
} |
|
1630 |
} |
|
1631 |
||
1632 |
// Need to map current listbox index to view indexes. |
|
1633 |
// But at the same time check whether the current item is a contact. |
|
1634 |
const TInt enabledCommandCount = CommandItemCount(); |
|
1635 |
TInt currentContactAsViewIndex = KErrNotReady; |
|
1636 |
if ( iListBox.CurrentItemIndex() >= enabledCommandCount ) |
|
1637 |
{ |
|
1638 |
// Yes, the current item is a contact. |
|
1639 |
currentContactAsViewIndex = |
|
1640 |
iListBox.CurrentItemIndex() - enabledCommandCount; |
|
1641 |
} |
|
1642 |
||
1643 |
// If index is valid, and not already the current one, then use it to set |
|
1644 |
// the current item. |
|
1645 |
if ( viewIndex != KErrNotReady && viewIndex != currentContactAsViewIndex ) |
|
1646 |
{ |
|
1647 |
iListBox.SetCurrentItemIndex( viewIndex + enabledCommandCount ); |
|
1648 |
// Force hiding of thumbnail from previously focused contact |
|
1649 |
HideThumbnail(); |
|
1650 |
HandleFocusChangeL(); |
|
1651 |
} |
|
1652 |
||
1653 |
// Should be drawn always to be sure that UI is updated |
|
1654 |
iParent.DrawDeferred(); |
|
1655 |
} |
|
1656 |
||
1657 |
// -------------------------------------------------------------------------- |
|
1658 |
// CPbk2NamesListReadyState::RestoreControlStateL |
|
1659 |
// -------------------------------------------------------------------------- |
|
1660 |
// |
|
1661 |
void CPbk2NamesListReadyState::RestoreControlStateL |
|
1662 |
(CPbk2ViewState* aState) |
|
1663 |
{ |
|
1664 |
TBool redraw = EFalse; |
|
1665 |
if (aState->Flags() & CPbk2ViewState::EInitialized) |
|
1666 |
{ |
|
1667 |
iListBox.Reset(); |
|
1668 |
redraw = ETrue; |
|
1669 |
} |
|
1670 |
else |
|
1671 |
{ |
|
1672 |
if (iViewStack.ContactCountL() > 0) |
|
1673 |
{ |
|
1674 |
if (aState->Flags() & CPbk2ViewState::EFocusFirst) |
|
1675 |
{ |
|
1676 |
iListBox.SetCurrentItemIndex(0); |
|
1677 |
} |
|
1678 |
else if (aState->Flags() & CPbk2ViewState::EFocusLast) |
|
1679 |
{ |
|
1680 |
iListBox.SetCurrentItemIndex(iListBox.Model()->NumberOfItems()-1); |
|
1681 |
} |
|
1682 |
else |
|
1683 |
{ |
|
1684 |
// Restore top contact |
|
1685 |
const MVPbkContactLink* topContact = aState->TopContact(); |
|
1686 |
if (topContact) |
|
1687 |
{ |
|
1688 |
const TInt viewIndex = iViewStack.IndexOfLinkL(*topContact); |
|
1689 |
if (viewIndex >= 0) |
|
1690 |
{ |
|
1691 |
const TInt prevListboxIndex = iListBox.TopItemIndex(); |
|
1692 |
// There is an offset between listbox indexes |
|
1693 |
// and view indexes. |
|
1694 |
const TInt listboxIndex = viewIndex + CommandItemCount(); |
|
1695 |
iListBox.SetTopItemIndex(listboxIndex); |
|
1696 |
iListBox.FixTopItemIndex(); |
|
1697 |
if (listboxIndex != prevListboxIndex) |
|
1698 |
{ |
|
1699 |
redraw = ETrue; |
|
1700 |
} |
|
1701 |
} |
|
1702 |
} |
|
1703 |
||
1704 |
const MVPbkContactLink* focusedContact = aState->FocusedContact(); |
|
1705 |
if (focusedContact) |
|
1706 |
{ |
|
1707 |
const TInt viewIndex = |
|
1708 |
iViewStack.IndexOfLinkL(*focusedContact); |
|
1709 |
if (viewIndex >= 0) |
|
1710 |
{ |
|
1711 |
const TInt prevListboxIndex = iListBox.CurrentItemIndex(); |
|
1712 |
// There is an offset between listbox indexes |
|
1713 |
// and view indexes. |
|
1714 |
const TInt listboxIndex = viewIndex + CommandItemCount(); |
|
1715 |
iListBox.SetCurrentItemIndex(listboxIndex); |
|
1716 |
if (listboxIndex != prevListboxIndex) |
|
1717 |
{ |
|
1718 |
redraw = ETrue; |
|
1719 |
} |
|
1720 |
} |
|
1721 |
} |
|
1722 |
} |
|
1723 |
// Restore selections |
|
1724 |
const MVPbkContactLinkArray* markedContacts = |
|
1725 |
aState->MarkedContacts(); |
|
1726 |
if (RestoreMarkedContactsL(markedContacts)) |
|
1727 |
{ |
|
1728 |
redraw = ETrue; |
|
1729 |
} |
|
1730 |
} |
|
1731 |
} |
|
1732 |
if (redraw) |
|
1733 |
{ |
|
1734 |
iParent.DrawDeferred(); |
|
1735 |
iListBox.UpdateScrollBarsL(); |
|
1736 |
HandleFocusChangeL(); |
|
1737 |
} |
|
1738 |
} |
|
1739 |
||
1740 |
// -------------------------------------------------------------------------- |
|
1741 |
// CPbk2NamesListReadyState::FindTextL |
|
1742 |
// -------------------------------------------------------------------------- |
|
1743 |
// |
|
1744 |
const TDesC& CPbk2NamesListReadyState::FindTextL() |
|
1745 |
{ |
|
1746 |
if ( iFindBox ) |
|
1747 |
{ |
|
1748 |
TPbk2FindTextUtil::EnsureFindTextBufSizeL( |
|
1749 |
*iFindBox, |
|
1750 |
&iFindTextBuf ); |
|
1751 |
TPtr bufPtr = iFindTextBuf->Des(); |
|
1752 |
iFindBox->GetSearchText(bufPtr); |
|
1753 |
return *iFindTextBuf; |
|
1754 |
} |
|
1755 |
||
1756 |
return KNullDesC; |
|
1757 |
} |
|
1758 |
||
1759 |
||
1760 |
// -------------------------------------------------------------------------- |
|
1761 |
// CPbk2NamesListReadyState::ResetFindL |
|
1762 |
// -------------------------------------------------------------------------- |
|
1763 |
// |
|
1764 |
void CPbk2NamesListReadyState::ResetFindL() |
|
1765 |
{ |
|
1766 |
if ( iFindBox && iFindBox->TextLength() > 0 ) |
|
1767 |
{ |
|
1768 |
iSearchFilter.ResetL(); |
|
1769 |
iFindBox->ResetL(); |
|
1770 |
iViewStack.Reset(); |
|
1771 |
iFindBox->DrawDeferred(); |
|
1772 |
} |
|
1773 |
} |
|
1774 |
||
1775 |
// -------------------------------------------------------------------------- |
|
1776 |
// CPbk2NamesListReadyState::HideThumbnail |
|
1777 |
// -------------------------------------------------------------------------- |
|
1778 |
// |
|
1779 |
void CPbk2NamesListReadyState::HideThumbnail() |
|
1780 |
{ |
|
1781 |
} |
|
1782 |
||
1783 |
// -------------------------------------------------------------------------- |
|
1784 |
// CPbk2NamesListReadyState::ShowThumbnail |
|
1785 |
// -------------------------------------------------------------------------- |
|
1786 |
// |
|
1787 |
void CPbk2NamesListReadyState::ShowThumbnail() |
|
1788 |
{ |
|
1789 |
} |
|
1790 |
||
1791 |
// -------------------------------------------------------------------------- |
|
1792 |
// CPbk2NamesListReadyState::SetBlank |
|
1793 |
// -------------------------------------------------------------------------- |
|
1794 |
// |
|
1795 |
void CPbk2NamesListReadyState::SetBlank(TBool aBlank) |
|
1796 |
{ |
|
1797 |
if (!aBlank) |
|
1798 |
{ |
|
1799 |
// Redraw |
|
1800 |
iParent.DrawDeferred(); |
|
1801 |
TRAPD( error, |
|
1802 |
iListBox.UpdateScrollBarsL(); |
|
1803 |
HandleFocusChangeL(); |
|
1804 |
); |
|
1805 |
if ( error != KErrNone ) |
|
1806 |
{ |
|
1807 |
CCoeEnv::Static()->HandleError( error ); |
|
1808 |
} |
|
1809 |
} |
|
1810 |
} |
|
1811 |
||
1812 |
// -------------------------------------------------------------------------- |
|
1813 |
// CPbk2NamesListReadyState::RegisterCommand |
|
1814 |
// -------------------------------------------------------------------------- |
|
1815 |
// |
|
1816 |
void CPbk2NamesListReadyState::RegisterCommand( |
|
1817 |
MPbk2Command* /*aCommand*/ ) |
|
1818 |
{ |
|
1819 |
// Do nothing |
|
1820 |
} |
|
1821 |
||
1822 |
// -------------------------------------------------------------------------- |
|
1823 |
// CPbk2NamesListReadyState::SetTextL |
|
1824 |
// -------------------------------------------------------------------------- |
|
1825 |
// |
|
1826 |
void CPbk2NamesListReadyState::SetTextL( const TDesC& aText ) |
|
1827 |
{ |
|
1828 |
iListBox.View()->SetListEmptyTextL( aText ); |
|
1829 |
} |
|
1830 |
||
1831 |
// -------------------------------------------------------------------------- |
|
1832 |
// CPbk2NamesListReadyState::ContactUiControlExtension |
|
1833 |
// -------------------------------------------------------------------------- |
|
1834 |
// |
|
1835 |
TAny* CPbk2NamesListReadyState::ContactUiControlExtension(TUid aExtensionUid ) |
|
1836 |
{ |
|
1837 |
if( aExtensionUid == KMPbk2ContactUiControlExtension2Uid ) |
|
1838 |
{ |
|
1839 |
return static_cast<MPbk2ContactUiControl2*>( this ); |
|
1840 |
} |
|
1841 |
||
1842 |
return NULL; |
|
1843 |
} |
|
1844 |
||
1845 |
// -------------------------------------------------------------------------- |
|
1846 |
// CPbk2NamesListReadyState::FocusedItemPointed |
|
1847 |
// -------------------------------------------------------------------------- |
|
1848 |
// |
|
1849 |
TBool CPbk2NamesListReadyState::FocusedItemPointed() |
|
1850 |
{ |
|
1851 |
return iListBox.FocusedItemPointed(); |
|
1852 |
} |
|
1853 |
||
1854 |
// -------------------------------------------------------------------------- |
|
1855 |
// CPbk2NamesListReadyState::FocusableItemPointed |
|
1856 |
// -------------------------------------------------------------------------- |
|
1857 |
// |
|
1858 |
TBool CPbk2NamesListReadyState::FocusableItemPointed() |
|
1859 |
{ |
|
1860 |
return iListBox.FocusableItemPointed(); |
|
1861 |
} |
|
1862 |
||
1863 |
// -------------------------------------------------------------------------- |
|
1864 |
// CPbk2NamesListReadyState::SearchFieldPointed |
|
1865 |
// -------------------------------------------------------------------------- |
|
1866 |
// |
|
1867 |
TBool CPbk2NamesListReadyState::SearchFieldPointed() |
|
1868 |
{ |
|
1869 |
return iSearchFieldPointed; |
|
1870 |
} |
|
1871 |
||
1872 |
// -------------------------------------------------------------------------- |
|
1873 |
// CPbk2NamesListReadyState::TopViewChangedL |
|
1874 |
// |
|
1875 |
// This is called when top view is changed. However this happens before .e.g |
|
1876 |
// the view containing top contacts is ready and therefore in this point of |
|
1877 |
// execution we don't know whether there will be e.g. "Add to favorites" |
|
1878 |
// command item visible or not |
|
1879 |
// -------------------------------------------------------------------------- |
|
1880 |
// |
|
1881 |
void CPbk2NamesListReadyState::TopViewChangedL( |
|
1882 |
MVPbkContactViewBase& aOldView ) |
|
1883 |
{ |
|
1884 |
PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
1885 |
("CPbk2NamesListReadyState::TopViewChangedL begin") ); |
|
1886 |
||
1887 |
// Switch view |
|
1888 |
TInt countBefore = aOldView.ContactCountL(); |
|
1889 |
TInt countAfter = iViewStack.ContactCountL(); |
|
1890 |
||
1891 |
PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
1892 |
("CPbk2NamesListReadyState::TopViewChangedL:before=%d,now=%d"), |
|
1893 |
countBefore, countAfter ); |
|
1894 |
||
1895 |
// Markings must be checked before HandleItemAdditionL or |
|
1896 |
// HandleItemRemovalL because they reset markings |
|
1897 |
TBool marked = ContactsMarked(); |
|
1898 |
||
1899 |
// Handle list box changes |
|
1900 |
// Promotion item "Add to favourites" should not be visible if top view is |
|
1901 |
// not base view (iViewStack.Level() !== 0). Remote search may be shown when there |
|
1902 |
// is text entered in find box. MyCard enabled similarly as add favorites. |
|
1903 |
TBool addFavoOk = iViewStack.Level() == 0 && !(iFindBox && iFindBox->TextLength()); |
|
1904 |
UpdateCommandEnabled( EPbk2CmdAddFavourites, addFavoOk ); |
|
1905 |
UpdateCommandEnabled( EPbk2CmdRcl, !addFavoOk ); |
|
1906 |
UpdateCommandEnabled( EPbk2CmdOpenMyCard, addFavoOk ); |
|
1907 |
||
1908 |
if ( countAfter > countBefore ) //count does not contain command items |
|
1909 |
{ |
|
1910 |
iListBox.HandleItemAdditionL(); |
|
1911 |
} |
|
1912 |
if ( countAfter < countBefore ) |
|
1913 |
{ |
|
1914 |
iListBox.HandleItemRemovalL(); |
|
1915 |
} |
|
1916 |
||
1917 |
UpdateAdaptiveSearchGridL( EFalse ); |
|
1918 |
||
1919 |
if ( marked ) |
|
1920 |
{ |
|
1921 |
// update markings to the new view |
|
1922 |
RestoreMarkedItemsL( iSelectedItems ); |
|
1923 |
} |
|
1924 |
||
1925 |
if ( iSearchFilter.IsPredictiveActivated() ) |
|
1926 |
{ |
|
1927 |
TInt indexOfMatchedItem = iSearchFilter.CommitFindPaneTextL( iViewStack, iNameFormatter ); |
|
1928 |
if ( indexOfMatchedItem == KErrNotFound ) |
|
1929 |
{ |
|
1930 |
indexOfMatchedItem = 0; |
|
1931 |
} |
|
1932 |
iListBox.SetCurrentItemIndexAndDraw(indexOfMatchedItem); |
|
1933 |
} |
|
1934 |
else |
|
1935 |
{ |
|
1936 |
SetCurrentItemIndexAndDrawL(); |
|
1937 |
} |
|
1938 |
||
1939 |
HandleFocusChangeL(); |
|
1940 |
||
1941 |
PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
1942 |
("CPbk2NamesListReadyState::TopViewChangedL end") ); |
|
1943 |
} |
|
1944 |
||
1945 |
// -------------------------------------------------------------------------- |
|
1946 |
// CPbk2NamesListReadyState::TopViewUpdatedL |
|
1947 |
// -------------------------------------------------------------------------- |
|
1948 |
// |
|
1949 |
void CPbk2NamesListReadyState::TopViewUpdatedL() |
|
1950 |
{ |
|
1951 |
PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
1952 |
("CPbk2NamesListReadyState::TopViewUpdatedL begin") ); |
|
1953 |
||
1954 |
// Promotion item "Add to favourites" should not be visible if top view is |
|
1955 |
// not base view (iViewStack.Level() !== 0). Remote search may be shown when there |
|
1956 |
// is text entered in find box. MyCard enabled similarly as add favorites. |
|
1957 |
TBool addFavoOk = iViewStack.Level() == 0 && !(iFindBox && iFindBox->TextLength()); |
|
1958 |
||
1959 |
UpdateCommandEnabled( EPbk2CmdAddFavourites, addFavoOk ); |
|
1960 |
UpdateCommandEnabled( EPbk2CmdRcl, !addFavoOk ); |
|
1961 |
UpdateCommandEnabled( EPbk2CmdOpenMyCard, addFavoOk ); |
|
1962 |
UpdateAdaptiveSearchGridL( ETrue ); |
|
1963 |
||
1964 |
if ( ContactsMarked() ) |
|
1965 |
{ |
|
1966 |
// The view didn't change so we have to restore the items that |
|
1967 |
// were saved last time the find box was updated. |
|
1968 |
RestoreMarkedItemsL( iSelectedItems ); |
|
1969 |
SetCurrentItemIndexAndDrawL(); |
|
1970 |
} |
|
1971 |
HandleFocusChangeL(); |
|
1972 |
} |
|
1973 |
||
1974 |
// -------------------------------------------------------------------------- |
|
1975 |
// CPbk2NamesListReadyState::BaseViewChangedL |
|
1976 |
// -------------------------------------------------------------------------- |
|
1977 |
// |
|
1978 |
void CPbk2NamesListReadyState::BaseViewChangedL() |
|
1979 |
{ |
|
1980 |
HandleFocusChangeL(); |
|
1981 |
} |
|
1982 |
||
1983 |
// -------------------------------------------------------------------------- |
|
1984 |
// CPbk2NamesListReadyState::ViewStackError |
|
1985 |
// -------------------------------------------------------------------------- |
|
1986 |
// |
|
1987 |
void CPbk2NamesListReadyState::ViewStackError( TInt /*aError*/ ) |
|
1988 |
{ |
|
1989 |
// CPbk2NameListControl is listening to view stack errors and handles |
|
1990 |
// them. This is UI control's internal design and the state can |
|
1991 |
// ignore the error |
|
1992 |
} |
|
1993 |
||
1994 |
// -------------------------------------------------------------------------- |
|
1995 |
// CPbk2NamesListReadyState::ContactAddedToBaseView |
|
1996 |
// -------------------------------------------------------------------------- |
|
1997 |
// |
|
1998 |
void CPbk2NamesListReadyState::ContactAddedToBaseView( |
|
1999 |
MVPbkContactViewBase& /*aBaseView*/, TInt /*aIndex*/, |
|
2000 |
const MVPbkContactLink& /*aContactLink*/ ) |
|
2001 |
{ |
|
2002 |
// CPbk2NameListControl handles this. |
|
2003 |
} |
|
2004 |
||
2005 |
// -------------------------------------------------------------------------- |
|
2006 |
// CPbk2NamesListReadyState::FindDelayComplete |
|
2007 |
// -------------------------------------------------------------------------- |
|
2008 |
// |
|
2009 |
void CPbk2NamesListReadyState::FindDelayComplete() |
|
2010 |
{ |
|
2011 |
TRAPD( error, UpdateFindResultL() ); |
|
2012 |
if ( error != KErrNone ) |
|
2013 |
{ |
|
2014 |
CCoeEnv::Static()->HandleError( error ); |
|
2015 |
iViewStack.Reset(); |
|
2016 |
} |
|
2017 |
} |
|
2018 |
||
2019 |
// -------------------------------------------------------------------------- |
|
2020 |
// CPbk2NamesListReadyState::AdaptiveSearchTextChanged |
|
2021 |
// -------------------------------------------------------------------------- |
|
2022 |
// |
|
2023 |
void CPbk2NamesListReadyState::AdaptiveSearchTextChanged( CAknSearchField* aSearchField ) |
|
2024 |
{ |
|
2025 |
//Add this line to call CPbk2AdaptiveSearchGridFiller::InvalidateAdaptiveSearchGrid() |
|
2026 |
//to control GRID must be updated always after user has pressed a key, even if the keymap does not changed |
|
2027 |
HandleControlEventL( aSearchField, MCoeControlObserver::EEventStateChanged, ETrue ); |
|
2028 |
||
2029 |
//this callback method is only used to notice when language has changed and |
|
2030 |
//to update adaptive search grid. |
|
2031 |
||
2032 |
if( aSearchField->LanguageChanged() ) |
|
2033 |
{ |
|
2034 |
UpdateAdaptiveSearchGridL( ETrue ); |
|
2035 |
} |
|
2036 |
} |
|
2037 |
||
2038 |
// -------------------------------------------------------------------------- |
|
2039 |
// CPbk2NamesListReadyState::CmdItemVisibilityChanged |
|
2040 |
// -------------------------------------------------------------------------- |
|
2041 |
// |
|
2042 |
void CPbk2NamesListReadyState::CmdItemVisibilityChanged( TInt aCmdItemId, TBool aVisible ) |
|
2043 |
{ |
|
2044 |
TInt cmdItemIndex = FindCommand(aCmdItemId); |
|
2045 |
TInt cmdListBoxIndex = EnabledCommandCount(); |
|
2046 |
if( aVisible ) |
|
2047 |
{ |
|
2048 |
cmdListBoxIndex--; |
|
2049 |
} |
|
2050 |
// Update the HiddenSelection property of the command items. |
|
2051 |
TListItemProperties prop( iListBox.ItemDrawer()->Properties(cmdListBoxIndex) ); |
|
2052 |
prop.SetHiddenSelection(aVisible); |
|
2053 |
||
2054 |
TRAP_IGNORE( |
|
2055 |
iListBox.ItemDrawer()->SetPropertiesL(cmdListBoxIndex, prop); |
|
2056 |
||
2057 |
HandleCommandEventL( |
|
2058 |
(aVisible ? EItemAdded : EItemRemoved), |
|
2059 |
cmdItemIndex); |
|
2060 |
); |
|
2061 |
} |
|
2062 |
||
2063 |
// -------------------------------------------------------------------------- |
|
2064 |
// CPbk2NamesListReadyState::RestoreMarkedContactsL |
|
2065 |
// Marks specified contacts in the listbox. |
|
2066 |
// |
|
2067 |
// @param aMarkedContacts Contacts to mark. |
|
2068 |
// @return True if any contacts were marked in the list. |
|
2069 |
// -------------------------------------------------------------------------- |
|
2070 |
// |
|
2071 |
TBool CPbk2NamesListReadyState::RestoreMarkedContactsL |
|
2072 |
(const MVPbkContactLinkArray* aMarkedContacts) |
|
2073 |
{ |
|
2074 |
TBool result = EFalse; |
|
2075 |
DisableRedrawEnablePushL(); |
|
2076 |
iListBox.ClearSelection(); |
|
2077 |
if (aMarkedContacts) |
|
2078 |
{ |
|
2079 |
const TInt count = aMarkedContacts->Count(); |
|
2080 |
for (TInt i=0; i < count; ++i) |
|
2081 |
{ |
|
2082 |
const MVPbkContactLink& contact = aMarkedContacts->At(i); |
|
2083 |
const TInt viewIndex = iViewStack.IndexOfLinkL(contact); |
|
2084 |
if (viewIndex >= 0) |
|
2085 |
{ |
|
2086 |
const TInt listboxIndex = viewIndex + CommandItemCount(); |
|
2087 |
iListBox.View()->SelectItemL(listboxIndex); |
|
2088 |
result = ETrue; |
|
2089 |
} |
|
2090 |
} |
|
2091 |
} |
|
2092 |
CleanupStack::PopAndDestroy(); // DisableRedrawEnablePushL |
|
2093 |
return result; |
|
2094 |
} |
|
2095 |
||
2096 |
// -------------------------------------------------------------------------- |
|
2097 |
// CPbk2NamesListReadyState::RestoreMarkedItemsL |
|
2098 |
// -------------------------------------------------------------------------- |
|
2099 |
// |
|
2100 |
void CPbk2NamesListReadyState::RestoreMarkedItemsL( |
|
2101 |
const MVPbkContactBookmarkCollection& aSelectedItems ) |
|
2102 |
{ |
|
2103 |
PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
2104 |
("CPbk2NamesListReadyState::RestoreMarkedItemsL: %d items"), |
|
2105 |
aSelectedItems.Count() ); |
|
21
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
2106 |
|
20 | 2107 |
const TInt count = aSelectedItems.Count(); |
21
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
2108 |
if ( count > 0 ) |
20 | 2109 |
{ |
21
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
2110 |
CListBoxView::CSelectionIndexArray* updateSelections = |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
2111 |
new(ELeave) CArrayFixFlat<TInt>( count ); |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
2112 |
CleanupStack::PushL( updateSelections ); |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
2113 |
|
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
2114 |
// Get the index of each selected item. If one of items could not be found, break. |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
2115 |
for ( TInt i = 0; i < count; ++i ) |
20 | 2116 |
{ |
21
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
2117 |
TInt index = iViewStack.IndexOfBookmarkL( aSelectedItems.At( i ) ) + CommandItemCount(); |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
2118 |
if ( index >= 0 ) |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
2119 |
{ |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
2120 |
updateSelections->AppendL( index ); |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
2121 |
} |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
2122 |
else |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
2123 |
{ |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
2124 |
break; |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
2125 |
} |
20 | 2126 |
} |
21
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
2127 |
|
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
2128 |
// If all the selected items can be found in iViewStack, update the list box. |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
2129 |
// The list box will change nothing if some of selected items are not found in iViewStack. |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
2130 |
if ( updateSelections->Count() == count ) |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
2131 |
{ |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
2132 |
DisableRedrawEnablePushL(); |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
2133 |
iListBox.ClearSelection(); |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
2134 |
iListBox.SetSelectionIndexesL( updateSelections ); |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
2135 |
CleanupStack::PopAndDestroy(); // DisableRedrawEnablePushL |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
2136 |
} |
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
2137 |
|
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
20
diff
changeset
|
2138 |
CleanupStack::PopAndDestroy( updateSelections ); // Destroy updateSelections |
20 | 2139 |
} |
2140 |
} |
|
2141 |
||
2142 |
// -------------------------------------------------------------------------- |
|
2143 |
// CPbk2NamesListReadyState::DisableRedrawEnablePushL |
|
2144 |
// -------------------------------------------------------------------------- |
|
2145 |
// |
|
2146 |
void CPbk2NamesListReadyState::DisableRedrawEnablePushL() |
|
2147 |
{ |
|
2148 |
CListBoxView& listBoxView = *iListBox.View(); |
|
2149 |
listBoxView.SetDisableRedraw(ETrue); |
|
2150 |
CleanupStack::PushL(TCleanupEnableListBoxViewRedraw(listBoxView)); |
|
2151 |
} |
|
2152 |
||
2153 |
// -------------------------------------------------------------------------- |
|
2154 |
// CPbk2NamesListReadyState::HandleFocusChangeL |
|
2155 |
// -------------------------------------------------------------------------- |
|
2156 |
// |
|
2157 |
void CPbk2NamesListReadyState::HandleFocusChangeL() |
|
2158 |
{ |
|
2159 |
iEventSender.SendEventToObserversL( |
|
2160 |
TPbk2ControlEvent::TPbk2ControlEvent::EControlFocusChanged ); |
|
2161 |
} |
|
2162 |
||
2163 |
// -------------------------------------------------------------------------- |
|
2164 |
// CPbk2NamesListReadyState::UpdateFindResultL |
|
2165 |
// -------------------------------------------------------------------------- |
|
2166 |
// |
|
2167 |
void CPbk2NamesListReadyState::UpdateFindResultL() |
|
2168 |
{ |
|
2169 |
TBuf <KSearchFieldLength> findPaneTxt( FindTextL() ); |
|
2170 |
||
2171 |
if ( iSearchFilter.StartFindPaneInlineEditL( findPaneTxt ) ) |
|
2172 |
{ |
|
2173 |
TBool selectionChanged = HasSelectedItemsChangedL(); |
|
2174 |
||
2175 |
MVPbkContactBookmarkCollection* marked = NULL; |
|
2176 |
if ( ContactsMarked() ) |
|
2177 |
{ |
|
2178 |
marked = &SelectedItemsL( iViewStack ); |
|
2179 |
} |
|
2180 |
else |
|
2181 |
{ |
|
2182 |
// User has removed all the marks so update also bookmarks. |
|
2183 |
iSelectedItems.RemoveAndDeleteAll(); |
|
2184 |
} |
|
2185 |
||
2186 |
// Extract the find text into array |
|
2187 |
if ( !iStringSplitter ) |
|
2188 |
{ |
|
2189 |
iStringSplitter = CPbk2FindStringSplitter::NewL( iNameFormatter ); |
|
2190 |
} |
|
2191 |
MDesCArray* temp = iStringSplitter->SplitTextIntoArrayL( findPaneTxt ); |
|
2192 |
delete iStringArray; |
|
2193 |
iStringArray = temp; |
|
2194 |
||
2195 |
iViewStack.UpdateFilterL( *iStringArray, marked, selectionChanged ); |
|
2196 |
||
2197 |
UpdateAdaptiveSearchGridL( EFalse ); |
|
2198 |
} |
|
2199 |
} |
|
2200 |
||
2201 |
// -------------------------------------------------------------------------- |
|
2202 |
// CPbk2NamesListReadyState::UpdateFindBoxL |
|
2203 |
// -------------------------------------------------------------------------- |
|
2204 |
// |
|
2205 |
void CPbk2NamesListReadyState::UpdateFindBoxL() |
|
2206 |
{ |
|
2207 |
if ( iFindBox ) |
|
2208 |
{ |
|
2209 |
if ( iViewStack.ContactCountL() > 0 && iParent.IsFocused() ) |
|
2210 |
{ |
|
2211 |
iFindBox->SetFocusing( ETrue ); |
|
2212 |
// If findbox is focusing, SetFocus would clear some flag of Fep, |
|
2213 |
// and it will cause 'b','c',''e',...could not be entered for the |
|
2214 |
// first character by V-ITUT. |
|
2215 |
if ( !iFindBox->IsFocused() ) |
|
2216 |
{ |
|
2217 |
iFindBox->SetFocus( ETrue, EDrawNow ); |
|
2218 |
} |
|
2219 |
} |
|
2220 |
} |
|
2221 |
} |
|
2222 |
||
2223 |
// -------------------------------------------------------------------------- |
|
2224 |
// CPbk2NamesListReadyState::SelectedItemsL |
|
2225 |
// -------------------------------------------------------------------------- |
|
2226 |
// |
|
2227 |
MVPbkContactBookmarkCollection& CPbk2NamesListReadyState::SelectedItemsL( |
|
2228 |
MVPbkContactViewBase& aCurrentView ) |
|
2229 |
{ |
|
2230 |
// Get listbox selection indexes, a reference only |
|
2231 |
const CListBoxView::CSelectionIndexArray* selArray = |
|
2232 |
iListBox.SelectionIndexes(); |
|
2233 |
||
2234 |
if ( selArray ) |
|
2235 |
{ |
|
2236 |
iSelectedItems.RemoveAndDeleteAll(); |
|
2237 |
const TInt count = selArray->Count(); |
|
2238 |
for ( TInt i = 0; i < count; ++i ) |
|
2239 |
{ |
|
2240 |
||
2241 |
iSelectedItems.AppendL( |
|
2242 |
aCurrentView.CreateBookmarkLC( selArray->At(i) - CommandItemCount() ) ); |
|
2243 |
CleanupStack::Pop(); |
|
2244 |
} |
|
2245 |
} |
|
2246 |
||
2247 |
PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
2248 |
("CPbk2NamesListReadyState::SelectedItemsL:%d marked"), |
|
2249 |
iSelectedItems.Count() ); |
|
2250 |
||
2251 |
return iSelectedItems; |
|
2252 |
} |
|
2253 |
||
2254 |
// -------------------------------------------------------------------------- |
|
2255 |
// CPbk2NamesListReadyState::HasSelectedItemsChangedL |
|
2256 |
// -------------------------------------------------------------------------- |
|
2257 |
// |
|
2258 |
TBool CPbk2NamesListReadyState::HasSelectedItemsChangedL() |
|
2259 |
{ |
|
2260 |
TBool result = EFalse; |
|
2261 |
||
2262 |
// Get listbox selection indexes, a reference only |
|
2263 |
const CListBoxView::CSelectionIndexArray* selArray = |
|
2264 |
iListBox.SelectionIndexes(); |
|
2265 |
||
2266 |
if ( selArray ) |
|
2267 |
{ |
|
2268 |
TInt bookmarkCount = iSelectedItems.Count(); |
|
2269 |
TInt markedCount = selArray->Count(); |
|
2270 |
// Changed if number of items are different |
|
2271 |
result = bookmarkCount != markedCount; |
|
2272 |
if ( !result ) |
|
2273 |
{ |
|
2274 |
// There are equeal amount of items. Compare as long |
|
2275 |
// as the difference is found |
|
2276 |
for ( TInt i = 0; i < bookmarkCount && !result; ++i ) |
|
2277 |
{ |
|
2278 |
result = selArray->At(i) != |
|
2279 |
iViewStack.IndexOfBookmarkL( iSelectedItems.At(i) ); |
|
2280 |
} |
|
2281 |
} |
|
2282 |
} |
|
2283 |
else if ( iSelectedItems.Count() > 0 ) |
|
2284 |
{ |
|
2285 |
result = ETrue; |
|
2286 |
} |
|
2287 |
||
2288 |
PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
2289 |
("CPbk2NamesListReadyState::HasSelectedItemsChangedL: %d "), |
|
2290 |
result ); |
|
2291 |
||
2292 |
return result; |
|
2293 |
} |
|
2294 |
||
2295 |
// -------------------------------------------------------------------------- |
|
2296 |
// CPbk2NamesListReadyState::SetCurrentItemIndexAndDrawL |
|
2297 |
// -------------------------------------------------------------------------- |
|
2298 |
// |
|
2299 |
void CPbk2NamesListReadyState::SetCurrentItemIndexAndDrawL() |
|
2300 |
{ |
|
2301 |
__ASSERT_DEBUG( &iListBox && iFindPolicy, |
|
2302 |
Panic(EPanicLogic_PreConds_SetCurrentItemIndexAndDraw) ); |
|
2303 |
||
2304 |
if ( iStringArray && iStringArray->MdcaCount() > 0 ) |
|
2305 |
{ |
|
2306 |
TBool isCurrentItemSet( EFalse ); |
|
2307 |
const TInt count( iViewStack.ContactCountL() ); |
|
2308 |
for ( TInt i(0); i < count; ++i ) |
|
2309 |
{ |
|
2310 |
const MVPbkViewContact& contact = iViewStack.ContactAtL( i ); |
|
2311 |
if ( iFindPolicy->MatchContactNameL( *iStringArray, contact ) ) |
|
2312 |
{ |
|
2313 |
isCurrentItemSet = ETrue; |
|
2314 |
iListBox.SetCurrentItemIndexAndDraw(i); |
|
2315 |
break; |
|
2316 |
} |
|
2317 |
} |
|
2318 |
if ( !isCurrentItemSet ) |
|
2319 |
{ |
|
2320 |
iListBox.SetCurrentItemIndexAndDraw(0); |
|
2321 |
} |
|
2322 |
} |
|
2323 |
} |
|
2324 |
||
2325 |
void CPbk2NamesListReadyState::UpdateAdaptiveSearchGridL( TBool aClearCache ) |
|
2326 |
{ |
|
2327 |
if( ( !iAdaptiveSearchGridFiller ) || ( !iFindBox ) ) |
|
2328 |
{ |
|
2329 |
return; |
|
2330 |
} |
|
2331 |
||
2332 |
CAknSearchField::TSearchFieldStyle searchStyle = iFindBox->SearchFieldStyle(); |
|
2333 |
||
2334 |
if ( searchStyle != CAknSearchField::EAdaptiveSearch ) |
|
2335 |
{ |
|
2336 |
delete iAdaptiveSearchGridFiller; |
|
2337 |
iAdaptiveSearchGridFiller = NULL; |
|
2338 |
return; |
|
2339 |
} |
|
2340 |
||
2341 |
iAdaptiveSearchGridFiller->StartFillingL( iViewStack, FindTextL(), aClearCache ); |
|
2342 |
} |
|
2343 |
||
2344 |
/** |
|
2345 |
* Tells whether the listbox line contains a contact or not. |
|
2346 |
* Does not check that the aListboxIndex is within range of listbox. |
|
2347 |
* @param aListboxIndex The position in the listbox to be checked. |
|
2348 |
*/ |
|
2349 |
TBool CPbk2NamesListReadyState::IsContactAtListboxIndex( TInt aListboxIndex ) const |
|
2350 |
{ |
|
2351 |
// There can be command items at the top of the list. |
|
2352 |
// The command items are not contacts. |
|
2353 |
const TInt enabledCommandCount = CommandItemCount(); |
|
2354 |
return aListboxIndex >= enabledCommandCount; |
|
2355 |
} |
|
2356 |
||
2357 |
void CPbk2NamesListReadyState::AllowCommandsToShowThemselves( TBool aVisible ) |
|
2358 |
{ |
|
2359 |
if ( aVisible ) |
|
2360 |
{ |
|
2361 |
// ownership not transferred |
|
2362 |
iListBox.SetListCommands( &iCommandItems ); |
|
2363 |
SubscribeCmdItemsVisibility(); |
|
2364 |
UpdateCommandEnabled( EPbk2CmdAddFavourites, ETrue ); //By default add favorites may be shown |
|
2365 |
UpdateCommandEnabled( EPbk2CmdOpenMyCard, ETrue ); |
|
2366 |
} |
|
2367 |
else |
|
2368 |
{ |
|
2369 |
UpdateCommandEnabled( EPbk2CmdRcl, EFalse ); |
|
2370 |
UpdateCommandEnabled( EPbk2CmdAddFavourites, EFalse ); |
|
2371 |
UpdateCommandEnabled( EPbk2CmdOpenMyCard, EFalse ); |
|
2372 |
UnsubscribeCmdItemsVisibility(); |
|
2373 |
iListBox.SetListCommands( NULL ); |
|
2374 |
} |
|
2375 |
} |
|
2376 |
||
2377 |
void CPbk2NamesListReadyState::UpdateCommandEnabled( TInt aCommandId, TBool aEnabled ) |
|
2378 |
{ |
|
2379 |
for ( TInt i = 0; i < iCommandItems.Count(); i++ ) |
|
2380 |
{ |
|
2381 |
if ( iCommandItems[i]->CommandId() == aCommandId ) |
|
2382 |
{ |
|
2383 |
iCommandItems[i]->SetEnabled( aEnabled ); |
|
2384 |
break; |
|
2385 |
} |
|
2386 |
} |
|
2387 |
} |
|
2388 |
||
2389 |
TBool CPbk2NamesListReadyState::IsCommandEnabled(TInt aCommandId) const |
|
2390 |
{ |
|
2391 |
TBool res = EFalse; |
|
2392 |
for ( TInt i = 0; i < iCommandItems.Count(); i++ ) |
|
2393 |
{ |
|
2394 |
if ( iCommandItems[i]->CommandId() == aCommandId ) |
|
2395 |
{ |
|
2396 |
res = iCommandItems[i]->IsEnabled(); |
|
2397 |
break; |
|
2398 |
} |
|
2399 |
} |
|
2400 |
return res; |
|
2401 |
} |
|
2402 |
||
2403 |
// |
|
2404 |
// Search for a command in iCommandItems and returns its index |
|
2405 |
// |
|
2406 |
TInt CPbk2NamesListReadyState::FindCommand(TInt aCommandId) const |
|
2407 |
{ |
|
2408 |
TInt result = KErrNotFound; |
|
2409 |
for ( TInt i = 0; i < iCommandItems.Count(); ++i ) |
|
2410 |
{ |
|
2411 |
if ( iCommandItems[i]->CommandId() == aCommandId ) |
|
2412 |
{ |
|
2413 |
result = i; |
|
2414 |
break; |
|
2415 |
} |
|
2416 |
||
2417 |
} |
|
2418 |
return result; |
|
2419 |
} |
|
2420 |
||
2421 |
TInt CPbk2NamesListReadyState::CalculateListboxIndex(TInt aCommandIndex) const |
|
2422 |
{ |
|
2423 |
//TInt num = 0; |
|
2424 |
TInt num(KErrNotFound); |
|
2425 |
for ( TInt i = 0; i <= aCommandIndex; ++i ) |
|
2426 |
{ |
|
2427 |
if(iCommandItems[i]->IsEnabled()) |
|
2428 |
{ |
|
2429 |
++num; |
|
2430 |
} |
|
2431 |
} |
|
2432 |
return num; |
|
2433 |
} |
|
2434 |
||
2435 |
||
2436 |
void CPbk2NamesListReadyState::UnmarkCommands() const |
|
2437 |
{ |
|
2438 |
for ( TInt i = 0; i < CommandItemCount(); i++ ) |
|
2439 |
{ |
|
2440 |
iListBox.View()->DeselectItem( i ); |
|
2441 |
} |
|
2442 |
} |
|
2443 |
||
2444 |
TInt CPbk2NamesListReadyState::EnabledCommandCount() const |
|
2445 |
{ |
|
2446 |
TInt result = 0; |
|
2447 |
for ( TInt i = 0; i < iCommandItems.Count(); ++i ) |
|
2448 |
{ |
|
2449 |
if(iCommandItems[i]->IsEnabled()) |
|
2450 |
{ |
|
2451 |
result++; |
|
2452 |
} |
|
2453 |
} |
|
2454 |
return result; |
|
2455 |
} |
|
2456 |
||
2457 |
// End of File |