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: Priority field for viewers
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "cesmrviewerpriorityfield.h"
|
|
19 |
|
|
20 |
#include "esmrdef.h"
|
|
21 |
#include "mesmrlistobserver.h"
|
|
22 |
#include "cmrimage.h"
|
|
23 |
#include "cmrlabel.h"
|
|
24 |
#include "nmrlayoutmanager.h"
|
|
25 |
#include "nmrbitmapmanager.h"
|
|
26 |
#include "cesmrglobalnote.h"
|
|
27 |
|
|
28 |
#include <calentry.h>
|
|
29 |
#include <eikenv.h>
|
|
30 |
#include <StringLoader.h>
|
|
31 |
#include <esmrgui.rsg>
|
|
32 |
|
|
33 |
// DEBUG
|
|
34 |
#include "emailtrace.h"
|
|
35 |
|
|
36 |
// ======== MEMBER FUNCTIONS ========
|
|
37 |
|
|
38 |
// ---------------------------------------------------------------------------
|
|
39 |
// CESMRViewerPriorityField::NewL()
|
|
40 |
// ---------------------------------------------------------------------------
|
|
41 |
//
|
|
42 |
CESMRViewerPriorityField* CESMRViewerPriorityField::NewL()
|
|
43 |
{
|
|
44 |
FUNC_LOG;
|
|
45 |
CESMRViewerPriorityField* self = new (ELeave) CESMRViewerPriorityField();
|
|
46 |
CleanupStack::PushL( self );
|
|
47 |
self->ConstructL();
|
|
48 |
CleanupStack::Pop( self );
|
|
49 |
return self;
|
|
50 |
}
|
|
51 |
|
|
52 |
// ---------------------------------------------------------------------------
|
|
53 |
// CESMRViewerPriorityField::~CESMRViewerPriorityField()
|
|
54 |
// ---------------------------------------------------------------------------
|
|
55 |
//
|
|
56 |
CESMRViewerPriorityField::~CESMRViewerPriorityField()
|
|
57 |
{
|
|
58 |
FUNC_LOG;
|
|
59 |
delete iIcon;
|
|
60 |
delete iLockIcon;
|
|
61 |
}
|
|
62 |
|
|
63 |
// ---------------------------------------------------------------------------
|
|
64 |
// CESMRViewerPriorityField::CESMRViewerPriorityField()
|
|
65 |
// ---------------------------------------------------------------------------
|
|
66 |
//
|
|
67 |
CESMRViewerPriorityField::CESMRViewerPriorityField()
|
|
68 |
{
|
|
69 |
FUNC_LOG;
|
|
70 |
SetFieldId( EESMRFieldPriority );
|
|
71 |
SetFocusType( EESMRHighlightFocus );
|
|
72 |
}
|
|
73 |
|
|
74 |
// ---------------------------------------------------------------------------
|
|
75 |
// CESMRViewerPriorityField::ConstructL()
|
|
76 |
// ---------------------------------------------------------------------------
|
|
77 |
//
|
|
78 |
void CESMRViewerPriorityField::ConstructL()
|
|
79 |
{
|
|
80 |
FUNC_LOG;
|
|
81 |
iLabel = CMRLabel::NewL( this );
|
|
82 |
CESMRField::ConstructL( iLabel ); // ownership transfered
|
|
83 |
|
|
84 |
iIcon = CMRImage::NewL( NMRBitmapManager::EMRBitmapPriorityNormal, this );
|
|
85 |
|
|
86 |
HBufC* priorityText = StringLoader::LoadLC(
|
|
87 |
R_QTN_CALENDAR_MEETING_OPT_PRIORITY_NORMAL,
|
|
88 |
iEikonEnv );
|
|
89 |
iLabel->SetTextL( *priorityText );
|
|
90 |
CleanupStack::PopAndDestroy( priorityText );
|
|
91 |
}
|
|
92 |
|
|
93 |
// ---------------------------------------------------------------------------
|
|
94 |
// CESMRViewerPriorityField::InternalizeL()
|
|
95 |
// ---------------------------------------------------------------------------
|
|
96 |
//
|
|
97 |
void CESMRViewerPriorityField::InternalizeL( MESMRCalEntry& aEntry )
|
|
98 |
{
|
|
99 |
FUNC_LOG;
|
|
100 |
// Get the priority
|
|
101 |
TInt priority = aEntry.GetPriorityL();
|
|
102 |
|
|
103 |
HBufC* priorityText;
|
|
104 |
TInt resourceId(KErrNotFound);
|
|
105 |
NMRBitmapManager::TMRBitmapId bitmapId;
|
|
106 |
|
|
107 |
if ( aEntry.Type() == MESMRCalEntry::EESMRCalEntryTodo )
|
|
108 |
{
|
|
109 |
switch( priority )
|
|
110 |
{
|
|
111 |
case EFSCalenTodoPriorityLow:
|
|
112 |
{
|
|
113 |
resourceId = R_QTN_CALENDAR_MEETING_OPT_PRIORITY_LOW;
|
|
114 |
bitmapId = NMRBitmapManager::EMRBitmapPriorityLow;
|
|
115 |
break;
|
|
116 |
}
|
|
117 |
case EFSCalenTodoPriorityHigh:
|
|
118 |
{
|
|
119 |
resourceId = R_QTN_CALENDAR_MEETING_OPT_PRIORITY_HIGH;
|
|
120 |
bitmapId = NMRBitmapManager::EMRBitmapPriorityHigh;
|
|
121 |
break;
|
|
122 |
}
|
|
123 |
default:
|
|
124 |
{
|
|
125 |
// Do nothing, priority normal remains
|
|
126 |
break;
|
|
127 |
}
|
|
128 |
}
|
|
129 |
}
|
|
130 |
else
|
|
131 |
{
|
|
132 |
switch( priority )
|
|
133 |
{
|
|
134 |
case EFSCalenMRPriorityLow:
|
|
135 |
{
|
|
136 |
resourceId = R_QTN_CALENDAR_MEETING_OPT_PRIORITY_LOW;
|
|
137 |
bitmapId = NMRBitmapManager::EMRBitmapPriorityLow;
|
|
138 |
break;
|
|
139 |
}
|
|
140 |
case EFSCalenMRPriorityHigh:
|
|
141 |
{
|
|
142 |
resourceId = R_QTN_CALENDAR_MEETING_OPT_PRIORITY_HIGH;
|
|
143 |
bitmapId = NMRBitmapManager::EMRBitmapPriorityHigh;
|
|
144 |
break;
|
|
145 |
}
|
|
146 |
default:
|
|
147 |
{
|
|
148 |
// Do nothing, priority normal remains
|
|
149 |
break;
|
|
150 |
}
|
|
151 |
}
|
|
152 |
}
|
|
153 |
|
|
154 |
// if not changed, the default set in ConstructL will be used:
|
|
155 |
if ( resourceId != KErrNotFound )
|
|
156 |
{
|
|
157 |
priorityText = StringLoader::LoadLC( resourceId,
|
|
158 |
iEikonEnv );
|
|
159 |
iLabel->SetTextL( *priorityText );
|
|
160 |
CleanupStack::PopAndDestroy( priorityText );
|
|
161 |
|
|
162 |
delete iIcon;
|
|
163 |
iIcon = NULL;
|
|
164 |
iIcon = CMRImage::NewL( bitmapId, this );
|
|
165 |
|
|
166 |
// This needs to be called so icon will be redrawn
|
|
167 |
SizeChanged();
|
|
168 |
}
|
|
169 |
}
|
|
170 |
|
|
171 |
// ---------------------------------------------------------------------------
|
|
172 |
// CESMRViewerPriorityField::SizeChanged()
|
|
173 |
// ---------------------------------------------------------------------------
|
|
174 |
//
|
|
175 |
void CESMRViewerPriorityField::SizeChanged()
|
|
176 |
{
|
|
177 |
FUNC_LOG;
|
|
178 |
TRect rect = Rect();
|
|
179 |
TAknLayoutRect rowLayoutRect =
|
|
180 |
NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 );
|
|
181 |
rect = rowLayoutRect.Rect();
|
|
182 |
|
|
183 |
TAknWindowComponentLayout iconLayout =
|
|
184 |
NMRLayoutManager::GetWindowComponentLayout(
|
|
185 |
NMRLayoutManager::EMRLayoutTextEditorIcon );
|
|
186 |
AknLayoutUtils::LayoutImage( iIcon, rect, iconLayout );
|
|
187 |
|
|
188 |
// Layouting lock icon
|
|
189 |
if( iLockIcon )
|
|
190 |
{
|
|
191 |
TAknWindowComponentLayout iconLayout(
|
|
192 |
NMRLayoutManager::GetWindowComponentLayout(
|
|
193 |
NMRLayoutManager::EMRLayoutSingleRowDColumnGraphic ) );
|
|
194 |
AknLayoutUtils::LayoutImage( iLockIcon, rect, iconLayout );
|
|
195 |
}
|
|
196 |
|
|
197 |
// Layouting label
|
|
198 |
TAknTextComponentLayout viewerLayoutText;
|
|
199 |
|
|
200 |
if( iLockIcon )
|
|
201 |
{
|
|
202 |
viewerLayoutText = NMRLayoutManager::GetTextComponentLayout(
|
|
203 |
NMRLayoutManager::EMRTextLayoutSingleRowEditorText );
|
|
204 |
}
|
|
205 |
else
|
|
206 |
{
|
|
207 |
viewerLayoutText = NMRLayoutManager::GetTextComponentLayout(
|
|
208 |
NMRLayoutManager::EMRTextLayoutTextEditor );
|
|
209 |
}
|
|
210 |
|
|
211 |
AknLayoutUtils::LayoutLabel( iLabel, rect, viewerLayoutText );
|
|
212 |
TRect viewerRect( iLabel->Rect() );
|
|
213 |
|
|
214 |
// Move focus rect so that it's relative to field's position.
|
|
215 |
viewerRect.Move( -Position() );
|
|
216 |
SetFocusRect( viewerRect );
|
|
217 |
}
|
|
218 |
|
|
219 |
// ---------------------------------------------------------------------------
|
|
220 |
// CESMRViewerPriorityField::CountComponentControls()
|
|
221 |
// ---------------------------------------------------------------------------
|
|
222 |
//
|
|
223 |
TInt CESMRViewerPriorityField::CountComponentControls() const
|
|
224 |
{
|
|
225 |
FUNC_LOG;
|
|
226 |
TInt count( 0 );
|
|
227 |
if ( iIcon )
|
|
228 |
{
|
|
229 |
++count;
|
|
230 |
}
|
|
231 |
|
|
232 |
if ( iLabel )
|
|
233 |
{
|
|
234 |
++count;
|
|
235 |
}
|
|
236 |
if ( iLockIcon )
|
|
237 |
{
|
|
238 |
++count;
|
|
239 |
}
|
|
240 |
return count;
|
|
241 |
}
|
|
242 |
|
|
243 |
// ---------------------------------------------------------------------------
|
|
244 |
// CESMRViewerPriorityField::ComponentControl()
|
|
245 |
// ---------------------------------------------------------------------------
|
|
246 |
//
|
|
247 |
CCoeControl* CESMRViewerPriorityField::ComponentControl( TInt aIndex ) const
|
|
248 |
{
|
|
249 |
FUNC_LOG;
|
|
250 |
switch ( aIndex )
|
|
251 |
{
|
|
252 |
case 0:
|
|
253 |
return iIcon;
|
|
254 |
case 1:
|
|
255 |
return iLabel;
|
|
256 |
case 2:
|
|
257 |
return iLockIcon;
|
|
258 |
default:
|
|
259 |
return NULL;
|
|
260 |
}
|
|
261 |
}
|
|
262 |
|
|
263 |
// ---------------------------------------------------------------------------
|
|
264 |
// CESMRViewerPriorityField::SetOutlineFocusL()
|
|
265 |
// ---------------------------------------------------------------------------
|
|
266 |
//
|
|
267 |
void CESMRViewerPriorityField::SetOutlineFocusL( TBool aFocus )
|
|
268 |
{
|
|
269 |
FUNC_LOG;
|
|
270 |
CESMRField::SetOutlineFocusL ( aFocus );
|
|
271 |
|
|
272 |
iLabel->SetFocus( aFocus );
|
|
273 |
}
|
|
274 |
|
|
275 |
// ---------------------------------------------------------------------------
|
|
276 |
// CESMRViewerPriorityField::LockL()
|
|
277 |
// ---------------------------------------------------------------------------
|
|
278 |
//
|
|
279 |
void CESMRViewerPriorityField::LockL()
|
|
280 |
{
|
|
281 |
FUNC_LOG;
|
|
282 |
if( IsLocked() )
|
|
283 |
{
|
|
284 |
return;
|
|
285 |
}
|
|
286 |
|
|
287 |
CESMRField::LockL();
|
|
288 |
|
|
289 |
delete iLockIcon;
|
|
290 |
iLockIcon = NULL;
|
|
291 |
iLockIcon = CMRImage::NewL(
|
|
292 |
NMRBitmapManager::EMRBitmapLockField,
|
|
293 |
this,
|
|
294 |
ETrue );
|
|
295 |
}
|
|
296 |
|
|
297 |
// ---------------------------------------------------------------------------
|
|
298 |
// CESMRViewerPriorityField::ExecuteGenericCommandL()
|
|
299 |
// ---------------------------------------------------------------------------
|
|
300 |
//
|
|
301 |
TBool CESMRViewerPriorityField::ExecuteGenericCommandL( TInt aCommand )
|
|
302 |
{
|
|
303 |
FUNC_LOG;
|
|
304 |
|
|
305 |
TBool retValue( EFalse );
|
|
306 |
|
|
307 |
if( (aCommand == EAknCmdOpen) && IsLocked() )
|
|
308 |
{
|
|
309 |
HandleTactileFeedbackL();
|
|
310 |
|
|
311 |
CESMRGlobalNote::ExecuteL(
|
|
312 |
CESMRGlobalNote::EESMRUnableToEdit );
|
|
313 |
retValue = ETrue;
|
|
314 |
}
|
|
315 |
|
|
316 |
return retValue;
|
|
317 |
}
|
|
318 |
// EOF
|
|
319 |
|