64
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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: ESMR titled field implementation
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
#include "cesmrattendeefield.h"
|
|
18 |
//<cmail>
|
|
19 |
#include "esmrcommands.h"
|
|
20 |
#include "cfsmailclient.h"
|
|
21 |
//</cmail>
|
|
22 |
#include "cesmrncspopuplistbox.h"
|
|
23 |
#include "cesmrncsemailaddressobject.h"
|
|
24 |
#include "mesmrlistobserver.h"
|
|
25 |
#include "cesmrcontacthandler.h"
|
|
26 |
#include "mesmrmeetingrequestentry.h"
|
|
27 |
#include "esmrfieldbuilderdef.h"
|
|
28 |
#include "cmrlabel.h"
|
|
29 |
#include "nmrlayoutmanager.h"
|
|
30 |
#include "nmrbitmapmanager.h"
|
|
31 |
#include "cmrimage.h"
|
|
32 |
#include "cmrbutton.h"
|
|
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 |
|
|
46 |
// unnamed namespace for local definitions
|
|
47 |
namespace { // codescanner::namespace
|
|
48 |
//CONSTANTS
|
|
49 |
const TInt KMaxAmountOfItems( 4 );
|
|
50 |
const TInt KMaxRemoteSearchResponseLength = 255;
|
|
51 |
|
|
52 |
// Panic code literal
|
|
53 |
_LIT( KESMRAttendeeField, "ESMRAttendeeField" );
|
|
54 |
|
|
55 |
/** Panic code enumeration */
|
|
56 |
enum TESMRAttendeeFieldPanic
|
|
57 |
{
|
|
58 |
EESMRAttendeeFieldNotMeetingRequestEntry // Passed entry is not MR
|
|
59 |
};
|
|
60 |
|
|
61 |
void Panic( TESMRAttendeeFieldPanic aPanic )
|
|
62 |
{
|
|
63 |
User::Panic( KESMRAttendeeField, aPanic );
|
|
64 |
}
|
|
65 |
|
|
66 |
}//namespace
|
|
67 |
|
|
68 |
// ======== MEMBER FUNCTIONS ========
|
|
69 |
|
|
70 |
// ---------------------------------------------------------------------------
|
|
71 |
// CESMRAttendeeField::CESMRAttendeeField
|
|
72 |
// ---------------------------------------------------------------------------
|
|
73 |
//
|
|
74 |
CESMRAttendeeField::CESMRAttendeeField( CCalAttendee::TCalRole aRole )
|
|
75 |
:iRole( aRole )
|
|
76 |
{
|
|
77 |
FUNC_LOG;
|
|
78 |
SetFocusType( EESMRHighlightFocus );
|
|
79 |
SetFieldId ( (iRole == CCalAttendee::EReqParticipant) ?
|
|
80 |
EESMRFieldAttendee : EESMRFieldOptAttendee );
|
|
81 |
}
|
|
82 |
|
|
83 |
// ---------------------------------------------------------------------------
|
|
84 |
// CESMRAttendeeField::~CESMRAttendeeField
|
|
85 |
// ---------------------------------------------------------------------------
|
|
86 |
//
|
|
87 |
CESMRAttendeeField::~CESMRAttendeeField( )
|
|
88 |
{
|
|
89 |
FUNC_LOG;
|
|
90 |
delete iAacListBox;
|
|
91 |
delete iContactHandler;
|
|
92 |
delete iDefaultText;
|
|
93 |
delete iBgCtrlContext;
|
|
94 |
delete iFieldButton;
|
|
95 |
delete iTitle;
|
|
96 |
}
|
|
97 |
|
|
98 |
// ---------------------------------------------------------------------------
|
|
99 |
// CESMRAttendeeField::NewL
|
|
100 |
// ---------------------------------------------------------------------------
|
|
101 |
//
|
|
102 |
CESMRAttendeeField* CESMRAttendeeField::NewL( CCalAttendee::TCalRole aRole )
|
|
103 |
{
|
|
104 |
FUNC_LOG;
|
|
105 |
CESMRAttendeeField* self = new (ELeave) CESMRAttendeeField( aRole );
|
|
106 |
CleanupStack::PushL ( self );
|
|
107 |
self->ConstructL ( );
|
|
108 |
CleanupStack::Pop ( self );
|
|
109 |
return self;
|
|
110 |
}
|
|
111 |
|
|
112 |
// ---------------------------------------------------------------------------
|
|
113 |
// CESMRAttendeeField::ConstructL
|
|
114 |
// ---------------------------------------------------------------------------
|
|
115 |
//
|
|
116 |
void CESMRAttendeeField::ConstructL( )
|
|
117 |
{
|
|
118 |
FUNC_LOG;
|
|
119 |
SetComponentsToInheritVisibility( ETrue );
|
|
120 |
|
|
121 |
iContactHandler = CESMRContactHandler::NewL();
|
|
122 |
|
|
123 |
iDefaultText = StringLoader::LoadL ( R_QTN_MEET_REQ_CONTACT_FIELD );
|
|
124 |
|
|
125 |
iFieldButton = CMRButton::NewL( NMRBitmapManager::EMRBitmapSearchContacts );
|
|
126 |
iFieldButton->SetParent( this );
|
|
127 |
iFieldButton->SetObserver( this );
|
|
128 |
|
|
129 |
iTitle = CMRLabel::NewL();
|
|
130 |
iTitle->SetParent( this );
|
|
131 |
|
|
132 |
HBufC* buf = NULL;
|
|
133 |
if( FieldId() == EESMRFieldAttendee )
|
|
134 |
{
|
|
135 |
buf = StringLoader::LoadLC( R_QTN_MEET_REQ_LABEL_REQUIRED );
|
|
136 |
}
|
|
137 |
|
|
138 |
if( FieldId() == EESMRFieldOptAttendee )
|
|
139 |
{
|
|
140 |
buf = StringLoader::LoadLC( R_QTN_MEET_REQ_LABEL_OPT );
|
|
141 |
}
|
|
142 |
|
|
143 |
iTitle->SetTextL( *buf ); // ownership transferred
|
|
144 |
CleanupStack::Pop( buf );
|
|
145 |
|
|
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 );
|
|
161 |
iEditor->SetAlignment ( EAknEditorAlignBidi | EAknEditorAlignCenter );
|
|
162 |
iEditor->SetAknEditorInputMode ( EAknEditorTextInputMode );
|
|
163 |
iEditor->SetAknEditorFlags (
|
|
164 |
EAknEditorFlagNoT9| EAknEditorFlagUseSCTNumericCharmap );
|
|
165 |
iEditor->SetAknEditorCurrentCase ( EAknEditorLowerCase );
|
|
166 |
|
|
167 |
// Draw bg instead of using skin bg
|
|
168 |
TRect tempRect( 0, 0, 0, 0 );
|
|
169 |
NMRBitmapManager::TMRBitmapStruct bitmapStruct;
|
|
170 |
bitmapStruct = NMRBitmapManager::GetBitmapStruct( NMRBitmapManager::EMRBitmapInputCenter );
|
|
171 |
iBgCtrlContext = CAknsBasicBackgroundControlContext::NewL(
|
|
172 |
bitmapStruct.iItemId,
|
|
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
|
|
213 |
}
|
|
214 |
|
|
215 |
// ---------------------------------------------------------------------------
|
|
216 |
// CESMRAttendeeField::InternalizeL
|
|
217 |
// ---------------------------------------------------------------------------
|
|
218 |
//
|
|
219 |
void CESMRAttendeeField::InternalizeL( MESMRCalEntry& aEntry )
|
|
220 |
{
|
|
221 |
FUNC_LOG;
|
|
222 |
iEditor->CreateScrollBarFrameL()->SetScrollBarVisibilityL (
|
|
223 |
CEikScrollBarFrame::EOff,
|
|
224 |
CEikScrollBarFrame::EOff );
|
|
225 |
|
|
226 |
TInt fieldAttendeeCount( 0 );
|
|
227 |
|
|
228 |
CCalEntry& entry = aEntry.Entry ( );
|
|
229 |
RPointerArray< CCalAttendee > attendees = entry.AttendeesL ( );
|
|
230 |
RCPointerArray< CESMRNcsEmailAddressObject > addressList;
|
|
231 |
CleanupClosePushL( addressList );
|
|
232 |
|
|
233 |
for (TInt i(0); i < attendees.Count(); i++ )
|
|
234 |
{
|
|
235 |
if ( attendees[i]->RoleL() == iRole )
|
|
236 |
{
|
|
237 |
fieldAttendeeCount++;
|
|
238 |
|
|
239 |
const TDesC& addr = attendees[i]->Address ( );
|
|
240 |
const TDesC& commonName = attendees[i]->CommonName ( );
|
|
241 |
|
|
242 |
CESMRNcsEmailAddressObject* obj =
|
|
243 |
CESMRNcsEmailAddressObject::NewL ( commonName, addr );
|
|
244 |
CleanupStack::PushL (obj );
|
|
245 |
addressList.AppendL( obj );
|
|
246 |
CleanupStack::Pop( obj );
|
|
247 |
}
|
|
248 |
}
|
|
249 |
|
|
250 |
if ( fieldAttendeeCount > 0 )
|
|
251 |
{
|
|
252 |
if ( !iObserver->IsControlVisible(iFieldId ) )
|
|
253 |
{
|
|
254 |
iObserver->ShowControl( iFieldId );
|
|
255 |
}
|
|
256 |
iEditor->SetAddressesL( addressList );
|
|
257 |
}
|
|
258 |
else
|
|
259 |
{
|
|
260 |
AppendDefaultTextL();
|
|
261 |
//during initialisation, SelectAllL() in setoutlinefocus gets overridden so this is needed
|
|
262 |
iEditor->SelectAllL();
|
|
263 |
}
|
|
264 |
|
|
265 |
//don't show optional attendees field on initialisation if there are none
|
|
266 |
if ( ( EESMRFieldModeEdit == FieldMode() ) && ( iRole == CCalAttendee::EOptParticipant ) )
|
|
267 |
{
|
|
268 |
if ( fieldAttendeeCount == 0 )
|
|
269 |
{
|
|
270 |
this->MakeVisible(EFalse);
|
|
271 |
}
|
|
272 |
}
|
|
273 |
|
|
274 |
CleanupStack::PopAndDestroy( &addressList );
|
|
275 |
// this is needed to be re-called here, otherwise the CEikEdwin
|
|
276 |
// does not get correctly instantiated with default text
|
|
277 |
iEditor->FocusChanged(EDrawNow);
|
|
278 |
|
|
279 |
UpdateSendOptionL();
|
|
280 |
}
|
|
281 |
|
|
282 |
// ---------------------------------------------------------------------------
|
|
283 |
// CESMRAttendeeField::ExternalizeL
|
|
284 |
// ---------------------------------------------------------------------------
|
|
285 |
//
|
|
286 |
void CESMRAttendeeField::ExternalizeL( MESMRCalEntry& aEntry )
|
|
287 |
{
|
|
288 |
FUNC_LOG;
|
|
289 |
MESMRMeetingRequestEntry* mrEntry = NULL;
|
|
290 |
if ( MESMRCalEntry::EESMRCalEntryMeetingRequest == aEntry.Type() )
|
|
291 |
{
|
|
292 |
mrEntry = static_cast<MESMRMeetingRequestEntry*>(&aEntry);
|
|
293 |
}
|
|
294 |
|
|
295 |
// This should always be called for MR entries
|
|
296 |
__ASSERT_ALWAYS( mrEntry, Panic( EESMRAttendeeFieldNotMeetingRequestEntry ));
|
|
297 |
|
|
298 |
if( iEditor->HasDefaultText() )
|
|
299 |
{
|
|
300 |
ClearDefaultTextL();
|
|
301 |
}
|
|
302 |
|
|
303 |
UpdateAttendeesL( *mrEntry );
|
|
304 |
|
|
305 |
HBufC* text = iEditor->GetTextInHBufL();
|
|
306 |
|
|
307 |
//If there is no attendees, put back the default text
|
|
308 |
if( !text )
|
|
309 |
{
|
|
310 |
AppendDefaultTextL();
|
|
311 |
//during initialisation, SelectAllL() in setoutlinefocus gets overridden so this is needed
|
|
312 |
iEditor->SelectAllL();
|
|
313 |
}
|
|
314 |
delete text;
|
|
315 |
}
|
|
316 |
|
|
317 |
// ---------------------------------------------------------------------------
|
|
318 |
// CESMRAttendeeField::CountComponentControls
|
|
319 |
// ---------------------------------------------------------------------------
|
|
320 |
//
|
|
321 |
TInt CESMRAttendeeField::CountComponentControls( ) const
|
|
322 |
{
|
|
323 |
FUNC_LOG;
|
|
324 |
TInt count( 0 );
|
|
325 |
if( iFieldButton )
|
|
326 |
{
|
|
327 |
++count;
|
|
328 |
}
|
|
329 |
|
|
330 |
if ( iTitle )
|
|
331 |
{
|
|
332 |
++count;
|
|
333 |
}
|
|
334 |
|
|
335 |
if( iEditor )
|
|
336 |
{
|
|
337 |
++count;
|
|
338 |
}
|
|
339 |
|
|
340 |
return count;
|
|
341 |
}
|
|
342 |
|
|
343 |
// ---------------------------------------------------------------------------
|
|
344 |
// CESMRAttendeeField::ComponentControl
|
|
345 |
// ---------------------------------------------------------------------------
|
|
346 |
//
|
|
347 |
CCoeControl* CESMRAttendeeField::ComponentControl( TInt aInd ) const
|
|
348 |
{
|
|
349 |
FUNC_LOG;
|
|
350 |
switch ( aInd )
|
|
351 |
{
|
|
352 |
case 0:
|
|
353 |
return iFieldButton;
|
|
354 |
case 1:
|
|
355 |
return iTitle;
|
|
356 |
case 2:
|
|
357 |
return iEditor;
|
|
358 |
default:
|
|
359 |
return NULL;
|
|
360 |
}
|
|
361 |
}
|
|
362 |
|
|
363 |
// ---------------------------------------------------------------------------
|
|
364 |
// CESMRAttendeeField::SizeChanged
|
|
365 |
// ---------------------------------------------------------------------------
|
|
366 |
//
|
|
367 |
void CESMRAttendeeField::SizeChanged( )
|
|
368 |
{
|
|
369 |
FUNC_LOG;
|
|
370 |
TRect rect( Rect() );
|
|
371 |
|
|
372 |
TAknLayoutRect firstRowLayoutRect(
|
|
373 |
NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 ) );
|
|
374 |
TRect firstRowRect( firstRowLayoutRect.Rect() );
|
|
375 |
|
|
376 |
TRect secondRowRect( firstRowRect );
|
|
377 |
secondRowRect.Move( 0, firstRowRect.Height() );
|
|
378 |
|
|
379 |
// Layout field button
|
|
380 |
if( iFieldButton )
|
|
381 |
{
|
|
382 |
TAknWindowComponentLayout buttonLayout(
|
|
383 |
NMRLayoutManager::GetWindowComponentLayout(
|
|
384 |
NMRLayoutManager::EMRLayoutTextEditorIcon ) );
|
|
385 |
AknLayoutUtils::LayoutControl(
|
|
386 |
iFieldButton, firstRowRect, buttonLayout );
|
|
387 |
}
|
|
388 |
|
|
389 |
// Layout field title
|
|
390 |
if ( iTitle )
|
|
391 |
{
|
|
392 |
TAknTextComponentLayout editorLayout =
|
|
393 |
NMRLayoutManager::GetTextComponentLayout(
|
|
394 |
NMRLayoutManager::EMRTextLayoutTextEditor );
|
|
395 |
|
|
396 |
AknLayoutUtils::LayoutLabel( iTitle, rect, editorLayout );
|
|
397 |
}
|
|
398 |
|
|
399 |
// Layout field editor
|
|
400 |
if( iEditor )
|
|
401 |
{
|
|
402 |
TAknLayoutText editorLayoutText = NMRLayoutManager::GetLayoutText(
|
|
403 |
secondRowRect,
|
|
404 |
NMRLayoutManager::EMRTextLayoutTextEditor );
|
|
405 |
|
|
406 |
TRect editorRect = editorLayoutText.TextRect();
|
|
407 |
|
|
408 |
// Resize height according to actual height required by edwin.
|
|
409 |
editorRect.Resize( 0, iSize.iHeight - editorRect.Height() );
|
|
410 |
|
|
411 |
iEditor->SetRect( editorRect );
|
|
412 |
|
|
413 |
// Try setting font. Failures are ignored.
|
|
414 |
TRAP_IGNORE( iEditor->SetFontL( editorLayoutText.Font() ) );
|
|
415 |
}
|
|
416 |
|
|
417 |
// Layout field focus
|
|
418 |
if( iEditor )
|
|
419 |
{
|
|
420 |
// Layouting focus for rich text editor area
|
|
421 |
TRect bgRect( iEditor->Rect() );
|
|
422 |
|
|
423 |
// Move focus rect so that it's relative to field's position.
|
|
424 |
bgRect.Move( -Position() );
|
|
425 |
SetFocusRect( bgRect );
|
|
426 |
}
|
|
427 |
|
|
428 |
if ( iAacListBox && iAacListBox->IsVisible ( ) )
|
|
429 |
{
|
|
430 |
TRAPD( error, iAacListBox->SetPopupMaxRectL( ResolvePopupRectL()) )
|
|
431 |
if ( error )
|
|
432 |
{
|
|
433 |
iCoeEnv->HandleError( error );
|
|
434 |
}
|
|
435 |
}
|
|
436 |
}
|
|
437 |
|
|
438 |
// -----------------------------------------------------------------------------
|
|
439 |
// CESMRAttendeeField::ResolvePopupRectL
|
|
440 |
// -----------------------------------------------------------------------------
|
|
441 |
//
|
|
442 |
TRect CESMRAttendeeField::ResolvePopupRectL( )
|
|
443 |
{
|
|
444 |
FUNC_LOG;
|
|
445 |
if ( !iAacListBox )
|
|
446 |
{
|
|
447 |
return TRect( 0, 0, 0, 0 );
|
|
448 |
}
|
|
449 |
|
|
450 |
TRect popupRect( 0, 0, 0, 0 );
|
|
451 |
|
|
452 |
// Let's determine Popup's maximum height
|
|
453 |
TInt requiredPopupHeight = iAacListBox->CalcHeightBasedOnNumOfItems(
|
|
454 |
iAacListBox->Model()->NumberOfItems() );
|
|
455 |
TInt numberOfItemsInPopUp = iAacListBox->Model()->NumberOfItems();
|
|
456 |
|
|
457 |
if( numberOfItemsInPopUp > KMaxAmountOfItems )
|
|
458 |
{
|
|
459 |
// reducing popup item count shown at once to maximum value
|
|
460 |
requiredPopupHeight = iAacListBox->CalcHeightBasedOnNumOfItems(
|
|
461 |
KMaxAmountOfItems );
|
|
462 |
}
|
|
463 |
|
|
464 |
// Popup x-coords are always the same
|
|
465 |
TInt topLeftX = iEditor->Rect().iTl.iX;
|
|
466 |
TInt bottomRightX = iEditor->Rect().iBr.iX;
|
|
467 |
|
|
468 |
// Popup y-coords need to be calculated
|
|
469 |
TInt topLeftY( 0 );
|
|
470 |
TInt bottomRightY( 0 );
|
|
471 |
|
|
472 |
// Next we have to resolve if popup needs to be drawn below or
|
|
473 |
// above the cursor (space requirement)
|
|
474 |
|
|
475 |
TRect editorLineRect;
|
|
476 |
iEditor->GetLineRectL( editorLineRect );
|
|
477 |
TInt editorLineTopLeftY = editorLineRect.iTl.iY;
|
|
478 |
TInt diff = iEditor->Rect().iTl.iY;
|
|
479 |
TInt editorLineTopLeftYRelativeToParent = editorLineTopLeftY + diff;
|
|
480 |
|
|
481 |
TInt listPaneHeight = Parent()->Rect().Height();
|
|
482 |
|
|
483 |
// Popup will be drawn above the cursor
|
|
484 |
if( editorLineTopLeftYRelativeToParent > TReal( listPaneHeight / 2 ) )
|
|
485 |
{
|
|
486 |
topLeftY = editorLineTopLeftYRelativeToParent - requiredPopupHeight;
|
|
487 |
bottomRightY = editorLineTopLeftYRelativeToParent;
|
|
488 |
}
|
|
489 |
// Popup will be drawn below the cursor
|
|
490 |
else
|
|
491 |
{
|
|
492 |
topLeftY = editorLineTopLeftYRelativeToParent + iEditor->GetLineHeightL();
|
|
493 |
bottomRightY = topLeftY + requiredPopupHeight;
|
|
494 |
}
|
|
495 |
|
|
496 |
popupRect.SetRect( topLeftX, topLeftY, bottomRightX, bottomRightY );
|
|
497 |
|
|
498 |
return popupRect;
|
|
499 |
}
|
|
500 |
|
|
501 |
// -----------------------------------------------------------------------------
|
|
502 |
// CNcsAddressInputField:::AppendDefaultTextL()
|
|
503 |
// -----------------------------------------------------------------------------
|
|
504 |
//
|
|
505 |
void CESMRAttendeeField::AppendDefaultTextL()
|
|
506 |
{
|
|
507 |
FUNC_LOG;
|
|
508 |
iEditor->SetTextL( iDefaultText );
|
|
509 |
iEditor->HandleTextChangedL();
|
|
510 |
}
|
|
511 |
|
|
512 |
// -----------------------------------------------------------------------------
|
|
513 |
// CNcsAddressInputField::ClearDefaultTextL()
|
|
514 |
// -----------------------------------------------------------------------------
|
|
515 |
//
|
|
516 |
void CESMRAttendeeField::ClearDefaultTextL()
|
|
517 |
{
|
|
518 |
FUNC_LOG;
|
|
519 |
iEditor->SetTextL( &KNullDesC );
|
|
520 |
iEditor->HandleTextChangedL();
|
|
521 |
}
|
|
522 |
|
|
523 |
// ---------------------------------------------------------------------------
|
|
524 |
// CESMRAttendeeField::OfferKeyEventL
|
|
525 |
// ---------------------------------------------------------------------------
|
|
526 |
//
|
|
527 |
TKeyResponse CESMRAttendeeField::OfferKeyEventL(
|
|
528 |
const TKeyEvent& aKeyEvent,
|
|
529 |
TEventCode aType )
|
|
530 |
{
|
|
531 |
FUNC_LOG;
|
|
532 |
|
|
533 |
TKeyResponse ret( EKeyWasNotConsumed);
|
|
534 |
|
|
535 |
if ( aKeyEvent.iCode == EKeyEnter ||
|
|
536 |
aKeyEvent.iScanCode == EStdKeyEnter ||
|
|
537 |
aKeyEvent.iCode == EKeyYes ||
|
|
538 |
aKeyEvent.iScanCode == EStdKeyYes )
|
|
539 |
{//prevent these keys from being used in any attendee field editor
|
|
540 |
return EKeyWasConsumed;
|
|
541 |
}
|
|
542 |
|
|
543 |
if ( aKeyEvent.iCode == EKeyUpArrow || aKeyEvent.iCode == EKeyDownArrow )
|
|
544 |
{
|
|
545 |
if( iAacListBox && iAacListBox->IsVisible() && !iAacListBox->IsPopupEmpty() )
|
|
546 |
{
|
|
547 |
return iAacListBox->OfferKeyEventL( aKeyEvent, aType );
|
|
548 |
}
|
|
549 |
else
|
|
550 |
{
|
|
551 |
ret = iEditor->OfferKeyEventL (aKeyEvent, aType );
|
|
552 |
}
|
|
553 |
}
|
|
554 |
else
|
|
555 |
{
|
|
556 |
if ( iAacListBox && iAacListBox->IsVisible ( ) )
|
|
557 |
{
|
|
558 |
if( aKeyEvent.iCode == EKeyDevice3 || aKeyEvent.iCode == EKeyDevice4 ||
|
|
559 |
aKeyEvent.iCode == EKeyOK )
|
|
560 |
{
|
|
561 |
DoPopupSelectL();
|
|
562 |
ret = EKeyWasConsumed;
|
|
563 |
}
|
|
564 |
}
|
|
565 |
}
|
|
566 |
|
|
567 |
if ( ret == EKeyWasNotConsumed )
|
|
568 |
{
|
|
569 |
ret = iEditor->OfferKeyEventL (aKeyEvent, aType );
|
|
570 |
UpdateSendOptionL();
|
|
571 |
}
|
|
572 |
|
|
573 |
// Scroll editor visible, if for example cursor is out of the
|
|
574 |
// viewable area when user enters more text.
|
|
575 |
if ( iObserver && aType == EEventKey )
|
|
576 |
{
|
|
577 |
CTextLayout* textLayout = iEditor->TextLayout();
|
|
578 |
TInt lineHeight = iEditor->GetLineHeightL();
|
|
579 |
|
|
580 |
TPoint cursorPos( 0,0 );
|
|
581 |
textLayout->DocPosToXyPosL( iEditor->CursorPos(), cursorPos );
|
|
582 |
|
|
583 |
TInt editorTlY = iEditor->Position().iY;
|
|
584 |
TInt listHeight = iObserver->ViewableAreaRect().Height();
|
|
585 |
|
|
586 |
TInt cursorTopY = cursorPos.iY - lineHeight + editorTlY;
|
|
587 |
TInt cursorBottomY = cursorPos.iY + lineHeight + editorTlY;
|
|
588 |
|
|
589 |
// If cursor is below visible area
|
|
590 |
if ( cursorBottomY > listHeight )
|
|
591 |
{
|
|
592 |
iObserver->RePositionFields( -( cursorBottomY - listHeight ) );
|
|
593 |
}
|
|
594 |
// If cursor is over the top of visible area
|
|
595 |
else if ( cursorTopY < 0 )
|
|
596 |
{
|
|
597 |
iObserver->RePositionFields( -cursorTopY );
|
|
598 |
}
|
|
599 |
}
|
|
600 |
|
|
601 |
return ret;
|
|
602 |
}
|
|
603 |
|
|
604 |
// ---------------------------------------------------------------------------
|
|
605 |
// CESMRAttendeeField::SetContainerWindowL()
|
|
606 |
// ---------------------------------------------------------------------------
|
|
607 |
//
|
|
608 |
void CESMRAttendeeField::SetContainerWindowL( const CCoeControl& aControl )
|
|
609 |
{
|
|
610 |
FUNC_LOG;
|
|
611 |
CCoeControl::SetContainerWindowL( aControl );
|
|
612 |
|
|
613 |
iFieldButton->SetContainerWindowL( aControl );
|
|
614 |
iFieldButton->SetParent( this );
|
|
615 |
|
|
616 |
iTitle->SetContainerWindowL( aControl );
|
|
617 |
iTitle->SetParent( this );
|
|
618 |
|
|
619 |
iEditor->SetContainerWindowL( aControl );
|
|
620 |
iEditor->SetParent( this );
|
|
621 |
|
|
622 |
iAacListBox = CESMRNcsPopupListBox::NewL ( this, *iContactHandler );
|
|
623 |
iAacListBox->MakeVisible ( EFalse );
|
|
624 |
iAacListBox->SetListBoxObserver( this );
|
|
625 |
iAacListBox->SetObserver( this );
|
|
626 |
iAacListBox->ActivateL();
|
|
627 |
|
|
628 |
iButtonGroupContainer = CEikButtonGroupContainer::Current();
|
|
629 |
}
|
|
630 |
|
|
631 |
// ---------------------------------------------------------------------------
|
|
632 |
// CESMRAttendeeField::HandleEdwinSizeEventL
|
|
633 |
// ---------------------------------------------------------------------------
|
|
634 |
//
|
|
635 |
TBool CESMRAttendeeField::HandleEdwinSizeEventL( CEikEdwin* aEdwin,
|
|
636 |
TEdwinSizeEvent /*aType*/, TSize aSize )
|
|
637 |
{
|
|
638 |
FUNC_LOG;
|
|
639 |
TBool reDraw( EFalse );
|
|
640 |
|
|
641 |
if( iSize != aSize )
|
|
642 |
{
|
|
643 |
// Let's save the required size for the iEditor
|
|
644 |
iSize = aSize;
|
|
645 |
|
|
646 |
if ( iObserver && aEdwin == iEditor )
|
|
647 |
{
|
|
648 |
iObserver->ControlSizeChanged ( this );
|
|
649 |
reDraw = ETrue;
|
|
650 |
}
|
|
651 |
}
|
|
652 |
|
|
653 |
return reDraw;
|
|
654 |
}
|
|
655 |
|
|
656 |
// ---------------------------------------------------------------------------
|
|
657 |
// CESMRAttendeeField::UpdatePopupContactListL
|
|
658 |
// ---------------------------------------------------------------------------
|
|
659 |
//
|
|
660 |
void CESMRAttendeeField::UpdatePopupContactListL(
|
|
661 |
const TDesC& aMatchString,
|
|
662 |
TBool /*iListAll*/)
|
|
663 |
{
|
|
664 |
FUNC_LOG;
|
|
665 |
if ( aMatchString.CompareC( KNullDesC ) == 0 ||
|
|
666 |
aMatchString.CompareC( *iDefaultText ) == 0 )
|
|
667 |
{
|
|
668 |
ClosePopupContactListL();
|
|
669 |
}
|
|
670 |
else if ( iAacListBox )
|
|
671 |
{
|
|
672 |
// Popup will be shown when async HandleControlEventL is received
|
|
673 |
iAacListBoxEnabled = ETrue;
|
|
674 |
|
|
675 |
if ( iAacListBox->IsVisible() )
|
|
676 |
{
|
|
677 |
iAacListBox->SetSearchTextL( aMatchString );
|
|
678 |
}
|
|
679 |
else
|
|
680 |
{
|
|
681 |
iAacListBox->InitAndSearchL( aMatchString );
|
|
682 |
}
|
|
683 |
}
|
|
684 |
}
|
|
685 |
|
|
686 |
// ---------------------------------------------------------------------------
|
|
687 |
// CESMRAttendeeField::ShowPopupCbaL
|
|
688 |
// ---------------------------------------------------------------------------
|
|
689 |
//
|
|
690 |
void CESMRAttendeeField::ShowPopupCbaL( TBool aShow )
|
|
691 |
{
|
|
692 |
if( aShow )
|
|
693 |
{
|
|
694 |
iButtonGroupContainer->SetCommandSetL(
|
|
695 |
R_CONTACT_POPUP_SOFTKEYS_SELECT_CANCEL);
|
|
696 |
}
|
|
697 |
else
|
|
698 |
{
|
|
699 |
iButtonGroupContainer->SetCommandSetL(
|
|
700 |
R_CONTACT_EDITOR_SOFTKEYS_OPTIONS_DONE__ADD);
|
|
701 |
}
|
|
702 |
|
|
703 |
iButtonGroupContainer->DrawDeferred();
|
|
704 |
}
|
|
705 |
|
|
706 |
// ---------------------------------------------------------------------------
|
|
707 |
// CESMRAttendeeField::ExecuteGenericCommandL
|
|
708 |
// ---------------------------------------------------------------------------
|
|
709 |
//
|
|
710 |
TBool CESMRAttendeeField::ExecuteGenericCommandL( TInt aCommand )
|
|
711 |
{
|
|
712 |
FUNC_LOG;
|
|
713 |
TBool isUsed( EFalse );
|
|
714 |
switch ( aCommand )
|
|
715 |
{
|
|
716 |
case EESMRCmdAttendeeInsertContact:
|
|
717 |
{
|
|
718 |
HandleTactileFeedbackL();
|
|
719 |
iContactHandler->GetAddressesFromPhonebookL( this );
|
|
720 |
isUsed = ETrue;
|
|
721 |
break;
|
|
722 |
}
|
|
723 |
case EESMRCmdAttendeeSoftkeySelect:
|
|
724 |
{
|
|
725 |
DoPopupSelectL();
|
|
726 |
isUsed = ETrue;
|
|
727 |
break;
|
|
728 |
}
|
|
729 |
case EESMRCmdAttendeeSoftkeyCancel:
|
|
730 |
{
|
|
731 |
ClosePopupContactListL();
|
|
732 |
isUsed = ETrue;
|
|
733 |
break;
|
|
734 |
}
|
|
735 |
case EESMRCmdLongtapDetected:
|
|
736 |
{
|
|
737 |
if(iEditor->IsFocused())
|
|
738 |
NotifyEventL(EESMRCmdLongtapDetected);
|
|
739 |
isUsed = ETrue;
|
|
740 |
|
|
741 |
HandleTactileFeedbackL();
|
|
742 |
break;
|
|
743 |
}
|
|
744 |
default:
|
|
745 |
break;
|
|
746 |
}
|
|
747 |
return isUsed;
|
|
748 |
}
|
|
749 |
|
|
750 |
// ---------------------------------------------------------------------------
|
|
751 |
// CESMRAttendeeField::SetOutlineFocusL
|
|
752 |
// ---------------------------------------------------------------------------
|
|
753 |
//
|
|
754 |
void CESMRAttendeeField::SetOutlineFocusL( TBool aFocus )
|
|
755 |
{
|
|
756 |
FUNC_LOG;
|
|
757 |
CESMRField::SetOutlineFocusL( aFocus );
|
|
758 |
|
|
759 |
|
|
760 |
if (aFocus) //Focus is gained on the field
|
|
761 |
{
|
|
762 |
if ( iEditor->HasDefaultText() )
|
|
763 |
{
|
|
764 |
iEditor->SelectAllL();
|
|
765 |
}
|
|
766 |
ChangeMiddleSoftKeyL( R_MR_ADD_SOFTKEY );
|
|
767 |
}
|
|
768 |
}
|
|
769 |
|
|
770 |
// ---------------------------------------------------------------------------
|
|
771 |
// CESMRAttendeeField::OperationComplete()
|
|
772 |
// ---------------------------------------------------------------------------
|
|
773 |
//
|
|
774 |
void CESMRAttendeeField::OperationCompleteL(
|
|
775 |
TContactHandlerCmd /*aCmd*/,
|
|
776 |
const RPointerArray<CESMRClsItem>* aContacts )
|
|
777 |
{
|
|
778 |
FUNC_LOG;
|
|
779 |
if ( aContacts )
|
|
780 |
{
|
|
781 |
if( aContacts->Count() > 0 )
|
|
782 |
{
|
|
783 |
RCPointerArray<CESMRNcsEmailAddressObject> ncsObjects; // codescanner::resourcenotoncleanupstack
|
|
784 |
CleanupClosePushL( ncsObjects );
|
|
785 |
for ( int i = 0; i < aContacts->Count(); i++ )
|
|
786 |
{
|
|
787 |
CESMRNcsEmailAddressObject* object =
|
|
788 |
CESMRNcsEmailAddressObject::NewL(
|
|
789 |
( *aContacts )[i]->DisplayName(),
|
|
790 |
( *aContacts )[i]->EmailAddress() );
|
|
791 |
object->SetDisplayFull( ( *aContacts)[i]->MultipleEmails() );
|
|
792 |
ncsObjects.Append( object );
|
|
793 |
}
|
|
794 |
|
|
795 |
iEditor->AppendAddressesL( ncsObjects );
|
|
796 |
CleanupStack::PopAndDestroy( &ncsObjects );
|
|
797 |
UpdateSendOptionL();
|
|
798 |
}
|
|
799 |
}
|
|
800 |
}
|
|
801 |
|
|
802 |
// ---------------------------------------------------------------------------
|
|
803 |
// CESMRAttendeeField::OperationError
|
|
804 |
// ---------------------------------------------------------------------------
|
|
805 |
//
|
|
806 |
void CESMRAttendeeField::OperationErrorL( TContactHandlerCmd /*aCmd*/,
|
|
807 |
TInt /*aError*/ )
|
|
808 |
{
|
|
809 |
FUNC_LOG;
|
|
810 |
//Nothing to do
|
|
811 |
}
|
|
812 |
|
|
813 |
// ---------------------------------------------------------------------------
|
|
814 |
// CESMRAttendeeField::HandleControlEventL
|
|
815 |
// ---------------------------------------------------------------------------
|
|
816 |
//
|
|
817 |
void CESMRAttendeeField::HandleControlEventL(
|
|
818 |
CCoeControl *aControl,
|
|
819 |
TCoeEvent aEventType )
|
|
820 |
{
|
|
821 |
FUNC_LOG;
|
|
822 |
if ( aControl == iAacListBox &&
|
|
823 |
aEventType == MCoeControlObserver::EEventStateChanged &&
|
|
824 |
iAacListBoxEnabled )
|
|
825 |
{
|
|
826 |
if ( iAacListBox && iAacListBox->IsVisible() && iAacListBox->IsPopupEmpty() )
|
|
827 |
{
|
|
828 |
ClosePopupContactListL();
|
|
829 |
}
|
|
830 |
else if ( iAacListBox && !iAacListBox->IsPopupEmpty() )
|
|
831 |
{
|
|
832 |
iAacListBox->SetPopupMaxRectL( ResolvePopupRectL() );
|
|
833 |
iAacListBox->MakeVisible ( ETrue );
|
|
834 |
ShowPopupCbaL( ETrue );
|
|
835 |
}
|
|
836 |
else
|
|
837 |
{
|
|
838 |
UpdateSendOptionL();
|
|
839 |
}
|
|
840 |
}
|
|
841 |
}
|
|
842 |
|
|
843 |
// -----------------------------------------------------------------------------
|
|
844 |
// CESMRAttendeeField::DoPopupSelect
|
|
845 |
// -----------------------------------------------------------------------------
|
|
846 |
//
|
|
847 |
void CESMRAttendeeField::DoPopupSelectL()
|
|
848 |
{
|
|
849 |
FUNC_LOG;
|
|
850 |
if( iAacListBox && iAacListBox->IsRemoteLookupItemSelected() )
|
|
851 |
{
|
|
852 |
// Launch remote lookup
|
|
853 |
HBufC* lookupText = iEditor->GetLookupTextLC();
|
|
854 |
CPbkxRemoteContactLookupServiceUiContext::TResult::TExitReason exitReason;
|
|
855 |
CESMRNcsEmailAddressObject* address = ExecuteRemoteSearchL(
|
|
856 |
exitReason,
|
|
857 |
*lookupText );
|
|
858 |
if ( address )
|
|
859 |
{
|
|
860 |
CleanupStack::PushL( address );
|
|
861 |
iEditor->AddAddressL( *address );
|
|
862 |
CleanupStack::PopAndDestroy( address );
|
|
863 |
}
|
|
864 |
CleanupStack::PopAndDestroy( lookupText );
|
|
865 |
}
|
|
866 |
else if( iAacListBox && !iAacListBox->IsPopupEmpty() )
|
|
867 |
{
|
|
868 |
CESMRNcsEmailAddressObject* emailAddress =
|
|
869 |
iAacListBox->ReturnCurrentEmailAddressLC();
|
|
870 |
if( emailAddress )
|
|
871 |
{
|
|
872 |
if ( emailAddress->EmailAddress().Compare( KNullDesC ))
|
|
873 |
{
|
|
874 |
iEditor->AddAddressL( *emailAddress );
|
|
875 |
}
|
|
876 |
else
|
|
877 |
{
|
|
878 |
// selected contact doesn't have email address, launch remote contact lookup
|
|
879 |
// rcl must be usable, since otherwise there couldn't be any items
|
|
880 |
// without email addresses
|
|
881 |
CPbkxRemoteContactLookupServiceUiContext::TResult::TExitReason exitReason;
|
|
882 |
CESMRNcsEmailAddressObject* remAddress = ExecuteRemoteSearchL(
|
|
883 |
exitReason,
|
|
884 |
emailAddress->DisplayName() );
|
|
885 |
if ( remAddress )
|
|
886 |
{
|
|
887 |
CleanupStack::PushL( remAddress );
|
|
888 |
iEditor->AddAddressL( *remAddress );
|
|
889 |
CleanupStack::PopAndDestroy( remAddress );
|
|
890 |
}
|
|
891 |
}
|
|
892 |
CleanupStack::PopAndDestroy( emailAddress );
|
|
893 |
}
|
|
894 |
}
|
|
895 |
ClosePopupContactListL();
|
|
896 |
}
|
|
897 |
|
|
898 |
// -----------------------------------------------------------------------------
|
|
899 |
// CESMRAttendeeField::ClosePopupContactListL()
|
|
900 |
// -----------------------------------------------------------------------------
|
|
901 |
//
|
|
902 |
void CESMRAttendeeField::ClosePopupContactListL()
|
|
903 |
{
|
|
904 |
FUNC_LOG;
|
|
905 |
// Disable popup if we get async HandleControlEventL later
|
|
906 |
iAacListBoxEnabled = EFalse;
|
|
907 |
|
|
908 |
if ( iAacListBox && iAacListBox->IsVisible() )
|
|
909 |
{
|
|
910 |
iAacListBox->MakeVisible( EFalse );
|
|
911 |
AknsUtils::SetAvkonSkinEnabledL( ETrue );
|
|
912 |
}
|
|
913 |
|
|
914 |
ShowPopupCbaL( EFalse );
|
|
915 |
UpdateSendOptionL();
|
|
916 |
}
|
|
917 |
|
|
918 |
// ---------------------------------------------------------------------------
|
|
919 |
// CESMRAttendeeField::ExecuteRemoteSearchL
|
|
920 |
// ---------------------------------------------------------------------------
|
|
921 |
//
|
|
922 |
CESMRNcsEmailAddressObject* CESMRAttendeeField::ExecuteRemoteSearchL(
|
|
923 |
CPbkxRemoteContactLookupServiceUiContext::TResult::TExitReason& /*aExitReason*/,
|
|
924 |
const TDesC& aSearchText )
|
|
925 |
{
|
|
926 |
FUNC_LOG;
|
|
927 |
RBuf displayname; // codescanner::resourcenotoncleanupstack
|
|
928 |
displayname.CreateL( KMaxRemoteSearchResponseLength );
|
|
929 |
displayname.CleanupClosePushL();
|
|
930 |
RBuf emailAddress; // codescanner::resourcenotoncleanupstack
|
|
931 |
emailAddress.CreateL( KMaxRemoteSearchResponseLength );
|
|
932 |
emailAddress.CleanupClosePushL();
|
|
933 |
|
|
934 |
// Pop-up needs to be closed before executing remote lookup with
|
|
935 |
// query dialog, because combination of this pop-up and any query dialog
|
|
936 |
// causes background drawing problems with CEikMfne editors.
|
|
937 |
// Reason unknown.
|
|
938 |
ClosePopupContactListL();
|
|
939 |
|
|
940 |
TBool contactSelected = iContactHandler->LaunchRemoteLookupL( aSearchText,
|
|
941 |
displayname,
|
|
942 |
emailAddress );
|
|
943 |
|
|
944 |
CESMRNcsEmailAddressObject* address = NULL;
|
|
945 |
if ( contactSelected )
|
|
946 |
{
|
|
947 |
if ( !displayname.Length() )
|
|
948 |
{
|
|
949 |
address = CESMRNcsEmailAddressObject::NewL( emailAddress, emailAddress );
|
|
950 |
}
|
|
951 |
else
|
|
952 |
{
|
|
953 |
address = CESMRNcsEmailAddressObject::NewL( displayname, emailAddress );
|
|
954 |
}
|
|
955 |
}
|
|
956 |
|
|
957 |
CleanupStack::PopAndDestroy( &emailAddress );
|
|
958 |
CleanupStack::PopAndDestroy( &displayname );
|
|
959 |
|
|
960 |
return address;
|
|
961 |
}
|
|
962 |
|
|
963 |
// ---------------------------------------------------------------------------
|
|
964 |
// CESMRAttendeeField::UpdateSendOptionL
|
|
965 |
// ---------------------------------------------------------------------------
|
|
966 |
//
|
|
967 |
void CESMRAttendeeField::UpdateSendOptionL()
|
|
968 |
{
|
|
969 |
FUNC_LOG;
|
|
970 |
// Check if editor has text and it is different from default text.
|
|
971 |
HBufC *text = iEditor->GetTextInHBufL();
|
|
972 |
TBool enable = text && text->Length() > 0 && text->Compare( *iDefaultText ) != 0;
|
|
973 |
if( enable )
|
|
974 |
{
|
|
975 |
TPtr ptr = text->Des();
|
|
976 |
ptr.Trim();
|
|
977 |
}
|
|
978 |
enable = text && text->Length() > 0 && text->Compare( *iDefaultText ) != 0;
|
|
979 |
delete text;
|
|
980 |
|
|
981 |
// Send proper command to CESMREditorDialog::ProcessCommandL
|
|
982 |
TInt command = 0;
|
|
983 |
if ( iRole == CCalAttendee::EReqParticipant )
|
|
984 |
{
|
|
985 |
if ( enable )
|
|
986 |
{
|
|
987 |
command = EESMRCmdAttendeeRequiredEnabled;
|
|
988 |
}
|
|
989 |
else
|
|
990 |
{
|
|
991 |
command = EESMRCmdAttendeeRequiredDisabled;
|
|
992 |
}
|
|
993 |
}
|
|
994 |
else if ( iRole == CCalAttendee::EOptParticipant )
|
|
995 |
{
|
|
996 |
if ( enable )
|
|
997 |
{
|
|
998 |
command = EESMRCmdAttendeeOptionalEnabled;
|
|
999 |
}
|
|
1000 |
else
|
|
1001 |
{
|
|
1002 |
command = EESMRCmdAttendeeOptionalDisabled;
|
|
1003 |
}
|
|
1004 |
}
|
|
1005 |
|
|
1006 |
NotifyEventL( command );
|
|
1007 |
}
|
|
1008 |
|
|
1009 |
// ---------------------------------------------------------------------------
|
|
1010 |
// CESMRAttendeeField::HandleListBoxEventL
|
|
1011 |
// ---------------------------------------------------------------------------
|
|
1012 |
//
|
|
1013 |
void CESMRAttendeeField::HandleListBoxEventL( CEikListBox* aListBox,
|
|
1014 |
TListBoxEvent aEventType )
|
|
1015 |
{
|
|
1016 |
if( aEventType == EEventEnterKeyPressed || aEventType == EEventItemClicked
|
|
1017 |
|| aEventType == EEventItemDoubleClicked || aEventType == EEventItemSingleClicked )
|
|
1018 |
{
|
|
1019 |
TInt newIndex = aListBox->CurrentItemIndex();
|
|
1020 |
|
|
1021 |
// if item is already highlighted and then clicked,
|
|
1022 |
// it is considered that it has been selected
|
|
1023 |
if( newIndex == iPreviousIndex )
|
|
1024 |
{
|
|
1025 |
HandleTactileFeedbackL();
|
|
1026 |
DoPopupSelectL();
|
|
1027 |
|
|
1028 |
// Item selected, index reseted
|
|
1029 |
iPreviousIndex = 0;
|
|
1030 |
}
|
|
1031 |
else
|
|
1032 |
{
|
|
1033 |
iPreviousIndex = newIndex;
|
|
1034 |
}
|
|
1035 |
}
|
|
1036 |
}
|
|
1037 |
|
|
1038 |
// -----------------------------------------------------------------------------
|
|
1039 |
// CESMRAttendeeField::GetCursorLineVerticalPos
|
|
1040 |
// -----------------------------------------------------------------------------
|
|
1041 |
//
|
|
1042 |
void CESMRAttendeeField::GetCursorLineVerticalPos(
|
|
1043 |
TInt& aUpper, TInt& aLower)
|
|
1044 |
{
|
|
1045 |
FUNC_LOG;
|
|
1046 |
TRect rect;
|
|
1047 |
|
|
1048 |
TRAPD( err, iEditor->GetLineRectL( rect ) );
|
|
1049 |
|
|
1050 |
if ( err == KErrNone )
|
|
1051 |
{
|
|
1052 |
rect.Move( 0, iFieldButton->Rect().Size().iHeight );
|
|
1053 |
aUpper = rect.iTl.iY;
|
|
1054 |
aLower = rect.iBr.iY;
|
|
1055 |
}
|
|
1056 |
else
|
|
1057 |
{
|
|
1058 |
// This isn't expected to happen in any situation.
|
|
1059 |
// but if it does at least there will be no zero size
|
|
1060 |
CESMRField::GetCursorLineVerticalPos( aUpper, aLower );
|
|
1061 |
}
|
|
1062 |
}
|
|
1063 |
|
|
1064 |
// ---------------------------------------------------------------------------
|
|
1065 |
// CESMRAttendeeField::HandleSingletapEventL
|
|
1066 |
// ---------------------------------------------------------------------------
|
|
1067 |
//
|
|
1068 |
TBool CESMRAttendeeField::HandleSingletapEventL( const TPoint& aPosition )
|
|
1069 |
{
|
|
1070 |
FUNC_LOG;
|
|
1071 |
TBool ret( EFalse );
|
|
1072 |
|
|
1073 |
if( iTitle->Rect().Contains( aPosition ) ||
|
|
1074 |
iFieldButton->Rect().Contains( aPosition ) )
|
|
1075 |
{
|
|
1076 |
HandleTactileFeedbackL();
|
|
1077 |
|
|
1078 |
iContactHandler->GetAddressesFromPhonebookL( this );
|
|
1079 |
ret = ETrue;
|
|
1080 |
}
|
|
1081 |
|
|
1082 |
return ret;
|
|
1083 |
}
|
|
1084 |
|
|
1085 |
// ---------------------------------------------------------------------------
|
|
1086 |
// CESMRAttendeeField::HandleLongtapEventL
|
|
1087 |
// ---------------------------------------------------------------------------
|
|
1088 |
//
|
|
1089 |
void CESMRAttendeeField::HandleLongtapEventL( const TPoint& aPosition )
|
|
1090 |
{
|
|
1091 |
FUNC_LOG;
|
|
1092 |
|
|
1093 |
if( iTitle->Rect().Contains( aPosition ) ||
|
|
1094 |
iFieldButton->Rect().Contains( aPosition ) )
|
|
1095 |
{
|
|
1096 |
NotifyEventL( EAknSoftkeyContextOptions );
|
|
1097 |
}
|
|
1098 |
}
|
|
1099 |
|
|
1100 |
// ---------------------------------------------------------------------------
|
|
1101 |
// CESMRAttendeeField::UpdateAttendeesL
|
|
1102 |
// ---------------------------------------------------------------------------
|
|
1103 |
//
|
|
1104 |
void CESMRAttendeeField::UpdateAttendeesL( MESMRMeetingRequestEntry& aMREntry )
|
|
1105 |
{
|
|
1106 |
FUNC_LOG;
|
|
1107 |
/*
|
|
1108 |
* Compare editor attendees to existing attendees and add / remove
|
|
1109 |
* when necessary.
|
|
1110 |
*/
|
|
1111 |
iEditor->CheckAddressWhenFocusLostL();
|
|
1112 |
|
|
1113 |
CCalEntry& entry( aMREntry.Entry() );
|
|
1114 |
|
|
1115 |
// Get editor's attendees
|
|
1116 |
RPointerArray<CESMRNcsEmailAddressObject> editorAttendees =
|
|
1117 |
iEditor->GetAddressesL();
|
|
1118 |
TInt editorAttendeesCount( editorAttendees.Count() );
|
|
1119 |
|
|
1120 |
// Get existing attendees
|
|
1121 |
RPointerArray<CCalAttendee>& existingAttendees = entry.AttendeesL();
|
|
1122 |
TInt existingAttendeesCount( existingAttendees.Count() );
|
|
1123 |
|
|
1124 |
// Remove removed attendees from entry
|
|
1125 |
for( TInt i( existingAttendeesCount - 1 ); i >= 0 ; --i )
|
|
1126 |
{
|
|
1127 |
// existing address and role
|
|
1128 |
const TDesC& address = existingAttendees[i]->Address();
|
|
1129 |
CCalAttendee::TCalRole role = existingAttendees[i]->RoleL();
|
|
1130 |
|
|
1131 |
// Let's try to find them amongst editor attendees
|
|
1132 |
TBool matchFound( EFalse );
|
|
1133 |
for( TInt j( 0 ); j < editorAttendeesCount ; ++j )
|
|
1134 |
{
|
|
1135 |
// if address match is found ...
|
|
1136 |
if( editorAttendees[j]->EmailAddress().Compare( address ) == 0 )
|
|
1137 |
{
|
|
1138 |
// ... And roles match also
|
|
1139 |
if( role == iRole )
|
|
1140 |
{
|
|
1141 |
// This attendee is left to the entry
|
|
1142 |
matchFound = ETrue;
|
|
1143 |
break;
|
|
1144 |
}
|
|
1145 |
}
|
|
1146 |
}
|
|
1147 |
if( !matchFound )
|
|
1148 |
{
|
|
1149 |
// Existing attendee not found from editor -> Let's delete that
|
|
1150 |
// from entry if roles match
|
|
1151 |
if ( existingAttendees[i]->RoleL( )== iRole )
|
|
1152 |
{
|
|
1153 |
entry.DeleteAttendeeL( i );
|
|
1154 |
}
|
|
1155 |
}
|
|
1156 |
}
|
|
1157 |
|
|
1158 |
// Update existing attendees count, because some attendees might
|
|
1159 |
// have been removed
|
|
1160 |
existingAttendees.Reset();
|
|
1161 |
existingAttendees = entry.AttendeesL();
|
|
1162 |
existingAttendeesCount = existingAttendees.Count();
|
|
1163 |
|
|
1164 |
// Add new attendees to entry
|
|
1165 |
for( TInt i( 0 ); i < editorAttendeesCount ; ++i )
|
|
1166 |
{
|
|
1167 |
CESMRNcsEmailAddressObject* obj = editorAttendees[i];
|
|
1168 |
CCalAttendee* attendee = CCalAttendee::NewL( obj->EmailAddress() );
|
|
1169 |
attendee->SetRoleL( iRole );
|
|
1170 |
attendee->SetCommonNameL( obj->DisplayName() );
|
|
1171 |
|
|
1172 |
if ( EESMRRoleOrganizer == aMREntry.RoleL() ||
|
|
1173 |
aMREntry.IsForwardedL() )
|
|
1174 |
{
|
|
1175 |
attendee->SetResponseRequested( ETrue );
|
|
1176 |
}
|
|
1177 |
|
|
1178 |
TBool isNewAttendee( ETrue );
|
|
1179 |
for( TInt i( 0 ); i < existingAttendeesCount; ++i )
|
|
1180 |
{
|
|
1181 |
if( existingAttendees[i]->Address().Compare( attendee->Address() ) == 0 )
|
|
1182 |
{
|
|
1183 |
if( existingAttendees[i]->RoleL() == iRole )
|
|
1184 |
{
|
|
1185 |
// Match found, this is not a new attendee
|
|
1186 |
isNewAttendee = EFalse;
|
|
1187 |
break;
|
|
1188 |
}
|
|
1189 |
}
|
|
1190 |
}
|
|
1191 |
// If this is new attendee, let's add it to entry
|
|
1192 |
if( isNewAttendee )
|
|
1193 |
{
|
|
1194 |
entry.AddAttendeeL( attendee );
|
|
1195 |
}
|
|
1196 |
}
|
|
1197 |
}
|
|
1198 |
|
|
1199 |
|
|
1200 |
//EOF
|
|
1201 |
|