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: MR multi calendar field implementation
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "cmrmulticalenfield.h"
|
|
19 |
#include "cmrimage.h"
|
|
20 |
#include "cmrlabel.h"
|
|
21 |
#include "cesmrtextitem.h"
|
|
22 |
#include "cesmrlistquery.h"
|
|
23 |
#include "nmrlayoutmanager.h"
|
|
24 |
#include "nmrcolormanager.h"
|
|
25 |
#include "mesmrmeetingrequestentry.h"
|
|
26 |
#include "cesmrglobalnote.h"
|
|
27 |
#include <calinstance.h>
|
|
28 |
#include <esmrgui.rsg>
|
|
29 |
#include <StringLoader.h>
|
|
30 |
#include <barsread.h>
|
|
31 |
#include <avkon.hrh>
|
|
32 |
#include <AknUtils.h>
|
|
33 |
#include <calentry.h>
|
|
34 |
#include <CalenInterimUtils2.h>
|
|
35 |
// DEBUG
|
|
36 |
#include "emailtrace.h"
|
|
37 |
#include "cesmrcaldbmgr.h"
|
|
38 |
|
|
39 |
|
|
40 |
// ======== MEMBER FUNCTIONS ========
|
|
41 |
|
|
42 |
// ---------------------------------------------------------------------------
|
|
43 |
// CMRMultiCalenField::NewL
|
|
44 |
// ---------------------------------------------------------------------------
|
|
45 |
//
|
|
46 |
CMRMultiCalenField* CMRMultiCalenField::NewL( )
|
|
47 |
{
|
|
48 |
FUNC_LOG;
|
|
49 |
CMRMultiCalenField* self = new (ELeave) CMRMultiCalenField;
|
|
50 |
CleanupStack::PushL ( self );
|
|
51 |
self->ConstructL ( );
|
|
52 |
CleanupStack::Pop ( self );
|
|
53 |
return self;
|
|
54 |
}
|
|
55 |
|
|
56 |
// ---------------------------------------------------------------------------
|
|
57 |
// CMRMultiCalenField::~CMRMultiCalenField
|
|
58 |
// ---------------------------------------------------------------------------
|
|
59 |
//
|
|
60 |
CMRMultiCalenField::~CMRMultiCalenField( )
|
|
61 |
{
|
|
62 |
FUNC_LOG;
|
|
63 |
iCalenNameList.Close();
|
|
64 |
delete iIcon;
|
|
65 |
delete iLockIcon;
|
|
66 |
}
|
|
67 |
|
|
68 |
// ---------------------------------------------------------------------------
|
|
69 |
// CMRMultiCalenField::InitializeL()
|
|
70 |
// ---------------------------------------------------------------------------
|
|
71 |
//
|
|
72 |
void CMRMultiCalenField::InitializeL()
|
|
73 |
{
|
|
74 |
TAknLayoutText text = NMRLayoutManager::GetLayoutText(
|
|
75 |
Rect(),
|
|
76 |
NMRLayoutManager::EMRTextLayoutTextEditor );
|
|
77 |
|
|
78 |
iCalenName->SetFont( text.Font() );
|
|
79 |
// This is called so that theme changes will apply when changing theme "on the fly"
|
|
80 |
if ( IsFocused() )
|
|
81 |
{
|
|
82 |
iCalenName->FocusChanged( EDrawNow );
|
|
83 |
}
|
|
84 |
}
|
|
85 |
// ---------------------------------------------------------------------------
|
|
86 |
// CMRMultiCalenField::InternalizeL
|
|
87 |
// ---------------------------------------------------------------------------
|
|
88 |
//
|
|
89 |
void CMRMultiCalenField::InternalizeL( MESMRCalEntry& aEntry )
|
|
90 |
{
|
|
91 |
FUNC_LOG;
|
|
92 |
MESMRCalDbMgr& dbMgr = aEntry.GetDBMgr();
|
|
93 |
iCalenNameList.Reset();
|
|
94 |
|
|
95 |
dbMgr.GetMultiCalendarNameListL( iCalenNameList );
|
|
96 |
TPtrC calenName = dbMgr.GetCalendarNameByEntryL( aEntry );
|
|
97 |
iIndex = dbMgr.GetCurCalendarIndex();
|
|
98 |
iCalenName->SetTextL( calenName );
|
|
99 |
|
|
100 |
iEntry = &aEntry;
|
|
101 |
|
|
102 |
// Set's the calendar type change enabled or disabled.
|
|
103 |
if( FieldMode() == EESMRFieldModeEdit && !TypeChangeEnabledL() )
|
|
104 |
{
|
|
105 |
iTypeChangeEnabled = EFalse;
|
|
106 |
|
|
107 |
LockL();
|
|
108 |
}
|
|
109 |
else
|
|
110 |
{
|
|
111 |
iTypeChangeEnabled = ETrue;
|
|
112 |
}
|
|
113 |
}
|
|
114 |
|
|
115 |
// ---------------------------------------------------------------------------
|
|
116 |
// CMRMultiCalenField::SetOutlineFocusL
|
|
117 |
// ---------------------------------------------------------------------------
|
|
118 |
//
|
|
119 |
void CMRMultiCalenField::SetOutlineFocusL( TBool aFocus )
|
|
120 |
{
|
|
121 |
FUNC_LOG;
|
|
122 |
CESMRField::SetOutlineFocusL ( aFocus );
|
|
123 |
|
|
124 |
//Focus gained
|
|
125 |
if ( aFocus )
|
|
126 |
{
|
|
127 |
ChangeMiddleSoftKeyL(
|
|
128 |
EESMRCmdOpenMultiCalenSelectQuery, R_QTN_MSK_OPEN );
|
|
129 |
}
|
|
130 |
}
|
|
131 |
|
|
132 |
// ---------------------------------------------------------------------------
|
|
133 |
// CMRMultiCalenField::ExecuteGenericCommandL
|
|
134 |
// ---------------------------------------------------------------------------
|
|
135 |
//
|
|
136 |
TBool CMRMultiCalenField::ExecuteGenericCommandL( TInt aCommand )
|
|
137 |
{
|
|
138 |
FUNC_LOG;
|
|
139 |
|
|
140 |
TBool isUsed( EFalse );
|
|
141 |
if( aCommand == EESMRCmdOpenMultiCalenSelectQuery ||
|
|
142 |
aCommand == EAknCmdOpen )
|
|
143 |
{
|
|
144 |
if( IsLocked() )
|
|
145 |
{
|
|
146 |
HandleTactileFeedbackL();
|
|
147 |
|
|
148 |
CESMRGlobalNote::ExecuteL(
|
|
149 |
CESMRGlobalNote::EESMRUnableToEdit );
|
|
150 |
isUsed = ETrue;
|
|
151 |
}
|
|
152 |
|
|
153 |
else if( iTypeChangeEnabled )
|
|
154 |
{
|
|
155 |
HandleTactileFeedbackL();
|
|
156 |
|
|
157 |
ExecuteTypeQueryL();
|
|
158 |
isUsed = ETrue;
|
|
159 |
}
|
|
160 |
}
|
|
161 |
|
|
162 |
return isUsed;
|
|
163 |
}
|
|
164 |
|
|
165 |
// ---------------------------------------------------------------------------
|
|
166 |
// CMRMultiCalenField::Lock
|
|
167 |
// ---------------------------------------------------------------------------
|
|
168 |
//
|
|
169 |
void CMRMultiCalenField::LockL()
|
|
170 |
{
|
|
171 |
FUNC_LOG;
|
|
172 |
if( IsLocked() )
|
|
173 |
{
|
|
174 |
return;
|
|
175 |
}
|
|
176 |
|
|
177 |
CESMRField::LockL();
|
|
178 |
|
|
179 |
delete iLockIcon;
|
|
180 |
iLockIcon = NULL;
|
|
181 |
iLockIcon = CMRImage::NewL(
|
|
182 |
NMRBitmapManager::EMRBitmapLockField,
|
|
183 |
this,
|
|
184 |
ETrue );
|
|
185 |
}
|
|
186 |
|
|
187 |
// ---------------------------------------------------------------------------
|
|
188 |
// CMRMultiCalenField::ExecuteTypeQueryL
|
|
189 |
// ---------------------------------------------------------------------------
|
|
190 |
//
|
|
191 |
void CMRMultiCalenField::ExecuteTypeQueryL()
|
|
192 |
{
|
|
193 |
FUNC_LOG;
|
|
194 |
if ( FieldMode() == EESMRFieldModeView )
|
|
195 |
return;
|
|
196 |
|
|
197 |
TInt ret =
|
|
198 |
CESMRListQuery::ExecuteL(
|
|
199 |
CESMRListQuery::EESMRMultiCalenQuery,
|
|
200 |
iCalenNameList );
|
|
201 |
|
|
202 |
if ( ret != KErrCancel )
|
|
203 |
{
|
|
204 |
iIndex = ret;
|
|
205 |
iEntry->GetDBMgr().SetCurCalendarByIndex( iIndex );
|
|
206 |
|
|
207 |
// Send command to dialog
|
|
208 |
NotifyEventAsyncL( EESMRCmdCalendarChange );
|
|
209 |
UpdateLabelL( ret );
|
|
210 |
}
|
|
211 |
}
|
|
212 |
|
|
213 |
// ---------------------------------------------------------------------------
|
|
214 |
// CMRMultiCalenField::CMRMultiCalenField
|
|
215 |
// ---------------------------------------------------------------------------
|
|
216 |
//
|
|
217 |
CMRMultiCalenField::CMRMultiCalenField( ) :
|
|
218 |
iIndex( 0 )
|
|
219 |
{
|
|
220 |
FUNC_LOG;
|
|
221 |
SetFieldId( EESMRFieldCalendarName );
|
|
222 |
SetFocusType( EESMRHighlightFocus );
|
|
223 |
}
|
|
224 |
|
|
225 |
// ---------------------------------------------------------------------------
|
|
226 |
// CMRMultiCalenField::ConstructL
|
|
227 |
// ---------------------------------------------------------------------------
|
|
228 |
//
|
|
229 |
void CMRMultiCalenField::ConstructL( )
|
|
230 |
{
|
|
231 |
FUNC_LOG;
|
|
232 |
|
|
233 |
iCalenName = CMRLabel::NewL( this );
|
|
234 |
CESMRField::ConstructL( iCalenName );
|
|
235 |
iCalenName->SetTextL( KNullDesC() );
|
|
236 |
|
|
237 |
iIcon = CMRImage::NewL(
|
|
238 |
NMRBitmapManager::EMRBitmapCalendarSelection,
|
|
239 |
this );
|
|
240 |
|
|
241 |
}
|
|
242 |
|
|
243 |
// ---------------------------------------------------------------------------
|
|
244 |
// CMRMultiCalenField::UpdateLabelL
|
|
245 |
// ---------------------------------------------------------------------------
|
|
246 |
//
|
|
247 |
void CMRMultiCalenField::UpdateLabelL( TInt aIndex )
|
|
248 |
{
|
|
249 |
FUNC_LOG;
|
|
250 |
|
|
251 |
iCalenName->SetTextL( iCalenNameList[aIndex] );
|
|
252 |
iCalenName->DrawDeferred();
|
|
253 |
}
|
|
254 |
|
|
255 |
// ---------------------------------------------------------------------------
|
|
256 |
// CMRMultiCalenField::CountComponentControls
|
|
257 |
// ---------------------------------------------------------------------------
|
|
258 |
//
|
|
259 |
TInt CMRMultiCalenField::CountComponentControls() const
|
|
260 |
{
|
|
261 |
FUNC_LOG;
|
|
262 |
TInt count( 0 );
|
|
263 |
if ( iIcon )
|
|
264 |
{
|
|
265 |
++count;
|
|
266 |
}
|
|
267 |
|
|
268 |
if ( iCalenName )
|
|
269 |
{
|
|
270 |
++count;
|
|
271 |
}
|
|
272 |
|
|
273 |
if ( iLockIcon )
|
|
274 |
{
|
|
275 |
++count;
|
|
276 |
}
|
|
277 |
return count;
|
|
278 |
|
|
279 |
}
|
|
280 |
|
|
281 |
// ---------------------------------------------------------------------------
|
|
282 |
// CMRMultiCalenField::ComponentControl
|
|
283 |
// ---------------------------------------------------------------------------
|
|
284 |
//
|
|
285 |
CCoeControl* CMRMultiCalenField::ComponentControl( TInt aIndex ) const
|
|
286 |
{
|
|
287 |
FUNC_LOG;
|
|
288 |
CCoeControl* control = NULL;
|
|
289 |
switch( aIndex )
|
|
290 |
{
|
|
291 |
case 0:
|
|
292 |
{
|
|
293 |
control = iIcon;
|
|
294 |
break;
|
|
295 |
}
|
|
296 |
case 1:
|
|
297 |
{
|
|
298 |
control = iCalenName;
|
|
299 |
break;
|
|
300 |
}
|
|
301 |
case 2:
|
|
302 |
{
|
|
303 |
control = iLockIcon;
|
|
304 |
break;
|
|
305 |
}
|
|
306 |
default:
|
|
307 |
ASSERT( EFalse );
|
|
308 |
}
|
|
309 |
|
|
310 |
return control;
|
|
311 |
}
|
|
312 |
|
|
313 |
// ---------------------------------------------------------------------------
|
|
314 |
// CMRMultiCalenField::SizeChanged
|
|
315 |
// ---------------------------------------------------------------------------
|
|
316 |
//
|
|
317 |
void CMRMultiCalenField::SizeChanged()
|
|
318 |
{
|
|
319 |
FUNC_LOG;
|
|
320 |
TRect rect( Rect() );
|
|
321 |
TAknLayoutRect iconLayout =
|
|
322 |
NMRLayoutManager::GetLayoutRect(
|
|
323 |
rect, NMRLayoutManager::EMRLayoutTextEditorIcon );
|
|
324 |
TRect iconRect( iconLayout.Rect() );
|
|
325 |
iIcon->SetRect( iconRect );
|
|
326 |
|
|
327 |
// Layouting lock icon
|
|
328 |
TAknLayoutRect rowLayoutRect(
|
|
329 |
NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 ) );
|
|
330 |
TRect rowRect( rowLayoutRect.Rect() );
|
|
331 |
if( iLockIcon )
|
|
332 |
{
|
|
333 |
TAknWindowComponentLayout iconLayout(
|
|
334 |
NMRLayoutManager::GetWindowComponentLayout(
|
|
335 |
NMRLayoutManager::EMRLayoutSingleRowDColumnGraphic ) );
|
|
336 |
AknLayoutUtils::LayoutImage( iLockIcon, rowRect, iconLayout );
|
|
337 |
}
|
|
338 |
|
|
339 |
// Layouting label
|
|
340 |
TAknTextComponentLayout viewerLayoutText;
|
|
341 |
if( iLockIcon )
|
|
342 |
{
|
|
343 |
viewerLayoutText = NMRLayoutManager::GetTextComponentLayout(
|
|
344 |
NMRLayoutManager::EMRTextLayoutSingleRowEditorText );
|
|
345 |
}
|
|
346 |
else
|
|
347 |
{
|
|
348 |
viewerLayoutText = NMRLayoutManager::GetTextComponentLayout(
|
|
349 |
NMRLayoutManager::EMRTextLayoutTextEditor );
|
|
350 |
}
|
|
351 |
|
|
352 |
AknLayoutUtils::LayoutLabel( iCalenName, rect, viewerLayoutText );
|
|
353 |
TRect viewerRect( iCalenName->Rect() );
|
|
354 |
|
|
355 |
// Move focus rect so that it's relative to field's position.
|
|
356 |
viewerRect.Move( -Position() );
|
|
357 |
|
|
358 |
TAknLayoutRect bgLayoutRect =
|
|
359 |
NMRLayoutManager::GetLayoutRect(
|
|
360 |
rect, NMRLayoutManager::EMRLayoutTextEditorBg );
|
|
361 |
TRect bgRect( bgLayoutRect.Rect() );
|
|
362 |
|
|
363 |
// Adjust background rect according to viewerRect
|
|
364 |
bgRect.SetWidth( viewerRect.Width() );
|
|
365 |
|
|
366 |
// Move focus rect so that it's relative to field's position.
|
|
367 |
bgRect.Move( -Position() );
|
|
368 |
|
|
369 |
SetFocusRect( bgRect );
|
|
370 |
}
|
|
371 |
|
|
372 |
// ---------------------------------------------------------------------------
|
|
373 |
// CMRMultiCalenField::SetTextDimmed
|
|
374 |
// ---------------------------------------------------------------------------
|
|
375 |
//
|
|
376 |
void CMRMultiCalenField::SetTextDimmed()
|
|
377 |
{
|
|
378 |
FUNC_LOG;
|
|
379 |
|
|
380 |
NMRColorManager::SetColor(
|
|
381 |
*iCalenName,
|
|
382 |
NMRColorManager::EMRMainAreaTextColorDimmed );
|
|
383 |
}
|
|
384 |
|
|
385 |
// ---------------------------------------------------------------------------
|
|
386 |
// CMRMultiCalenField::TypeChangeEnabledL
|
|
387 |
// ---------------------------------------------------------------------------
|
|
388 |
//
|
|
389 |
TBool CMRMultiCalenField::TypeChangeEnabledL()
|
|
390 |
{
|
|
391 |
TBool ret( ETrue );
|
|
392 |
|
|
393 |
/*
|
|
394 |
* Case 1:
|
|
395 |
* If entry is single occurancy of a series, calendar type change
|
|
396 |
* is disabled for the user.
|
|
397 |
*/
|
|
398 |
if( iEntry->IsRecurrentEventL() &&
|
|
399 |
iEntry->RecurrenceModRule() == MESMRCalEntry::EESMRThisOnly &&
|
|
400 |
FieldMode() == EESMRFieldModeEdit )
|
|
401 |
{
|
|
402 |
ret = EFalse;
|
|
403 |
}
|
|
404 |
|
|
405 |
/*
|
|
406 |
* Case 2:
|
|
407 |
* If entry is meeting request, and opened from mailbox that does not
|
|
408 |
* support multiple calendar, calendar type change is disabled
|
|
409 |
* for the user.
|
|
410 |
*/
|
|
411 |
if( ret && CCalenInterimUtils2::IsMeetingRequestL( iEntry->Entry() ) &&
|
|
412 |
FieldMode() == EESMRFieldModeEdit )
|
|
413 |
{
|
|
414 |
MESMRMeetingRequestEntry* entry =
|
|
415 |
static_cast< MESMRMeetingRequestEntry* >( iEntry );
|
|
416 |
|
|
417 |
// If entry's current plugin is active sync, it means that
|
|
418 |
// Mail For Exchange is in use. This means, that multiple calendar
|
|
419 |
// functionality is not supported.
|
|
420 |
if( entry->CurrentPluginL() == EESMRActiveSync )
|
|
421 |
{
|
|
422 |
ret = EFalse;
|
|
423 |
}
|
|
424 |
}
|
|
425 |
|
|
426 |
/*
|
|
427 |
* Case 3:
|
|
428 |
* When the organizer of the MR edits an already sent MR, calendar
|
|
429 |
* cannot be changed --> calendar selection needs to be locked.
|
|
430 |
*/
|
|
431 |
if( ret && CCalenInterimUtils2::IsMeetingRequestL( iEntry->Entry() ) &&
|
|
432 |
FieldMode() == EESMRFieldModeEdit )
|
|
433 |
{
|
|
434 |
MESMRMeetingRequestEntry* entry =
|
|
435 |
static_cast< MESMRMeetingRequestEntry* >( iEntry );
|
|
436 |
if( entry->RoleL() == EESMRRoleOrganizer && entry->IsSentL() )
|
|
437 |
{
|
|
438 |
ret = EFalse;
|
|
439 |
}
|
|
440 |
}
|
|
441 |
|
|
442 |
return ret;
|
|
443 |
}
|
|
444 |
|
|
445 |
// EOF
|
|
446 |
|