author | Simon Howkins <simonh@symbian.org> |
Thu, 25 Nov 2010 12:13:04 +0000 | |
branch | RCL_3 |
changeset 83 | 31a5fbf5db1d |
parent 80 | 726fba06891a |
permissions | -rw-r--r-- |
64 | 1 |
/* |
2 |
* Copyright (c) 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: This file implements classes CNcsPopupListBox, CNcsListItemDrawer. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
// INCLUDE FILES |
|
20 |
#include "emailtrace.h" |
|
21 |
#include <eikclbd.h> |
|
22 |
#include <AknsFrameBackgroundControlContext.h> |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
23 |
#include <FreestyleEmailUi.rsg> // R_FSE_EDITOR_ADDRESS_LIST_REMOTE_LOOKUP_SEARCH |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
24 |
#include <StringLoader.h> // StringLoader |
64 | 25 |
#include <CPbkContactEngine.h> |
26 |
#include <AknsDrawUtils.h> |
|
27 |
#include <AknsUtils.h> |
|
28 |
#include <aknlayoutscalable_apps.cdl.h> |
|
29 |
#include <aknlayoutscalable_avkon.cdl.h> |
|
30 |
||
31 |
#include "ncspopuplistbox.h" |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
32 |
#include "ncsemailaddressobject.h" // CNcsEmailAddressObject |
64 | 33 |
#include "ncsconstants.h" |
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
34 |
#include "ncsheadercontainer.h" // CNcsHeaderContainer |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
35 |
#include "FreestyleEmailUiContactHandler.h" // CFSEmailUiClsListsHandler |
64 | 36 |
#include "ncsutility.h" |
37 |
#include "FreestyleEmailUiUtilities.h" |
|
38 |
#include "FreestyleEmailUiAppui.h" |
|
39 |
#include "FreestyleEmailUiLayoutHandler.h" |
|
40 |
#include "FSDelayedLoader.h" |
|
41 |
#include "FreestyleEmailUiCLSItem.h" |
|
42 |
||
43 |
const TInt KHighlightFrameWidth = 2; |
|
44 |
||
45 |
// ========================= MEMBER FUNCTIONS ================================== |
|
46 |
||
47 |
// ----------------------------------------------------------------------------- |
|
48 |
// CNcsPopupListBox::NewL |
|
49 |
// ----------------------------------------------------------------------------- |
|
50 |
CNcsPopupListBox* CNcsPopupListBox::NewL( const CCoeControl* aParent, |
|
51 |
CFSMailBox& aMailBox, |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
52 |
CNcsHeaderContainer& aHeaderContainer, |
64 | 53 |
TBool aRemoteLookupSupported ) |
54 |
{ |
|
55 |
FUNC_LOG; |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
56 |
CNcsPopupListBox* self = new (ELeave) CNcsPopupListBox( aHeaderContainer, |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
57 |
aRemoteLookupSupported, aMailBox ); |
64 | 58 |
CleanupStack::PushL( self ); |
59 |
self->ConstructL( aParent ); |
|
60 |
CleanupStack::Pop( self ); |
|
61 |
return self; |
|
62 |
} |
|
63 |
||
64 |
// ----------------------------------------------------------------------------- |
|
65 |
// CNcsPopupListBox::CNcsPopupListBox |
|
66 |
// ----------------------------------------------------------------------------- |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
67 |
CNcsPopupListBox::CNcsPopupListBox( CNcsHeaderContainer& aHeaderContainer, |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
68 |
TBool aRemoteLookupSupported, |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
69 |
CFSMailBox& aMailBox) |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
70 |
: iHeaderContainer( aHeaderContainer ), |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
71 |
iMailBox( aMailBox ), |
64 | 72 |
iRemoteLookupSupported( aRemoteLookupSupported ), |
73 |
iCachingInProgress( EFalse ), |
|
74 |
iAppUi( static_cast<CFreestyleEmailUiAppUi*>( iEikonEnv->AppUi() ) ) |
|
75 |
{ |
|
76 |
FUNC_LOG; |
|
77 |
iPopupMaxRect = TRect( 100, 100, 100, 100 ); |
|
78 |
} |
|
79 |
||
80 |
// ----------------------------------------------------------------------------- |
|
81 |
// CNcsPopupListBox::ConstructL |
|
82 |
// ----------------------------------------------------------------------------- |
|
83 |
void CNcsPopupListBox::ConstructL( const CCoeControl* aParent ) |
|
84 |
{ |
|
85 |
FUNC_LOG; |
|
86 |
CEikTextListBox::ConstructL( NULL, CEikListBox::EPopout ); |
|
87 |
SetMopParent( const_cast<CCoeControl*>( aParent ) ); |
|
88 |
User::LeaveIfError( SetParent( const_cast<CCoeControl*>( aParent ) ) ); |
|
89 |
||
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
90 |
CEikScrollBarFrame* frame = CreateScrollBarFrameL( EFalse, EFalse, ETrue ); |
64 | 91 |
|
92 |
CEikTextListBox::SetBorder( TGulBorder::ENone ); |
|
93 |
||
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
94 |
const CFont* font = AknLayoutUtils::FontFromId( EAknLogicalFontPrimarySmallFont ); |
64 | 95 |
CEikTextListBox::SetItemHeightL( font->FontMaxHeight() + 12 ); |
96 |
||
97 |
iBackgroundContext = CAknsFrameBackgroundControlContext::NewL( |
|
98 |
KAknsIIDQsnFrPopupSub, Rect(), Rect(), EFalse ); |
|
99 |
UpdateTextColors(); |
|
100 |
||
101 |
iContactHandler = CFsDelayedLoader::InstanceL()->GetContactHandlerL(); |
|
102 |
if ( !iContactHandler->IsLanguageSupportedL() ) |
|
103 |
{ |
|
104 |
iContactHandler = NULL; |
|
105 |
} |
|
106 |
||
107 |
SetListBoxObserver( this ); |
|
108 |
} |
|
109 |
||
110 |
// ----------------------------------------------------------------------------- |
|
111 |
// CNcsPopupListBox::InitAndSearchL |
|
112 |
// ----------------------------------------------------------------------------- |
|
113 |
void CNcsPopupListBox::InitAndSearchL( const TDesC& aText, TInt aMode ) |
|
114 |
{ |
|
115 |
FUNC_LOG; |
|
116 |
SetSearchTextL( aText, aMode ); |
|
117 |
RPointerArray<CFSEmailUiClsItem> emptyArray; |
|
118 |
CleanupClosePushL( emptyArray ); |
|
119 |
OperationCompleteL( ESearchContacts, emptyArray ); |
|
120 |
CleanupStack::PopAndDestroy( &emptyArray ); |
|
121 |
} |
|
122 |
||
123 |
// --------------------------------------------------------------------------- |
|
124 |
// CNcsPopupListBox::~CNcsPopupListBox |
|
125 |
// --------------------------------------------------------------------------- |
|
126 |
CNcsPopupListBox::~CNcsPopupListBox() |
|
127 |
{ |
|
128 |
FUNC_LOG; |
|
129 |
delete iBackgroundContext; |
|
130 |
delete iItemTextsArray; |
|
131 |
delete iCurrentSearchText; |
|
132 |
iMatchingItems.ResetAndDestroy(); |
|
133 |
} |
|
134 |
||
135 |
// ----------------------------------------------------------------------------- |
|
136 |
// CNcsPopupListBox::CreateItemDrawerL |
|
137 |
// ----------------------------------------------------------------------------- |
|
138 |
void CNcsPopupListBox::CreateItemDrawerL() |
|
139 |
{ |
|
140 |
FUNC_LOG; |
|
141 |
iItemDrawer = new (ELeave) CNcsListItemDrawer( *this ); |
|
142 |
} |
|
143 |
||
144 |
// ----------------------------------------------------------------------------- |
|
145 |
// CNcsPopupListBox::MopSupplyObject |
|
146 |
// ----------------------------------------------------------------------------- |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
147 |
TTypeUid::Ptr CNcsPopupListBox::MopSupplyObject(TTypeUid aId) |
64 | 148 |
{ |
149 |
FUNC_LOG; |
|
150 |
if ( aId.iUid == MAknsControlContext::ETypeId ) |
|
151 |
{ |
|
152 |
return MAknsControlContext::SupplyMopObject( aId, iBackgroundContext ); |
|
153 |
} |
|
154 |
return CCoeControl::MopSupplyObject( aId ); |
|
155 |
} |
|
156 |
||
157 |
// ----------------------------------------------------------------------------- |
|
158 |
// CNcsPopupListBox::SizeChanged |
|
159 |
// ----------------------------------------------------------------------------- |
|
160 |
void CNcsPopupListBox::SizeChanged() |
|
161 |
{ |
|
162 |
FUNC_LOG; |
|
163 |
const TRect outerRect = Rect(); |
|
164 |
||
165 |
TAknLayoutRect subpane; |
|
166 |
subpane.LayoutRect( outerRect, |
|
167 |
AknLayoutScalable_Avkon::bg_popup_sub_pane_g1() ); |
|
168 |
const TRect innerRect = subpane.Rect(); |
|
169 |
||
170 |
iBackgroundContext->SetFrameRects( outerRect, innerRect ); |
|
171 |
||
172 |
SetViewRectFromClientRect( innerRect ); |
|
173 |
TRAP_IGNORE( HandleViewRectSizeChangeL() ); |
|
174 |
} |
|
175 |
||
176 |
void CNcsPopupListBox::HandleResourceChange( TInt aType ) |
|
177 |
{ |
|
178 |
FUNC_LOG; |
|
179 |
if ( aType == KAknsMessageSkinChange ) |
|
180 |
{ |
|
181 |
UpdateTextColors(); |
|
182 |
} |
|
183 |
} |
|
184 |
||
185 |
void CNcsPopupListBox::HandlePointerEventL( const TPointerEvent& aPointerEvent ) |
|
186 |
{ |
|
187 |
CEikTextListBox::HandlePointerEventL( aPointerEvent ); |
|
188 |
} |
|
189 |
||
190 |
// ----------------------------------------------------------------------------- |
|
191 |
// CNcsPopupListBox::OfferKeyEventL |
|
192 |
// ----------------------------------------------------------------------------- |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
193 |
// |
64 | 194 |
TKeyResponse CNcsPopupListBox::OfferKeyEventL( const TKeyEvent& aKeyEvent, |
195 |
TEventCode aType ) |
|
196 |
{ |
|
197 |
FUNC_LOG; |
|
198 |
TKeyResponse ret( EKeyWasNotConsumed ); |
|
199 |
if( aKeyEvent.iCode == EKeyDownArrow ) |
|
200 |
{ |
|
201 |
MoveRemoteLookupItemL( ERemoteLookupItemDown ); |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
202 |
iView->MoveCursorL( CListBoxView::ECursorNextItem, CListBoxView::ENoSelection ); |
64 | 203 |
ret = EKeyWasConsumed; |
204 |
} |
|
205 |
else if( aKeyEvent.iCode == EKeyUpArrow ) |
|
206 |
{ |
|
207 |
TBool stay = EFalse; |
|
208 |
// Move cursor separator line over |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
209 |
if ( CurrentItemIndex() - 1 > 0 && CurrentItemIndex() - 1 == iRemoteLookupItemPos ) |
64 | 210 |
{ |
211 |
MoveRemoteLookupItemL( ERemoteLookupItemUp ); |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
212 |
iView->MoveCursorL( CListBoxView::ECursorPreviousItem, CListBoxView::ENoSelection ); |
64 | 213 |
stay = ETrue; |
214 |
} |
|
215 |
||
216 |
MoveRemoteLookupItemL( ERemoteLookupItemUp ); |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
217 |
iView->MoveCursorL( CListBoxView::ECursorPreviousItem, CListBoxView::ENoSelection ); |
64 | 218 |
if( stay ) |
219 |
{ |
|
220 |
MoveRemoteLookupItemL( ERemoteLookupItemDown ); |
|
221 |
||
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
222 |
iView->MoveCursorL( CListBoxView::ECursorNextItem, CListBoxView::ENoSelection ); |
64 | 223 |
} |
224 |
||
225 |
||
226 |
ret = EKeyWasConsumed; |
|
227 |
} |
|
228 |
||
229 |
if( ret == EKeyWasNotConsumed ) |
|
230 |
{ |
|
231 |
ret = CEikListBox::OfferKeyEventL( aKeyEvent, aType ); |
|
232 |
} |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
233 |
// call HandleItemAdditionL just in case. There might be changes on remote lookup item place. |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
234 |
// The call is here, because we don't want to have extra redraw events when the popuplist |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
235 |
// is not fully updated. |
64 | 236 |
HandleItemAdditionL(); |
237 |
return ret; |
|
238 |
} |
|
239 |
||
240 |
// --------------------------------------------------------------------------- |
|
241 |
// CNcsPopupListBox::HandleListBoxEventL |
|
242 |
// --------------------------------------------------------------------------- |
|
243 |
// |
|
244 |
void CNcsPopupListBox::HandleListBoxEventL( CEikListBox* /*aListBox*/, |
|
245 |
TListBoxEvent aEventType ) |
|
246 |
{ |
|
247 |
if ( aEventType == EEventItemClicked || |
|
248 |
aEventType == EEventItemSingleClicked ) |
|
249 |
{ |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
250 |
iHeaderContainer.DoPopupSelectL(); |
64 | 251 |
} |
252 |
} |
|
253 |
||
254 |
// ----------------------------------------------------------------------------- |
|
255 |
// CNcsPopupListBox::OperationComplete |
|
256 |
// ----------------------------------------------------------------------------- |
|
257 |
// |
|
258 |
void CNcsPopupListBox::OperationCompleteL( TContactHandlerCmd /*aCmd*/, |
|
259 |
const RPointerArray<CFSEmailUiClsItem>& aMatchingItems ) |
|
260 |
{ |
|
261 |
FUNC_LOG; |
|
262 |
iMatchingItems.ResetAndDestroy(); |
|
263 |
// Replace old matcing items. |
|
264 |
||
265 |
for ( TInt ii = 0; ii < aMatchingItems.Count(); ++ii ) |
|
266 |
{ |
|
267 |
if ( aMatchingItems[ii] ) |
|
268 |
{ |
|
269 |
CFSEmailUiClsItem* item = aMatchingItems[ii]->CloneLC(); |
|
270 |
iMatchingItems.AppendL( item ); |
|
271 |
CleanupStack::Pop( item ); |
|
272 |
} |
|
273 |
} |
|
274 |
||
275 |
UpdateListL(); |
|
276 |
} |
|
277 |
||
278 |
void CNcsPopupListBox::OperationErrorL( TContactHandlerCmd aCmd, TInt aError ) |
|
279 |
{ |
|
280 |
FUNC_LOG; |
|
281 |
||
282 |
if ( aCmd == ESearchContacts ) |
|
283 |
{ |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
284 |
// KerrNotReady --> caching in progress, KErrNotFound --> caching not started yet |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
285 |
if ( (aError == KErrNotReady) || (aError == KErrNotFound) ) |
64 | 286 |
{ |
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
287 |
if(!iAppUi->AppUiExitOngoing()) //<cmail> |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
288 |
TFsEmailUiUtility::ShowInfoNoteL( R_FSE_EDITOR_INFO_BUILDING_CACHE ); |
64 | 289 |
iCachingInProgress = ETrue; |
290 |
} |
|
291 |
if ( aError == KErrNone && iCachingInProgress ) |
|
292 |
{ |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
293 |
if(!iAppUi->AppUiExitOngoing()) //<cmail> |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
294 |
TFsEmailUiUtility::ShowInfoNoteL( R_FSE_EDITOR_INFO_CACHING_COMPLETED ); |
64 | 295 |
iCachingInProgress = EFalse; |
296 |
} |
|
297 |
} |
|
298 |
} |
|
299 |
||
300 |
// ----------------------------------------------------------------------------- |
|
301 |
// CNcsPopupListBox::SetSearchTextL |
|
302 |
// ----------------------------------------------------------------------------- |
|
303 |
// |
|
304 |
void CNcsPopupListBox::SetSearchTextL( const TDesC& aText, TInt aMode ) |
|
305 |
{ |
|
306 |
FUNC_LOG; |
|
307 |
delete iCurrentSearchText; |
|
308 |
iCurrentSearchText = NULL; |
|
309 |
iCurrentSearchText = aText.AllocL(); |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
310 |
if ( !iCachingInProgress ) |
64 | 311 |
{ |
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
312 |
if ( iContactHandler ) |
64 | 313 |
{ |
314 |
iContactHandler->SearchMatchesL( aText, this, &iMailBox, aMode ); |
|
315 |
} |
|
316 |
} |
|
317 |
} |
|
318 |
||
319 |
// ----------------------------------------------------------------------------- |
|
320 |
// CNcsPopupListBox::ReturnCurrentEmailAddressLC |
|
321 |
// ----------------------------------------------------------------------------- |
|
322 |
// |
|
323 |
CNcsEmailAddressObject* CNcsPopupListBox::ReturnCurrentEmailAddressLC() |
|
324 |
{ |
|
325 |
FUNC_LOG; |
|
326 |
CNcsEmailAddressObject* addressObject = NULL; |
|
327 |
||
328 |
if ( iMatchingItems.Count() ) |
|
329 |
{ |
|
330 |
CFSEmailUiClsItem* clsItem = NULL; |
|
331 |
if ( iRemoteLookupSupported ) |
|
332 |
{ |
|
333 |
// calculate index of item |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
334 |
TInt index = (CurrentItemIndex() > iRemoteLookupItemPos ? CurrentItemIndex() - 1 : CurrentItemIndex()); |
64 | 335 |
clsItem = iMatchingItems[index]; |
336 |
} |
|
337 |
else |
|
338 |
{ |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
339 |
clsItem = iMatchingItems[CurrentItemIndex()]; // no iRemoteLookupItemPos |
64 | 340 |
} |
341 |
||
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
342 |
addressObject= CNcsEmailAddressObject::NewL( clsItem->DisplayName(), clsItem->EmailAddress() ); |
64 | 343 |
CleanupStack::PushL( addressObject ); |
344 |
if ( clsItem->MultipleEmails() ) |
|
345 |
{ |
|
346 |
addressObject->SetDisplayFull( ETrue ); |
|
347 |
} |
|
348 |
} |
|
349 |
||
350 |
return addressObject; |
|
351 |
} |
|
352 |
||
353 |
// ----------------------------------------------------------------------------- |
|
354 |
// CNcsPopupListBox::SetPopupMaxRect |
|
355 |
// ----------------------------------------------------------------------------- |
|
356 |
void CNcsPopupListBox::SetPopupMaxRect( const TRect& aPopupMaxRect ) |
|
357 |
{ |
|
358 |
FUNC_LOG; |
|
359 |
iPopupMaxRect = aPopupMaxRect; |
|
360 |
||
361 |
SetPopupRect(); |
|
362 |
TRAP_IGNORE( UpdateScrollBarsL() ); |
|
363 |
TRAP_IGNORE( SetScrollBarVisibilityL() ); |
|
364 |
} |
|
365 |
||
366 |
// ----------------------------------------------------------------------------- |
|
367 |
// CNcsPopupListBox::IsPopupEmpty |
|
368 |
// ----------------------------------------------------------------------------- |
|
369 |
TBool CNcsPopupListBox::IsPopupEmpty() const |
|
370 |
{ |
|
371 |
FUNC_LOG; |
|
372 |
if ( Model()->NumberOfItems() > 0 ) |
|
373 |
return EFalse; |
|
374 |
else |
|
375 |
return ETrue; |
|
376 |
} |
|
377 |
||
378 |
// ----------------------------------------------------------------------------- |
|
379 |
// CNcsPopupListBox::IsRemoteLookupItemSelected |
|
380 |
// ----------------------------------------------------------------------------- |
|
381 |
TBool CNcsPopupListBox::IsRemoteLookupItemSelected() const |
|
382 |
{ |
|
383 |
FUNC_LOG; |
|
384 |
if ( CurrentItemIndex() == iRemoteLookupItemPos && iRemoteLookupSupported ) |
|
385 |
return ETrue; |
|
386 |
else |
|
387 |
return EFalse; |
|
388 |
} |
|
389 |
||
390 |
// ----------------------------------------------------------------------------- |
|
391 |
// CNcsPopupListBox::CurrentPopupClsItemsArray |
|
392 |
// ----------------------------------------------------------------------------- |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
393 |
const RPointerArray<CFSEmailUiClsItem>& CNcsPopupListBox::CurrentPopupClsItemsArray() const |
64 | 394 |
{ |
395 |
return iMatchingItems; |
|
396 |
} |
|
397 |
||
398 |
// ----------------------------------------------------------------------------- |
|
399 |
// CNcsPopupListBox::RemoteLookupItemPos |
|
400 |
// ----------------------------------------------------------------------------- |
|
401 |
TInt CNcsPopupListBox::RemoteLookupItemPos() const |
|
402 |
{ |
|
403 |
FUNC_LOG; |
|
404 |
return iRemoteLookupItemPos; |
|
405 |
} |
|
406 |
||
407 |
// ----------------------------------------------------------------------------- |
|
408 |
// CNcsPopupListBox::LayoutHandler |
|
409 |
// ----------------------------------------------------------------------------- |
|
410 |
CFSEmailUiLayoutHandler& CNcsPopupListBox::LayoutHandler() const |
|
411 |
{ |
|
412 |
FUNC_LOG; |
|
413 |
return *iAppUi->LayoutHandler(); |
|
414 |
} |
|
415 |
||
416 |
// ----------------------------------------------------------------------------- |
|
417 |
// CNcsPopupListBox::SetListItemsFromArrayL |
|
418 |
// ----------------------------------------------------------------------------- |
|
419 |
void CNcsPopupListBox::SetListItemsFromArrayL() |
|
420 |
{ |
|
421 |
FUNC_LOG; |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
422 |
// reset the cursor to point to the first item |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
423 |
//iView->MoveCursorL( CListBoxView::ECursorFirstItem, CListBoxView::ENoSelection); |
64 | 424 |
Reset(); |
425 |
||
426 |
// Create totally new text array |
|
427 |
CreateTextArrayAndSetToTheListboxL( ETrue ); |
|
428 |
||
429 |
// append texts to text array |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
430 |
for( TInt i=0; i < iMatchingItems.Count(); i++ ) |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
431 |
{ |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
432 |
iItemTextsArray->AppendL( iMatchingItems[i]->FullTextL() ); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
433 |
} |
64 | 434 |
|
435 |
// Update rmlu item |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
436 |
SetRemoteLookupItemFirstToTheListL(); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
437 |
|
64 | 438 |
SetPopupRect(); |
439 |
SetScrollBarVisibilityL(); |
|
440 |
HandleItemAdditionL(); |
|
441 |
||
442 |
if ( iItemTextsArray && iItemTextsArray->Count() > 0 ) |
|
443 |
{ |
|
444 |
SetCurrentItemIndex( 0 ); |
|
445 |
} |
|
446 |
||
447 |
if ( IsVisible() ) |
|
448 |
{ |
|
449 |
DrawDeferred(); |
|
450 |
} |
|
451 |
} |
|
452 |
||
453 |
// ----------------------------------------------------------------------------- |
|
454 |
// CNcsPopupListBox::RoundToItemHeight |
|
455 |
// ----------------------------------------------------------------------------- |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
456 |
TInt CNcsPopupListBox::RoundToItemHeight(const TInt aPopupHeight) const |
64 | 457 |
{ |
458 |
TReal fullItems; // number of full visible items in window |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
459 |
TInt err = Math::Round(fullItems, (aPopupHeight / ItemHeight()), 0); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
460 |
if (err == KErrNone) |
64 | 461 |
{ |
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
462 |
return (TInt)(fullItems * ItemHeight()); |
64 | 463 |
} |
464 |
return aPopupHeight; // in case of error |
|
465 |
} |
|
466 |
||
467 |
// ----------------------------------------------------------------------------- |
|
468 |
// CNcsPopupListBox::SetPopupRect |
|
469 |
// ----------------------------------------------------------------------------- |
|
470 |
void CNcsPopupListBox::SetPopupRect() |
|
471 |
{ |
|
472 |
FUNC_LOG; |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
473 |
// The popup width and horizontal position is adjusted so that it |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
474 |
// will be within the area specified in both layout data and the set |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
475 |
// maximum rect. |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
476 |
TAknLayoutRect editorPane; |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
477 |
editorPane.LayoutRect( iAppUi->ClientRect(), |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
478 |
TAknWindowComponentLayout::Compose( |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
479 |
TAknWindowComponentLayout::Compose( |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
480 |
AknLayoutScalable_Apps::list_cmail_pane(), |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
481 |
AknLayoutScalable_Apps::list_single_cmail_header_detail_pane( 0 ) ), |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
482 |
AknLayoutScalable_Apps::list_single_cmail_header_editor_pane_bg( 4 ) ) ); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
483 |
TRect editorPaneRect = editorPane.Rect(); |
64 | 484 |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
485 |
TRect newRect = iPopupMaxRect; |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
486 |
newRect.iTl.iX = Max( iPopupMaxRect.iTl.iX, editorPaneRect.iTl.iX ); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
487 |
newRect.iBr.iX = Min( iPopupMaxRect.iBr.iX, editorPaneRect.iBr.iX ); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
488 |
|
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
489 |
// Thhe popup height and vertical position is adjusted based on the |
64 | 490 |
// available space below and above the cursor and the number of items |
491 |
// in the list. |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
492 |
const TRect rect = iPopupMaxRect; |
64 | 493 |
TAknLayoutRect subpane; |
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
494 |
subpane.LayoutRect( rect, AknLayoutScalable_Avkon::bg_popup_sub_pane_g1() ); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
495 |
const TRect subpaneRect = subpane.Rect(); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
496 |
|
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
497 |
const TInt frameHeights = iPopupMaxRect.Height() - subpaneRect.Height(); |
64 | 498 |
|
499 |
// This is the total height in pixels needed to show all items |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
500 |
TInt minimumHeight = frameHeights + |
64 | 501 |
CalcHeightBasedOnNumOfItems( Model()->NumberOfItems() ); |
502 |
||
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
503 |
CCoeControl* container = Parent()->Parent(); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
504 |
TInt containerTop = container->PositionRelativeToScreen().iY; |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
505 |
TInt containerHeight = container->Rect().Height(); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
506 |
TInt containerCenter = containerTop + containerHeight / 2; |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
507 |
|
64 | 508 |
// Get height of one line in Address field |
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
509 |
CNcsHeaderContainer* headerObj = static_cast<CNcsHeaderContainer* >(Parent()); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
510 |
TInt toLineHeight = headerObj->GetToLineHeight(); // height of one line height |
64 | 511 |
if ( toLineHeight == 0 ) |
512 |
{ |
|
513 |
toLineHeight = ItemHeight(); |
|
514 |
} |
|
515 |
||
516 |
TInt newHeight = minimumHeight; // default window height |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
517 |
|
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
518 |
// latch listbox on the bottom of the editor field |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
519 |
if ( newRect.iTl.iY <= containerCenter ) |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
520 |
{ |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
521 |
TInt maxHeight = containerHeight - ( newRect.iTl.iY - containerTop ); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
522 |
newHeight = RoundToItemHeight( maxHeight - frameHeights ) + frameHeights; |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
523 |
if ( newHeight > minimumHeight ) |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
524 |
{ |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
525 |
newHeight = minimumHeight; // shrink window (if needed) |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
526 |
} |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
527 |
} |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
528 |
// latch listbox on the top of the editor field |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
529 |
else |
64 | 530 |
{ |
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
531 |
TInt yOffset = -minimumHeight - toLineHeight; // how much up |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
532 |
TInt newTlY = newRect.iTl.iY + yOffset; // new Top Left Y coordinate |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
533 |
if ( newTlY >= containerTop ) |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
534 |
{ |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
535 |
newRect.Move( 0, yOffset ); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
536 |
} |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
537 |
else |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
538 |
{ |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
539 |
// shrink height to visible area and move |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
540 |
TInt maxHeight = newRect.iTl.iY - toLineHeight - containerTop; |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
541 |
newHeight = RoundToItemHeight( maxHeight - frameHeights ) + frameHeights; |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
542 |
newRect.Move( 0, -newHeight - toLineHeight ); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
543 |
} |
64 | 544 |
} |
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
545 |
newRect.SetHeight( newHeight ); // set new height |
64 | 546 |
SetRect( newRect ); |
547 |
} |
|
548 |
||
549 |
// ----------------------------------------------------------------------------- |
|
550 |
// CNcsPopupListBox::SetScrollBarVisibilityL |
|
551 |
// ----------------------------------------------------------------------------- |
|
552 |
void CNcsPopupListBox::SetScrollBarVisibilityL() |
|
553 |
{ |
|
554 |
FUNC_LOG; |
|
555 |
// This is the total height in pixels needed to show all items |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
556 |
TInt minimumHeight = CalcHeightBasedOnNumOfItems( Model()->NumberOfItems() ); |
64 | 557 |
|
558 |
// Show scroll bar if there is more items we can show at once. |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
559 |
if( iPopupMaxRect.Height() > minimumHeight ) |
64 | 560 |
{ |
561 |
ScrollBarFrame()->SetScrollBarVisibilityL( |
|
562 |
CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff ); |
|
563 |
} |
|
564 |
else |
|
565 |
{ |
|
566 |
ScrollBarFrame()->SetScrollBarVisibilityL( |
|
567 |
CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOn ); |
|
568 |
} |
|
569 |
} |
|
570 |
||
571 |
||
572 |
// ----------------------------------------------------------------------------- |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
573 |
// CNcsPopupListBox::SetRemoteLookupItemFirstToTheListL |
64 | 574 |
// ----------------------------------------------------------------------------- |
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
575 |
void CNcsPopupListBox::SetRemoteLookupItemFirstToTheListL() |
64 | 576 |
{ |
577 |
FUNC_LOG; |
|
578 |
if( iRemoteLookupSupported ) |
|
579 |
{ |
|
580 |
HBufC* rmluText = StringLoader::LoadLC( |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
581 |
R_FSE_EDITOR_ADDRESS_LIST_REMOTE_LOOKUP_SEARCH, *iCurrentSearchText ); |
64 | 582 |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
583 |
iItemTextsArray->InsertL( 0, *rmluText ); |
64 | 584 |
CleanupStack::PopAndDestroy( rmluText ); |
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
585 |
iRemoteLookupItemPos = 0; |
64 | 586 |
} |
587 |
else |
|
588 |
{ |
|
589 |
iRemoteLookupItemPos = -1; |
|
590 |
} |
|
591 |
} |
|
592 |
||
593 |
// ----------------------------------------------------------------------------- |
|
594 |
// CNcsPopupListBox::MoveRemoteLookupItemL |
|
595 |
// ----------------------------------------------------------------------------- |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
596 |
void CNcsPopupListBox::MoveRemoteLookupItemL( TRemoteLookupItemMoveDirection aDirection ) |
64 | 597 |
{ |
598 |
FUNC_LOG; |
|
599 |
if( iRemoteLookupSupported ) |
|
600 |
{ |
|
601 |
TInt newRMLUItemIndex = -1; |
|
602 |
TInt newCurrentItem = -1; |
|
603 |
if( aDirection == ERemoteLookupItemUp && |
|
604 |
iView->CurrentItemIndex() == iView->TopItemIndex() ) |
|
605 |
{ |
|
606 |
newRMLUItemIndex = iRemoteLookupItemPos - 1; |
|
607 |
newCurrentItem = CurrentItemIndex() - 1; |
|
608 |
} |
|
609 |
else if( aDirection == ERemoteLookupItemDown && |
|
610 |
iView->CurrentItemIndex() == iView->BottomItemIndex() ) |
|
611 |
{ |
|
612 |
newRMLUItemIndex = iRemoteLookupItemPos + 1; |
|
613 |
newCurrentItem = CurrentItemIndex() + 1; |
|
614 |
} |
|
615 |
||
616 |
||
617 |
if( ItemExists ( newCurrentItem ) && newRMLUItemIndex != -1 ) |
|
618 |
{ |
|
619 |
iItemTextsArray->Delete( iRemoteLookupItemPos ); |
|
620 |
||
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
621 |
HBufC* rmluText = StringLoader::LoadLC( R_FSE_EDITOR_ADDRESS_LIST_REMOTE_LOOKUP_SEARCH, *iCurrentSearchText ); |
64 | 622 |
|
623 |
iItemTextsArray->InsertL( newRMLUItemIndex, *rmluText ); |
|
624 |
CleanupStack::PopAndDestroy( rmluText ); |
|
625 |
iRemoteLookupItemPos = newRMLUItemIndex; |
|
626 |
} |
|
627 |
} |
|
628 |
} |
|
629 |
||
630 |
||
631 |
// ----------------------------------------------------------------------------- |
|
632 |
// CNcsPopupListBox::CreateTextArrayAndSetToTheListboxL |
|
633 |
// ----------------------------------------------------------------------------- |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
634 |
void CNcsPopupListBox::CreateTextArrayAndSetToTheListboxL( const TBool& aResetIfExists ) |
64 | 635 |
{ |
636 |
FUNC_LOG; |
|
637 |
if( !iItemTextsArray ) |
|
638 |
{ |
|
639 |
iItemTextsArray = new ( ELeave ) CDesCArraySeg( 8 ); |
|
640 |
// Set the popup list data |
|
641 |
Model()->SetItemTextArray( iItemTextsArray ); |
|
642 |
Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
643 |
} |
|
644 |
||
645 |
if( aResetIfExists ) |
|
646 |
{ |
|
647 |
delete iItemTextsArray; |
|
648 |
iItemTextsArray = NULL; |
|
649 |
CreateTextArrayAndSetToTheListboxL( EFalse ); |
|
650 |
} |
|
651 |
} |
|
652 |
||
653 |
||
654 |
// ----------------------------------------------------------------------------- |
|
655 |
// CNcsListItemDrawer::CNcsListItemDrawer |
|
656 |
// ----------------------------------------------------------------------------- |
|
657 |
CNcsListItemDrawer::CNcsListItemDrawer( const CNcsPopupListBox& aListBox ) |
|
658 |
:CListItemDrawer(), iListBox( aListBox ) |
|
659 |
{ |
|
660 |
FUNC_LOG; |
|
661 |
// Store a GC for later use |
|
662 |
iGc = &CCoeEnv::Static()->SystemGc(); |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
663 |
SetGc(iGc); |
64 | 664 |
} |
665 |
||
666 |
// ----------------------------------------------------------------------------- |
|
667 |
// CNcsListItemDrawer::DrawActualItem |
|
668 |
// ----------------------------------------------------------------------------- |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
669 |
void CNcsListItemDrawer::DrawActualItem(TInt aItemIndex, |
64 | 670 |
const TRect& aActualItemRect, TBool aItemIsCurrent, |
671 |
TBool /*aViewIsEmphasized*/, TBool /*aViewIsDimmed*/, |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
672 |
TBool /*aItemIsSelected*/) const |
64 | 673 |
{ |
674 |
FUNC_LOG; |
|
675 |
iGc->DiscardFont(); |
|
676 |
||
677 |
// Get reference to curren popup cls item list. |
|
678 |
const RPointerArray<CFSEmailUiClsItem>& clsItemArray = |
|
679 |
iListBox.CurrentPopupClsItemsArray(); |
|
680 |
TInt rmluPosition = iListBox.RemoteLookupItemPos(); |
|
681 |
||
682 |
// Sets all the attributes, like font, text color and background color. |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
683 |
const CFont* font = AknLayoutUtils::FontFromId( EAknLogicalFontPrimarySmallFont ); |
64 | 684 |
iGc->UseFont( font ); |
685 |
iGc->SetPenStyle( CGraphicsContext::ESolidPen ); |
|
686 |
iGc->SetBrushStyle( CGraphicsContext::ENullBrush ); |
|
687 |
||
688 |
TRect itemRect = aActualItemRect; |
|
689 |
{ |
|
690 |
// temporary const_cast to get the scrollbar width |
|
691 |
CNcsPopupListBox& tmpListBox = const_cast<CNcsPopupListBox&>( iListBox ); |
|
692 |
const TInt scrollbarBreadth = tmpListBox.ScrollBarFrame()-> |
|
693 |
ScrollBarBreadth( CEikScrollBar::EVertical ); |
|
694 |
if ( scrollbarBreadth > 0 ) |
|
695 |
{ |
|
696 |
if ( AknLayoutUtils::LayoutMirrored() ) |
|
697 |
{ |
|
698 |
itemRect.iTl.iX = iListBox.Rect().iTl.iX + scrollbarBreadth; |
|
699 |
} |
|
700 |
else |
|
701 |
{ |
|
702 |
itemRect.iBr.iX = iListBox.Rect().iBr.iX - scrollbarBreadth; |
|
703 |
} |
|
704 |
} |
|
705 |
} |
|
706 |
||
707 |
TRect textRect = itemRect; |
|
708 |
textRect.Shrink( KHighlightFrameWidth, KHighlightFrameWidth ); |
|
709 |
||
710 |
// Get skin instance. |
|
711 |
MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
712 |
||
713 |
// Draw background using the control context from the list box. |
|
714 |
MAknsControlContext* cc = AknsDrawUtils::ControlContext( &iListBox ); |
|
715 |
if ( cc ) |
|
716 |
{ |
|
717 |
AknsDrawUtils::Background( skin, cc, *iGc, aActualItemRect ); |
|
718 |
} |
|
719 |
else |
|
720 |
{ |
|
721 |
iGc->Clear( aActualItemRect ); |
|
722 |
} |
|
723 |
||
724 |
// Draw the highlight, when necessary. |
|
725 |
if ( aItemIsCurrent ) |
|
726 |
{ |
|
727 |
AknsDrawUtils::DrawFrame( skin, *iGc, itemRect, textRect, |
|
728 |
KAknsIIDQsnFrList, KAknsIIDQsnFrListCenter ); |
|
729 |
} |
|
730 |
||
731 |
// Get text color. |
|
732 |
TRgb textColor = TextColor(); |
|
733 |
if ( aItemIsCurrent ) |
|
734 |
{ |
|
735 |
textColor = HighlightedTextColor(); |
|
736 |
} |
|
737 |
||
738 |
iGc->SetPenColor( textColor ); |
|
739 |
TInt topToBaseline = ( textRect.Height() - font->FontMaxHeight() ) / 2 |
|
740 |
+ font->FontMaxAscent(); |
|
741 |
||
742 |
TPtrC itemText = iListBox.Model()->ItemText( aItemIndex ); |
|
743 |
||
744 |
// Construct bidirectional text object |
|
745 |
// <cmail> Removed leave from non-leaving function. |
|
746 |
TBidiText* bidiText = NULL; |
|
747 |
TRAPD( err, bidiText = TBidiText::NewL( itemText, 1 ) ); |
|
748 |
if ( err == KErrNone ) |
|
749 |
{ |
|
750 |
bidiText->WrapText( textRect.Width(), *font, NULL ); |
|
751 |
} |
|
752 |
||
753 |
TPoint leftBase = textRect.iTl + TPoint( 0, topToBaseline ); |
|
754 |
||
755 |
if ( err != KErrNone ) |
|
756 |
{ |
|
757 |
bidiText = NULL; // to be on the safe side |
|
758 |
} |
|
759 |
||
760 |
// check if we are drawing remote lookup item or contact match |
|
761 |
else if ( rmluPosition == aItemIndex ) |
|
762 |
{ |
|
763 |
iGc->SetUnderlineStyle( EUnderlineOff ); |
|
764 |
bidiText->DrawText( *iGc, leftBase ); |
|
765 |
} |
|
766 |
else |
|
767 |
{ |
|
768 |
// if list has rmlu item change item index right |
|
769 |
if ( rmluPosition >= 0 && aItemIndex > rmluPosition ) |
|
770 |
{ |
|
771 |
aItemIndex--; |
|
772 |
} |
|
773 |
||
774 |
// Change text transparency if match doesn't have email address. |
|
775 |
if ( clsItemArray[aItemIndex]->EmailAddress().Compare( KNullDesC ) == 0 ) |
|
776 |
{ |
|
777 |
const TInt KTransparency = |
|
778 |
iListBox.LayoutHandler().PcsPopupDimmedFontTransparency(); |
|
779 |
textColor.SetAlpha( KTransparency ); |
|
780 |
iGc->SetPenColor( textColor ); |
|
781 |
} |
|
782 |
||
783 |
// For now, we support underlining the matching part only if the |
|
784 |
// text is written completely with left-to-right script |
|
785 |
||
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
786 |
// We know the text contains RTL script if the display string is not just |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
787 |
// truncated version of the original string. |
64 | 788 |
TPtrC dispText = bidiText->DisplayText(); |
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
789 |
TInt compLength = dispText.Length() - 1; // -1 to omit the truncation character |
64 | 790 |
TBool textContainsRtl = |
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
791 |
( itemText.Left(compLength) != dispText.Left(compLength) ); |
64 | 792 |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
793 |
const RArray<TPsMatchLocation>& underlines = clsItemArray[aItemIndex]->Highlights(); |
64 | 794 |
|
795 |
if ( underlines.Count() > 0 && !textContainsRtl ) |
|
796 |
{ |
|
797 |
TInt i = 0; |
|
798 |
TBool partsLeft = ETrue; |
|
799 |
TInt currentTextStart = 0; |
|
800 |
TInt currentTextLength = 0; |
|
801 |
||
802 |
while ( partsLeft ) |
|
803 |
{ |
|
804 |
if ( currentTextStart < underlines[i].index ) |
|
805 |
{ |
|
806 |
// draw letters to the start of the underlined part |
|
807 |
currentTextLength = underlines[i].index - currentTextStart; |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
808 |
DrawPartOfItem( textRect, *font, currentTextStart, currentTextLength, itemText, |
64 | 809 |
EFalse, topToBaseline ); |
810 |
} |
|
811 |
else if ( currentTextStart == underlines[i].index ) |
|
812 |
{ |
|
813 |
// draw underlined letters |
|
814 |
currentTextLength = underlines[i].length; |
|
815 |
||
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
816 |
DrawPartOfItem( textRect, *font, currentTextStart, currentTextLength, itemText, |
64 | 817 |
ETrue, topToBaseline ); |
818 |
i++; |
|
819 |
} |
|
820 |
else |
|
821 |
{ |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
822 |
// This is here, because PCS Engine might give you duplicate match entries, |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
823 |
// in this case we're not advancing text but we'll skip that match |
64 | 824 |
currentTextLength = 0; |
825 |
i++; |
|
826 |
} |
|
827 |
// update text start point |
|
828 |
currentTextStart += currentTextLength; |
|
829 |
||
830 |
if ( i >= underlines.Count() ) |
|
831 |
{ |
|
832 |
partsLeft = EFalse; |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
833 |
// draw rest of the letters, if there are any after the last underlined part |
64 | 834 |
if ( currentTextStart < itemText.Length() ) |
835 |
{ |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
836 |
currentTextLength = itemText.Length() - currentTextStart; |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
837 |
DrawPartOfItem( textRect, *font, currentTextStart, currentTextLength, itemText, |
64 | 838 |
EFalse, topToBaseline ); |
839 |
} |
|
840 |
} |
|
841 |
||
842 |
} |
|
843 |
} |
|
844 |
else |
|
845 |
{ |
|
846 |
iGc->SetUnderlineStyle( EUnderlineOff ); |
|
847 |
bidiText->DrawText( *iGc, leftBase ); |
|
848 |
} |
|
849 |
} |
|
850 |
||
851 |
delete bidiText; |
|
852 |
bidiText = NULL; |
|
853 |
} |
|
854 |
||
855 |
// ----------------------------------------------------------------------------- |
|
856 |
// CNcsListItemDrawer::DrawPartOfItem |
|
857 |
// ----------------------------------------------------------------------------- |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
858 |
void CNcsListItemDrawer::DrawPartOfItem( const TRect& aItemRect, const CFont& aFont, |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
859 |
TInt aStartPos, TInt aLength, const TDesC& aDes, |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
860 |
TBool aUnderlined, TInt aBaselineOffsetFromTop ) const |
64 | 861 |
{ |
862 |
FUNC_LOG; |
|
863 |
if( aUnderlined ) |
|
864 |
{ |
|
865 |
iGc->SetUnderlineStyle( EUnderlineOn ); |
|
866 |
} |
|
867 |
else |
|
868 |
{ |
|
869 |
iGc->SetUnderlineStyle( EUnderlineOff ); |
|
870 |
} |
|
871 |
TRect currentTextRect( aItemRect ); |
|
872 |
TInt pixels = aFont.TextWidthInPixels( aDes.Left( aStartPos ) ); |
|
873 |
currentTextRect.iTl.iX = currentTextRect.iTl.iX + pixels; |
|
874 |
iGc->DrawText( aDes.Mid( aStartPos, aLength ), |
|
875 |
currentTextRect, aBaselineOffsetFromTop ); |
|
876 |
} |
|
877 |
||
878 |
||
879 |
void CNcsPopupListBox::UpdateListL() |
|
880 |
{ |
|
881 |
FUNC_LOG; |
|
882 |
SetListItemsFromArrayL(); |
|
883 |
||
884 |
// Close the popup if it's empty and make sure it's visible if it's not empty. |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
885 |
if ( IsPopupEmpty() ) |
64 | 886 |
{ |
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
887 |
iHeaderContainer.ClosePopupContactListL(); |
64 | 888 |
} |
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
889 |
else |
64 | 890 |
{ |
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
891 |
MakeVisible( ETrue ); |
64 | 892 |
UpdateScrollBarsL(); |
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
73
diff
changeset
|
893 |
iHeaderContainer.ShowPopupMenuBarL( ETrue ); |
64 | 894 |
} |
895 |
} |
|
896 |
||
897 |
void CNcsPopupListBox::UpdateTextColors() |
|
898 |
{ |
|
899 |
if ( iItemDrawer ) |
|
900 |
{ |
|
901 |
// Get skin instance. |
|
902 |
MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
903 |
||
904 |
// Get color for popup text from current skin. |
|
905 |
TRgb textColor = KRgbBlack; |
|
906 |
AknsUtils::GetCachedColor( skin, textColor, KAknsIIDQsnTextColors, |
|
907 |
EAknsCIQsnTextColorsCG20 ); |
|
908 |
iItemDrawer->SetTextColor( textColor ); |
|
909 |
||
910 |
// Get text color for highlighted list item from current skin. |
|
911 |
AknsUtils::GetCachedColor( skin, textColor, KAknsIIDQsnTextColors, |
|
912 |
EAknsCIQsnTextColorsCG10 ); |
|
913 |
iItemDrawer->SetHighlightedTextColor( textColor ); |
|
914 |
} |
|
915 |
} |
|
916 |
||
917 |
void CNcsPopupListBox::Draw( const TRect& /*aRect*/ ) const |
|
918 |
{ |
|
919 |
CWindowGc& gc = SystemGc(); |
|
920 |
MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
921 |
if ( iBackgroundContext ) |
|
922 |
{ |
|
923 |
AknsDrawUtils::DrawBackground( skin, iBackgroundContext, this, gc, |
|
924 |
Rect().iTl, Rect(), KAknsDrawParamNoClearUnderImage ); |
|
925 |
} |
|
926 |
else |
|
927 |
{ |
|
928 |
gc.Clear( Rect() ); |
|
929 |
} |
|
930 |
CEikListBox::Draw( Rect() ); |
|
931 |
} |
|
932 |
||
933 |
// End of File |
|
934 |