13 * |
13 * |
14 * Description: Recurrence date field for viewers |
14 * Description: Recurrence date field for viewers |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
|
18 |
18 #include "cesmrviewerrecurrencedatefield.h" |
19 #include "cesmrviewerrecurrencedatefield.h" |
19 #include "mesmrresponseobserver.h" |
20 #include "mesmrresponseobserver.h" |
20 #include "cesmrborderlayer.h" |
|
21 #include "mesmrlistobserver.h" |
21 #include "mesmrlistobserver.h" |
22 #include "esmrfieldbuilderdef.h" |
22 #include "esmrfieldbuilderdef.h" |
23 #include "cesmrlayoutmgr.h" |
|
24 #include "cmrlabel.h" |
23 #include "cmrlabel.h" |
25 #include "nmrlayoutmanager.h" |
24 #include "nmrlayoutmanager.h" |
|
25 #include "nmrcolormanager.h" |
|
26 #include "cesmrglobalnote.h" |
26 |
27 |
27 #include <eikenv.h> |
28 #include <eikenv.h> |
28 #include <avkon.rsg> |
29 #include <avkon.rsg> |
29 #include <avkon.hrh> |
30 #include <avkon.hrh> |
30 #include <StringLoader.h> |
31 #include <stringloader.h> |
31 #include <AknUtils.h> |
32 #include <aknutils.h> |
32 #include <esmrgui.rsg> |
33 #include <esmrgui.rsg> |
33 #include <caltime.h> |
34 #include <caltime.h> |
34 // DEBUG |
35 // DEBUG |
35 #include "emailtrace.h" |
36 #include "emailtrace.h" |
36 |
|
37 using namespace ESMRLayout; |
|
38 |
|
39 namespace // codescanner::namespace |
37 namespace // codescanner::namespace |
40 { |
38 { |
41 const TInt KComponentCount( 2 ); |
39 const TInt KComponentCount( 2 ); |
42 const TInt KMargin (5); |
40 const TInt KMargin (5); |
43 } |
41 } |
44 // ======== MEMBER FUNCTIONS ======== |
42 // ======== MEMBER FUNCTIONS ======== |
45 |
43 |
46 // ----------------------------------------------------------------------------- |
44 // ----------------------------------------------------------------------------- |
|
45 // CESMRViewerRecurrenceDateField::CESMRViewerRecurrenceDateField |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 CESMRViewerRecurrenceDateField::CESMRViewerRecurrenceDateField() |
|
49 : iRepeatUntilDate( Time::NullTTime() ) |
|
50 { |
|
51 FUNC_LOG; |
|
52 SetFieldId( EESMRFieldRecurrenceDate ); |
|
53 SetFocusType( EESMRHighlightFocus ); |
|
54 } |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // CESMRViewerRecurrenceDateField::~CESMRViewerRecurrenceDateField |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 CESMRViewerRecurrenceDateField::~CESMRViewerRecurrenceDateField() |
|
61 { |
|
62 FUNC_LOG; |
|
63 delete iRepeatTopic; |
|
64 delete iRepeatDate; |
|
65 } |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
47 // CESMRViewerRecurrenceDateField::NewL |
68 // CESMRViewerRecurrenceDateField::NewL |
48 // ----------------------------------------------------------------------------- |
69 // ----------------------------------------------------------------------------- |
49 // |
70 // |
50 CESMRViewerRecurrenceDateField* CESMRViewerRecurrenceDateField::NewL() |
71 CESMRViewerRecurrenceDateField* CESMRViewerRecurrenceDateField::NewL() |
51 { |
72 { |
52 FUNC_LOG; |
73 FUNC_LOG; |
53 CESMRViewerRecurrenceDateField* self = new (ELeave) CESMRViewerRecurrenceDateField(); |
74 CESMRViewerRecurrenceDateField* self = |
|
75 new (ELeave) CESMRViewerRecurrenceDateField(); |
54 CleanupStack::PushL( self ); |
76 CleanupStack::PushL( self ); |
55 self->ConstructL(); |
77 self->ConstructL(); |
56 CleanupStack::Pop( self ); |
78 CleanupStack::Pop( self ); |
57 return self; |
79 return self; |
58 } |
80 } |
59 |
81 |
60 // ----------------------------------------------------------------------------- |
82 // ----------------------------------------------------------------------------- |
61 // CESMRViewerRecurrenceDateField::~CESMRViewerRecurrenceDateField |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 CESMRViewerRecurrenceDateField::~CESMRViewerRecurrenceDateField() |
|
65 { |
|
66 FUNC_LOG; |
|
67 delete iRepeatTopic; |
|
68 delete iRepeatDate; |
|
69 } |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // CESMRViewerRecurrenceDateField::CESMRViewerRecurrenceDateField |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 CESMRViewerRecurrenceDateField::CESMRViewerRecurrenceDateField() |
|
76 { |
|
77 FUNC_LOG; |
|
78 SetFieldId( EESMRFieldRecurrenceDate ); |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // CESMRViewerRecurrenceDateField::ConstructL |
83 // CESMRViewerRecurrenceDateField::ConstructL |
83 // ----------------------------------------------------------------------------- |
84 // ----------------------------------------------------------------------------- |
84 // |
85 // |
85 void CESMRViewerRecurrenceDateField::ConstructL() |
86 void CESMRViewerRecurrenceDateField::ConstructL() |
86 { |
87 { |
97 // ----------------------------------------------------------------------------- |
98 // ----------------------------------------------------------------------------- |
98 // |
99 // |
99 void CESMRViewerRecurrenceDateField::InitializeL() |
100 void CESMRViewerRecurrenceDateField::InitializeL() |
100 { |
101 { |
101 FUNC_LOG; |
102 FUNC_LOG; |
102 TAknLayoutText editorRect = |
103 NMRColorManager::SetColor( *iRepeatTopic, |
103 NMRLayoutManager::GetLayoutText( |
104 NMRColorManager::EMRMainAreaTextColor ); |
104 Rect(), NMRLayoutManager::EMRTextLayoutMultiRowTextEditor ); |
105 |
105 |
106 NMRColorManager::SetColor( *iRepeatDate, |
106 iRepeatTopic->SetFont( editorRect.Font() ); |
107 NMRColorManager::EMRMainAreaTextColor ); |
107 iRepeatDate->SetFont( editorRect.Font() ); |
|
108 |
|
109 AknLayoutUtils::OverrideControlColorL( *iRepeatTopic, EColorLabelText, |
|
110 KRgbBlack ); |
|
111 AknLayoutUtils::OverrideControlColorL( *iRepeatDate, EColorLabelText, |
|
112 KRgbBlack ); |
|
113 //this control cannot ever get keyboard focus |
108 //this control cannot ever get keyboard focus |
114 SetFocusing(EFalse); |
109 SetFocusing(EFalse); |
|
110 } |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // CESMRViewerRecurrenceDateField::ExecuteGenericCommandL |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 TBool CESMRViewerRecurrenceDateField::ExecuteGenericCommandL( TInt aCommand ) |
|
117 { |
|
118 FUNC_LOG; |
|
119 |
|
120 TBool retValue( EFalse ); |
|
121 |
|
122 if( (aCommand == EAknCmdOpen) && IsLocked() ) |
|
123 { |
|
124 HandleTactileFeedbackL(); |
|
125 |
|
126 CESMRGlobalNote::ExecuteL( |
|
127 CESMRGlobalNote::EESMRUnableToEdit ); |
|
128 retValue = ETrue; |
|
129 } |
|
130 else if ( EMRCmdDoEnvironmentChange == aCommand ) |
|
131 { |
|
132 FormatRepeatUntilDateL(); |
|
133 retValue = ETrue; |
|
134 } |
|
135 |
|
136 return retValue; |
115 } |
137 } |
116 |
138 |
117 // ----------------------------------------------------------------------------- |
139 // ----------------------------------------------------------------------------- |
118 // CESMRViewerRecurrenceDateField::SizeChanged |
140 // CESMRViewerRecurrenceDateField::SizeChanged |
119 // ----------------------------------------------------------------------------- |
141 // ----------------------------------------------------------------------------- |
123 FUNC_LOG; |
145 FUNC_LOG; |
124 TRect rect( Rect() ); |
146 TRect rect( Rect() ); |
125 // First row |
147 // First row |
126 TAknLayoutRect row1LayoutRect = |
148 TAknLayoutRect row1LayoutRect = |
127 NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 ); |
149 NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 ); |
128 rect = row1LayoutRect.Rect(); |
150 rect = row1LayoutRect.Rect(); |
129 |
151 |
130 TAknLayoutText topicRect = |
152 TAknLayoutText topicRect = |
131 NMRLayoutManager::GetLayoutText( |
153 NMRLayoutManager::GetLayoutText( |
132 rect, NMRLayoutManager::EMRTextLayoutMultiRowTextEditor ); |
154 rect, NMRLayoutManager::EMRTextLayoutMultiRowTextEditor ); |
133 |
155 |
134 TRect rectWithMargin = topicRect.TextRect(); |
156 TRect rectWithMargin = topicRect.TextRect(); |
135 rectWithMargin.iTl.iX += KMargin; |
157 rectWithMargin.iTl.iX += KMargin; |
136 iRepeatTopic->SetRect( rectWithMargin ); |
158 iRepeatTopic->SetRect( rectWithMargin ); |
137 |
159 |
138 rect = Rect(); |
160 rect = Rect(); |
139 // Move the iY down the height of the topic field |
161 // Move the iY down the height of the topic field |
140 TInt movement = row1LayoutRect.Rect().Height(); |
162 TInt movement = row1LayoutRect.Rect().Height(); |
141 rect.Move( 0, movement ); |
163 rect.Move( 0, movement ); |
142 |
164 |
143 // Second row |
165 // Second row |
144 TAknLayoutRect row2LayoutRect = |
166 TAknLayoutRect row2LayoutRect = |
145 NMRLayoutManager::GetFieldRowLayoutRect( rect, 2 ); |
167 NMRLayoutManager::GetFieldRowLayoutRect( rect, 2 ); |
146 rect = row2LayoutRect.Rect(); |
168 rect = row2LayoutRect.Rect(); |
147 |
169 |
148 TAknLayoutText dateRect = |
170 TAknLayoutText dateRect = |
149 NMRLayoutManager::GetLayoutText( |
171 NMRLayoutManager::GetLayoutText( |
150 rect, NMRLayoutManager::EMRTextLayoutMultiRowTextEditor ); |
172 rect, NMRLayoutManager::EMRTextLayoutMultiRowTextEditor ); |
151 |
173 |
152 rectWithMargin = dateRect.TextRect(); |
174 rectWithMargin = dateRect.TextRect(); |
153 rectWithMargin.iTl.iX += KMargin; |
175 rectWithMargin.iTl.iX += KMargin; |
154 iRepeatDate->SetRect( rectWithMargin ); |
176 iRepeatDate->SetRect( rectWithMargin ); |
|
177 |
|
178 // Setting font also for the label |
|
179 iRepeatTopic->SetFont( topicRect.Font() ); |
|
180 iRepeatDate->SetFont( dateRect.Font() ); |
155 } |
181 } |
156 |
182 |
157 // ----------------------------------------------------------------------------- |
183 // ----------------------------------------------------------------------------- |
158 // CESMRViewerRecurrenceDateField::MinimumSize |
184 // CESMRViewerRecurrenceDateField::MinimumSize |
159 // ----------------------------------------------------------------------------- |
185 // ----------------------------------------------------------------------------- |
166 NMRLayoutManager::GetFieldRowLayoutRect( Rect(), 1 ); |
192 NMRLayoutManager::GetFieldRowLayoutRect( Rect(), 1 ); |
167 height += row1LayoutRect.Rect().Height(); |
193 height += row1LayoutRect.Rect().Height(); |
168 // Second row |
194 // Second row |
169 TAknLayoutRect row2LayoutRect = |
195 TAknLayoutRect row2LayoutRect = |
170 NMRLayoutManager::GetFieldRowLayoutRect( Rect(), 2 ); |
196 NMRLayoutManager::GetFieldRowLayoutRect( Rect(), 2 ); |
171 height += row2LayoutRect.Rect().Height(); |
197 height += row2LayoutRect.Rect().Height(); |
172 |
198 |
173 TInt width( Parent()->Size().iWidth ); |
199 TInt width( Parent()->Size().iWidth ); |
174 return TSize( width, height ); |
200 return TSize( width, height ); |
175 } |
201 } |
176 |
202 |
177 // ----------------------------------------------------------------------------- |
203 // ----------------------------------------------------------------------------- |
181 void CESMRViewerRecurrenceDateField::InternalizeL( |
207 void CESMRViewerRecurrenceDateField::InternalizeL( |
182 MESMRCalEntry& aEntry ) |
208 MESMRCalEntry& aEntry ) |
183 { |
209 { |
184 FUNC_LOG; |
210 FUNC_LOG; |
185 // Get recurrence |
211 // Get recurrence |
186 TESMRRecurrenceValue recValue( ERecurrenceNot ); |
212 TESMRRecurrenceValue recValue( ERecurrenceNot ); |
187 TTime recTime( Time::NullTTime() ); |
213 aEntry.GetRecurrenceL( recValue, iRepeatUntilDate ); |
188 aEntry.GetRecurrenceL( recValue, recTime ); |
|
189 |
214 |
190 // Recurrence time has to be shown in the viewer as local time |
215 // Recurrence time has to be shown in the viewer as local time |
191 TCalTime recurrenceTime; |
216 TCalTime recurrenceTime; |
192 recurrenceTime.SetTimeUtcL( recTime ); |
217 recurrenceTime.SetTimeUtcL( iRepeatUntilDate ); |
193 TTime localRecurrenceTime; |
218 iRepeatUntilDate = recurrenceTime.TimeLocalL(); |
194 localRecurrenceTime = recurrenceTime.TimeLocalL(); |
|
195 |
219 |
196 if( aEntry.IsRecurrentEventL() && |
220 if( aEntry.IsRecurrentEventL() && |
197 recValue != ERecurrenceNot && |
221 recValue != ERecurrenceNot && |
198 Time::NullTTime() != recTime ) |
222 Time::NullTTime() != iRepeatUntilDate ) |
199 { |
223 { |
200 HBufC* topicHolder = |
224 FormatRepeatUntilDateL(); |
201 StringLoader::LoadLC( |
|
202 R_QTN_MEET_REQ_REPEAT_UNTIL, |
|
203 iEikonEnv ); |
|
204 // Set text for repeat topic (e.g. "Repeat until") |
|
205 iRepeatTopic->SetTextL( topicHolder->Des() ); |
|
206 CleanupStack::PopAndDestroy( topicHolder ); |
|
207 |
|
208 // Format date string |
|
209 HBufC* timeFormatString = iEikonEnv->AllocReadResourceLC( |
|
210 R_QTN_DATE_USUAL); |
|
211 |
|
212 TBuf< KDateStringLength > finalBuf; |
|
213 localRecurrenceTime.FormatL( finalBuf, *timeFormatString ); |
|
214 |
|
215 // Set repeat until date value |
|
216 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( finalBuf ); |
|
217 iRepeatDate->SetTextL( finalBuf ); |
|
218 CleanupStack::PopAndDestroy( timeFormatString ); |
|
219 timeFormatString = NULL; |
|
220 } |
225 } |
221 else |
226 else |
222 { |
227 { |
223 MakeVisible( EFalse ); |
228 MakeVisible( EFalse ); |
224 } |
229 } |
258 } |
263 } |
259 |
264 |
260 return retVal; |
265 return retVal; |
261 } |
266 } |
262 |
267 |
|
268 // ----------------------------------------------------------------------------- |
|
269 // CESMRViewerRecurrenceDateField::FormatRepeatUntilDateL |
|
270 // ----------------------------------------------------------------------------- |
|
271 // |
|
272 void CESMRViewerRecurrenceDateField::FormatRepeatUntilDateL() |
|
273 { |
|
274 FUNC_LOG; |
|
275 |
|
276 HBufC* topicHolder = |
|
277 StringLoader::LoadLC( |
|
278 R_QTN_MEET_REQ_REPEAT_UNTIL, |
|
279 iEikonEnv ); |
|
280 |
|
281 // Set text for repeat topic (e.g. "Repeat until") |
|
282 iRepeatTopic->SetTextL( topicHolder->Des() ); |
|
283 CleanupStack::PopAndDestroy( topicHolder ); |
|
284 |
|
285 // Format date string |
|
286 HBufC* timeFormatString = iEikonEnv->AllocReadResourceLC( |
|
287 R_QTN_DATE_USUAL); |
|
288 |
|
289 TBuf< KDateStringLength > finalBuf; |
|
290 iRepeatUntilDate.FormatL( finalBuf, *timeFormatString ); |
|
291 |
|
292 // Set repeat until date value |
|
293 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( finalBuf ); |
|
294 iRepeatDate->SetTextL( finalBuf ); |
|
295 CleanupStack::PopAndDestroy( timeFormatString ); |
|
296 timeFormatString = NULL; |
|
297 } |
|
298 |
263 // End of file |
299 // End of file |
264 |
300 |
265 |
301 |