author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:15:33 +0300 | |
branch | RCL_3 |
changeset 85 | 38bb213f60ba |
parent 63 | f4a778e096c2 |
permissions | -rw-r--r-- |
63 | 1 |
/* |
2 |
* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. |
|
4 |
* This component and the accompanying materials are made available |
|
5 |
* under the terms of "Eclipse Public License v1.0" |
|
6 |
* which accompanies this distribution, and is available |
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
14 |
* Description: Phonebook 2 contact view list box. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
// INCLUDE FILES |
|
20 |
#include "CPbk2ContactViewListBox.h" |
|
21 |
||
22 |
// Phonebook 2 |
|
23 |
#include "MPbk2ContactViewListBoxModel.h" |
|
24 |
#include "CPbk2IconArray.h" |
|
25 |
#include "MPbk2NamesListState.h" |
|
26 |
#include "cpbk2contactviewdoublelistboxmodel.h" |
|
27 |
#include <CPbk2UIExtensionManager.h> |
|
28 |
#include <MPbk2UIExtensionIconSupport.h> |
|
29 |
#include <MPbk2UIExtensionFactory.h> |
|
30 |
#include <MPbk2ContactUiControlExtension.h> |
|
31 |
#include "CPbk2ListboxModelCmdDecorator.h" |
|
32 |
#include <CPbk2ContactIconsUtils.h> |
|
33 |
#include <Pbk2UIControls.hrh> |
|
34 |
||
35 |
// Virtual Phonebook |
|
36 |
#include <CVPbkContactManager.h> |
|
37 |
||
38 |
// System includes |
|
39 |
#include <barsread.h> |
|
40 |
#include <eikclbd.h> |
|
41 |
||
42 |
#include <aknappui.h> |
|
43 |
#include <aknViewAppUi.h> |
|
44 |
||
45 |
// Debugging headers |
|
46 |
#include <Pbk2Debug.h> |
|
47 |
#include <featmgr.h> |
|
48 |
||
49 |
#include <skinlayout.cdl.h> |
|
50 |
#include <aknlayoutscalable_apps.cdl.h> |
|
51 |
#include "cpbk2contactviewcustomlistboxitemdrawer.h" |
|
52 |
#include "cpbk2contactviewcustomlistboxdata.h" |
|
53 |
#include "CPbk2NamesListControl.h" |
|
54 |
||
55 |
||
56 |
/// Unnamed namespace for local definitions |
|
57 |
namespace { |
|
58 |
||
59 |
// LOCAL FUNCTIONS |
|
60 |
||
61 |
_LIT( KTabChar, "\t" ); |
|
62 |
||
63 |
/** |
|
64 |
* Returns icon array from given list box. |
|
65 |
* |
|
66 |
* @param aListBox List box. |
|
67 |
* @return Icon array in Phonebook 2 format. |
|
68 |
*/ |
|
69 |
inline CPbk2IconArray* IconArray( CEikColumnListBox& aListBox ) |
|
70 |
{ |
|
71 |
return static_cast<CPbk2IconArray*>( |
|
72 |
aListBox.ItemDrawer()->ColumnData()->IconArray() ); |
|
73 |
} |
|
74 |
||
75 |
/** |
|
76 |
* Sets given icon array as given listbox's icon array. |
|
77 |
* |
|
78 |
* @param aListBox List box. |
|
79 |
* @param aIconArray Icon array. |
|
80 |
*/ |
|
81 |
inline void SetIconArray( CEikColumnListBox& aListBox, |
|
82 |
CPbk2IconArray* aIconArray ) |
|
83 |
{ |
|
84 |
aListBox.ItemDrawer()->ColumnData()->SetIconArray( aIconArray ); |
|
85 |
} |
|
86 |
||
87 |
#ifdef _DEBUG |
|
88 |
enum TPanicCode |
|
89 |
{ |
|
90 |
EPanicPreCond_CreateListBoxModelL = 1 |
|
91 |
}; |
|
92 |
||
93 |
void Panic(TInt aReason) |
|
94 |
{ |
|
95 |
_LIT(KPanicText, "CPbk2ContactViewListBox"); |
|
96 |
User::Panic(KPanicText, aReason); |
|
97 |
} |
|
98 |
#endif // _DEBUG |
|
99 |
} /// namespace |
|
100 |
||
101 |
// -------------------------------------------------------------------------- |
|
102 |
// CPbk2ContactViewListBox::CPbk2ContactViewListBox |
|
103 |
// -------------------------------------------------------------------------- |
|
104 |
// |
|
105 |
CPbk2ContactViewListBox::CPbk2ContactViewListBox |
|
106 |
( CCoeControl& aContainer, |
|
107 |
MPbk2ContactUiControlExtension* aUiExtension, |
|
108 |
CPbk2PredictiveSearchFilter &aSearchFilter ) : |
|
109 |
iContainer(aContainer), |
|
110 |
iChangedIndexes( 1 ), // allocation granularity |
|
111 |
iUiExtension( aUiExtension ), |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
63
diff
changeset
|
112 |
iSearchFilter( aSearchFilter ) |
63 | 113 |
{ |
114 |
} |
|
115 |
||
116 |
// -------------------------------------------------------------------------- |
|
117 |
// CPbk2ContactViewListBox::~CPbk2ContactViewListBox |
|
118 |
// -------------------------------------------------------------------------- |
|
119 |
// |
|
120 |
CPbk2ContactViewListBox::~CPbk2ContactViewListBox() |
|
121 |
{ |
|
122 |
delete iListboxModelDecorator; |
|
123 |
delete iModel; |
|
124 |
FeatureManager::UnInitializeLib(); |
|
125 |
CCoeEnv::Static()->RemoveForegroundObserver( *this ); |
|
126 |
} |
|
127 |
||
128 |
// -------------------------------------------------------------------------- |
|
129 |
// CPbk2ContactViewListBox::ConstructL |
|
130 |
// -------------------------------------------------------------------------- |
|
131 |
// |
|
132 |
void CPbk2ContactViewListBox::ConstructL( |
|
133 |
CCoeControl& aContainer, TResourceReader& aResourceReader, |
|
134 |
const CVPbkContactManager& aManager, MVPbkContactViewBase& aView, |
|
135 |
MPbk2ContactNameFormatter& aNameFormatter, |
|
136 |
CPbk2StorePropertyArray& aStoreProperties ) |
|
137 |
{ |
|
138 |
PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
139 |
("CPbk2ContactViewListBox::ConstructL")); |
|
140 |
||
141 |
FeatureManager::InitializeLibL(); |
|
142 |
||
143 |
// Preallocate space for the one required integer |
|
144 |
iChangedIndexes.AppendL( KErrNotFound ); |
|
145 |
||
146 |
// Read flags from resources |
|
147 |
iResourceData.iFlags = aResourceReader.ReadUint32(); // flags |
|
148 |
||
149 |
SetContainerWindowL( aContainer ); |
|
150 |
||
151 |
PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
152 |
("CPbk2ContactViewListBox::ConstructL about to resource construct")); |
|
153 |
||
154 |
// Let Avkon read it's share of the resources |
|
155 |
ConstructFromResourceL( aResourceReader ); |
|
156 |
||
157 |
// Remove the platform default "No data" text |
|
158 |
View()->SetListEmptyTextL( KNullDesC ); |
|
159 |
||
160 |
PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
161 |
("CPbk2ContactViewListBox::ConstructL about to create icon array")); |
|
162 |
||
163 |
CPbk2IconArray* iconArray = |
|
164 |
CPbk2ContactIconsUtils::CreateListboxIconArrayL( |
|
165 |
aResourceReader.ReadInt32()); |
|
166 |
||
167 |
SetIconArray( *this, iconArray ); |
|
168 |
||
169 |
iResourceData.iEmptyIconId = |
|
170 |
TPbk2IconId( aResourceReader ); // empty icon |
|
171 |
iResourceData.iDefaultIconId = |
|
172 |
TPbk2IconId( aResourceReader ); // default icon |
|
173 |
||
174 |
CreateScrollBarFrameL( ETrue ); |
|
175 |
ScrollBarFrame()->SetScrollBarVisibilityL( |
|
176 |
CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto ); |
|
177 |
||
178 |
MakeVisible( EFalse ); |
|
179 |
||
180 |
PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
181 |
("CPbk2ContactViewListBox::ConstructL about to create model")); |
|
182 |
||
183 |
CreateListBoxModelL( aManager, aView, |
|
184 |
aNameFormatter, aStoreProperties ); |
|
185 |
||
186 |
CCoeEnv::Static()->AddForegroundObserverL( *this ); |
|
187 |
PBK2_DEBUG_PRINT(PBK2_DEBUG_STRING |
|
188 |
("CPbk2ContactViewListBox::ConstructL end")); |
|
189 |
} |
|
190 |
||
191 |
// -------------------------------------------------------------------------- |
|
192 |
// CPbk2ContactViewListBox::NewL |
|
193 |
// -------------------------------------------------------------------------- |
|
194 |
// |
|
195 |
CPbk2ContactViewListBox* CPbk2ContactViewListBox::NewL( |
|
196 |
CCoeControl& aContainer, TResourceReader& aResourceReader, |
|
197 |
const CVPbkContactManager& aManager, MVPbkContactViewBase& aView, |
|
198 |
MPbk2ContactNameFormatter& aNameFormatter, |
|
199 |
CPbk2StorePropertyArray& aStoreProperties, |
|
200 |
MPbk2ContactUiControlExtension* aUiExtension, |
|
201 |
CPbk2PredictiveSearchFilter &aSearchFilter ) |
|
202 |
{ |
|
203 |
CPbk2ContactViewListBox* self = |
|
204 |
new ( ELeave ) CPbk2ContactViewListBox( aContainer, aUiExtension, aSearchFilter ); |
|
205 |
CleanupStack::PushL( self ); |
|
206 |
self->ConstructL( aContainer, aResourceReader, aManager, |
|
207 |
aView, aNameFormatter, aStoreProperties ); |
|
208 |
CleanupStack::Pop( self ); |
|
209 |
return self; |
|
210 |
} |
|
211 |
||
212 |
// -------------------------------------------------------------------------- |
|
213 |
// CPbk2ContactViewListBox::NumberOfItems |
|
214 |
// -------------------------------------------------------------------------- |
|
215 |
// |
|
216 |
TInt CPbk2ContactViewListBox::NumberOfItems() const |
|
217 |
{ |
|
218 |
TInt result = 0; |
|
219 |
if ( iListboxModelDecorator ) |
|
220 |
{ |
|
221 |
result = iListboxModelDecorator->MdcaCount(); |
|
222 |
} |
|
223 |
return result; |
|
224 |
} |
|
225 |
||
226 |
// -------------------------------------------------------------------------- |
|
227 |
// CPbk2ContactViewListBox::ContactsMarked |
|
228 |
// -------------------------------------------------------------------------- |
|
229 |
// |
|
230 |
TBool CPbk2ContactViewListBox::ContactsMarked() const |
|
231 |
{ |
|
232 |
const CListBoxView::CSelectionIndexArray* selections = |
|
233 |
View()->SelectionIndexes(); |
|
234 |
TBool notEmpty = selections && selections->Count() > 0; |
|
235 |
TBool containsContacts = EFalse; |
|
236 |
for (TInt n = 0; notEmpty && n < selections->Count() && !containsContacts; ++n ) |
|
237 |
{ |
|
238 |
const TInt index = selections->At( n ); |
|
239 |
// The item is either a contact or a command. |
|
240 |
containsContacts = IsContact( index ); |
|
241 |
} |
|
242 |
return containsContacts; |
|
243 |
} |
|
244 |
||
245 |
// -------------------------------------------------------------------------- |
|
246 |
// CPbk2ContactViewListBox::HandleContactViewEventL |
|
247 |
// -------------------------------------------------------------------------- |
|
248 |
// |
|
249 |
void CPbk2ContactViewListBox::HandleEventL |
|
250 |
( TInt aEvent, TInt aIndex ) |
|
251 |
{ |
|
252 |
switch ( aEvent ) |
|
253 |
{ |
|
254 |
case MPbk2NamesListState::EItemAdded: |
|
255 |
{ |
|
256 |
iChangedIndexes[0] = aIndex; |
|
257 |
HandleItemAdditionL( iChangedIndexes ); |
|
258 |
break; |
|
259 |
} |
|
260 |
case MPbk2NamesListState::EItemRemoved: |
|
261 |
{ |
|
262 |
// Deselect item |
|
263 |
CListBoxView& listBoxView = *View(); |
|
264 |
listBoxView.SetDisableRedraw( ETrue ); |
|
265 |
listBoxView.DeselectItem( aIndex ); |
|
266 |
listBoxView.SetDisableRedraw( EFalse ); |
|
267 |
||
268 |
TInt focusIndex = CurrentItemIndex(); |
|
269 |
TInt topIndex = TopItemIndex(); |
|
270 |
iChangedIndexes[0] = aIndex; |
|
271 |
HandleItemRemovalL( iChangedIndexes ); |
|
272 |
||
273 |
// The deduction of 1 is for adapting with the different bases |
|
274 |
const TInt lastIndex = Model()->NumberOfItems() - 1; |
|
275 |
if ( lastIndex == KErrNotFound ) |
|
276 |
{ |
|
277 |
Reset(); |
|
278 |
} |
|
279 |
else |
|
280 |
{ |
|
281 |
if ( aIndex < focusIndex ) |
|
282 |
{ |
|
283 |
// If item was removed above focused item, maintain |
|
284 |
// focus by moving it up by one |
|
285 |
--focusIndex; |
|
286 |
} |
|
287 |
if ( focusIndex > lastIndex || focusIndex < 0 ) |
|
288 |
{ |
|
289 |
focusIndex = lastIndex; |
|
290 |
} |
|
291 |
const TInt numVisibleItems = |
|
292 |
View()->NumberOfItemsThatFitInRect( |
|
293 |
View()->ViewRect() ); |
|
294 |
if ( topIndex + numVisibleItems > lastIndex ) |
|
295 |
{ |
|
296 |
topIndex = Max( lastIndex - numVisibleItems + 1, 0 ); |
|
297 |
} |
|
298 |
if ( topIndex >= 0 ) |
|
299 |
{ |
|
300 |
SetTopItemIndex( topIndex ); |
|
301 |
} |
|
302 |
if ( focusIndex >= 0 ) |
|
303 |
{ |
|
304 |
SetCurrentItemIndex( focusIndex ); |
|
305 |
} |
|
306 |
} |
|
307 |
break; |
|
308 |
} |
|
309 |
default: |
|
310 |
{ |
|
311 |
// Do nothing |
|
312 |
break; |
|
313 |
} |
|
314 |
} |
|
315 |
} |
|
316 |
||
317 |
// -------------------------------------------------------------------------- |
|
318 |
// CPbk2ContactViewListBox::FixTopItemIndex |
|
319 |
// -------------------------------------------------------------------------- |
|
320 |
// |
|
321 |
void CPbk2ContactViewListBox::FixTopItemIndex() |
|
322 |
{ |
|
323 |
TInt index = TopItemIndex(); |
|
324 |
const TInt height = View()->NumberOfItemsThatFitInRect( |
|
325 |
View()->ViewRect() ); |
|
326 |
const TInt numItems = Model()->NumberOfItems(); |
|
327 |
if ( index + height > numItems ) |
|
328 |
{ |
|
329 |
index += numItems - ( height + index ); |
|
330 |
if ( index < 0 ) |
|
331 |
{ |
|
332 |
index = 0; |
|
333 |
} |
|
334 |
if ( index != TopItemIndex() ) |
|
335 |
{ |
|
336 |
SetTopItemIndex( index ); |
|
337 |
} |
|
338 |
} |
|
339 |
} |
|
340 |
||
341 |
// -------------------------------------------------------------------------- |
|
342 |
// CPbk2ContactViewListBox::CheckFocusIndex |
|
343 |
// -------------------------------------------------------------------------- |
|
344 |
// |
|
345 |
void CPbk2ContactViewListBox::CheckFocusIndex() |
|
346 |
{ |
|
347 |
if ( CurrentItemIndex() == KErrNotFound ) |
|
348 |
{ |
|
349 |
SetCurrentItemIndex( 0 ); |
|
350 |
} |
|
351 |
} |
|
352 |
||
353 |
// -------------------------------------------------------------------------- |
|
354 |
// CPbk2ContactViewListBox::HandlePointerEventL |
|
355 |
// -------------------------------------------------------------------------- |
|
356 |
// |
|
357 |
void CPbk2ContactViewListBox::HandlePointerEventL |
|
358 |
( const TPointerEvent& aPointerEvent ) |
|
359 |
{ |
|
360 |
TInt oldIndex = CurrentItemIndex(); |
|
361 |
||
362 |
// Base class handles the pointer event |
|
363 |
CAknSingleGraphicStyleListBox::HandlePointerEventL( aPointerEvent ); |
|
364 |
||
365 |
switch( aPointerEvent.iType ) |
|
366 |
{ |
|
367 |
case TPointerEvent::EButton1Down: |
|
368 |
{ |
|
369 |
TInt pointedItemIndex; |
|
370 |
iFocusableContactPointed = View()->XYPosToItemIndex( |
|
371 |
aPointerEvent.iPosition, pointedItemIndex ); |
|
372 |
||
373 |
//no prior focus needed |
|
374 |
iFocusedContactPointed = iFocusableContactPointed; |
|
375 |
break; |
|
376 |
} |
|
377 |
default: |
|
378 |
{ |
|
379 |
// Do nothing |
|
380 |
break; |
|
381 |
} |
|
382 |
}; |
|
383 |
} |
|
384 |
||
385 |
// -------------------------------------------------------------------------- |
|
386 |
// CPbk2ContactViewListBox::Flags |
|
387 |
// -------------------------------------------------------------------------- |
|
388 |
// |
|
389 |
TUint CPbk2ContactViewListBox::Flags() const |
|
390 |
{ |
|
391 |
return iResourceData.iFlags; |
|
392 |
} |
|
393 |
||
394 |
// -------------------------------------------------------------------------- |
|
395 |
// CPbk2ContactViewListBox::SetScrollEventObserver |
|
396 |
// -------------------------------------------------------------------------- |
|
397 |
// |
|
398 |
void CPbk2ContactViewListBox::SetScrollEventObserver(MEikScrollBarObserver* aObserver) |
|
399 |
{ |
|
400 |
iScrollEventObserver = aObserver; |
|
401 |
} |
|
402 |
||
403 |
// -------------------------------------------------------------------------- |
|
404 |
// CPbk2ContactViewListBox::IsSelectionListBox |
|
405 |
// This function is non const because IsMultiselection is non const. |
|
406 |
// -------------------------------------------------------------------------- |
|
407 |
// |
|
408 |
TBool CPbk2ContactViewListBox::IsSelectionListBox() |
|
409 |
{ |
|
410 |
// Try firs the CEikListBox method for multiselection |
|
411 |
TBool result = IsMultiselection(); |
|
412 |
||
413 |
if ( !result ) |
|
414 |
{ |
|
415 |
// Then try other flags |
|
416 |
TUint32 markableFlags = |
|
417 |
EAknListBoxStylusMarkableList | |
|
418 |
EAknListBoxStylusMultiselectionList | |
|
419 |
EAknListBoxMarkableList | |
|
420 |
EAknListBoxMultiselectionList; |
|
421 |
||
422 |
// Compare CEikListBox flags to Avkon markable list flags |
|
423 |
result = iListBoxFlags & markableFlags; |
|
424 |
} |
|
425 |
return result; |
|
426 |
} |
|
427 |
||
428 |
void CPbk2ContactViewListBox::SetListCommands( |
|
429 |
const RPointerArray<MPbk2UiControlCmdItem>* aCommands ) |
|
430 |
{ |
|
431 |
iListboxModelDecorator->SetListCommands( aCommands ); |
|
432 |
if( iColumnData ) |
|
433 |
{ |
|
434 |
iColumnData->SetListCommands( aCommands ); |
|
435 |
} |
|
436 |
} |
|
437 |
||
438 |
// -------------------------------------------------------------------------- |
|
439 |
// CPbk2ContactViewListBox::ClipFromBeginning |
|
440 |
// -------------------------------------------------------------------------- |
|
441 |
// |
|
442 |
TBool CPbk2ContactViewListBox::ClipFromBeginning |
|
443 |
( TDes& aBuffer, TInt aItemIndex, TInt aSubCellNumber ) |
|
444 |
{ |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
63
diff
changeset
|
445 |
return AknTextUtils::ClipToFit( aBuffer, |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
63
diff
changeset
|
446 |
AknTextUtils::EClipFromBeginning, this, aItemIndex, |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
63
diff
changeset
|
447 |
aSubCellNumber ); |
63 | 448 |
} |
449 |
||
450 |
// -------------------------------------------------------------------------- |
|
451 |
// CPbk2ContactViewListBox::FocusedItemPointed |
|
452 |
// -------------------------------------------------------------------------- |
|
453 |
// |
|
454 |
TBool CPbk2ContactViewListBox::FocusedItemPointed() |
|
455 |
{ |
|
456 |
return iFocusedContactPointed; |
|
457 |
} |
|
458 |
||
459 |
// -------------------------------------------------------------------------- |
|
460 |
// CPbk2ContactViewListBox::FocusableItemPointed |
|
461 |
// -------------------------------------------------------------------------- |
|
462 |
// |
|
463 |
TBool CPbk2ContactViewListBox::FocusableItemPointed() |
|
464 |
{ |
|
465 |
return iFocusableContactPointed; |
|
466 |
} |
|
467 |
||
468 |
// -------------------------------------------------------------------------- |
|
469 |
// CPbk2ContactViewListBox::SearchFieldPointed |
|
470 |
// -------------------------------------------------------------------------- |
|
471 |
// |
|
472 |
TBool CPbk2ContactViewListBox::SearchFieldPointed() |
|
473 |
{ |
|
474 |
return EFalse; |
|
475 |
} |
|
476 |
||
477 |
// -------------------------------------------------------------------------- |
|
478 |
// CPbk2ContactViewListBox::HandleScrollEventL |
|
479 |
// -------------------------------------------------------------------------- |
|
480 |
// |
|
481 |
void CPbk2ContactViewListBox::HandleScrollEventL(CEikScrollBar* aScrollBar, TEikScrollEvent aEventType) |
|
482 |
{ |
|
483 |
// Handle showing of popupcharacter when user scrolls list using using scroll bar |
|
484 |
TBool prevState = iShowPopupChar; |
|
485 |
||
486 |
iShowPopupChar = ( aEventType == EEikScrollThumbDragHoriz || aEventType == EEikScrollThumbDragVert ); |
|
487 |
||
488 |
if( prevState != iShowPopupChar ) |
|
489 |
{ |
|
490 |
DrawDeferred(); |
|
491 |
} |
|
492 |
||
493 |
CAknSingleGraphicStyleListBox::HandleScrollEventL( aScrollBar, aEventType ); |
|
494 |
if( iScrollEventObserver ) |
|
495 |
{ |
|
496 |
iScrollEventObserver->HandleScrollEventL( aScrollBar, aEventType ); |
|
497 |
} |
|
498 |
} |
|
499 |
||
500 |
// -------------------------------------------------------------------------- |
|
501 |
// CPbk2ContactViewListBox::CreateListBoxModelL |
|
502 |
// -------------------------------------------------------------------------- |
|
503 |
// |
|
504 |
void CPbk2ContactViewListBox::CreateListBoxModelL |
|
505 |
( const CVPbkContactManager& aManager, MVPbkContactViewBase& aView, |
|
506 |
MPbk2ContactNameFormatter& aNameFormatter, |
|
507 |
CPbk2StorePropertyArray& aStoreProperties ) |
|
508 |
{ |
|
509 |
__ASSERT_DEBUG( !iModel && !iListboxModelDecorator, |
|
510 |
Panic( EPanicPreCond_CreateListBoxModelL ) ); |
|
511 |
||
512 |
// Set up listbox model |
|
513 |
CPbk2ContactViewListBoxModel::TParams params; |
|
514 |
params.iContactManager = &aManager; |
|
515 |
params.iView = &aView; |
|
516 |
params.iStoreProperties = &aStoreProperties; |
|
517 |
params.iNameFormatter = &aNameFormatter; |
|
518 |
params.iIconArray = IconArray( *this ); |
|
519 |
params.iEmptyId = iResourceData.iEmptyIconId; |
|
520 |
params.iDefaultId = iResourceData.iDefaultIconId; |
|
521 |
params.iClipListBoxText = this; |
|
522 |
params.iUiExtension = iUiExtension; |
|
523 |
params.iMultiselection = IsMultiselection(); |
|
524 |
CPbk2ContactViewListBoxModel* model = DoCreateModelL( params ); |
|
525 |
model->SetUnnamedText( iResourceData.iUnnamedText ); |
|
526 |
iModel = model; |
|
527 |
||
528 |
if( iColumnData ) |
|
529 |
{ |
|
530 |
iColumnData->SetDataModel( iModel ); |
|
531 |
} |
|
532 |
// Wrap the original model. |
|
533 |
iListboxModelDecorator = DoCreateDecoratorL( |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
63
diff
changeset
|
534 |
*IconArray( *this ), |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
63
diff
changeset
|
535 |
iResourceData.iEmptyIconId, |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
63
diff
changeset
|
536 |
iResourceData.iDefaultIconId ); |
63 | 537 |
|
538 |
||
539 |
iListboxModelDecorator->SetDecoratedModel( *iModel ); |
|
540 |
Model()->SetItemTextArray( iListboxModelDecorator ); |
|
541 |
Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
542 |
} |
|
543 |
||
544 |
// -------------------------------------------------------------------------- |
|
545 |
// CPbk2ContactViewListBox::DoCreateModelL |
|
546 |
// -------------------------------------------------------------------------- |
|
547 |
// |
|
548 |
CPbk2ContactViewListBoxModel* CPbk2ContactViewListBox::DoCreateModelL( |
|
549 |
CPbk2ContactViewListBoxModel::TParams params ) |
|
550 |
{ |
|
551 |
return CPbk2ContactViewListBoxModel::NewL( params ); |
|
552 |
} |
|
553 |
||
554 |
||
555 |
// -------------------------------------------------------------------------- |
|
556 |
// CPbk2ContactViewListBox::DoCreateDecoratorL |
|
557 |
// -------------------------------------------------------------------------- |
|
558 |
// |
|
559 |
CPbk2ListboxModelCmdDecorator* CPbk2ContactViewListBox::DoCreateDecoratorL( |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
63
diff
changeset
|
560 |
const CPbk2IconArray& aIconArray, |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
63
diff
changeset
|
561 |
TPbk2IconId aEmptyIconId, |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
63
diff
changeset
|
562 |
TPbk2IconId aDefaultIconId ) |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
63
diff
changeset
|
563 |
{ |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
63
diff
changeset
|
564 |
return CPbk2ListboxModelCmdDecorator::NewL( |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
63
diff
changeset
|
565 |
aIconArray, |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
63
diff
changeset
|
566 |
aEmptyIconId, |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
63
diff
changeset
|
567 |
aDefaultIconId ); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
63
diff
changeset
|
568 |
} |
63 | 569 |
|
570 |
||
571 |
// -------------------------------------------------------------------------- |
|
572 |
// CPbk2ContactViewListBox::IsContact |
|
573 |
// -------------------------------------------------------------------------- |
|
574 |
// |
|
575 |
TBool CPbk2ContactViewListBox::IsContact( TInt aIndex ) const |
|
576 |
{ |
|
577 |
// The command items are always at the top of the list. |
|
578 |
return aIndex >= iListboxModelDecorator->NumberOfEnabledCommands(); |
|
579 |
} |
|
580 |
||
581 |
// -------------------------------------------------------------------------- |
|
582 |
// CPbk2ContactViewListBox::Draw |
|
583 |
// -------------------------------------------------------------------------- |
|
584 |
// |
|
585 |
void CPbk2ContactViewListBox::Draw( const TRect& aRect ) const |
|
586 |
{ |
|
587 |
CAknSingleGraphicStyleListBox::Draw(aRect); |
|
588 |
HandlePopupCharacter(NULL, Rect()); |
|
589 |
} |
|
590 |
||
591 |
// -------------------------------------------------------------------------- |
|
592 |
// CPbk2ContactViewListBox::CreateItemDrawerL |
|
593 |
// -------------------------------------------------------------------------- |
|
594 |
// |
|
595 |
void CPbk2ContactViewListBox::CreateItemDrawerL() |
|
596 |
{ |
|
597 |
// Use custom drawer only if predictive search is enabled |
|
598 |
if( FeatureManager::FeatureSupported(KFeatureIdFfContactsPredictiveSearch) ) |
|
599 |
{ |
|
600 |
CPbk2ContactViewCustomListBoxData* columnData = |
|
601 |
CPbk2ContactViewCustomListBoxData::NewL( iSearchFilter ); |
|
602 |
||
603 |
CleanupStack::PushL( columnData ); |
|
604 |
||
605 |
iItemDrawer=new(ELeave) CPbk2ContactViewCustomListBoxItemDrawer( |
|
606 |
static_cast<MTextListBoxModel*>(Model()), iCoeEnv->NormalFont(), |
|
607 |
columnData); |
|
608 |
CleanupStack::Pop( columnData ); |
|
609 |
||
610 |
//Ownership has been transferred to iItemDrawer |
|
611 |
iColumnData = columnData; |
|
612 |
} |
|
613 |
else |
|
614 |
{ |
|
615 |
CAknSingleGraphicStyleListBox::CreateItemDrawerL(); |
|
616 |
} |
|
617 |
} |
|
618 |
||
619 |
// -------------------------------------------------------------------------- |
|
620 |
// CPbk2ContactViewListBox::HandleGainingForeground |
|
621 |
// -------------------------------------------------------------------------- |
|
622 |
// |
|
623 |
void CPbk2ContactViewListBox::HandleGainingForeground() |
|
624 |
{ |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
63
diff
changeset
|
625 |
DrawDeferred(); |
63 | 626 |
} |
627 |
||
628 |
// -------------------------------------------------------------------------- |
|
629 |
// CPbk2ContactViewListBox::HandleLosingForeground |
|
630 |
// -------------------------------------------------------------------------- |
|
631 |
// |
|
632 |
void CPbk2ContactViewListBox::HandleLosingForeground() |
|
633 |
{ |
|
634 |
if ( iShowPopupChar ) |
|
635 |
{ |
|
636 |
//Simulate an EButton1Up event to force a DrawDeferred() calling |
|
637 |
//in case of the scrollbar¡¯s at the background that can¡¯t receive the EButton1Up event. |
|
638 |
TPointerEvent PointEvent; |
|
639 |
PointEvent.iType = TPointerEvent::EButton1Up ; |
|
640 |
TRAP_IGNORE( ScrollBarFrame()->VerticalScrollBar()->HandlePointerEventL( PointEvent ) ); |
|
641 |
DrawDeferred(); |
|
642 |
} |
|
643 |
} |
|
644 |
||
645 |
// -------------------------------------------------------------------------- |
|
646 |
// CPbk2ContactViewListBox::HandlePopupCharacter |
|
647 |
// -------------------------------------------------------------------------- |
|
648 |
// |
|
649 |
void CPbk2ContactViewListBox::HandlePopupCharacter( CWindowGc* aGc, const TRect& aRectOfListBoxItem ) const |
|
650 |
{ |
|
651 |
CPbk2NamesListControl& listControl = static_cast<CPbk2NamesListControl&>(iContainer); |
|
652 |
TInt itemIndex = TopItemIndex() - listControl.CommandItemCount(); |
|
653 |
||
654 |
// itemIndex >= 0 filter out command item |
|
655 |
if ( itemIndex >= 0 && iShowPopupChar ) |
|
656 |
{ |
|
657 |
TAknLayoutRect layout; |
|
658 |
layout.LayoutRect(Rect(), AknLayoutScalable_Apps::popup_navstr_preview_pane(0)); |
|
659 |
||
660 |
if (!layout.Rect().Intersects(aRectOfListBoxItem)) |
|
661 |
{ |
|
662 |
// If the rect of PopupCharacter not overlapped |
|
663 |
// with aRectOfListBoxItem, do nothing. |
|
664 |
return; |
|
665 |
} |
|
666 |
||
667 |
// Handle showing of popupcharacter when user scrolls list using using scroll bar |
|
668 |
CWindowGc* gc = aGc; |
|
669 |
if (!gc) |
|
670 |
{ |
|
671 |
gc = &SystemGc(); |
|
672 |
} |
|
673 |
||
674 |
TRgb normal; |
|
675 |
AknsUtils::GetCachedColor(AknsUtils::SkinInstance(), |
|
676 |
normal, |
|
677 |
KAknsIIDQsnTextColors, |
|
678 |
EAknsCIQsnTextColorsCG6 ); |
|
679 |
||
680 |
TAknLayoutRect cornerRect; |
|
681 |
// skinned draw uses submenu popup window skin (skinned border) |
|
682 |
cornerRect.LayoutRect( |
|
683 |
layout.Rect(), |
|
684 |
SkinLayout::Submenu_skin_placing_Line_2() ); |
|
685 |
||
686 |
TRect innerRect( layout.Rect() ); |
|
687 |
innerRect.Shrink( cornerRect.Rect().Width(), cornerRect.Rect().Height() ); |
|
688 |
||
689 |
if ( !AknsDrawUtils::DrawFrame( |
|
690 |
AknsUtils::SkinInstance(), |
|
691 |
*gc, |
|
692 |
layout.Rect(), |
|
693 |
innerRect, |
|
694 |
KAknsIIDQsnFrPopupSub, |
|
695 |
KAknsIIDQsnFrPopupCenterSubmenu ) ) |
|
696 |
{ |
|
697 |
// skinned border failed -> black border |
|
698 |
gc->SetPenStyle( CGraphicsContext::ESolidPen ); |
|
699 |
gc->SetBrushColor( KRgbBlack ); |
|
700 |
gc->DrawRect( layout.Rect() ); |
|
701 |
} |
|
702 |
||
703 |
TAknLayoutText textLayout; |
|
704 |
textLayout.LayoutText(layout.Rect(), AknLayoutScalable_Apps::popup_navstr_preview_pane_t1(0).LayoutLine()); |
|
705 |
||
706 |
TPtrC desc(Model()->ItemTextArray()->MdcaPoint(View()->TopItemIndex())); |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
63
diff
changeset
|
707 |
|
63 | 708 |
//Add "if-clause" to avaid the error that argument of Mid() out of range. |
709 |
TInt index = desc.Find( KTabChar ); |
|
710 |
if ( index != KErrNotFound && index < desc.Length()-1 ) |
|
711 |
{ |
|
712 |
HBufC* buf = desc.Mid( index + 1, 1 ).AllocL(); |
|
713 |
||
714 |
TPtr textPtr = buf->Des(); |
|
715 |
textPtr.UpperCase(); |
|
716 |
||
717 |
textLayout.DrawText( *gc, textPtr, ETrue, normal ); |
|
718 |
||
719 |
delete buf; |
|
720 |
} |
|
721 |
} |
|
722 |
} |
|
723 |
// End of File |