25
|
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 Synchronization field implementation
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "cesmrsyncfield.h"
|
|
19 |
#include "cmrimage.h"
|
|
20 |
#include "cmrlabel.h"
|
|
21 |
#include "cesmrtextitem.h"
|
|
22 |
#include "cesmrlistquery.h"
|
|
23 |
#include "nmrlayoutmanager.h"
|
|
24 |
|
|
25 |
#include <esmrgui.rsg>
|
|
26 |
#include <StringLoader.h>
|
|
27 |
#include <barsread.h>
|
|
28 |
#include <avkon.hrh>
|
|
29 |
#include <AknUtils.h>
|
|
30 |
#include <calentry.h>
|
|
31 |
// DEBUG
|
|
32 |
#include "emailtrace.h"
|
|
33 |
|
|
34 |
// Unnamed namespace for local definitions and functions
|
|
35 |
namespace // codescanner::namespace
|
|
36 |
{
|
|
37 |
CCalEntry::TReplicationStatus MapToReplicationStatus(
|
|
38 |
TESMRSyncValue aSyncValue )
|
|
39 |
{
|
|
40 |
CCalEntry::TReplicationStatus ret;
|
|
41 |
switch ( aSyncValue )
|
|
42 |
{
|
|
43 |
case ESyncNone:
|
|
44 |
{
|
|
45 |
ret = CCalEntry::ERestricted;
|
|
46 |
break;
|
|
47 |
}
|
|
48 |
case ESyncPrivate:
|
|
49 |
{
|
|
50 |
ret = CCalEntry::EPrivate;
|
|
51 |
break;
|
|
52 |
}
|
|
53 |
case ESyncPublic:
|
|
54 |
{
|
|
55 |
ret = CCalEntry::EOpen;
|
|
56 |
break;
|
|
57 |
}
|
|
58 |
default:
|
|
59 |
{
|
|
60 |
ret = CCalEntry::ERestricted;
|
|
61 |
}
|
|
62 |
}
|
|
63 |
|
|
64 |
return ret;
|
|
65 |
}
|
|
66 |
|
|
67 |
// Field's component count, icon and label
|
|
68 |
const TInt KComponentCount( 2 );
|
|
69 |
} // namespace
|
|
70 |
|
|
71 |
// ======== MEMBER FUNCTIONS ========
|
|
72 |
|
|
73 |
// ---------------------------------------------------------------------------
|
|
74 |
// CESMRSyncField::NewL
|
|
75 |
// ---------------------------------------------------------------------------
|
|
76 |
//
|
|
77 |
CESMRSyncField* CESMRSyncField::NewL( )
|
|
78 |
{
|
|
79 |
FUNC_LOG;
|
|
80 |
CESMRSyncField* self = new (ELeave) CESMRSyncField;
|
|
81 |
CleanupStack::PushL ( self );
|
|
82 |
self->ConstructL ( );
|
|
83 |
CleanupStack::Pop ( self );
|
|
84 |
return self;
|
|
85 |
}
|
|
86 |
|
|
87 |
// ---------------------------------------------------------------------------
|
|
88 |
// CESMRSyncField::~CESMRSyncField
|
|
89 |
// ---------------------------------------------------------------------------
|
|
90 |
//
|
|
91 |
CESMRSyncField::~CESMRSyncField( )
|
|
92 |
{
|
|
93 |
FUNC_LOG;
|
|
94 |
iArray.ResetAndDestroy ( );
|
|
95 |
iArray.Close ( );
|
|
96 |
|
|
97 |
delete iIcon;
|
|
98 |
}
|
|
99 |
|
|
100 |
// ---------------------------------------------------------------------------
|
|
101 |
// CESMRSyncField::InternalizeL
|
|
102 |
// ---------------------------------------------------------------------------
|
|
103 |
//
|
|
104 |
void CESMRSyncField::InternalizeL( MESMRCalEntry& aEntry )
|
|
105 |
{
|
|
106 |
FUNC_LOG;
|
|
107 |
TInt synchValue = aEntry.Entry().ReplicationStatusL ( );
|
|
108 |
|
|
109 |
// esmrgui.rss
|
|
110 |
TResourceReader reader;
|
|
111 |
iCoeEnv->CreateResourceReaderLC ( reader, R_ESMREDITOR_SYNC );
|
|
112 |
|
|
113 |
// Read sync items to array
|
|
114 |
iArray.ResetAndDestroy( );
|
|
115 |
TInt count = reader.ReadInt16 ( );
|
|
116 |
for (TInt i(0); i < count; i++ )
|
|
117 |
{
|
|
118 |
CESMRTextItem* sync = new (ELeave) CESMRTextItem();
|
|
119 |
CleanupStack::PushL( sync );
|
|
120 |
sync->ConstructFromResourceL ( reader );
|
|
121 |
iArray.AppendL ( sync );
|
|
122 |
CleanupStack::Pop( sync );
|
|
123 |
if ( synchValue == MapToReplicationStatus ( static_cast<TESMRSyncValue>( sync->Id ( ) ) ) )
|
|
124 |
{
|
|
125 |
iIndex = i;
|
|
126 |
iSync->SetTextL ( sync->TextL ( ) );
|
|
127 |
}
|
|
128 |
}
|
|
129 |
// resource reader
|
|
130 |
CleanupStack::PopAndDestroy(); // codescanner::cleanup
|
|
131 |
}
|
|
132 |
|
|
133 |
// ---------------------------------------------------------------------------
|
|
134 |
// CESMRSyncField::ExternalizeL
|
|
135 |
// ---------------------------------------------------------------------------
|
|
136 |
//
|
|
137 |
void CESMRSyncField::ExternalizeL( MESMRCalEntry& aEntry )
|
|
138 |
{
|
|
139 |
FUNC_LOG;
|
|
140 |
if ( iIndex < iArray.Count() )
|
|
141 |
{
|
|
142 |
CCalEntry::TReplicationStatus
|
|
143 |
repStatus = MapToReplicationStatus ( static_cast<TESMRSyncValue>( iArray[iIndex]->Id ( ) ) );
|
|
144 |
aEntry.Entry().SetReplicationStatusL (repStatus );
|
|
145 |
}
|
|
146 |
else
|
|
147 |
{
|
|
148 |
User::Leave( KErrOverflow );
|
|
149 |
}
|
|
150 |
}
|
|
151 |
|
|
152 |
// ---------------------------------------------------------------------------
|
|
153 |
// CESMRPriorityField::SetOutlineFocusL
|
|
154 |
// ---------------------------------------------------------------------------
|
|
155 |
//
|
|
156 |
void CESMRSyncField::SetOutlineFocusL( TBool aFocus )
|
|
157 |
{
|
|
158 |
FUNC_LOG;
|
|
159 |
CESMRField::SetOutlineFocusL ( aFocus );
|
|
160 |
|
|
161 |
//Focus gained
|
|
162 |
if ( aFocus )
|
|
163 |
{
|
|
164 |
ChangeMiddleSoftKeyL(EESMRCmdOpenSyncQuery, R_QTN_MSK_OPEN);
|
|
165 |
}
|
|
166 |
}
|
|
167 |
|
|
168 |
// ---------------------------------------------------------------------------
|
|
169 |
// CESMRPriorityField::ExecuteGenericCommandL
|
|
170 |
// ---------------------------------------------------------------------------
|
|
171 |
//
|
|
172 |
TBool CESMRSyncField::ExecuteGenericCommandL( TInt aCommand )
|
|
173 |
{
|
|
174 |
FUNC_LOG;
|
|
175 |
TBool isUsed( EFalse );
|
|
176 |
if(aCommand == EESMRCmdOpenSyncQuery ||
|
|
177 |
aCommand == EAknCmdOpen )
|
|
178 |
{
|
|
179 |
HandleTactileFeedbackL();
|
|
180 |
|
|
181 |
ExecuteSyncQueryL();
|
|
182 |
isUsed = ETrue;
|
|
183 |
}
|
|
184 |
return isUsed;
|
|
185 |
}
|
|
186 |
|
|
187 |
// ---------------------------------------------------------------------------
|
|
188 |
// CESMRPriorityField::ExecuteSyncQuery
|
|
189 |
// ---------------------------------------------------------------------------
|
|
190 |
//
|
|
191 |
void CESMRSyncField::ExecuteSyncQueryL()
|
|
192 |
{
|
|
193 |
FUNC_LOG;
|
|
194 |
|
|
195 |
TInt ret =
|
|
196 |
CESMRListQuery::ExecuteL( CESMRListQuery::EESMRSynchronizationPopup );
|
|
197 |
if ( ret != KErrCancel )
|
|
198 |
{
|
|
199 |
iIndex = ret;
|
|
200 |
UpdateLabelL (ret );
|
|
201 |
}
|
|
202 |
}
|
|
203 |
|
|
204 |
|
|
205 |
// ---------------------------------------------------------------------------
|
|
206 |
// CESMRSyncField::OfferKeyEventL
|
|
207 |
// ---------------------------------------------------------------------------
|
|
208 |
//
|
|
209 |
TKeyResponse CESMRSyncField::OfferKeyEventL( const TKeyEvent& aEvent,
|
|
210 |
TEventCode aType )
|
|
211 |
{
|
|
212 |
FUNC_LOG;
|
|
213 |
TKeyResponse response( EKeyWasNotConsumed);
|
|
214 |
if ( aType == EEventKey )
|
|
215 |
{
|
|
216 |
switch ( aEvent.iScanCode )
|
|
217 |
{
|
|
218 |
case EStdKeyLeftArrow:
|
|
219 |
{
|
|
220 |
if ( iIndex > 0 )
|
|
221 |
{
|
|
222 |
UpdateLabelL ( --iIndex );
|
|
223 |
response = EKeyWasConsumed;
|
|
224 |
}
|
|
225 |
}
|
|
226 |
break;
|
|
227 |
|
|
228 |
case EStdKeyRightArrow:
|
|
229 |
{
|
|
230 |
if ( iIndex < (iArray.Count() - 1) )
|
|
231 |
{
|
|
232 |
UpdateLabelL ( ++iIndex );
|
|
233 |
response = EKeyWasConsumed;
|
|
234 |
}
|
|
235 |
}
|
|
236 |
break;
|
|
237 |
|
|
238 |
default:
|
|
239 |
break;
|
|
240 |
}
|
|
241 |
}
|
|
242 |
return response;
|
|
243 |
}
|
|
244 |
|
|
245 |
// ---------------------------------------------------------------------------
|
|
246 |
// CESMRSyncField::CESMRSyncField
|
|
247 |
// ---------------------------------------------------------------------------
|
|
248 |
//
|
|
249 |
CESMRSyncField::CESMRSyncField( ) :
|
|
250 |
iIndex(0)
|
|
251 |
{
|
|
252 |
FUNC_LOG;
|
|
253 |
SetFieldId( EESMRFieldSync );
|
|
254 |
SetFocusType( EESMRHighlightFocus );
|
|
255 |
}
|
|
256 |
|
|
257 |
// ---------------------------------------------------------------------------
|
|
258 |
// CESMRSyncField::ConstructL
|
|
259 |
// ---------------------------------------------------------------------------
|
|
260 |
//
|
|
261 |
void CESMRSyncField::ConstructL( )
|
|
262 |
{
|
|
263 |
FUNC_LOG;
|
|
264 |
iSync = CMRLabel::NewL();
|
|
265 |
CESMRField::ConstructL( iSync );
|
|
266 |
iSync->SetTextL( KNullDesC() );
|
|
267 |
|
|
268 |
TGulAlignment align;
|
|
269 |
align.SetHAlignment( EHLeft );
|
|
270 |
align.SetVAlignment( EVCenter );
|
|
271 |
iSync->SetAlignment( align );
|
|
272 |
|
|
273 |
iIcon = CMRImage::NewL( NMRBitmapManager::EMRBitmapSynchronization );
|
|
274 |
}
|
|
275 |
|
|
276 |
// ---------------------------------------------------------------------------
|
|
277 |
// CESMRSyncField::UpdateLabelL
|
|
278 |
// ---------------------------------------------------------------------------
|
|
279 |
//
|
|
280 |
void CESMRSyncField::UpdateLabelL( TInt aIndex )
|
|
281 |
{
|
|
282 |
FUNC_LOG;
|
|
283 |
CESMRTextItem* sync = iArray[ aIndex ];
|
|
284 |
iSync->SetTextL( sync->TextL() );
|
|
285 |
iSync->DrawDeferred();
|
|
286 |
}
|
|
287 |
|
|
288 |
// ---------------------------------------------------------------------------
|
|
289 |
// CESMRSyncField::CountComponentControls
|
|
290 |
// ---------------------------------------------------------------------------
|
|
291 |
//
|
|
292 |
TInt CESMRSyncField::CountComponentControls() const
|
|
293 |
{
|
|
294 |
return KComponentCount;
|
|
295 |
}
|
|
296 |
|
|
297 |
// ---------------------------------------------------------------------------
|
|
298 |
// CESMRSyncField::ComponentControl
|
|
299 |
// ---------------------------------------------------------------------------
|
|
300 |
//
|
|
301 |
CCoeControl* CESMRSyncField::ComponentControl( TInt aIndex ) const
|
|
302 |
{
|
|
303 |
CCoeControl* control = NULL;
|
|
304 |
switch( aIndex )
|
|
305 |
{
|
|
306 |
case 0:
|
|
307 |
{
|
|
308 |
control = iSync;
|
|
309 |
break;
|
|
310 |
}
|
|
311 |
case 1:
|
|
312 |
{
|
|
313 |
control = iIcon;
|
|
314 |
break;
|
|
315 |
}
|
|
316 |
default:
|
|
317 |
ASSERT( EFalse );
|
|
318 |
}
|
|
319 |
|
|
320 |
return control;
|
|
321 |
}
|
|
322 |
|
|
323 |
// ---------------------------------------------------------------------------
|
|
324 |
// CESMRSyncField::SizeChanged
|
|
325 |
// ---------------------------------------------------------------------------
|
|
326 |
//
|
|
327 |
void CESMRSyncField::SizeChanged()
|
|
328 |
{
|
|
329 |
TRect rect( Rect() );
|
|
330 |
TAknLayoutRect iconLayout =
|
|
331 |
NMRLayoutManager::GetLayoutRect(
|
|
332 |
rect, NMRLayoutManager::EMRLayoutTextEditorIcon );
|
|
333 |
TRect iconRect( iconLayout.Rect() );
|
|
334 |
iIcon->SetRect( iconRect );
|
|
335 |
|
|
336 |
TAknLayoutRect bgLayoutRect =
|
|
337 |
NMRLayoutManager::GetLayoutRect(
|
|
338 |
rect, NMRLayoutManager::EMRLayoutTextEditorBg );
|
|
339 |
TRect bgRect( bgLayoutRect.Rect() );
|
|
340 |
// Move focus rect so that it's relative to field's position.
|
|
341 |
bgRect.Move( -Position() );
|
|
342 |
SetFocusRect( bgRect );
|
|
343 |
|
|
344 |
TAknTextComponentLayout editorLayout =
|
|
345 |
NMRLayoutManager::GetTextComponentLayout(
|
|
346 |
NMRLayoutManager::EMRTextLayoutTextEditor );
|
|
347 |
|
|
348 |
AknLayoutUtils::LayoutLabel( iSync, rect, editorLayout );
|
|
349 |
}
|
|
350 |
|
|
351 |
// EOF
|
|
352 |
|