1 /* |
1 /* |
2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
8 * |
8 * |
9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
|
14 * Description: ESMR titled field implementation |
|
15 * |
13 * |
16 */ |
14 * Description: ESMR titled field implementation |
17 |
15 * |
18 #include "emailtrace.h" |
16 */ |
19 #include "cesmrattendeefield.h" |
17 #include "cesmrattendeefield.h" |
20 |
|
21 #include <eiklabel.h> |
|
22 #include <avkon.hrh> |
|
23 #include <caluser.h> |
|
24 #include <calentry.h> |
|
25 #include <StringLoader.h> |
|
26 #include <esmrgui.rsg> |
|
27 #include <AknsFrameBackgroundControlContext.h> |
|
28 //<cmail> |
18 //<cmail> |
29 #include "esmrcommands.h" |
19 #include "esmrcommands.h" |
30 #include "cfsmailclient.h" |
20 #include "CFSMailClient.h" |
31 //</cmail> |
21 //</cmail> |
32 #include "cesmrncspopuplistbox.h" |
22 #include "cesmrncspopuplistbox.h" |
33 #include "cesmrncsemailaddressobject.h" |
23 #include "cesmrncsemailaddressobject.h" |
34 #include "mesmrlistobserver.h" |
24 #include "mesmrlistobserver.h" |
35 #include "cesmrborderlayer.h" |
|
36 #include "cesmrcontacthandler.h" |
25 #include "cesmrcontacthandler.h" |
37 #include "mesmrmeetingrequestentry.h" |
26 #include "mesmrmeetingrequestentry.h" |
38 #include "esmrfieldbuilderdef.h" |
27 #include "esmrfieldbuilderdef.h" |
39 #include "cesmrlayoutmgr.h" |
28 #include "cmrlabel.h" |
40 // <cmail> Removed profiling. </cmail> |
29 #include "nmrlayoutmanager.h" |
41 |
30 #include "nmrbitmapmanager.h" |
42 using namespace ESMRLayout; |
31 #include "cmrimage.h" |
43 |
32 #include "cmrbutton.h" |
44 //CONSTANTS |
33 |
|
34 #include <aknsbasicbackgroundcontrolcontext.h> |
|
35 #include <calentry.h> |
|
36 #include <stringloader.h> |
|
37 #include <esmrgui.rsg> |
|
38 #include <aknbutton.h> |
|
39 #include <gulicon.h> |
|
40 #include <ct/rcpointerarray.h> |
|
41 |
|
42 // DEBUG |
|
43 #include "emailtrace.h" |
|
44 |
45 |
45 |
46 // unnamed namespace for local definitions |
46 // unnamed namespace for local definitions |
47 namespace { // codescanner::namespace |
47 namespace { // codescanner::namespace |
48 |
48 //CONSTANTS |
|
49 const TInt KMaxAmountOfItems( 4 ); |
49 const TInt KMaxRemoteSearchResponseLength = 255; |
50 const TInt KMaxRemoteSearchResponseLength = 255; |
50 |
|
51 static void RPointerArrayResetAndDestroy( TAny* aPtr ) |
|
52 { |
|
53 static_cast<RPointerArray<CESMRNcsEmailAddressObject>*>( aPtr )->ResetAndDestroy(); |
|
54 } |
|
55 |
|
56 #ifdef _DEBUG |
|
57 |
51 |
58 // Panic code literal |
52 // Panic code literal |
59 _LIT( KESMRAttendeeField, "ESMRAttendeeField" ); |
53 _LIT( KESMRAttendeeField, "ESMRAttendeeField" ); |
60 |
54 |
61 /** Panic code enumeration */ |
55 /** Panic code enumeration */ |
67 void Panic( TESMRAttendeeFieldPanic aPanic ) |
61 void Panic( TESMRAttendeeFieldPanic aPanic ) |
68 { |
62 { |
69 User::Panic( KESMRAttendeeField, aPanic ); |
63 User::Panic( KESMRAttendeeField, aPanic ); |
70 } |
64 } |
71 |
65 |
72 #endif // _DEBUG |
|
73 |
|
74 }//namespace |
66 }//namespace |
75 |
67 |
76 // ======== MEMBER FUNCTIONS ======== |
68 // ======== MEMBER FUNCTIONS ======== |
77 |
69 |
78 // --------------------------------------------------------------------------- |
70 // --------------------------------------------------------------------------- |
79 // CESMRAttendeeField::CESMRAttendeeField |
71 // CESMRAttendeeField::CESMRAttendeeField |
80 // --------------------------------------------------------------------------- |
72 // --------------------------------------------------------------------------- |
81 // |
73 // |
82 CESMRAttendeeField::CESMRAttendeeField( CCalAttendee::TCalRole aRole ) : |
74 CESMRAttendeeField::CESMRAttendeeField( CCalAttendee::TCalRole aRole ) |
83 iRole( aRole) |
75 :iRole( aRole ) |
84 { |
76 { |
85 FUNC_LOG; |
77 FUNC_LOG; |
86 //do nothing |
78 SetFocusType( EESMRHighlightFocus ); |
|
79 SetFieldId ( (iRole == CCalAttendee::EReqParticipant) ? |
|
80 EESMRFieldAttendee : EESMRFieldOptAttendee ); |
87 } |
81 } |
88 |
82 |
89 // --------------------------------------------------------------------------- |
83 // --------------------------------------------------------------------------- |
90 // CESMRAttendeeField::~CESMRAttendeeField |
84 // CESMRAttendeeField::~CESMRAttendeeField |
91 // --------------------------------------------------------------------------- |
85 // --------------------------------------------------------------------------- |
92 // |
86 // |
93 CESMRAttendeeField::~CESMRAttendeeField( ) |
87 CESMRAttendeeField::~CESMRAttendeeField( ) |
94 { |
88 { |
95 FUNC_LOG; |
89 FUNC_LOG; |
96 delete iAacListBox; |
90 delete iAacListBox; |
97 delete iTitle; |
|
98 delete iContactHandler; |
91 delete iContactHandler; |
99 delete iDefaultText; |
92 delete iDefaultText; |
100 delete iFrameBgContext; |
93 delete iBgCtrlContext; |
101 delete iPhoneOwnerAddr; |
94 delete iFieldButton; |
|
95 delete iTitle; |
102 } |
96 } |
103 |
97 |
104 // --------------------------------------------------------------------------- |
98 // --------------------------------------------------------------------------- |
105 // CESMRAttendeeField::NewL |
99 // CESMRAttendeeField::NewL |
106 // --------------------------------------------------------------------------- |
100 // --------------------------------------------------------------------------- |
120 // --------------------------------------------------------------------------- |
114 // --------------------------------------------------------------------------- |
121 // |
115 // |
122 void CESMRAttendeeField::ConstructL( ) |
116 void CESMRAttendeeField::ConstructL( ) |
123 { |
117 { |
124 FUNC_LOG; |
118 FUNC_LOG; |
125 SetExpandable ( ); |
119 SetComponentsToInheritVisibility( ETrue ); |
126 |
|
127 SetFieldId ( (iRole == CCalAttendee::EReqParticipant) ? EESMRFieldAttendee |
|
128 : EESMRFieldOptAttendee ); |
|
129 |
|
130 iTitle = new (ELeave) CEikLabel(); |
|
131 iTitle->SetLabelAlignment ( CESMRLayoutManager::IsMirrored ( ) ? ELayoutAlignRight |
|
132 : ELayoutAlignLeft ); |
|
133 |
120 |
134 iContactHandler = CESMRContactHandler::NewL(); |
121 iContactHandler = CESMRContactHandler::NewL(); |
135 |
122 |
136 iDefaultText = StringLoader::LoadL ( R_QTN_MEET_REQ_CONTACT_FIELD ); |
123 iDefaultText = StringLoader::LoadL ( R_QTN_MEET_REQ_CONTACT_FIELD ); |
137 iEditor = new ( ELeave ) CESMRNcsAifEditor( *iContactHandler, iDefaultText ); |
124 |
138 |
125 iFieldButton = CMRButton::NewL( NMRBitmapManager::EMRBitmapSearchContacts ); |
139 iEditor->SetPopupList(this ); |
126 iFieldButton->SetParent( this ); |
140 |
127 iFieldButton->SetObserver( this ); |
141 HBufC* label = StringLoader::LoadLC (iRole == CCalAttendee::EReqParticipant ? |
128 |
142 R_QTN_MEET_REQ_LABEL_REQUIRED:R_QTN_MEET_REQ_LABEL_OPT ); |
129 iTitle = CMRLabel::NewL(); |
143 |
130 iTitle->SetParent( this ); |
144 iTitle->SetTextL ( *label ); |
131 |
145 CleanupStack::PopAndDestroy (label ); |
132 HBufC* buf = NULL; |
146 |
133 if( FieldId() == EESMRFieldAttendee ) |
147 iBackground = AknsDrawUtils::ControlContext( this ); |
134 { |
148 |
135 buf = StringLoader::LoadLC( R_QTN_MEET_REQ_LABEL_REQUIRED ); |
149 CESMRField::ConstructL ( iEditor ); |
136 } |
150 } |
137 |
151 |
138 if( FieldId() == EESMRFieldOptAttendee ) |
152 // --------------------------------------------------------------------------- |
139 { |
153 // CESMRAttendeeField::InitializeL |
140 buf = StringLoader::LoadLC( R_QTN_MEET_REQ_LABEL_OPT ); |
154 // --------------------------------------------------------------------------- |
141 } |
155 // |
142 |
156 void CESMRAttendeeField::InitializeL() |
143 iTitle->SetTextL( *buf ); // ownership transferred |
157 { |
144 CleanupStack::Pop( buf ); |
158 FUNC_LOG; |
145 |
159 iEditor->SetFontL( iLayout->Font(iCoeEnv, iFieldId), iLayout ); |
146 |
|
147 iEditor = |
|
148 new ( ELeave ) CESMRNcsAifEditor( *iContactHandler, iDefaultText ); |
|
149 CESMRField::ConstructL( iEditor ); |
|
150 iEditor->ConstructL ( |
|
151 this, |
|
152 KMaxAddressFieldLines, |
|
153 0, |
|
154 CEikEdwin::EAvkonEditor | CEikEdwin::EResizable | |
|
155 CEikEdwin::ENoAutoSelection |CEikEdwin::EInclusiveSizeFixed | |
|
156 CEikEdwin::ENoHorizScrolling |
|
157 ); |
|
158 iEditor->SetEdwinSizeObserver( this ); |
|
159 iEditor->SetParent( this ); |
|
160 iEditor->SetPopupList( this ); |
160 iEditor->SetAlignment ( EAknEditorAlignBidi | EAknEditorAlignCenter ); |
161 iEditor->SetAlignment ( EAknEditorAlignBidi | EAknEditorAlignCenter ); |
161 iEditor->SetAknEditorInputMode ( EAknEditorTextInputMode ); |
162 iEditor->SetAknEditorInputMode ( EAknEditorTextInputMode ); |
162 iEditor->SetAknEditorFlags ( EAknEditorFlagNoT9| EAknEditorFlagUseSCTNumericCharmap ); |
163 iEditor->SetAknEditorFlags ( |
|
164 EAknEditorFlagNoT9| EAknEditorFlagUseSCTNumericCharmap ); |
163 iEditor->SetAknEditorCurrentCase ( EAknEditorLowerCase ); |
165 iEditor->SetAknEditorCurrentCase ( EAknEditorLowerCase ); |
164 iEditor->CreateScrollBarFrameL()->SetScrollBarVisibilityL ( CEikScrollBarFrame::EOff, |
166 |
165 CEikScrollBarFrame::EOff ); |
167 // Draw bg instead of using skin bg |
166 iEditor->SetEdwinSizeObserver ( this ); |
168 TRect tempRect( 0, 0, 0, 0 ); |
167 |
169 NMRBitmapManager::TMRBitmapStruct bitmapStruct; |
168 iTitleSize = iLayout->FieldSize ( EESMRFieldAttendeeLabel ); |
170 bitmapStruct = NMRBitmapManager::GetBitmapStruct( NMRBitmapManager::EMRBitmapInputCenter ); |
169 iTitle->SetFont( iLayout->Font(iCoeEnv, EESMRFieldAttendeeLabel) ); |
171 iBgCtrlContext = CAknsBasicBackgroundControlContext::NewL( |
170 |
172 bitmapStruct.iItemId, |
171 iAacListBox->Initialise(iLayout); |
173 tempRect, |
|
174 EFalse ); |
|
175 iEditor->SetSkinBackgroundControlContextL( iBgCtrlContext ); |
|
176 } |
|
177 |
|
178 // --------------------------------------------------------------------------- |
|
179 // CESMRAttendeeField::MinimumSize |
|
180 // --------------------------------------------------------------------------- |
|
181 // |
|
182 TSize CESMRAttendeeField::MinimumSize() |
|
183 { |
|
184 TRect parentRect( Parent()->Rect() ); |
|
185 |
|
186 TRect richTextRect = |
|
187 NMRLayoutManager::GetFieldLayoutRect( parentRect, 1 ).Rect(); |
|
188 |
|
189 TRect textRect( NMRLayoutManager::GetLayoutText( |
|
190 richTextRect, |
|
191 NMRLayoutManager::EMRTextLayoutTextEditor ).TextRect() ); |
|
192 |
|
193 // Adjust field size so that there's room for expandable editor. |
|
194 richTextRect.Resize( 0, iSize.iHeight - textRect.Height() ); |
|
195 |
|
196 // Add title area to the required size |
|
197 TSize titleSize( CESMRField::MinimumSize() ); |
|
198 |
|
199 TSize completeFieldSize( titleSize ); |
|
200 completeFieldSize.iHeight += richTextRect.Height(); |
|
201 |
|
202 return completeFieldSize; |
|
203 } |
|
204 |
|
205 // --------------------------------------------------------------------------- |
|
206 // CESMRAttendeeField::InitializeL |
|
207 // --------------------------------------------------------------------------- |
|
208 // |
|
209 void CESMRAttendeeField::InitializeL() |
|
210 { |
|
211 FUNC_LOG; |
|
212 // No Implementation |
172 } |
213 } |
173 |
214 |
174 // --------------------------------------------------------------------------- |
215 // --------------------------------------------------------------------------- |
175 // CESMRAttendeeField::InternalizeL |
216 // CESMRAttendeeField::InternalizeL |
176 // --------------------------------------------------------------------------- |
217 // --------------------------------------------------------------------------- |
177 // |
218 // |
178 void CESMRAttendeeField::InternalizeL( MESMRCalEntry& aEntry ) |
219 void CESMRAttendeeField::InternalizeL( MESMRCalEntry& aEntry ) |
179 { |
220 { |
180 FUNC_LOG; |
221 FUNC_LOG; |
|
222 iEditor->CreateScrollBarFrameL()->SetScrollBarVisibilityL ( |
|
223 CEikScrollBarFrame::EOff, |
|
224 CEikScrollBarFrame::EOff ); |
|
225 |
|
226 TInt fieldAttendeeCount( 0 ); |
|
227 |
181 CCalEntry& entry = aEntry.Entry ( ); |
228 CCalEntry& entry = aEntry.Entry ( ); |
182 RPointerArray< CCalAttendee > attendees = entry.AttendeesL ( ); |
229 RPointerArray< CCalAttendee > attendees = entry.AttendeesL ( ); |
183 RPointerArray< CESMRNcsEmailAddressObject > addressList; // codescanner::resourcenotoncleanupstack |
230 RCPointerArray< CESMRNcsEmailAddressObject > addressList; |
184 TCleanupItem arrayCleanup( RPointerArrayResetAndDestroy, &addressList ); |
231 CleanupClosePushL( addressList ); |
185 CleanupStack::PushL( arrayCleanup ); |
232 |
186 |
233 for (TInt i(0); i < attendees.Count(); i++ ) |
187 for (TInt i(0); i < attendees.Count ( ); i++ ) |
|
188 { |
234 { |
189 if ( attendees[i]->RoleL() == iRole ) |
235 if ( attendees[i]->RoleL() == iRole ) |
190 { |
236 { |
|
237 fieldAttendeeCount++; |
|
238 |
191 const TDesC& addr = attendees[i]->Address ( ); |
239 const TDesC& addr = attendees[i]->Address ( ); |
192 const TDesC& commonName = attendees[i]->CommonName ( ); |
240 const TDesC& commonName = attendees[i]->CommonName ( ); |
193 |
241 |
194 CESMRNcsEmailAddressObject* obj = CESMRNcsEmailAddressObject::NewL ( commonName, addr ); |
242 CESMRNcsEmailAddressObject* obj = |
|
243 CESMRNcsEmailAddressObject::NewL ( commonName, addr ); |
195 CleanupStack::PushL (obj ); |
244 CleanupStack::PushL (obj ); |
196 addressList.AppendL( obj ); |
245 addressList.AppendL( obj ); |
197 CleanupStack::Pop( obj ); |
246 CleanupStack::Pop( obj ); |
198 } |
247 } |
199 } |
248 } |
200 |
249 |
201 if (attendees.Count() > 0 ) |
250 if ( fieldAttendeeCount > 0 ) |
202 { |
251 { |
203 if ( !iObserver->IsControlVisible(iFieldId ) ) |
252 if ( !iObserver->IsControlVisible(iFieldId ) ) |
204 { |
253 { |
205 iObserver->InsertControl(iFieldId ); |
254 iObserver->ShowControl( iFieldId ); |
206 } |
255 } |
207 iEditor->SetAddressesL( addressList ); |
256 iEditor->SetAddressesL( addressList ); |
208 } |
257 } |
209 else |
258 else |
210 { |
259 { |
242 { |
291 { |
243 mrEntry = static_cast<MESMRMeetingRequestEntry*>(&aEntry); |
292 mrEntry = static_cast<MESMRMeetingRequestEntry*>(&aEntry); |
244 } |
293 } |
245 |
294 |
246 // This should always be called for MR entries |
295 // This should always be called for MR entries |
247 __ASSERT_DEBUG( mrEntry, Panic(EESMRAttendeeFieldNotMeetingRequestEntry ) ); |
296 __ASSERT_ALWAYS( mrEntry, Panic( EESMRAttendeeFieldNotMeetingRequestEntry )); |
248 |
297 |
249 if(iEditor->HasDefaultText()) |
298 if( iEditor->HasDefaultText() ) |
250 { |
299 { |
251 ClearDefaultTextL(); |
300 ClearDefaultTextL(); |
252 } |
301 } |
253 |
302 |
254 // remove all previous attendees from the attendee list |
303 UpdateAttendeesL( *mrEntry ); |
255 CCalEntry& entry = mrEntry->Entry(); |
304 |
256 |
305 HBufC* text = iEditor->GetTextInHBufL(); |
257 if ( !iPhoneOwnerAddr ) |
|
258 { |
|
259 CCalUser* phoneOwner = entry.PhoneOwnerL(); |
|
260 if (phoneOwner) |
|
261 { |
|
262 iPhoneOwnerAddr = phoneOwner->Address().AllocL(); |
|
263 } |
|
264 } |
|
265 |
|
266 ClearAttendeeListL ( entry ); |
|
267 ParseAttendeesL ( *mrEntry ); |
|
268 |
|
269 HBufC *text = iEditor->GetTextInHBufL(); |
|
270 |
306 |
271 //If there is no added attendees put back the default text |
307 //If there is no attendees, put back the default text |
272 if(!text) |
308 if( !text ) |
273 { |
309 { |
274 AppendDefaultTextL(); |
310 AppendDefaultTextL(); |
275 //during initialisation, SelectAllL() in setoutlinefocus gets overridden so this is needed |
311 //during initialisation, SelectAllL() in setoutlinefocus gets overridden so this is needed |
276 iEditor->SelectAllL(); |
312 iEditor->SelectAllL(); |
277 } |
313 } |
278 delete text; |
314 delete text; |
279 } |
315 } |
280 |
316 |
281 // --------------------------------------------------------------------------- |
317 // --------------------------------------------------------------------------- |
282 // CESMRAttendeeField::ExpandedHeight |
|
283 // --------------------------------------------------------------------------- |
|
284 // |
|
285 TInt CESMRAttendeeField::ExpandedHeight( ) const |
|
286 { |
|
287 FUNC_LOG; |
|
288 return iTitleSize.iHeight + iExpandedSize.iHeight; |
|
289 } |
|
290 |
|
291 // --------------------------------------------------------------------------- |
|
292 // CESMRSubjectField::GetMinimumVisibleVerticalArea |
|
293 // --------------------------------------------------------------------------- |
|
294 // |
|
295 void CESMRAttendeeField::GetMinimumVisibleVerticalArea(TInt& aUpper, TInt& aLower) |
|
296 { |
|
297 FUNC_LOG; |
|
298 TRect rect; |
|
299 |
|
300 TRAPD( err, iEditor->GetLineRectL( rect ) ); |
|
301 |
|
302 if ( err == KErrNone ) |
|
303 { |
|
304 rect.Move( 0, iTitleSize.iHeight ); |
|
305 aUpper = rect.iTl.iY; |
|
306 aLower = rect.iBr.iY; |
|
307 } |
|
308 else |
|
309 { |
|
310 // This isn't expected to happen in any situation. |
|
311 // but if it does at least there will be no zero size |
|
312 CESMRField::GetMinimumVisibleVerticalArea( aUpper, aLower ); |
|
313 } |
|
314 } |
|
315 |
|
316 // --------------------------------------------------------------------------- |
|
317 // CESMRAttendeeField::CountComponentControls |
318 // CESMRAttendeeField::CountComponentControls |
318 // --------------------------------------------------------------------------- |
319 // --------------------------------------------------------------------------- |
319 // |
320 // |
320 TInt CESMRAttendeeField::CountComponentControls( ) const |
321 TInt CESMRAttendeeField::CountComponentControls( ) const |
321 { |
322 { |
322 FUNC_LOG; |
323 FUNC_LOG; |
323 TInt count = CESMRField::CountComponentControls ( ); |
324 TInt count( 0 ); |
324 |
325 if( iFieldButton ) |
|
326 { |
|
327 ++count; |
|
328 } |
|
329 |
325 if ( iTitle ) |
330 if ( iTitle ) |
326 { |
331 { |
327 ++count; |
332 ++count; |
328 } |
333 } |
329 |
334 |
|
335 if( iEditor ) |
|
336 { |
|
337 ++count; |
|
338 } |
|
339 |
330 return count; |
340 return count; |
331 } |
341 } |
332 |
342 |
333 // --------------------------------------------------------------------------- |
343 // --------------------------------------------------------------------------- |
334 // CESMRAttendeeField::ComponentControl |
344 // CESMRAttendeeField::ComponentControl |
335 // --------------------------------------------------------------------------- |
345 // --------------------------------------------------------------------------- |
336 // |
346 // |
337 CCoeControl* CESMRAttendeeField::ComponentControl( TInt aInd ) const |
347 CCoeControl* CESMRAttendeeField::ComponentControl( TInt aInd ) const |
338 { |
348 { |
339 FUNC_LOG; |
349 FUNC_LOG; |
340 if ( aInd == 0 ) |
350 switch ( aInd ) |
341 { |
351 { |
342 return iTitle; |
352 case 0: |
343 } |
353 return iFieldButton; |
344 return CESMRField::ComponentControl ( aInd ); |
354 case 1: |
|
355 return iTitle; |
|
356 case 2: |
|
357 return iEditor; |
|
358 default: |
|
359 return NULL; |
|
360 } |
345 } |
361 } |
346 |
362 |
347 // --------------------------------------------------------------------------- |
363 // --------------------------------------------------------------------------- |
348 // CESMRAttendeeField::SizeChanged |
364 // CESMRAttendeeField::SizeChanged |
349 // --------------------------------------------------------------------------- |
365 // --------------------------------------------------------------------------- |
350 // |
366 // |
351 void CESMRAttendeeField::SizeChanged( ) |
367 void CESMRAttendeeField::SizeChanged( ) |
352 { |
368 { |
353 FUNC_LOG; |
369 FUNC_LOG; |
354 TRect rect = Rect ( ); |
370 TRect rect( Rect() ); |
355 |
371 |
356 if ( CESMRLayoutManager::IsMirrored ( ) ) |
372 TAknLayoutRect firstRowLayoutRect( |
357 { |
373 NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 ) ); |
358 TPoint titlePos( rect.iBr.iX - iTitleSize.iWidth, rect.iTl.iY ); |
374 TRect firstRowRect( firstRowLayoutRect.Rect() ); |
359 iTitle->SetExtent ( titlePos, iTitleSize ); |
375 |
360 |
376 TRect secondRowRect( firstRowRect ); |
361 TSize textSize( rect.Width ( ) - ( KIconSize.iWidth + KIconBorderMargin ), |
377 secondRowRect.Move( 0, firstRowRect.Height() ); |
362 iExpandedSize.iHeight ); |
378 |
363 TPoint textPos( rect.iBr.iX - KIconSize.iWidth- textSize.iWidth, |
379 // Layout field button |
364 rect.iTl.iY + iTitleSize.iHeight ); |
380 if( iFieldButton ) |
365 iBorder->SetExtent ( textPos, textSize ); |
381 { |
366 } |
382 TAknWindowComponentLayout buttonLayout( |
367 else |
383 NMRLayoutManager::GetWindowComponentLayout( |
368 { |
384 NMRLayoutManager::EMRLayoutTextEditorIcon ) ); |
369 // title |
385 AknLayoutUtils::LayoutControl( |
370 iTitle->SetExtent ( rect.iTl, iTitleSize ); |
386 iFieldButton, firstRowRect, buttonLayout ); |
371 |
387 } |
372 // editor (editor is wrapped inside the 'iBorder' member) |
388 |
373 TRect borderRect(TPoint ( |
389 // Layout field title |
374 rect.iTl.iX + KIconSize.iWidth + KIconBorderMargin, |
390 if( iTitle ) |
375 rect.iTl.iY + iTitleSize.iHeight ), TSize ( |
391 { |
376 rect.Width ( )- KIconSize.iWidth + KIconBorderMargin - KFieldEndMargin, |
392 TAknLayoutText labelLayout( |
377 iExpandedSize.iHeight )); |
393 NMRLayoutManager::GetLayoutText( |
378 |
394 firstRowRect, |
379 iBorder->SetRect (borderRect ); |
395 NMRLayoutManager::EMRTextLayoutTextEditor ) ); |
380 } |
396 |
|
397 iTitle->SetRect( labelLayout.TextRect() ); |
|
398 |
|
399 // Setting font also for the label. Failures are ignored. |
|
400 iTitle->SetFont( labelLayout.Font() ); |
|
401 } |
|
402 |
|
403 // Layout field editor |
|
404 if( iEditor ) |
|
405 { |
|
406 TAknLayoutText editorLayoutText = NMRLayoutManager::GetLayoutText( |
|
407 secondRowRect, |
|
408 NMRLayoutManager::EMRTextLayoutTextEditor ); |
|
409 |
|
410 TRect editorRect = editorLayoutText.TextRect(); |
|
411 |
|
412 // Resize height according to actual height required by edwin. |
|
413 editorRect.Resize( 0, iSize.iHeight - editorRect.Height() ); |
|
414 |
|
415 iEditor->SetRect( editorRect ); |
|
416 |
|
417 // Try setting font. Failures are ignored. |
|
418 TRAP_IGNORE( iEditor->SetFontL( editorLayoutText.Font() ) ); |
|
419 } |
|
420 |
|
421 // Layout field focus |
|
422 if( iEditor ) |
|
423 { |
|
424 // Layouting focus for rich text editor area |
|
425 TRect bgRect( iEditor->Rect() ); |
|
426 |
|
427 // Move focus rect so that it's relative to field's position. |
|
428 bgRect.Move( -Position() ); |
|
429 SetFocusRect( bgRect ); |
|
430 } |
381 |
431 |
382 if ( iAacListBox && iAacListBox->IsVisible ( ) ) |
432 if ( iAacListBox && iAacListBox->IsVisible ( ) ) |
383 { |
433 { |
384 TRAPD( error, iAacListBox->SetPopupMaxRectL( ResolvePopupRectL()) ) |
434 TRAPD( error, iAacListBox->SetPopupMaxRectL( ResolvePopupRectL()) ) |
385 if ( error ) |
435 if ( error ) |
386 { |
436 { |
387 CEikonEnv::Static()->// codescanner::eikonenvstatic |
437 iCoeEnv->HandleError( error ); |
388 HandleError( error ); |
438 } |
389 } |
|
390 } |
|
391 |
|
392 if( iFrameBgContext ) |
|
393 { |
|
394 TRect visibleRect = CalculateVisibleRect( iEditor->Rect() ); |
|
395 iFrameBgContext->SetFrameRects( visibleRect, visibleRect ); |
|
396 } |
|
397 } |
|
398 |
|
399 // --------------------------------------------------------------------------- |
|
400 // CESMRAttendeeField::PositionChanged |
|
401 // --------------------------------------------------------------------------- |
|
402 // |
|
403 void CESMRAttendeeField::PositionChanged( ) |
|
404 { |
|
405 FUNC_LOG; |
|
406 if ( iAacListBox && iAacListBox->IsVisible ( ) ) |
|
407 { |
|
408 TRAPD( error, iAacListBox->SetPopupMaxRectL( ResolvePopupRectL()) ) |
|
409 if ( error ) |
|
410 { |
|
411 CEikonEnv::Static()->// codescanner::eikonenvstatic |
|
412 HandleError( error ); |
|
413 } |
|
414 } |
|
415 |
|
416 if( iFrameBgContext ) |
|
417 { |
|
418 TRect visibleRect = CalculateVisibleRect( iEditor->Rect() ); |
|
419 iFrameBgContext->SetFrameRects( visibleRect, visibleRect ); |
|
420 } |
439 } |
421 } |
440 } |
422 |
441 |
423 // ----------------------------------------------------------------------------- |
442 // ----------------------------------------------------------------------------- |
424 // CESMRAttendeeField::ResolvePopupRectL |
443 // CESMRAttendeeField::ResolvePopupRectL |
427 TRect CESMRAttendeeField::ResolvePopupRectL( ) |
446 TRect CESMRAttendeeField::ResolvePopupRectL( ) |
428 { |
447 { |
429 FUNC_LOG; |
448 FUNC_LOG; |
430 if ( !iAacListBox ) |
449 if ( !iAacListBox ) |
431 { |
450 { |
432 return TRect(0,0,0,0); |
451 return TRect( 0, 0, 0, 0 ); |
433 } |
452 } |
434 |
453 |
435 TRect popupRect = iBorder->Rect(); |
454 TRect popupRect( 0, 0, 0, 0 ); |
436 TRect lineRect; |
455 |
437 iEditor->GetLineRectL( lineRect ); |
456 // Let's determine Popup's maximum height |
438 lineRect.Move( 0, popupRect.iTl.iY ); |
457 TInt requiredPopupHeight = iAacListBox->CalcHeightBasedOnNumOfItems( |
439 TRect parentRect = Parent()->Rect(); |
458 iAacListBox->Model()->NumberOfItems() ); |
440 |
459 TInt numberOfItemsInPopUp = iAacListBox->Model()->NumberOfItems(); |
441 TInt listBoxBorderHeight = iAacListBox->CalcHeightBasedOnNumOfItems( 0 ); |
460 |
442 TInt listBoxItemHeight = iAacListBox->CalcHeightBasedOnNumOfItems( 1 ) |
461 if( numberOfItemsInPopUp > KMaxAmountOfItems ) |
443 - listBoxBorderHeight; |
462 { |
444 |
463 // reducing popup item count shown at once to maximum value |
445 if ( lineRect.iTl.iY > ( parentRect.Height() >> 1 ) ) |
464 requiredPopupHeight = iAacListBox->CalcHeightBasedOnNumOfItems( |
446 { |
465 KMaxAmountOfItems ); |
447 // Draw popup list on top of cursor |
466 } |
448 popupRect.iTl.iY = parentRect.iTl.iY; |
467 |
449 popupRect.iBr.iY = lineRect.iTl.iY; |
468 // Popup x-coords are always the same |
450 |
469 TInt topLeftX = iEditor->Rect().iTl.iX; |
451 TInt diff = popupRect.Height() % listBoxItemHeight; |
470 TInt bottomRightX = iEditor->Rect().iBr.iX; |
452 popupRect.iTl.iY += diff - listBoxBorderHeight; |
471 |
453 } |
472 // Popup y-coords need to be calculated |
|
473 TInt topLeftY( 0 ); |
|
474 TInt bottomRightY( 0 ); |
|
475 |
|
476 // Next we have to resolve if popup needs to be drawn below or |
|
477 // above the cursor (space requirement) |
|
478 |
|
479 TRect editorLineRect; |
|
480 iEditor->GetLineRectL( editorLineRect ); |
|
481 TInt editorLineTopLeftY = editorLineRect.iTl.iY; |
|
482 TInt diff = iEditor->Rect().iTl.iY; |
|
483 TInt editorLineTopLeftYRelativeToParent = editorLineTopLeftY + diff; |
|
484 |
|
485 TInt listPaneHeight = Parent()->Rect().Height(); |
|
486 |
|
487 // Popup will be drawn above the cursor |
|
488 if( editorLineTopLeftYRelativeToParent > TReal( listPaneHeight / 2 ) ) |
|
489 { |
|
490 topLeftY = editorLineTopLeftYRelativeToParent - requiredPopupHeight; |
|
491 bottomRightY = editorLineTopLeftYRelativeToParent; |
|
492 } |
|
493 // Popup will be drawn below the cursor |
454 else |
494 else |
455 { |
495 { |
456 // Draw popup list below cursor |
496 topLeftY = editorLineTopLeftYRelativeToParent + iEditor->GetLineHeightL(); |
457 popupRect.iTl.iY = lineRect.iBr.iY; |
497 bottomRightY = topLeftY + requiredPopupHeight; |
458 popupRect.iBr.iY = parentRect.iBr.iY; |
498 } |
459 |
499 |
460 TInt diff = popupRect.Height() % listBoxItemHeight; |
500 popupRect.SetRect( topLeftX, topLeftY, bottomRightX, bottomRightY ); |
461 popupRect.iBr.iY -= diff - listBoxBorderHeight; |
501 |
462 } |
|
463 |
|
464 return popupRect; |
502 return popupRect; |
465 } |
503 } |
466 |
504 |
467 // ----------------------------------------------------------------------------- |
505 // ----------------------------------------------------------------------------- |
468 // CNcsAddressInputField:::AppendDefaultTextL() |
506 // CNcsAddressInputField:::AppendDefaultTextL() |
534 { |
572 { |
535 ret = iEditor->OfferKeyEventL (aKeyEvent, aType ); |
573 ret = iEditor->OfferKeyEventL (aKeyEvent, aType ); |
536 UpdateSendOptionL(); |
574 UpdateSendOptionL(); |
537 } |
575 } |
538 |
576 |
539 // Scroll editor. |
577 // Scroll editor visible, if for example cursor is out of the |
|
578 // viewable area when user enters more text. |
540 if ( iObserver && aType == EEventKey ) |
579 if ( iObserver && aType == EEventKey ) |
541 { |
580 { |
542 CTextLayout* textLayout = iEditor->TextLayout(); |
581 CTextLayout* textLayout = iEditor->TextLayout(); |
543 TInt lineHeight = iEditor->GetLineHeightL(); |
582 TInt lineHeight = iEditor->GetLineHeightL(); |
544 |
583 |
545 TPoint cursorPos( 0,0 ); |
584 TPoint cursorPos( 0,0 ); |
546 textLayout->DocPosToXyPosL( iEditor->CursorPos(), cursorPos ); |
585 textLayout->DocPosToXyPosL( iEditor->CursorPos(), cursorPos ); |
547 |
586 |
548 TInt editorTlY = iEditor->Position().iY; |
587 TInt editorTlY = iEditor->Position().iY; |
549 TInt listHeight = iObserver->ListHeight(); |
588 TInt listHeight = iObserver->ViewableAreaRect().Height(); |
550 |
589 |
551 TInt cursorTopY = cursorPos.iY - lineHeight + editorTlY; |
590 TInt cursorTopY = cursorPos.iY - lineHeight + editorTlY; |
552 TInt cursorBottomY = cursorPos.iY + lineHeight + editorTlY; |
591 TInt cursorBottomY = cursorPos.iY + lineHeight + editorTlY; |
553 |
592 |
554 // If cursor is below visible area |
593 // If cursor is below visible area |
555 if ( cursorBottomY > listHeight ) |
594 if ( cursorBottomY > listHeight ) |
556 { |
595 { |
557 iObserver->MoveListAreaUpL( cursorBottomY - listHeight ); |
596 iObserver->RePositionFields( -( cursorBottomY - listHeight ) ); |
558 } |
597 } |
559 // If cursor is over the top of visible area |
598 // If cursor is over the top of visible area |
560 else if ( cursorTopY < 0 ) |
599 else if ( cursorTopY < 0 ) |
561 { |
600 { |
562 iObserver->MoveListAreaDownL( -cursorTopY ); |
601 iObserver->RePositionFields( -cursorTopY ); |
563 } |
602 } |
564 // Latch on top of the screen |
603 } |
565 else if ( textLayout->GetLineNumber( iEditor->CursorPos() ) < 2 ) |
604 |
566 { |
605 return ret; |
567 iObserver->MoveListAreaDownL( iTitleSize.iHeight ); |
606 } |
568 } |
607 |
|
608 // --------------------------------------------------------------------------- |
|
609 // CESMRAttendeeField::SetContainerWindowL() |
|
610 // --------------------------------------------------------------------------- |
|
611 // |
|
612 void CESMRAttendeeField::SetContainerWindowL( const CCoeControl& aControl ) |
|
613 { |
|
614 FUNC_LOG; |
|
615 CCoeControl::SetContainerWindowL( aControl ); |
|
616 |
|
617 iFieldButton->SetContainerWindowL( aControl ); |
|
618 iFieldButton->SetParent( this ); |
|
619 |
|
620 iTitle->SetContainerWindowL( aControl ); |
|
621 iTitle->SetParent( this ); |
|
622 |
|
623 iEditor->SetContainerWindowL( aControl ); |
|
624 iEditor->SetParent( this ); |
569 |
625 |
570 } |
|
571 return ret; |
|
572 } |
|
573 |
|
574 // --------------------------------------------------------------------------- |
|
575 // CESMRAttendeeField::SetContainerWindowL() |
|
576 // --------------------------------------------------------------------------- |
|
577 // |
|
578 void CESMRAttendeeField::SetContainerWindowL( const CCoeControl& aControl ) |
|
579 { |
|
580 FUNC_LOG; |
|
581 CESMRField::SetContainerWindowL ( aControl ); |
|
582 |
|
583 iEditor->ConstructL ( |
|
584 this, |
|
585 KMaxAddressFieldLines, |
|
586 0, |
|
587 CEikEdwin::EAvkonEditor | CEikEdwin::EResizable | |
|
588 CEikEdwin::ENoAutoSelection |CEikEdwin::EInclusiveSizeFixed | |
|
589 CEikEdwin::ENoHorizScrolling |
|
590 ); |
|
591 |
|
592 iAacListBox = CESMRNcsPopupListBox::NewL ( this, *iContactHandler ); |
626 iAacListBox = CESMRNcsPopupListBox::NewL ( this, *iContactHandler ); |
593 iAacListBox->MakeVisible ( EFalse ); |
627 iAacListBox->MakeVisible ( EFalse ); |
|
628 iAacListBox->SetListBoxObserver( this ); |
594 iAacListBox->SetObserver( this ); |
629 iAacListBox->SetObserver( this ); |
595 iAacListBox->ActivateL(); |
630 iAacListBox->ActivateL(); |
|
631 |
596 iButtonGroupContainer = CEikButtonGroupContainer::Current(); |
632 iButtonGroupContainer = CEikButtonGroupContainer::Current(); |
597 |
633 } |
598 } |
|
599 |
|
600 // --------------------------------------------------------------------------- |
|
601 // CESMRAttendeeField::ActivateL |
|
602 // --------------------------------------------------------------------------- |
|
603 // |
|
604 void CESMRAttendeeField::ActivateL() |
|
605 { |
|
606 CCoeControl::ActivateL(); |
|
607 |
|
608 TRect editorRect = iEditor->Rect(); |
|
609 |
|
610 delete iFrameBgContext; |
|
611 iFrameBgContext = NULL; |
|
612 iFrameBgContext = CAknsFrameBackgroundControlContext::NewL( KAknsIIDQsnFrInput, editorRect, editorRect, EFalse ) ; |
|
613 |
|
614 iFrameBgContext->SetParentContext( iBackground ); |
|
615 iEditor->SetSkinBackgroundControlContextL( iFrameBgContext ); |
|
616 } |
|
617 |
634 |
618 // --------------------------------------------------------------------------- |
635 // --------------------------------------------------------------------------- |
619 // CESMRAttendeeField::HandleEdwinSizeEventL |
636 // CESMRAttendeeField::HandleEdwinSizeEventL |
620 // --------------------------------------------------------------------------- |
637 // --------------------------------------------------------------------------- |
621 // |
638 // |
622 TBool CESMRAttendeeField::HandleEdwinSizeEventL(CEikEdwin* /*aEdwin*/, |
639 TBool CESMRAttendeeField::HandleEdwinSizeEventL( CEikEdwin* aEdwin, |
623 TEdwinSizeEvent /*aType*/, TSize aSize ) |
640 TEdwinSizeEvent /*aType*/, TSize aSize ) |
624 { |
641 { |
625 FUNC_LOG; |
642 FUNC_LOG; |
626 iExpandedSize = aSize; |
643 TBool reDraw( EFalse ); |
627 if ( iObserver ) |
644 |
628 { |
645 if( iSize != aSize ) |
629 iObserver->ControlSizeChanged ( this ); |
646 { |
630 } |
647 // Let's save the required size for the iEditor |
631 |
648 iSize = aSize; |
632 if ( iFrameBgContext ) |
649 |
633 { |
650 if ( iObserver && aEdwin == iEditor ) |
634 TRect visibleRect = CalculateVisibleRect( iEditor->Rect() ); |
651 { |
635 iFrameBgContext->SetFrameRects( visibleRect, visibleRect ); |
652 iObserver->ControlSizeChanged ( this ); |
636 } |
653 reDraw = ETrue; |
637 |
654 } |
638 return ETrue; |
655 } |
|
656 |
|
657 return reDraw; |
639 } |
658 } |
640 |
659 |
641 // --------------------------------------------------------------------------- |
660 // --------------------------------------------------------------------------- |
642 // CESMRAttendeeField::UpdatePopupContactListL |
661 // CESMRAttendeeField::UpdatePopupContactListL |
643 // --------------------------------------------------------------------------- |
662 // --------------------------------------------------------------------------- |
660 { |
680 { |
661 iAacListBox->SetSearchTextL( aMatchString ); |
681 iAacListBox->SetSearchTextL( aMatchString ); |
662 } |
682 } |
663 else |
683 else |
664 { |
684 { |
665 iAacListBox->InitAndSearchL ( aMatchString ); |
685 iAacListBox->InitAndSearchL( aMatchString ); |
666 } |
686 } |
667 } |
687 } |
668 } |
688 } |
669 |
689 |
670 // --------------------------------------------------------------------------- |
690 // --------------------------------------------------------------------------- |
671 // CESMRHeaderContainer:ShowPopupCbaL |
691 // CESMRAttendeeField::ShowPopupCbaL |
672 // --------------------------------------------------------------------------- |
692 // --------------------------------------------------------------------------- |
673 // |
693 // |
674 void CESMRAttendeeField::ShowPopupCbaL( TBool aShow ) |
694 void CESMRAttendeeField::ShowPopupCbaL( TBool aShow ) |
675 { |
695 { |
676 if( aShow ) |
696 if( aShow ) |
677 { |
697 { |
678 iButtonGroupContainer->SetCommandSetL( |
698 iButtonGroupContainer->SetCommandSetL( |
679 R_CONTACT_POPUP_SOFTKEYS_SELECT_CANCEL); |
699 R_CONTACT_POPUP_SOFTKEYS_SELECT_CANCEL); |
680 } |
700 } |
681 else |
701 else |
682 { |
702 { |
683 iButtonGroupContainer->SetCommandSetL( |
703 iButtonGroupContainer->SetCommandSetL( |
684 R_CONTACT_EDITOR_SOFTKEYS_OPTIONS_DONE__ADD); |
704 R_CONTACT_EDITOR_SOFTKEYS_OPTIONS_DONE__ADD); |
685 } |
705 } |
686 iButtonGroupContainer->DrawDeferred(); |
706 |
687 } |
707 iButtonGroupContainer->DrawDeferred(); |
688 |
708 } |
689 // --------------------------------------------------------------------------- |
709 |
690 // CESMRHeaderContainer:ExecuteGenericCommandL |
710 // --------------------------------------------------------------------------- |
691 // --------------------------------------------------------------------------- |
711 // CESMRAttendeeField::ExecuteGenericCommandL |
692 // |
712 // --------------------------------------------------------------------------- |
693 void CESMRAttendeeField::ExecuteGenericCommandL( TInt aCommand ) |
713 // |
694 { |
714 TBool CESMRAttendeeField::ExecuteGenericCommandL( TInt aCommand ) |
695 FUNC_LOG; |
715 { |
|
716 FUNC_LOG; |
|
717 TBool isUsed( EFalse ); |
696 switch ( aCommand ) |
718 switch ( aCommand ) |
697 { |
719 { |
698 case EESMRCmdAttendeeInsertContact: |
720 case EESMRCmdAttendeeInsertContact: |
699 { |
721 { |
|
722 HandleTactileFeedbackL(); |
700 iContactHandler->GetAddressesFromPhonebookL( this ); |
723 iContactHandler->GetAddressesFromPhonebookL( this ); |
701 } |
724 isUsed = ETrue; |
702 break; |
725 break; |
|
726 } |
703 case EESMRCmdAttendeeSoftkeySelect: |
727 case EESMRCmdAttendeeSoftkeySelect: |
704 { |
728 { |
705 DoPopupSelectL(); |
729 DoPopupSelectL(); |
|
730 isUsed = ETrue; |
|
731 break; |
706 } |
732 } |
707 break; |
|
708 case EESMRCmdAttendeeSoftkeyCancel: |
733 case EESMRCmdAttendeeSoftkeyCancel: |
709 { |
734 { |
710 ClosePopupContactListL(); |
735 ClosePopupContactListL(); |
|
736 isUsed = ETrue; |
|
737 break; |
711 } |
738 } |
|
739 case EESMRCmdLongtapDetected: |
|
740 { |
|
741 if(iEditor->IsFocused()) |
|
742 NotifyEventL(EESMRCmdLongtapDetected); |
|
743 isUsed = ETrue; |
|
744 |
|
745 HandleTactileFeedbackL(); |
712 break; |
746 break; |
|
747 } |
713 default: |
748 default: |
714 break; |
749 break; |
715 } |
750 } |
716 } |
751 return isUsed; |
717 |
752 } |
718 // --------------------------------------------------------------------------- |
753 |
719 // CESMRBooleanField::SetOutlineFocusL |
754 // --------------------------------------------------------------------------- |
|
755 // CESMRAttendeeField::SetOutlineFocusL |
720 // --------------------------------------------------------------------------- |
756 // --------------------------------------------------------------------------- |
721 // |
757 // |
722 void CESMRAttendeeField::SetOutlineFocusL( TBool aFocus ) |
758 void CESMRAttendeeField::SetOutlineFocusL( TBool aFocus ) |
723 { |
759 { |
724 FUNC_LOG; |
760 FUNC_LOG; |
725 CESMRField::SetOutlineFocusL( aFocus ); |
761 CESMRField::SetOutlineFocusL( aFocus ); |
726 |
762 |
|
763 |
727 if (aFocus) //Focus is gained on the field |
764 if (aFocus) //Focus is gained on the field |
728 { |
765 { |
729 if ( iEditor->HasDefaultText() ) |
766 if ( iEditor->HasDefaultText() ) |
730 { |
767 { |
731 iEditor->SelectAllL(); |
768 iEditor->SelectAllL(); |
743 const RPointerArray<CESMRClsItem>* aContacts ) |
780 const RPointerArray<CESMRClsItem>* aContacts ) |
744 { |
781 { |
745 FUNC_LOG; |
782 FUNC_LOG; |
746 if ( aContacts ) |
783 if ( aContacts ) |
747 { |
784 { |
748 RPointerArray<CESMRNcsEmailAddressObject> ncsObjects; // codescanner::resourcenotoncleanupstack |
785 if( aContacts->Count() > 0 ) |
749 TCleanupItem arrayCleanup( RPointerArrayResetAndDestroy, &ncsObjects ); |
786 { |
750 CleanupStack::PushL( arrayCleanup ); |
787 RCPointerArray<CESMRNcsEmailAddressObject> ncsObjects; // codescanner::resourcenotoncleanupstack |
751 for ( int i = 0; i < aContacts->Count(); i++ ) |
788 CleanupClosePushL( ncsObjects ); |
752 { |
789 for ( int i = 0; i < aContacts->Count(); i++ ) |
753 CESMRNcsEmailAddressObject* object = |
790 { |
754 CESMRNcsEmailAddressObject::NewL( |
791 CESMRNcsEmailAddressObject* object = |
755 (*aContacts)[i]->DisplayName(), |
792 CESMRNcsEmailAddressObject::NewL( |
756 (*aContacts)[i]->EmailAddress() ); |
793 ( *aContacts )[i]->DisplayName(), |
757 object->SetDisplayFull( (*aContacts)[i]->MultipleEmails() ); |
794 ( *aContacts )[i]->EmailAddress() ); |
758 ncsObjects.Append( object ); |
795 object->SetDisplayFull( ( *aContacts)[i]->MultipleEmails() ); |
759 } |
796 ncsObjects.Append( object ); |
760 |
797 } |
761 iEditor->AppendAddressesL(ncsObjects); |
798 |
762 CleanupStack::PopAndDestroy( &ncsObjects ); |
799 iEditor->AppendAddressesL( ncsObjects ); |
763 UpdateSendOptionL(); |
800 CleanupStack::PopAndDestroy( &ncsObjects ); |
|
801 UpdateSendOptionL(); |
|
802 } |
764 } |
803 } |
765 } |
804 } |
766 |
805 |
767 // --------------------------------------------------------------------------- |
806 // --------------------------------------------------------------------------- |
768 // CESMRAttendeeField::OperationError |
807 // CESMRAttendeeField::OperationError |
790 { |
829 { |
791 if ( iAacListBox && iAacListBox->IsVisible() && iAacListBox->IsPopupEmpty() ) |
830 if ( iAacListBox && iAacListBox->IsVisible() && iAacListBox->IsPopupEmpty() ) |
792 { |
831 { |
793 ClosePopupContactListL(); |
832 ClosePopupContactListL(); |
794 } |
833 } |
795 else if ( iAacListBox && !iAacListBox->IsVisible() && !iAacListBox->IsPopupEmpty() ) |
834 else if ( iAacListBox && !iAacListBox->IsPopupEmpty() ) |
796 { |
835 { |
797 iAacListBox->SetPopupMaxRectL( ResolvePopupRectL() ); |
836 iAacListBox->SetPopupMaxRectL( ResolvePopupRectL() ); |
798 iAacListBox->MakeVisible ( ETrue ); |
837 iAacListBox->MakeVisible ( ETrue ); |
799 ShowPopupCbaL( ETrue ); |
838 ShowPopupCbaL( ETrue ); |
800 } |
839 } |
801 else |
840 else |
802 { |
841 { |
803 UpdateSendOptionL(); |
842 UpdateSendOptionL(); |
804 } |
843 } |
805 } |
844 } |
806 } |
845 } |
807 |
|
808 // --------------------------------------------------------------------------- |
|
809 // CESMRAttendeeField::ClearAttendeeListL |
|
810 // --------------------------------------------------------------------------- |
|
811 // |
|
812 void CESMRAttendeeField::ClearAttendeeListL( CCalEntry& aEntry ) |
|
813 { |
|
814 FUNC_LOG; |
|
815 RPointerArray< CCalAttendee > & att = aEntry.AttendeesL( ); |
|
816 for (TInt i(0); i < att.Count( ); ) |
|
817 { |
|
818 // if there is an attendee with this fields role, remove it |
|
819 if ( att[i]->RoleL( )== iRole ) |
|
820 { |
|
821 aEntry.DeleteAttendeeL( i ); |
|
822 } |
|
823 else |
|
824 { |
|
825 ++i; |
|
826 } |
|
827 } |
|
828 } |
|
829 |
|
830 // --------------------------------------------------------------------------- |
|
831 // CESMRAttendeeField::ParseAttendeesL |
|
832 // --------------------------------------------------------------------------- |
|
833 // |
|
834 void CESMRAttendeeField::ParseAttendeesL( |
|
835 MESMRMeetingRequestEntry& aMREntry ) |
|
836 { |
|
837 FUNC_LOG; |
|
838 iEditor->CheckAddressWhenFocusLostL ( ); |
|
839 |
|
840 RPointerArray<CESMRNcsEmailAddressObject> attendees = iEditor->GetAddressesL ( ); |
|
841 CCalEntry& entry( aMREntry.Entry() ); |
|
842 TInt count = attendees.Count ( ); |
|
843 |
|
844 for (TInt i=0; i<count; i++ ) |
|
845 { |
|
846 CESMRNcsEmailAddressObject* obj = attendees[i]; |
|
847 CCalAttendee* attendee = CCalAttendee::NewL ( obj->EmailAddress ( ) ); |
|
848 attendee->SetRoleL ( iRole ); |
|
849 attendee->SetCommonNameL ( obj->DisplayName ( ) ); |
|
850 |
|
851 if ( EESMRRoleOrganizer == aMREntry.RoleL() || |
|
852 aMREntry.IsForwardedL() ) |
|
853 { |
|
854 attendee->SetResponseRequested( ETrue ); |
|
855 } |
|
856 |
|
857 entry.AddAttendeeL ( attendee ); |
|
858 if (iPhoneOwnerAddr && attendee->Address().CompareF(*iPhoneOwnerAddr) == 0) |
|
859 { |
|
860 entry.SetPhoneOwnerL(static_cast<CCalUser*>(attendee)); |
|
861 } |
|
862 } |
|
863 |
|
864 } |
|
865 |
846 |
866 // ----------------------------------------------------------------------------- |
847 // ----------------------------------------------------------------------------- |
867 // CESMRHeaderContainer::DoPopupSelect |
848 // CESMRAttendeeField::DoPopupSelect |
868 // ----------------------------------------------------------------------------- |
849 // ----------------------------------------------------------------------------- |
869 // |
850 // |
870 void CESMRAttendeeField::DoPopupSelectL() |
851 void CESMRAttendeeField::DoPopupSelectL() |
871 { |
852 { |
872 FUNC_LOG; |
853 FUNC_LOG; |
1015 } |
1008 } |
1016 |
1009 |
1017 NotifyEventL( command ); |
1010 NotifyEventL( command ); |
1018 } |
1011 } |
1019 |
1012 |
|
1013 // --------------------------------------------------------------------------- |
|
1014 // CESMRAttendeeField::HandleListBoxEventL |
|
1015 // --------------------------------------------------------------------------- |
|
1016 // |
|
1017 void CESMRAttendeeField::HandleListBoxEventL( CEikListBox* aListBox, |
|
1018 TListBoxEvent aEventType ) |
|
1019 { |
|
1020 if( aEventType == EEventEnterKeyPressed || aEventType == EEventItemClicked |
|
1021 || aEventType == EEventItemDoubleClicked || aEventType == EEventItemSingleClicked ) |
|
1022 { |
|
1023 TInt newIndex = aListBox->CurrentItemIndex(); |
|
1024 |
|
1025 // if item is already highlighted and then clicked, |
|
1026 // it is considered that it has been selected |
|
1027 if( newIndex == iPreviousIndex ) |
|
1028 { |
|
1029 HandleTactileFeedbackL(); |
|
1030 DoPopupSelectL(); |
|
1031 |
|
1032 // Item selected, index reseted |
|
1033 iPreviousIndex = 0; |
|
1034 } |
|
1035 else |
|
1036 { |
|
1037 iPreviousIndex = newIndex; |
|
1038 } |
|
1039 } |
|
1040 } |
|
1041 |
|
1042 // ----------------------------------------------------------------------------- |
|
1043 // CESMRAttendeeField::GetCursorLineVerticalPos |
|
1044 // ----------------------------------------------------------------------------- |
|
1045 // |
|
1046 void CESMRAttendeeField::GetCursorLineVerticalPos( |
|
1047 TInt& aUpper, TInt& aLower) |
|
1048 { |
|
1049 FUNC_LOG; |
|
1050 TRect rect; |
|
1051 |
|
1052 TRAPD( err, iEditor->GetLineRectL( rect ) ); |
|
1053 |
|
1054 if ( err == KErrNone ) |
|
1055 { |
|
1056 rect.Move( 0, iFieldButton->Rect().Size().iHeight ); |
|
1057 aUpper = rect.iTl.iY; |
|
1058 aLower = rect.iBr.iY; |
|
1059 } |
|
1060 else |
|
1061 { |
|
1062 // This isn't expected to happen in any situation. |
|
1063 // but if it does at least there will be no zero size |
|
1064 CESMRField::GetCursorLineVerticalPos( aUpper, aLower ); |
|
1065 } |
|
1066 } |
|
1067 |
|
1068 // --------------------------------------------------------------------------- |
|
1069 // CESMRAttendeeField::HandleSingletapEventL |
|
1070 // --------------------------------------------------------------------------- |
|
1071 // |
|
1072 TBool CESMRAttendeeField::HandleSingletapEventL( const TPoint& aPosition ) |
|
1073 { |
|
1074 FUNC_LOG; |
|
1075 TBool ret( EFalse ); |
|
1076 |
|
1077 if( iTitle->Rect().Contains( aPosition ) || |
|
1078 iFieldButton->Rect().Contains( aPosition ) ) |
|
1079 { |
|
1080 iContactHandler->GetAddressesFromPhonebookL( this ); |
|
1081 ret = ETrue; |
|
1082 |
|
1083 HandleTactileFeedbackL(); |
|
1084 } |
|
1085 |
|
1086 return ret; |
|
1087 } |
|
1088 |
|
1089 // --------------------------------------------------------------------------- |
|
1090 // CESMRAttendeeField::HandleLongtapEventL |
|
1091 // --------------------------------------------------------------------------- |
|
1092 // |
|
1093 void CESMRAttendeeField::HandleLongtapEventL( const TPoint& aPosition ) |
|
1094 { |
|
1095 FUNC_LOG; |
|
1096 |
|
1097 if( iTitle->Rect().Contains( aPosition ) || |
|
1098 iFieldButton->Rect().Contains( aPosition ) ) |
|
1099 { |
|
1100 NotifyEventL( EAknSoftkeyContextOptions ); |
|
1101 HandleTactileFeedbackL(); |
|
1102 } |
|
1103 } |
|
1104 |
|
1105 // --------------------------------------------------------------------------- |
|
1106 // CESMRAttendeeField::UpdateAttendeesL |
|
1107 // --------------------------------------------------------------------------- |
|
1108 // |
|
1109 void CESMRAttendeeField::UpdateAttendeesL( MESMRMeetingRequestEntry& aMREntry ) |
|
1110 { |
|
1111 FUNC_LOG; |
|
1112 /* |
|
1113 * Compare editor attendees to existing attendees and add / remove |
|
1114 * when necessary. |
|
1115 */ |
|
1116 iEditor->CheckAddressWhenFocusLostL(); |
|
1117 |
|
1118 CCalEntry& entry( aMREntry.Entry() ); |
|
1119 |
|
1120 // Get editor's attendees |
|
1121 RPointerArray<CESMRNcsEmailAddressObject> editorAttendees = |
|
1122 iEditor->GetAddressesL(); |
|
1123 TInt editorAttendeesCount( editorAttendees.Count() ); |
|
1124 |
|
1125 // Get existing attendees |
|
1126 RPointerArray<CCalAttendee>& existingAttendees = entry.AttendeesL(); |
|
1127 TInt existingAttendeesCount( existingAttendees.Count() ); |
|
1128 |
|
1129 // Remove removed attendees from entry |
|
1130 for( TInt i( existingAttendeesCount - 1 ); i >= 0 ; --i ) |
|
1131 { |
|
1132 // existing address and role |
|
1133 const TDesC& address = existingAttendees[i]->Address(); |
|
1134 CCalAttendee::TCalRole role = existingAttendees[i]->RoleL(); |
|
1135 |
|
1136 // Let's try to find them amongst editor attendees |
|
1137 TBool matchFound( EFalse ); |
|
1138 for( TInt j( 0 ); j < editorAttendeesCount ; ++j ) |
|
1139 { |
|
1140 // if address match is found ... |
|
1141 if( editorAttendees[j]->EmailAddress().Compare( address ) == 0 ) |
|
1142 { |
|
1143 // ... And roles match also |
|
1144 if( role == iRole ) |
|
1145 { |
|
1146 // This attendee is left to the entry |
|
1147 matchFound = ETrue; |
|
1148 break; |
|
1149 } |
|
1150 } |
|
1151 } |
|
1152 if( !matchFound ) |
|
1153 { |
|
1154 // Existing attendee not found from editor -> Let's delete that |
|
1155 // from entry if roles match |
|
1156 if ( existingAttendees[i]->RoleL( )== iRole ) |
|
1157 { |
|
1158 entry.DeleteAttendeeL( i ); |
|
1159 } |
|
1160 } |
|
1161 } |
|
1162 |
|
1163 // Update existing attendees count, because some attendees might |
|
1164 // have been removed |
|
1165 existingAttendees.Reset(); |
|
1166 existingAttendees = entry.AttendeesL(); |
|
1167 existingAttendeesCount = existingAttendees.Count(); |
|
1168 |
|
1169 // Add new attendees to entry |
|
1170 for( TInt i( 0 ); i < editorAttendeesCount ; ++i ) |
|
1171 { |
|
1172 CESMRNcsEmailAddressObject* obj = editorAttendees[i]; |
|
1173 CCalAttendee* attendee = CCalAttendee::NewL( obj->EmailAddress() ); |
|
1174 attendee->SetRoleL( iRole ); |
|
1175 attendee->SetCommonNameL( obj->DisplayName() ); |
|
1176 |
|
1177 if ( EESMRRoleOrganizer == aMREntry.RoleL() || |
|
1178 aMREntry.IsForwardedL() ) |
|
1179 { |
|
1180 attendee->SetResponseRequested( ETrue ); |
|
1181 } |
|
1182 |
|
1183 TBool isNewAttendee( ETrue ); |
|
1184 for( TInt i( 0 ); i < existingAttendeesCount; ++i ) |
|
1185 { |
|
1186 if( existingAttendees[i]->Address().Compare( attendee->Address() ) == 0 ) |
|
1187 { |
|
1188 if( existingAttendees[i]->RoleL() == iRole ) |
|
1189 { |
|
1190 // Match found, this is not a new attendee |
|
1191 isNewAttendee = EFalse; |
|
1192 break; |
|
1193 } |
|
1194 } |
|
1195 } |
|
1196 // If this is new attendee, let's add it to entry |
|
1197 if( isNewAttendee ) |
|
1198 { |
|
1199 entry.AddAttendeeL( attendee ); |
|
1200 } |
|
1201 } |
|
1202 } |
|
1203 |
|
1204 |
1020 //EOF |
1205 //EOF |
1021 |
1206 |