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