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 alarm on off field implementation
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "emailtrace.h"
|
|
19 |
#include "cmralarmonofffield.h"
|
|
20 |
#include "cmrlabel.h"
|
|
21 |
#include "cmrimage.h"
|
|
22 |
#include "mesmrcalentry.h"
|
|
23 |
#include "mesmrlistobserver.h"
|
|
24 |
#include "mesmrfieldvalidator.h"
|
|
25 |
#include "nmrlayoutmanager.h"
|
|
26 |
|
|
27 |
#include <StringLoader.h>
|
|
28 |
#include <avkon.hrh>
|
|
29 |
#include <esmrgui.rsg>
|
|
30 |
#include <AknUtils.h>
|
|
31 |
|
|
32 |
|
|
33 |
// ======== MEMBER FUNCTIONS ========
|
|
34 |
|
|
35 |
// ---------------------------------------------------------------------------
|
|
36 |
// CMRAlarmOnOffField::NewL
|
|
37 |
// ---------------------------------------------------------------------------
|
|
38 |
//
|
|
39 |
CMRAlarmOnOffField* CMRAlarmOnOffField::NewL( MESMRFieldValidator* aValidator )
|
|
40 |
{
|
|
41 |
FUNC_LOG;
|
|
42 |
CMRAlarmOnOffField* self = new (ELeave) CMRAlarmOnOffField();
|
|
43 |
CleanupStack::PushL ( self );
|
|
44 |
self->ConstructL ( aValidator );
|
|
45 |
CleanupStack::Pop ( self );
|
|
46 |
return self;
|
|
47 |
}
|
|
48 |
|
|
49 |
// ---------------------------------------------------------------------------
|
|
50 |
// CMRAlarmOnOffField::CMRAlarmOnOffField
|
|
51 |
// ---------------------------------------------------------------------------
|
|
52 |
//
|
|
53 |
CMRAlarmOnOffField::CMRAlarmOnOffField()
|
|
54 |
{
|
|
55 |
FUNC_LOG;
|
|
56 |
iStatus = ETrue;
|
|
57 |
|
|
58 |
SetFieldId ( EESMRFieldAlarmOnOff );
|
|
59 |
SetFocusType ( EESMRHighlightFocus );
|
|
60 |
}
|
|
61 |
|
|
62 |
// ---------------------------------------------------------------------------
|
|
63 |
// CMRAlarmOnOffField::ConstructL
|
|
64 |
// ---------------------------------------------------------------------------
|
|
65 |
//
|
|
66 |
void CMRAlarmOnOffField::ConstructL( MESMRFieldValidator* aValidator )
|
|
67 |
{
|
|
68 |
FUNC_LOG;
|
|
69 |
iValidator = aValidator;
|
|
70 |
iValidator->SetAbsoluteAlarmOnOffFieldL( *this );
|
|
71 |
|
|
72 |
iIcon = CMRImage::NewL( NMRBitmapManager::EMRBitmapAlarm );
|
|
73 |
iIcon->SetParent( this );
|
|
74 |
|
|
75 |
iLabel = CMRLabel::NewL();
|
|
76 |
CESMRField::ConstructL( iLabel ); // ownership transfered
|
|
77 |
iLabel->SetTextL( KNullDesC() );
|
|
78 |
iLabel->SetParent( this );
|
|
79 |
}
|
|
80 |
|
|
81 |
// ---------------------------------------------------------------------------
|
|
82 |
// CMRAlarmOnOffField::~CMRAlarmOnOffField
|
|
83 |
// ---------------------------------------------------------------------------
|
|
84 |
//
|
|
85 |
CMRAlarmOnOffField::~CMRAlarmOnOffField( )
|
|
86 |
{
|
|
87 |
FUNC_LOG;
|
|
88 |
delete iIcon;
|
|
89 |
}
|
|
90 |
|
|
91 |
// ---------------------------------------------------------------------------
|
|
92 |
// CMRAlarmOnOffField::InternalizeL
|
|
93 |
// ---------------------------------------------------------------------------
|
|
94 |
//
|
|
95 |
void CMRAlarmOnOffField::InternalizeL( MESMRCalEntry& aEntry )
|
|
96 |
{
|
|
97 |
FUNC_LOG;
|
|
98 |
if ( aEntry.IsStoredL() ) // entry is already stored in db
|
|
99 |
{
|
|
100 |
MESMRCalEntry::TESMRAlarmType alarmType;
|
|
101 |
TTime alarmTime;
|
|
102 |
aEntry.GetAlarmL( alarmType, alarmTime );
|
|
103 |
|
|
104 |
switch( alarmType )
|
|
105 |
{
|
|
106 |
//flow through
|
|
107 |
case MESMRCalEntry::EESMRAlarmAbsolute:
|
|
108 |
case MESMRCalEntry::EESMRAlarmRelative: // Show alarm as - ON
|
|
109 |
{
|
|
110 |
iStatus = ETrue;
|
|
111 |
}
|
|
112 |
break;
|
|
113 |
//flow through
|
|
114 |
case MESMRCalEntry::EESMRAlarmNotFound:
|
|
115 |
default: // Show alarm as - OFF
|
|
116 |
{
|
|
117 |
iStatus = EFalse;
|
|
118 |
}
|
|
119 |
break;
|
|
120 |
}
|
|
121 |
}
|
|
122 |
else // This is a new entry and default implementation is required
|
|
123 |
{
|
|
124 |
switch( aEntry.Type() )
|
|
125 |
{
|
|
126 |
case MESMRCalEntry::EESMRCalEntryTodo: // To-do
|
|
127 |
{
|
|
128 |
TTime alarmTime;
|
|
129 |
MESMRCalEntry::TESMRAlarmType alarmType;
|
|
130 |
aEntry.GetAlarmL (alarmType, alarmTime );
|
|
131 |
|
|
132 |
// Change status to "ON" if alarm has been set by default
|
|
133 |
iStatus = alarmType != MESMRCalEntry::EESMRAlarmNotFound;
|
|
134 |
}
|
|
135 |
break;
|
|
136 |
// Flow through
|
|
137 |
case MESMRCalEntry::EESMRCalEntryMeetingRequest: // Meeting request
|
|
138 |
case MESMRCalEntry::EESMRCalEntryMeeting: // Meeting
|
|
139 |
{
|
|
140 |
iStatus = ETrue;// Change the status to "ON" for these dialog default
|
|
141 |
}
|
|
142 |
break;
|
|
143 |
|
|
144 |
case MESMRCalEntry::EESMRCalEntryAnniversary: // Anniversary
|
|
145 |
{
|
|
146 |
iStatus = ETrue;// Change the status to "ON" for these dialog default
|
|
147 |
}
|
|
148 |
break;
|
|
149 |
// Flow through
|
|
150 |
case MESMRCalEntry::EESMRCalEntryMemo: // Memo
|
|
151 |
case MESMRCalEntry::EESMRCalEntryReminder: // Reminder
|
|
152 |
|
|
153 |
default:
|
|
154 |
iStatus = EFalse; // Change the status to "OFF" for these dialog default
|
|
155 |
break;
|
|
156 |
}
|
|
157 |
}
|
|
158 |
ResetFieldL();
|
|
159 |
}
|
|
160 |
|
|
161 |
// ---------------------------------------------------------------------------
|
|
162 |
// CMRAlarmOnOffField::OfferKeyEventL
|
|
163 |
// ---------------------------------------------------------------------------
|
|
164 |
//
|
|
165 |
TKeyResponse CMRAlarmOnOffField::OfferKeyEventL( const TKeyEvent& aEvent,
|
|
166 |
TEventCode aType )
|
|
167 |
{
|
|
168 |
FUNC_LOG;
|
|
169 |
TKeyResponse response( EKeyWasNotConsumed );
|
|
170 |
if ( aType == EEventKey )
|
|
171 |
{
|
|
172 |
switch( aEvent.iScanCode )
|
|
173 |
{
|
|
174 |
// Flowthrough, doesn't matter which key was pressed since
|
|
175 |
// the value is always changes from "off" to "on" or vice versus.
|
|
176 |
case EStdKeyDevice3: // selection key
|
|
177 |
case EStdKeyLeftArrow:
|
|
178 |
case EStdKeyRightArrow:
|
|
179 |
iStatus = !iStatus; // change status
|
|
180 |
ResetFieldL();
|
|
181 |
response = EKeyWasConsumed;
|
|
182 |
break;
|
|
183 |
|
|
184 |
default:
|
|
185 |
break;
|
|
186 |
}
|
|
187 |
}
|
|
188 |
return response;
|
|
189 |
}
|
|
190 |
|
|
191 |
// ---------------------------------------------------------------------------
|
|
192 |
// CMRAlarmOnOffField::SetOutlineFocusL
|
|
193 |
// ---------------------------------------------------------------------------
|
|
194 |
//
|
|
195 |
void CMRAlarmOnOffField::SetOutlineFocusL( TBool aFocus )
|
|
196 |
{
|
|
197 |
FUNC_LOG;
|
|
198 |
CESMRField::SetOutlineFocusL( aFocus );
|
|
199 |
|
|
200 |
iLabel->SetFocus( aFocus );
|
|
201 |
|
|
202 |
if( aFocus ) //Focus is gained on the field
|
|
203 |
{
|
|
204 |
if ( iStatus )
|
|
205 |
{
|
|
206 |
ChangeMiddleSoftKeyL( EESMRCmdAlarmOff,R_QTN_MEET_REQ_ALARM_OFF ); //R_TEXT_SOFTKEY_OFF
|
|
207 |
}
|
|
208 |
else
|
|
209 |
{
|
|
210 |
ChangeMiddleSoftKeyL( EESMRCmdAlarmOn,R_QTN_MEET_REQ_ALARM_ON ); //R_TEXT_SOFTKEY_ON
|
|
211 |
}
|
|
212 |
}
|
|
213 |
}
|
|
214 |
|
|
215 |
// ---------------------------------------------------------------------------
|
|
216 |
// CMRAlarmOnOffField::MakeVisible
|
|
217 |
// ---------------------------------------------------------------------------
|
|
218 |
//
|
|
219 |
void CMRAlarmOnOffField::MakeVisible( TBool aVisible )
|
|
220 |
{
|
|
221 |
FUNC_LOG;
|
|
222 |
CCoeControl::MakeVisible( aVisible );
|
|
223 |
if ( iObserver )
|
|
224 |
{
|
|
225 |
TRAP_IGNORE( ResetFieldL() );
|
|
226 |
}
|
|
227 |
}
|
|
228 |
|
|
229 |
// ---------------------------------------------------------------------------
|
|
230 |
// CMRAlarmOnOffField::ExecuteGenericCommandL()
|
|
231 |
// ---------------------------------------------------------------------------
|
|
232 |
//
|
|
233 |
TBool CMRAlarmOnOffField::ExecuteGenericCommandL( TInt aCommand )
|
|
234 |
{
|
|
235 |
FUNC_LOG;
|
|
236 |
TBool isUsed( EFalse );
|
|
237 |
// EAknCmdOpen is added for the Pointer events, see ListPane
|
|
238 |
if( aCommand == EESMRCmdAlarmOn || aCommand == EESMRCmdAlarmOff
|
|
239 |
|| aCommand == EAknCmdOpen )
|
|
240 |
{
|
|
241 |
HandleTactileFeedbackL();
|
|
242 |
|
|
243 |
SwitchMiddleSoftKeyL();
|
|
244 |
isUsed = ETrue;
|
|
245 |
}
|
|
246 |
return isUsed;
|
|
247 |
}
|
|
248 |
|
|
249 |
// ---------------------------------------------------------------------------
|
|
250 |
// CMRAlarmOnOffField::SwitchMiddleSoftKeyL
|
|
251 |
// ---------------------------------------------------------------------------
|
|
252 |
//
|
|
253 |
void CMRAlarmOnOffField::SwitchMiddleSoftKeyL()
|
|
254 |
{
|
|
255 |
FUNC_LOG;
|
|
256 |
iStatus = !iStatus; // change status
|
|
257 |
ResetFieldL();
|
|
258 |
if( iStatus )
|
|
259 |
{
|
|
260 |
ChangeMiddleSoftKeyL( EESMRCmdAlarmOff,R_QTN_MEET_REQ_ALARM_OFF );
|
|
261 |
}
|
|
262 |
else
|
|
263 |
{
|
|
264 |
ChangeMiddleSoftKeyL( EESMRCmdAlarmOn,R_QTN_MEET_REQ_ALARM_ON );
|
|
265 |
}
|
|
266 |
|
|
267 |
if( iLabel->IsVisible() )
|
|
268 |
{
|
|
269 |
iLabel->DrawDeferred();
|
|
270 |
}
|
|
271 |
}
|
|
272 |
|
|
273 |
// ---------------------------------------------------------------------------
|
|
274 |
// CMRAlarmOnOffField::ResetFieldL
|
|
275 |
// ---------------------------------------------------------------------------
|
|
276 |
//
|
|
277 |
void CMRAlarmOnOffField::ResetFieldL()
|
|
278 |
{
|
|
279 |
FUNC_LOG;
|
|
280 |
iValidator->SetAlarmOnOffL( iStatus );
|
|
281 |
|
|
282 |
HBufC* buf = StringLoader::LoadLC( iStatus ?
|
|
283 |
R_QTN_MEET_REQ_ALARM_ON :
|
|
284 |
R_QTN_MEET_REQ_ALARM_OFF );
|
|
285 |
|
|
286 |
iLabel->SetTextL( *buf );
|
|
287 |
CleanupStack::PopAndDestroy( buf );
|
|
288 |
|
|
289 |
// if status on 'on', add time and date fields for
|
|
290 |
// all day event alert, otherwise remove them.
|
|
291 |
// if this field is not visible -> alldayevent not set
|
|
292 |
// let's not show the date and time fields either.
|
|
293 |
if ( iStatus && IsVisible() )
|
|
294 |
{
|
|
295 |
iObserver->ShowControl ( EESMRFieldAlarmTime );
|
|
296 |
iObserver->ShowControl ( EESMRFieldAlarmDate );
|
|
297 |
}
|
|
298 |
else
|
|
299 |
{
|
|
300 |
iObserver->HideControl ( EESMRFieldAlarmTime );
|
|
301 |
iObserver->HideControl ( EESMRFieldAlarmDate );
|
|
302 |
}
|
|
303 |
}
|
|
304 |
|
|
305 |
// ---------------------------------------------------------------------------
|
|
306 |
// CMRAlarmOnOffField::SizeChanged()
|
|
307 |
// ---------------------------------------------------------------------------
|
|
308 |
//
|
|
309 |
void CMRAlarmOnOffField::SizeChanged()
|
|
310 |
{
|
|
311 |
FUNC_LOG;
|
|
312 |
TRect rect = Rect();
|
|
313 |
TAknLayoutRect rowLayoutRect =
|
|
314 |
NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 );
|
|
315 |
rect = rowLayoutRect.Rect();
|
|
316 |
|
|
317 |
TAknWindowComponentLayout iconLayout =
|
|
318 |
NMRLayoutManager::GetWindowComponentLayout(
|
|
319 |
NMRLayoutManager::EMRLayoutTextEditorIcon );
|
|
320 |
AknLayoutUtils::LayoutImage( iIcon, rect, iconLayout );
|
|
321 |
|
|
322 |
TAknLayoutRect bgLayoutRect =
|
|
323 |
NMRLayoutManager::GetLayoutRect(
|
|
324 |
rect, NMRLayoutManager::EMRLayoutTextEditorBg );
|
|
325 |
TRect bgRect( bgLayoutRect.Rect() );
|
|
326 |
// Move focus rect so that it's relative to field's position.
|
|
327 |
bgRect.Move( -Position() );
|
|
328 |
SetFocusRect( bgRect );
|
|
329 |
|
|
330 |
TAknTextComponentLayout labelLayout =
|
|
331 |
NMRLayoutManager::GetTextComponentLayout(
|
|
332 |
NMRLayoutManager::EMRTextLayoutTextEditor );
|
|
333 |
AknLayoutUtils::LayoutLabel( iLabel, rect, labelLayout );
|
|
334 |
}
|
|
335 |
|
|
336 |
// ---------------------------------------------------------------------------
|
|
337 |
// CMRAlarmOnOffField::CountComponentControls()
|
|
338 |
// ---------------------------------------------------------------------------
|
|
339 |
//
|
|
340 |
TInt CMRAlarmOnOffField::CountComponentControls() const
|
|
341 |
{
|
|
342 |
FUNC_LOG;
|
|
343 |
TInt count( 0 );
|
|
344 |
if ( iIcon )
|
|
345 |
{
|
|
346 |
++count;
|
|
347 |
}
|
|
348 |
|
|
349 |
if ( iLabel )
|
|
350 |
{
|
|
351 |
++count;
|
|
352 |
}
|
|
353 |
return count;
|
|
354 |
}
|
|
355 |
|
|
356 |
// ---------------------------------------------------------------------------
|
|
357 |
// CMRAlarmOnOffField::ComponentControl()
|
|
358 |
// ---------------------------------------------------------------------------
|
|
359 |
//
|
|
360 |
CCoeControl* CMRAlarmOnOffField::ComponentControl( TInt aIndex ) const
|
|
361 |
{
|
|
362 |
FUNC_LOG;
|
|
363 |
switch ( aIndex )
|
|
364 |
{
|
|
365 |
case 0:
|
|
366 |
return iIcon;
|
|
367 |
case 1:
|
|
368 |
return iLabel;
|
|
369 |
default:
|
|
370 |
return NULL;
|
|
371 |
}
|
|
372 |
}
|
|
373 |
|
|
374 |
// ---------------------------------------------------------------------------
|
|
375 |
// CMRAlarmOnOffField::SetContainerWindowL
|
|
376 |
// ---------------------------------------------------------------------------
|
|
377 |
//
|
|
378 |
void CMRAlarmOnOffField::SetContainerWindowL(
|
|
379 |
const CCoeControl& aContainer )
|
|
380 |
{
|
|
381 |
FUNC_LOG;
|
|
382 |
CCoeControl::SetContainerWindowL( aContainer );
|
|
383 |
iLabel->SetContainerWindowL( aContainer );
|
|
384 |
iLabel->SetParent( this );
|
|
385 |
}
|
|
386 |
|
|
387 |
// ---------------------------------------------------------------------------
|
|
388 |
// CMRAlarmOnOffField::SetAbsoluteAlarmOn
|
|
389 |
// ---------------------------------------------------------------------------
|
|
390 |
//
|
|
391 |
void CMRAlarmOnOffField::SetAbsoluteAlarmOn()
|
|
392 |
{
|
|
393 |
FUNC_LOG;
|
|
394 |
iStatus = ETrue;
|
|
395 |
}
|
|
396 |
|
|
397 |
// ---------------------------------------------------------------------------
|
|
398 |
// CMRAlarmOnOffField::SetAbsoluteAlarmOn
|
|
399 |
// ---------------------------------------------------------------------------
|
|
400 |
//
|
|
401 |
void CMRAlarmOnOffField::SetAbsoluteAlarmOff()
|
|
402 |
{
|
|
403 |
FUNC_LOG;
|
|
404 |
iStatus = EFalse;
|
|
405 |
}
|
|
406 |
|
|
407 |
// EOF
|