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: End date field for viewers
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "cesmrviewerstopdatefield.h"
|
|
19 |
#include "cesmreditor.h"
|
|
20 |
#include "mesmrlistobserver.h"
|
|
21 |
#include "nmrlayoutmanager.h"
|
|
22 |
#include "cmrlabel.h"
|
|
23 |
#include "cmrimage.h"
|
|
24 |
#include "nmrbitmapmanager.h"
|
|
25 |
#include "emailtrace.h"
|
|
26 |
#include "cesmrglobalnote.h"
|
|
27 |
|
|
28 |
#include <esmrgui.rsg>
|
|
29 |
#include <AknUtils.h>
|
|
30 |
#include <eiklabel.h>
|
|
31 |
#include <caluser.h>
|
|
32 |
#include <calalarm.h>
|
|
33 |
#include <avkon.rsg>
|
|
34 |
#include <calentry.h>
|
|
35 |
#include <eikenv.h>
|
|
36 |
#include <eikedwin.h>
|
|
37 |
#include <StringLoader.h>
|
|
38 |
#include <AknsConstants.h>
|
|
39 |
#include "esmrfieldbuilderdef.h"
|
|
40 |
|
|
41 |
// ======== LOCAL FUNCTIONS ========
|
|
42 |
namespace
|
|
43 |
{ // codescanner::namespace
|
|
44 |
|
|
45 |
const TInt KComponentCount( 2 ); // icon and label
|
|
46 |
const TInt KMaxTimeBuffer( 32 ); // buffer for date formatting
|
|
47 |
|
|
48 |
} // unnamed namespace
|
|
49 |
|
|
50 |
// ======== MEMBER FUNCTIONS ========
|
|
51 |
|
|
52 |
// ---------------------------------------------------------------------------
|
|
53 |
// CESMRViewerStopDateField::CESMRViewerStopDateField
|
|
54 |
// ---------------------------------------------------------------------------
|
|
55 |
//
|
|
56 |
CESMRViewerStopDateField::CESMRViewerStopDateField()
|
|
57 |
{
|
|
58 |
FUNC_LOG;
|
|
59 |
SetFieldId ( EESMRFieldStopDate );
|
|
60 |
SetFocusType( EESMRHighlightFocus );
|
|
61 |
}
|
|
62 |
|
|
63 |
// ---------------------------------------------------------------------------
|
|
64 |
// CESMRViewerStopDateField::~CESMRViewerStopDateField
|
|
65 |
// ---------------------------------------------------------------------------
|
|
66 |
//
|
|
67 |
CESMRViewerStopDateField::~CESMRViewerStopDateField()
|
|
68 |
{
|
|
69 |
FUNC_LOG;
|
|
70 |
delete iIcon;
|
|
71 |
delete iLockIcon;
|
|
72 |
}
|
|
73 |
|
|
74 |
// ---------------------------------------------------------------------------
|
|
75 |
// CESMRViewerStopDateField::NewL
|
|
76 |
// ---------------------------------------------------------------------------
|
|
77 |
//
|
|
78 |
CESMRViewerStopDateField* CESMRViewerStopDateField::NewL()
|
|
79 |
{
|
|
80 |
FUNC_LOG;
|
|
81 |
CESMRViewerStopDateField* self =
|
|
82 |
new (ELeave) CESMRViewerStopDateField();
|
|
83 |
CleanupStack::PushL( self );
|
|
84 |
self->ConstructL();
|
|
85 |
CleanupStack::Pop( self );
|
|
86 |
return self;
|
|
87 |
}
|
|
88 |
|
|
89 |
// -----------------------------------------------------------------------------
|
|
90 |
// CESMRViewerStopDateField::ConstructL()
|
|
91 |
// -----------------------------------------------------------------------------
|
|
92 |
//
|
|
93 |
void CESMRViewerStopDateField::ConstructL()
|
|
94 |
{
|
|
95 |
iLabel = CMRLabel::NewL( this );
|
|
96 |
CESMRField::ConstructL( iLabel ); // ownership transfered
|
|
97 |
|
|
98 |
iIcon = CMRImage::NewL( NMRBitmapManager::EMRBitmapDateEnd, this );
|
|
99 |
}
|
|
100 |
|
|
101 |
// ---------------------------------------------------------------------------
|
|
102 |
// CESMRViewerStartDateField::InitializeL()
|
|
103 |
// ---------------------------------------------------------------------------
|
|
104 |
//
|
|
105 |
void CESMRViewerStopDateField::InitializeL()
|
|
106 |
{
|
|
107 |
TAknLayoutText text = NMRLayoutManager::GetLayoutText(
|
|
108 |
Rect(),
|
|
109 |
NMRLayoutManager::EMRTextLayoutTextEditor );
|
|
110 |
|
|
111 |
iLabel->SetFont( text.Font() );
|
|
112 |
// This is called so that theme changes will apply when changing theme "on the fly"
|
|
113 |
if ( IsFocused() )
|
|
114 |
{
|
|
115 |
iLabel->FocusChanged( EDrawNow );
|
|
116 |
}
|
|
117 |
}
|
|
118 |
|
|
119 |
// ---------------------------------------------------------------------------
|
|
120 |
// CESMRViewerStopDateField::InternalizeL
|
|
121 |
// ---------------------------------------------------------------------------
|
|
122 |
//
|
|
123 |
void CESMRViewerStopDateField::InternalizeL(
|
|
124 |
MESMRCalEntry& aEntry )
|
|
125 |
{
|
|
126 |
FUNC_LOG;
|
|
127 |
CCalEntry& entry = aEntry.Entry();
|
|
128 |
TTime endTime = entry.EndTimeL().TimeLocalL();
|
|
129 |
TTime startTime = entry.StartTimeL().TimeLocalL();
|
|
130 |
TDateTime startDate = startTime.DateTime();
|
|
131 |
TDateTime endDate = endTime.DateTime();
|
|
132 |
|
|
133 |
if ( aEntry.IsAllDayEventL() )
|
|
134 |
{
|
|
135 |
// if the event is allday event, previous day for end date will be
|
|
136 |
// shown in UI. See Outlook for reference...
|
|
137 |
endTime -= TTimeIntervalDays( KAllDayEventDurationInDays );
|
|
138 |
endDate = endTime.DateTime();
|
|
139 |
}
|
|
140 |
|
|
141 |
// If the entry start and end date for the event are the same, hide end time.
|
|
142 |
// Hide only if the entry is meeting, meeting request or memo
|
|
143 |
if( ( (aEntry.Entry().EntryTypeL() == CCalEntry::EAppt ) ||
|
|
144 |
(aEntry.Entry().EntryTypeL() == CCalEntry::EEvent ) )&&
|
|
145 |
( startDate.Year() == endDate.Year() ) &&
|
|
146 |
( startDate.Month() == endDate.Month() ) &&
|
|
147 |
( startDate.Day() == endDate.Day() ) )
|
|
148 |
{
|
|
149 |
iObserver->HideControl( FieldId() );
|
|
150 |
}
|
|
151 |
else // else set the text for end time label
|
|
152 |
{
|
|
153 |
// Read format string from AVKON resource
|
|
154 |
iStopTime = endTime;
|
|
155 |
FormatDateStringL();
|
|
156 |
}
|
|
157 |
}
|
|
158 |
// ---------------------------------------------------------------------------
|
|
159 |
// CESMRViewerStopDateField::SizeChanged()
|
|
160 |
// ---------------------------------------------------------------------------
|
|
161 |
//
|
|
162 |
void CESMRViewerStopDateField::SizeChanged()
|
|
163 |
{
|
|
164 |
TRect rect = Rect();
|
|
165 |
TAknLayoutRect rowLayoutRect =
|
|
166 |
NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 );
|
|
167 |
rect = rowLayoutRect.Rect();
|
|
168 |
|
|
169 |
TAknWindowComponentLayout iconLayout =
|
|
170 |
NMRLayoutManager::GetWindowComponentLayout(
|
|
171 |
NMRLayoutManager::EMRLayoutTextEditorIcon );
|
|
172 |
AknLayoutUtils::LayoutImage( iIcon, rect, iconLayout );
|
|
173 |
|
|
174 |
// Layouting lock icon
|
|
175 |
if( iLockIcon )
|
|
176 |
{
|
|
177 |
TAknWindowComponentLayout iconLayout(
|
|
178 |
NMRLayoutManager::GetWindowComponentLayout(
|
|
179 |
NMRLayoutManager::EMRLayoutSingleRowDColumnGraphic ) );
|
|
180 |
AknLayoutUtils::LayoutImage( iLockIcon, rect, iconLayout );
|
|
181 |
}
|
|
182 |
|
|
183 |
// Layouting label
|
|
184 |
TAknTextComponentLayout viewerLayoutText;
|
|
185 |
if( iLockIcon )
|
|
186 |
{
|
|
187 |
viewerLayoutText = NMRLayoutManager::GetTextComponentLayout(
|
|
188 |
NMRLayoutManager::EMRTextLayoutSingleRowEditorText );
|
|
189 |
}
|
|
190 |
else
|
|
191 |
{
|
|
192 |
viewerLayoutText = NMRLayoutManager::GetTextComponentLayout(
|
|
193 |
NMRLayoutManager::EMRTextLayoutTextEditor );
|
|
194 |
}
|
|
195 |
|
|
196 |
AknLayoutUtils::LayoutLabel( iLabel, rect, viewerLayoutText );
|
|
197 |
TRect viewerRect( iLabel->Rect() );
|
|
198 |
|
|
199 |
// Move focus rect so that it's relative to field's position.
|
|
200 |
viewerRect.Move( -Position() );
|
|
201 |
SetFocusRect( viewerRect );
|
|
202 |
}
|
|
203 |
|
|
204 |
// ---------------------------------------------------------------------------
|
|
205 |
// CESMRViewerStopDateField::CountComponentControls()
|
|
206 |
// ---------------------------------------------------------------------------
|
|
207 |
//
|
|
208 |
TInt CESMRViewerStopDateField::CountComponentControls() const
|
|
209 |
{
|
|
210 |
TInt count( KComponentCount );
|
|
211 |
if( iLockIcon )
|
|
212 |
{
|
|
213 |
++count;
|
|
214 |
}
|
|
215 |
return count;
|
|
216 |
}
|
|
217 |
|
|
218 |
// ---------------------------------------------------------------------------
|
|
219 |
// CESMRViewerStopDateField::ComponentControl()
|
|
220 |
// ---------------------------------------------------------------------------
|
|
221 |
//
|
|
222 |
CCoeControl* CESMRViewerStopDateField::ComponentControl( TInt aIndex ) const
|
|
223 |
{
|
|
224 |
switch ( aIndex )
|
|
225 |
{
|
|
226 |
case 0:
|
|
227 |
return iIcon;
|
|
228 |
case 1:
|
|
229 |
return iLabel;
|
|
230 |
case 2:
|
|
231 |
return iLockIcon;
|
|
232 |
default:
|
|
233 |
return NULL;
|
|
234 |
}
|
|
235 |
}
|
|
236 |
|
|
237 |
// ---------------------------------------------------------------------------
|
|
238 |
// CESMRViewerStopDateField::SetOutlineFocusL()
|
|
239 |
// ---------------------------------------------------------------------------
|
|
240 |
//
|
|
241 |
void CESMRViewerStopDateField::SetOutlineFocusL( TBool aFocus )
|
|
242 |
{
|
|
243 |
CESMRField::SetOutlineFocusL ( aFocus );
|
|
244 |
|
|
245 |
iLabel->SetFocus( aFocus );
|
|
246 |
}
|
|
247 |
|
|
248 |
// ---------------------------------------------------------------------------
|
|
249 |
// CESMRViewerStopDateField::ExecuteGenericCommandL()
|
|
250 |
// ---------------------------------------------------------------------------
|
|
251 |
//
|
|
252 |
TBool CESMRViewerStopDateField::ExecuteGenericCommandL( TInt aCommand )
|
|
253 |
{
|
|
254 |
FUNC_LOG;
|
|
255 |
|
|
256 |
TBool retValue( EFalse );
|
|
257 |
|
|
258 |
if( (aCommand == EAknCmdOpen) && IsLocked() )
|
|
259 |
{
|
|
260 |
HandleTactileFeedbackL();
|
|
261 |
|
|
262 |
CESMRGlobalNote::ExecuteL(
|
|
263 |
CESMRGlobalNote::EESMRUnableToEdit );
|
|
264 |
retValue = ETrue;
|
|
265 |
}
|
|
266 |
|
|
267 |
if ( EMRCmdDoEnvironmentChange == aCommand )
|
|
268 |
{
|
|
269 |
FormatDateStringL();
|
|
270 |
retValue = ETrue;
|
|
271 |
}
|
|
272 |
|
|
273 |
return retValue;
|
|
274 |
}
|
|
275 |
|
|
276 |
// ---------------------------------------------------------------------------
|
|
277 |
// CESMRViewerStopDateField::LockL()
|
|
278 |
// ---------------------------------------------------------------------------
|
|
279 |
//
|
|
280 |
void CESMRViewerStopDateField::LockL()
|
|
281 |
{
|
|
282 |
FUNC_LOG;
|
|
283 |
if( IsLocked() )
|
|
284 |
{
|
|
285 |
return;
|
|
286 |
}
|
|
287 |
|
|
288 |
CESMRField::LockL();
|
|
289 |
|
|
290 |
delete iLockIcon;
|
|
291 |
iLockIcon = NULL;
|
|
292 |
iLockIcon = CMRImage::NewL(
|
|
293 |
NMRBitmapManager::EMRBitmapLockField,
|
|
294 |
this,
|
|
295 |
ETrue );
|
|
296 |
}
|
|
297 |
|
|
298 |
// ---------------------------------------------------------------------------
|
|
299 |
// CESMRViewerStopDateField::FormatDateStringL()
|
|
300 |
// ---------------------------------------------------------------------------
|
|
301 |
//
|
|
302 |
void CESMRViewerStopDateField::FormatDateStringL()
|
|
303 |
{
|
|
304 |
FUNC_LOG;
|
|
305 |
|
|
306 |
// Read format string from AVKON resource
|
|
307 |
HBufC* dateFormatString =
|
|
308 |
iEikonEnv->AllocReadResourceLC(
|
|
309 |
R_QTN_DATE_USUAL_WITH_ZERO);
|
|
310 |
|
|
311 |
TBuf<KMaxTimeBuffer> buf;
|
|
312 |
iStopTime.FormatL(buf, *dateFormatString);
|
|
313 |
|
|
314 |
AknTextUtils::DisplayTextLanguageSpecificNumberConversion( buf );
|
|
315 |
iLabel->SetTextL( buf );
|
|
316 |
CleanupStack::PopAndDestroy( dateFormatString );
|
|
317 |
}
|
|
318 |
|
|
319 |
// EOF
|