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 Recurrence field implementation
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "emailtrace.h"
|
|
19 |
#include "cesmrrecurencefield.h"
|
|
20 |
#include "cesmrrecurrence.h"
|
|
21 |
#include "mesmrlistobserver.h"
|
|
22 |
#include "cesmrlistquery.h"
|
|
23 |
#include "mesmrmeetingrequestentry.h"
|
|
24 |
#include "mesmrfieldvalidator.h"
|
|
25 |
#include "cesmrglobalnote.h"
|
|
26 |
#include "nmrlayoutmanager.h"
|
|
27 |
#include "cmrimage.h"
|
|
28 |
#include "cmrlabel.h"
|
|
29 |
|
|
30 |
#include <barsread.h>
|
|
31 |
#include <esmrgui.rsg>
|
|
32 |
//<cmail>
|
|
33 |
#include "esmrdef.h"
|
|
34 |
//</cmail>
|
|
35 |
|
|
36 |
|
|
37 |
// Unnamed namespace for local definitions
|
|
38 |
namespace { // codescanner::namespace
|
|
39 |
|
|
40 |
#ifdef _DEBUG
|
|
41 |
|
|
42 |
/** Panic code literal */
|
|
43 |
_LIT( KESMRRecurenceFieldPanicTxt, "ESMRRecurenceField" );
|
|
44 |
|
|
45 |
/** Panic code enumeration */
|
|
46 |
enum TESMRRecurenceFieldPanic
|
|
47 |
{
|
|
48 |
/** Observer is not set */
|
|
49 |
EESMRRecurenceFieldNoObserver = 0
|
|
50 |
};
|
|
51 |
|
|
52 |
/**
|
|
53 |
* Raises system panic.
|
|
54 |
* @param aPanic CESMRRecurenceField panic code.
|
|
55 |
*/
|
|
56 |
void Panic( TESMRRecurenceFieldPanic aPanic )
|
|
57 |
{
|
|
58 |
User::Panic( KESMRRecurenceFieldPanicTxt, aPanic );
|
|
59 |
}
|
|
60 |
|
|
61 |
#endif // DEBUG
|
|
62 |
|
|
63 |
}
|
|
64 |
|
|
65 |
// ======== MEMBER FUNCTIONS ========
|
|
66 |
|
|
67 |
// ---------------------------------------------------------------------------
|
|
68 |
// CESMRRecurrenceField::CESMRRecurrenceField
|
|
69 |
// ---------------------------------------------------------------------------
|
|
70 |
//
|
|
71 |
CESMRRecurenceField::CESMRRecurenceField( MESMRFieldValidator* aValidator )
|
|
72 |
: iIndex( 0 )
|
|
73 |
{
|
|
74 |
FUNC_LOG;
|
|
75 |
|
|
76 |
iValidator = aValidator;
|
|
77 |
|
|
78 |
SetFieldId ( EESMRFieldRecurrence );
|
|
79 |
SetFocusType( EESMRHighlightFocus );
|
|
80 |
}
|
|
81 |
|
|
82 |
// ---------------------------------------------------------------------------
|
|
83 |
// CESMRRecurrenceField::~CESMRRecurrenceField
|
|
84 |
// ---------------------------------------------------------------------------
|
|
85 |
//
|
|
86 |
CESMRRecurenceField::~CESMRRecurenceField( )
|
|
87 |
{
|
|
88 |
FUNC_LOG;
|
|
89 |
iArray.ResetAndDestroy();
|
|
90 |
iArray.Close();
|
|
91 |
|
|
92 |
delete iFieldIcon;
|
|
93 |
}
|
|
94 |
|
|
95 |
// ---------------------------------------------------------------------------
|
|
96 |
// CESMRRecurrenceField::NewL
|
|
97 |
// ---------------------------------------------------------------------------
|
|
98 |
//
|
|
99 |
CESMRRecurenceField* CESMRRecurenceField::NewL(
|
|
100 |
MESMRFieldValidator* aValidator )
|
|
101 |
{
|
|
102 |
FUNC_LOG;
|
|
103 |
CESMRRecurenceField* self =
|
|
104 |
new( ELeave )CESMRRecurenceField( aValidator );
|
|
105 |
CleanupStack::PushL( self );
|
|
106 |
self->ConstructL();
|
|
107 |
CleanupStack::Pop( self );
|
|
108 |
return self;
|
|
109 |
}
|
|
110 |
|
|
111 |
// ---------------------------------------------------------------------------
|
|
112 |
// CESMRRecurrenceField::ConstructL
|
|
113 |
// ---------------------------------------------------------------------------
|
|
114 |
//
|
|
115 |
void CESMRRecurenceField::ConstructL( )
|
|
116 |
{
|
|
117 |
FUNC_LOG;
|
|
118 |
iRecurrence = CMRLabel::NewL();
|
|
119 |
iRecurrence->SetParent( this );
|
|
120 |
CESMRField::ConstructL( iRecurrence );
|
|
121 |
|
|
122 |
iRecurrence->SetTextL( KNullDesC() );
|
|
123 |
|
|
124 |
iFieldIcon = CMRImage::NewL( NMRBitmapManager::EMRBitmapRecurrence );
|
|
125 |
iFieldIcon->SetParent( this );
|
|
126 |
}
|
|
127 |
|
|
128 |
// ---------------------------------------------------------------------------
|
|
129 |
// CESMRRecurrenceField::InternalizeL
|
|
130 |
// ---------------------------------------------------------------------------
|
|
131 |
//
|
|
132 |
void CESMRRecurenceField::InternalizeL( MESMRCalEntry& aEntry )
|
|
133 |
{
|
|
134 |
FUNC_LOG;
|
|
135 |
if ( aEntry.CanSetRecurrenceL() )
|
|
136 |
{
|
|
137 |
CCoeEnv* env = CCoeEnv::Static ( );
|
|
138 |
TResourceReader reader;
|
|
139 |
env->CreateResourceReaderLC( reader, R_ESMREDITOR_RECURRENCE );
|
|
140 |
|
|
141 |
TESMRRecurrenceValue recurrenceVal;
|
|
142 |
TTime until;
|
|
143 |
aEntry.GetRecurrenceL(recurrenceVal, until );
|
|
144 |
|
|
145 |
iArray.ResetAndDestroy( );
|
|
146 |
TInt count = reader.ReadInt16 ( );
|
|
147 |
for (TInt i(0); i < count; ++i )
|
|
148 |
{
|
|
149 |
CESMRRecurrence* recurrence = new (ELeave) CESMRRecurrence;
|
|
150 |
CleanupStack::PushL( recurrence );
|
|
151 |
recurrence->ConstructFromResourceL( env, reader );
|
|
152 |
iArray.AppendL( recurrence );
|
|
153 |
CleanupStack::Pop( recurrence );
|
|
154 |
// set default recurrence
|
|
155 |
if ( recurrence->RecurrenceValue() == recurrenceVal )
|
|
156 |
{
|
|
157 |
iIndex = i;
|
|
158 |
SetRecurrenceL ( iIndex );
|
|
159 |
}
|
|
160 |
}
|
|
161 |
// resource reader
|
|
162 |
CleanupStack::PopAndDestroy(); // codescanner::cleanup
|
|
163 |
}
|
|
164 |
else
|
|
165 |
{
|
|
166 |
__ASSERT_DEBUG( iObserver, Panic( EESMRRecurenceFieldNoObserver ) );
|
|
167 |
iObserver->HideControl ( iFieldId );
|
|
168 |
}
|
|
169 |
}
|
|
170 |
|
|
171 |
// ---------------------------------------------------------------------------
|
|
172 |
// CESMRRecurenceField::SetOutlineFocusL
|
|
173 |
// ---------------------------------------------------------------------------
|
|
174 |
//
|
|
175 |
void CESMRRecurenceField::SetOutlineFocusL( TBool aFocus )
|
|
176 |
{
|
|
177 |
FUNC_LOG;
|
|
178 |
CESMRField::SetOutlineFocusL ( aFocus );
|
|
179 |
|
|
180 |
//Focus gained
|
|
181 |
if ( aFocus )
|
|
182 |
{
|
|
183 |
ChangeMiddleSoftKeyL(EESMRCmdOpenRecurrenceQuery, R_QTN_MSK_OPEN);
|
|
184 |
}
|
|
185 |
}
|
|
186 |
|
|
187 |
// ---------------------------------------------------------------------------
|
|
188 |
// CESMRRecurenceField::ExecuteGenericCommandL
|
|
189 |
// ---------------------------------------------------------------------------
|
|
190 |
//
|
|
191 |
TBool CESMRRecurenceField::ExecuteGenericCommandL( TInt aCommand )
|
|
192 |
{
|
|
193 |
FUNC_LOG;
|
|
194 |
TBool isUsed( EFalse );
|
|
195 |
if (aCommand == EESMRCmdOpenRecurrenceQuery ||
|
|
196 |
aCommand == EAknCmdOpen )
|
|
197 |
{
|
|
198 |
HandleTactileFeedbackL();
|
|
199 |
|
|
200 |
ExecuteRecurrenceQueryL();
|
|
201 |
isUsed = ETrue;
|
|
202 |
}
|
|
203 |
return isUsed;
|
|
204 |
}
|
|
205 |
|
|
206 |
// ---------------------------------------------------------------------------
|
|
207 |
// CESMRRecurenceField::ExecuteRecurrenceQueryL
|
|
208 |
// ---------------------------------------------------------------------------
|
|
209 |
//
|
|
210 |
void CESMRRecurenceField::ExecuteRecurrenceQueryL()
|
|
211 |
{
|
|
212 |
FUNC_LOG;
|
|
213 |
TInt ret = CESMRListQuery::ExecuteL(
|
|
214 |
CESMRListQuery::EESMRRecurrenceQuery );
|
|
215 |
|
|
216 |
if ( ret != KErrCancel )
|
|
217 |
{
|
|
218 |
SetRecurrenceL( ret );
|
|
219 |
}
|
|
220 |
}
|
|
221 |
|
|
222 |
// ---------------------------------------------------------------------------
|
|
223 |
// CESMRRecurrenceField::OfferKeyEventL
|
|
224 |
// ---------------------------------------------------------------------------
|
|
225 |
//
|
|
226 |
TKeyResponse CESMRRecurenceField::OfferKeyEventL(
|
|
227 |
const TKeyEvent& aEvent,
|
|
228 |
TEventCode aType )
|
|
229 |
{
|
|
230 |
FUNC_LOG;
|
|
231 |
TKeyResponse response( EKeyWasNotConsumed);
|
|
232 |
if ( EEventKey == aType )
|
|
233 |
{
|
|
234 |
switch ( aEvent.iScanCode )
|
|
235 |
{
|
|
236 |
case EStdKeyLeftArrow:
|
|
237 |
{
|
|
238 |
if ( iIndex > 0 )
|
|
239 |
{
|
|
240 |
SetRecurrenceL ( iIndex - 1 );
|
|
241 |
response = EKeyWasConsumed;
|
|
242 |
}
|
|
243 |
}
|
|
244 |
break;
|
|
245 |
|
|
246 |
case EStdKeyRightArrow:
|
|
247 |
{
|
|
248 |
if ( iIndex < (iArray.Count() - 1) )
|
|
249 |
{
|
|
250 |
SetRecurrenceL ( iIndex + 1 );
|
|
251 |
response = EKeyWasConsumed;
|
|
252 |
}
|
|
253 |
}
|
|
254 |
break;
|
|
255 |
|
|
256 |
default:
|
|
257 |
break;
|
|
258 |
}
|
|
259 |
}
|
|
260 |
return response;
|
|
261 |
}
|
|
262 |
|
|
263 |
// ---------------------------------------------------------------------------
|
|
264 |
// CESMRRecurrenceField::SetRecurrence
|
|
265 |
// ---------------------------------------------------------------------------
|
|
266 |
//
|
|
267 |
void CESMRRecurenceField::SetRecurrenceL(
|
|
268 |
TInt aIndex )
|
|
269 |
{
|
|
270 |
FUNC_LOG;
|
|
271 |
if ( aIndex < 0 || aIndex >= iArray.Count() )
|
|
272 |
{
|
|
273 |
User::Leave( KErrArgument );
|
|
274 |
}
|
|
275 |
|
|
276 |
CESMRRecurrence* rec = iArray[ aIndex ];
|
|
277 |
TRAPD( err, iValidator->RecurrenceChangedL( rec->RecurrenceValue() ) );
|
|
278 |
if ( err == KErrNone )
|
|
279 |
{
|
|
280 |
iRecurrence->SetTextL( rec->RecurrenceText() );
|
|
281 |
iRecurrence->DrawDeferred();
|
|
282 |
|
|
283 |
iIndex = aIndex;
|
|
284 |
|
|
285 |
if ( rec->RecurrenceValue() != ERecurrenceNot )
|
|
286 |
{
|
|
287 |
// if recurrence is switched "on", the end date should be removed
|
|
288 |
iObserver->HideControl ( EESMRFieldStopDate );
|
|
289 |
iObserver->ShowControl ( EESMRFieldRecurrenceDate );
|
|
290 |
}
|
|
291 |
else
|
|
292 |
{
|
|
293 |
// if recurrence is switched off, end date should be visible
|
|
294 |
iObserver->ShowControl ( EESMRFieldStopDate );
|
|
295 |
iObserver->HideControl ( EESMRFieldRecurrenceDate );
|
|
296 |
}
|
|
297 |
}
|
|
298 |
else
|
|
299 |
{
|
|
300 |
// Error occured
|
|
301 |
CESMRGlobalNote::ExecuteL(
|
|
302 |
CESMRGlobalNote::EESMRRepeatDifferentStartAndEndDate );
|
|
303 |
}
|
|
304 |
}
|
|
305 |
|
|
306 |
// ---------------------------------------------------------------------------
|
|
307 |
// CESMRRecurenceField::SizeChanged
|
|
308 |
// ---------------------------------------------------------------------------
|
|
309 |
//
|
|
310 |
void CESMRRecurenceField::SizeChanged()
|
|
311 |
{
|
|
312 |
FUNC_LOG;
|
|
313 |
TRect rect = Rect();
|
|
314 |
|
|
315 |
TAknLayoutRect rowLayoutRect =
|
|
316 |
NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 );
|
|
317 |
rect = rowLayoutRect.Rect();
|
|
318 |
|
|
319 |
TAknWindowComponentLayout iconLayout =
|
|
320 |
NMRLayoutManager::GetWindowComponentLayout(
|
|
321 |
NMRLayoutManager::EMRLayoutTextEditorIcon );
|
|
322 |
AknLayoutUtils::LayoutImage( iFieldIcon, rect, iconLayout );
|
|
323 |
|
|
324 |
TAknLayoutRect bgLayoutRect =
|
|
325 |
NMRLayoutManager::GetLayoutRect(
|
|
326 |
rect, NMRLayoutManager::EMRLayoutTextEditorBg );
|
|
327 |
TRect bgRect( bgLayoutRect.Rect() );
|
|
328 |
// Move focus rect so that it's relative to field's position.
|
|
329 |
bgRect.Move( -Position() );
|
|
330 |
SetFocusRect( bgRect );
|
|
331 |
|
|
332 |
TAknTextComponentLayout editorLayout =
|
|
333 |
NMRLayoutManager::GetTextComponentLayout(
|
|
334 |
NMRLayoutManager::EMRTextLayoutTextEditor );
|
|
335 |
|
|
336 |
AknLayoutUtils::LayoutLabel( iRecurrence, rect, editorLayout );
|
|
337 |
}
|
|
338 |
|
|
339 |
// ---------------------------------------------------------------------------
|
|
340 |
// CESMRRecurenceField::CountComponentControls
|
|
341 |
// ---------------------------------------------------------------------------
|
|
342 |
//
|
|
343 |
TInt CESMRRecurenceField::CountComponentControls( ) const
|
|
344 |
{
|
|
345 |
FUNC_LOG;
|
|
346 |
TInt count( 0 );
|
|
347 |
if ( iFieldIcon )
|
|
348 |
{
|
|
349 |
++count;
|
|
350 |
}
|
|
351 |
if ( iRecurrence )
|
|
352 |
{
|
|
353 |
++count;
|
|
354 |
}
|
|
355 |
return count;
|
|
356 |
}
|
|
357 |
|
|
358 |
// ---------------------------------------------------------------------------
|
|
359 |
// CESMRRecurenceField::ComponentControl
|
|
360 |
// ---------------------------------------------------------------------------
|
|
361 |
//
|
|
362 |
CCoeControl* CESMRRecurenceField::ComponentControl( TInt aInd ) const
|
|
363 |
{
|
|
364 |
FUNC_LOG;
|
|
365 |
switch ( aInd )
|
|
366 |
{
|
|
367 |
case 0:
|
|
368 |
return iFieldIcon;
|
|
369 |
case 1:
|
|
370 |
return iRecurrence;
|
|
371 |
default:
|
|
372 |
return NULL;
|
|
373 |
}
|
|
374 |
}
|
|
375 |
|
|
376 |
// ---------------------------------------------------------------------------
|
|
377 |
// CESMRRecurenceField::SetContainerWindowL
|
|
378 |
// ---------------------------------------------------------------------------
|
|
379 |
//
|
|
380 |
void CESMRRecurenceField::SetContainerWindowL(
|
|
381 |
const CCoeControl& aContainer )
|
|
382 |
{
|
|
383 |
CCoeControl::SetContainerWindowL( aContainer );
|
|
384 |
iRecurrence->SetContainerWindowL( aContainer );
|
|
385 |
|
|
386 |
iRecurrence->SetParent( this );
|
|
387 |
}
|
|
388 |
|
|
389 |
// EOF
|