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 priority field implementation
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "cesmrpriorityfield.h"
|
|
19 |
|
|
20 |
#include "cesmrlistquery.h"
|
|
21 |
#include "nmrcolormanager.h"
|
|
22 |
#include "cmrimage.h"
|
|
23 |
#include "cmrlabel.h"
|
|
24 |
#include "nmrlayoutmanager.h"
|
|
25 |
#include "nmrbitmapmanager.h"
|
|
26 |
#include "mesmrtitlepaneobserver.h"
|
|
27 |
|
|
28 |
#include <calentry.h>
|
|
29 |
#include <esmrgui.rsg>
|
|
30 |
#include <StringLoader.h>
|
|
31 |
#include <barsread.h>
|
|
32 |
#include <eiklabel.h>
|
|
33 |
#include <avkon.hrh>
|
|
34 |
#include <AknsConstants.h>
|
|
35 |
#include <AknUtils.h>
|
|
36 |
|
|
37 |
#include "emailtrace.h"
|
|
38 |
|
|
39 |
// ======== MEMBER FUNCTIONS ========
|
|
40 |
|
|
41 |
// ---------------------------------------------------------------------------
|
|
42 |
// CESMRPriorityField::CESMRPriorityField
|
|
43 |
// ---------------------------------------------------------------------------
|
|
44 |
//
|
|
45 |
CESMRPriorityField::CESMRPriorityField()
|
|
46 |
{
|
|
47 |
FUNC_LOG;
|
|
48 |
SetFieldId( EESMRFieldPriority );
|
|
49 |
SetFocusType( EESMRHighlightFocus );
|
|
50 |
}
|
|
51 |
|
|
52 |
// ---------------------------------------------------------------------------
|
|
53 |
// CESMRPriorityField::~CESMRPriorityField
|
|
54 |
// ---------------------------------------------------------------------------
|
|
55 |
//
|
|
56 |
CESMRPriorityField::~CESMRPriorityField()
|
|
57 |
{
|
|
58 |
FUNC_LOG;
|
|
59 |
iArray.ResetAndDestroy();
|
|
60 |
iArray.Close();
|
|
61 |
|
|
62 |
delete iIcon;
|
|
63 |
}
|
|
64 |
|
|
65 |
// ---------------------------------------------------------------------------
|
|
66 |
// CESMRPriorityField::NewL
|
|
67 |
// ---------------------------------------------------------------------------
|
|
68 |
//
|
|
69 |
CESMRPriorityField* CESMRPriorityField::NewL()
|
|
70 |
{
|
|
71 |
FUNC_LOG;
|
|
72 |
CESMRPriorityField* self = new (ELeave) CESMRPriorityField;
|
|
73 |
CleanupStack::PushL ( self );
|
|
74 |
self->ConstructL ( );
|
|
75 |
CleanupStack::Pop ( self );
|
|
76 |
return self;
|
|
77 |
}
|
|
78 |
|
|
79 |
// ---------------------------------------------------------------------------
|
|
80 |
// CESMRPriorityField::ConstructL
|
|
81 |
// ---------------------------------------------------------------------------
|
|
82 |
//
|
|
83 |
void CESMRPriorityField::ConstructL()
|
|
84 |
{
|
|
85 |
FUNC_LOG;
|
|
86 |
iLabel = CMRLabel::NewL();
|
|
87 |
iLabel->SetParent( this );
|
|
88 |
CESMRField::ConstructL( iLabel ); // ownership transfered
|
|
89 |
|
|
90 |
iIcon = CMRImage::NewL( NMRBitmapManager::EMRBitmapPriorityNormal );
|
|
91 |
iIcon->SetParent( this );
|
|
92 |
}
|
|
93 |
|
|
94 |
// ---------------------------------------------------------------------------
|
|
95 |
// CESMRPriorityField::InitializeL
|
|
96 |
// ---------------------------------------------------------------------------
|
|
97 |
//
|
|
98 |
void CESMRPriorityField::InitializeL()
|
|
99 |
{
|
|
100 |
FUNC_LOG;
|
|
101 |
NMRColorManager::SetColor( *iLabel,
|
|
102 |
NMRColorManager::EMRMainAreaTextColor );
|
|
103 |
}
|
|
104 |
|
|
105 |
// ---------------------------------------------------------------------------
|
|
106 |
// CESMRPriorityField::InternalizeL
|
|
107 |
// ---------------------------------------------------------------------------
|
|
108 |
//
|
|
109 |
void CESMRPriorityField::InternalizeL( MESMRCalEntry& aEntry )
|
|
110 |
{
|
|
111 |
FUNC_LOG;
|
|
112 |
TInt prior = aEntry.GetPriorityL ( );
|
|
113 |
|
|
114 |
iEntryType = aEntry.Type();
|
|
115 |
|
|
116 |
// esmrgui.rss
|
|
117 |
TResourceReader reader;
|
|
118 |
TInt resourceId(KErrNotFound);
|
|
119 |
if ( aEntry.Type() == MESMRCalEntry::EESMRCalEntryTodo )
|
|
120 |
{
|
|
121 |
resourceId = R_ESMREDITOR_TODO_PRIORITY;
|
|
122 |
}
|
|
123 |
else
|
|
124 |
{
|
|
125 |
resourceId = R_ESMREDITOR_PRIORITY;
|
|
126 |
}
|
|
127 |
|
|
128 |
iCoeEnv->CreateResourceReaderLC ( reader, resourceId );
|
|
129 |
|
|
130 |
iArray.Reset ( );
|
|
131 |
// Read priority items to array
|
|
132 |
TInt count = reader.ReadInt16 ( );
|
|
133 |
for (TInt i(0); i < count; i++ )
|
|
134 |
{
|
|
135 |
CESMRPriority* priority = new (ELeave) CESMRPriority;
|
|
136 |
CleanupStack::PushL ( priority );
|
|
137 |
priority->ConstructFromResourceL ( reader );
|
|
138 |
iArray.AppendL ( priority );
|
|
139 |
CleanupStack::Pop ( priority );
|
|
140 |
if ( priority->Id ( )== prior )
|
|
141 |
{
|
|
142 |
iIndex = i;
|
|
143 |
UpdateTextL ( iIndex );
|
|
144 |
}
|
|
145 |
}
|
|
146 |
// reader
|
|
147 |
CleanupStack::PopAndDestroy(); // codescanner::cleanup
|
|
148 |
}
|
|
149 |
|
|
150 |
// ---------------------------------------------------------------------------
|
|
151 |
// CESMRPriorityField::ExternalizeL
|
|
152 |
// ---------------------------------------------------------------------------
|
|
153 |
//
|
|
154 |
void CESMRPriorityField::ExternalizeL( MESMRCalEntry& aEntry )
|
|
155 |
{
|
|
156 |
FUNC_LOG;
|
|
157 |
if ( iIndex < iArray.Count() )
|
|
158 |
{
|
|
159 |
CCalEntry& calEntry = aEntry.Entry ( );
|
|
160 |
calEntry.SetPriorityL ( iArray[iIndex]->Id ( ) );
|
|
161 |
}
|
|
162 |
else
|
|
163 |
{
|
|
164 |
User::Leave( KErrOverflow );
|
|
165 |
}
|
|
166 |
}
|
|
167 |
|
|
168 |
// ---------------------------------------------------------------------------
|
|
169 |
// CESMRPriorityField::SetOutlineFocusL
|
|
170 |
// ---------------------------------------------------------------------------
|
|
171 |
//
|
|
172 |
void CESMRPriorityField::SetOutlineFocusL( TBool aFocus )
|
|
173 |
{
|
|
174 |
FUNC_LOG;
|
|
175 |
CESMRField::SetOutlineFocusL ( aFocus );
|
|
176 |
iLabel->SetFocus( aFocus );
|
|
177 |
|
|
178 |
//Focus gained
|
|
179 |
if ( aFocus )
|
|
180 |
{
|
|
181 |
ChangeMiddleSoftKeyL(EESMRCmdOpenPriorityQuery, R_QTN_MSK_OPEN);
|
|
182 |
}
|
|
183 |
}
|
|
184 |
|
|
185 |
// ---------------------------------------------------------------------------
|
|
186 |
// CESMRPriorityField::SizeChanged()
|
|
187 |
// ---------------------------------------------------------------------------
|
|
188 |
//
|
|
189 |
void CESMRPriorityField::SizeChanged()
|
|
190 |
{
|
|
191 |
FUNC_LOG;
|
|
192 |
TRect rect = Rect();
|
|
193 |
TAknLayoutRect rowLayoutRect =
|
|
194 |
NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 );
|
|
195 |
rect = rowLayoutRect.Rect();
|
|
196 |
|
|
197 |
TAknWindowComponentLayout iconLayout =
|
|
198 |
NMRLayoutManager::GetWindowComponentLayout(
|
|
199 |
NMRLayoutManager::EMRLayoutTextEditorIcon );
|
|
200 |
AknLayoutUtils::LayoutImage( iIcon, rect, iconLayout );
|
|
201 |
|
|
202 |
TAknLayoutRect bgLayoutRect =
|
|
203 |
NMRLayoutManager::GetLayoutRect(
|
|
204 |
rect, NMRLayoutManager::EMRLayoutTextEditorBg );
|
|
205 |
TRect bgRect( bgLayoutRect.Rect() );
|
|
206 |
// Move focus rect so that it's relative to field's position.
|
|
207 |
bgRect.Move( -Position() );
|
|
208 |
SetFocusRect( bgRect );
|
|
209 |
|
|
210 |
TAknTextComponentLayout editorLayout =
|
|
211 |
NMRLayoutManager::GetTextComponentLayout(
|
|
212 |
NMRLayoutManager::EMRTextLayoutTextEditor );
|
|
213 |
|
|
214 |
AknLayoutUtils::LayoutLabel( iLabel, rect, editorLayout );
|
|
215 |
}
|
|
216 |
|
|
217 |
// ---------------------------------------------------------------------------
|
|
218 |
// CESMRPriorityField::CountComponentControls()
|
|
219 |
// ---------------------------------------------------------------------------
|
|
220 |
//
|
|
221 |
TInt CESMRPriorityField::CountComponentControls() const
|
|
222 |
{
|
|
223 |
FUNC_LOG;
|
|
224 |
TInt count( 0 );
|
|
225 |
if ( iIcon )
|
|
226 |
{
|
|
227 |
++count;
|
|
228 |
}
|
|
229 |
|
|
230 |
if ( iLabel )
|
|
231 |
{
|
|
232 |
++count;
|
|
233 |
}
|
|
234 |
return count;
|
|
235 |
}
|
|
236 |
|
|
237 |
// ---------------------------------------------------------------------------
|
|
238 |
// CESMRPriorityField::ComponentControl()
|
|
239 |
// ---------------------------------------------------------------------------
|
|
240 |
//
|
|
241 |
CCoeControl* CESMRPriorityField::ComponentControl( TInt aIndex ) const
|
|
242 |
{
|
|
243 |
FUNC_LOG;
|
|
244 |
switch ( aIndex )
|
|
245 |
{
|
|
246 |
case 0:
|
|
247 |
return iIcon;
|
|
248 |
case 1:
|
|
249 |
return iLabel;
|
|
250 |
default:
|
|
251 |
return NULL;
|
|
252 |
}
|
|
253 |
}
|
|
254 |
|
|
255 |
|
|
256 |
|
|
257 |
// ---------------------------------------------------------------------------
|
|
258 |
// CESMRPriorityField::ExecuteGenericCommandL()
|
|
259 |
// ---------------------------------------------------------------------------
|
|
260 |
//
|
|
261 |
TBool CESMRPriorityField::ExecuteGenericCommandL( TInt aCommand )
|
|
262 |
{
|
|
263 |
FUNC_LOG;
|
|
264 |
TBool isUsed( EFalse );
|
|
265 |
if( aCommand == EESMRCmdOpenPriorityQuery ||
|
|
266 |
aCommand == EAknCmdOpen )
|
|
267 |
{
|
|
268 |
HandleTactileFeedbackL();
|
|
269 |
|
|
270 |
ExecutePriorityQueryL();
|
|
271 |
isUsed = ETrue;
|
|
272 |
}
|
|
273 |
return isUsed;
|
|
274 |
}
|
|
275 |
|
|
276 |
// ---------------------------------------------------------------------------
|
|
277 |
// CESMRPriorityField::ExecutePriorityQueryL
|
|
278 |
// ---------------------------------------------------------------------------
|
|
279 |
//
|
|
280 |
void CESMRPriorityField::ExecutePriorityQueryL()
|
|
281 |
{
|
|
282 |
FUNC_LOG;
|
|
283 |
|
|
284 |
TInt ret(KErrNone);
|
|
285 |
if ( iEntryType == MESMRCalEntry::EESMRCalEntryTodo)
|
|
286 |
{
|
|
287 |
ret = CESMRListQuery::ExecuteL (CESMRListQuery::EESMRTodoPriorityPopup );
|
|
288 |
}
|
|
289 |
else
|
|
290 |
{
|
|
291 |
ret = CESMRListQuery::ExecuteL (CESMRListQuery::EESMRPriorityPopup );
|
|
292 |
}
|
|
293 |
|
|
294 |
if ( ret != KErrCancel )
|
|
295 |
{
|
|
296 |
// ret is priority value, not index
|
|
297 |
for ( TInt i=0; i<iArray.Count(); ++i )
|
|
298 |
{
|
|
299 |
if ( iArray[i]->Id() == ret )
|
|
300 |
{
|
|
301 |
iIndex = i;
|
|
302 |
UpdateTextL( iIndex );
|
|
303 |
break;
|
|
304 |
}
|
|
305 |
}
|
|
306 |
}
|
|
307 |
|
|
308 |
}
|
|
309 |
|
|
310 |
// ---------------------------------------------------------------------------
|
|
311 |
// CESMRPriorityField::OfferKeyEventL
|
|
312 |
// ---------------------------------------------------------------------------
|
|
313 |
//
|
|
314 |
TKeyResponse CESMRPriorityField::OfferKeyEventL(const TKeyEvent& aEvent,
|
|
315 |
TEventCode aType )
|
|
316 |
{
|
|
317 |
FUNC_LOG;
|
|
318 |
TKeyResponse response( EKeyWasNotConsumed);
|
|
319 |
if ( aType == EEventKey )
|
|
320 |
{
|
|
321 |
switch ( aEvent.iScanCode )
|
|
322 |
{
|
|
323 |
case EStdKeyLeftArrow:
|
|
324 |
{
|
|
325 |
if ( iIndex > 0 )
|
|
326 |
{
|
|
327 |
UpdateTextL ( --iIndex );
|
|
328 |
response = EKeyWasConsumed;
|
|
329 |
}
|
|
330 |
}
|
|
331 |
break;
|
|
332 |
case EStdKeyRightArrow:
|
|
333 |
{
|
|
334 |
if ( iIndex < iArray.Count ( )- 1 )
|
|
335 |
{
|
|
336 |
UpdateTextL ( ++iIndex );
|
|
337 |
response = EKeyWasConsumed;
|
|
338 |
}
|
|
339 |
}
|
|
340 |
break;
|
|
341 |
case EStdKeyDevice3:
|
|
342 |
{
|
|
343 |
TInt ret(KErrNone);
|
|
344 |
if ( iEntryType == MESMRCalEntry::EESMRCalEntryTodo)
|
|
345 |
{
|
|
346 |
ret = CESMRListQuery::ExecuteL (CESMRListQuery::EESMRTodoPriorityPopup );
|
|
347 |
}
|
|
348 |
else
|
|
349 |
{
|
|
350 |
ret = CESMRListQuery::ExecuteL (CESMRListQuery::EESMRPriorityPopup );
|
|
351 |
}
|
|
352 |
if ( ret != KErrCancel )
|
|
353 |
{
|
|
354 |
// ret is priority value, not index
|
|
355 |
for ( TInt i=0; i<iArray.Count(); ++i )
|
|
356 |
{
|
|
357 |
if ( iArray[i]->Id() == ret )
|
|
358 |
{
|
|
359 |
iIndex = i;
|
|
360 |
UpdateTextL( iIndex );
|
|
361 |
break;
|
|
362 |
}
|
|
363 |
}
|
|
364 |
}
|
|
365 |
response = EKeyWasConsumed;
|
|
366 |
}
|
|
367 |
break;
|
|
368 |
default:
|
|
369 |
break;
|
|
370 |
}
|
|
371 |
}
|
|
372 |
return response;
|
|
373 |
}
|
|
374 |
|
|
375 |
// ---------------------------------------------------------------------------
|
|
376 |
// CESMRPriorityField::UpdateTextL
|
|
377 |
// ---------------------------------------------------------------------------
|
|
378 |
//
|
|
379 |
void CESMRPriorityField::UpdateTextL( TInt aIndex )
|
|
380 |
{
|
|
381 |
FUNC_LOG;
|
|
382 |
CESMRPriority* priority = iArray[ aIndex ];
|
|
383 |
iLabel->SetTextL ( priority->Text ( ) );
|
|
384 |
|
|
385 |
NMRBitmapManager::TMRBitmapId bitmapId(
|
|
386 |
NMRBitmapManager::EMRBitmapPriorityNormal );
|
|
387 |
|
|
388 |
switch ( priority->Id() )
|
|
389 |
{
|
|
390 |
case EFSCalenMRPriorityLow:
|
|
391 |
case EFSCalenTodoPriorityLow:
|
|
392 |
{
|
|
393 |
bitmapId = NMRBitmapManager::EMRBitmapPriorityLow;
|
|
394 |
break;
|
|
395 |
}
|
|
396 |
case EFSCalenMRPriorityUnknown:
|
|
397 |
case EFSCalenMRPriorityNormal:
|
|
398 |
case EFSCalenTodoPriorityNormal:
|
|
399 |
{
|
|
400 |
bitmapId = NMRBitmapManager::EMRBitmapPriorityNormal;
|
|
401 |
break;
|
|
402 |
}
|
|
403 |
case EFSCalenMRPriorityHigh: // same value as EFSCalenTodoPriorityHigh
|
|
404 |
{
|
|
405 |
bitmapId = NMRBitmapManager::EMRBitmapPriorityHigh;
|
|
406 |
break;
|
|
407 |
}
|
|
408 |
default:
|
|
409 |
ASSERT(EFalse);
|
|
410 |
break;
|
|
411 |
}
|
|
412 |
|
|
413 |
delete iIcon;
|
|
414 |
iIcon = NULL;
|
|
415 |
iIcon = CMRImage::NewL( bitmapId );
|
|
416 |
iIcon->SetParent( this );
|
|
417 |
|
|
418 |
// This needs to be called so icon will be redrawn
|
|
419 |
SizeChanged();
|
|
420 |
DrawDeferred();
|
|
421 |
}
|
|
422 |
|
|
423 |
// EOF
|
|
424 |
|