author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:30:35 +0300 | |
branch | RCL_3 |
changeset 86 | ed599363c2d7 |
parent 66 | bd7edf625bdd |
permissions | -rw-r--r-- |
66 | 1 |
/* |
2 |
* Copyright (c) 2008 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: Container base class of Calendar application. |
|
15 |
* This class is the derivation origin of Calendar container. |
|
16 |
* |
|
17 |
*/ |
|
18 |
||
19 |
// System includes |
|
20 |
#include <Calendar.rsg> |
|
21 |
#include <StringLoader.h> |
|
22 |
#include <AknsBasicBackgroundControlContext.h> |
|
23 |
#include <layoutmetadata.cdl.h> |
|
24 |
#include <aknconsts.h> |
|
25 |
#include <AknIconArray.h> |
|
26 |
#include <aknlists.h> |
|
27 |
#include <akntitle.h> |
|
28 |
#include <eikclbd.h> |
|
29 |
#include <aknnavi.h> |
|
30 |
#include <gulicon.h> |
|
31 |
#include <aknenv.h> |
|
32 |
#include <aknnotewrappers.h> |
|
33 |
#include <centralrepository.h> |
|
34 |
#include <aknlayoutscalable_apps.cdl.h> |
|
35 |
#include <AknIconUtils.h> |
|
36 |
#include <aknbutton.h> |
|
37 |
#include <akntoolbar.h> |
|
38 |
#include <avkon.mbg> |
|
39 |
#include <calencommonui.rsg> |
|
40 |
#include <calentoolbar.h> |
|
41 |
#include <calcalendarinfo.h> |
|
42 |
#include <CalenInterimUtils2.h> |
|
43 |
#include <calenmulticalutil.h> |
|
44 |
#include <calenmulticaluids.hrh> |
|
45 |
#include <featmgr.h> |
|
46 |
#include <hlplch.h> |
|
47 |
#include <csxhelp/cale.hlp.hrh> |
|
48 |
||
49 |
// User includes |
|
50 |
#include "calendarui_debug.h" |
|
51 |
#include "calenmultipledbui.h" |
|
52 |
#include "calendar.hrh" |
|
53 |
#include "calenmultidbeditor.h" |
|
54 |
#include "CalendarPrivateCRKeys.h" |
|
55 |
#include "calencontroller.h" |
|
56 |
#include "CalenUid.h" |
|
57 |
||
58 |
// Constants |
|
59 |
_LIT( KListSeparatorFormat, "\t" ); |
|
60 |
const TInt KMultiDbMaxLength = 300; |
|
61 |
const TInt KBuffLength = 24; |
|
62 |
||
63 |
||
64 |
||
65 |
// ---------------------------------------------------------------------------- |
|
66 |
// CCalenMultipleDbListboxItemDrawer::CCalenMultipleDbListboxItemDrawer |
|
67 |
// Constructor |
|
68 |
// ---------------------------------------------------------------------------- |
|
69 |
// |
|
70 |
CCalenMultipleDbListboxItemDrawer::CCalenMultipleDbListboxItemDrawer( |
|
71 |
MTextListBoxModel* aTextListBoxModel, |
|
72 |
const CFont* aFont, |
|
73 |
CFormattedCellListBoxData* aFormattedCellData, |
|
74 |
CEikListBox* aListBox , |
|
75 |
const RArray<TInt32>& aColorUidArray ) |
|
76 |
: CFormattedCellListBoxItemDrawer(aTextListBoxModel,aFont,aFormattedCellData), |
|
77 |
iListBox(aListBox), |
|
78 |
iColorUidArray(aColorUidArray) |
|
79 |
{ |
|
80 |
TRACE_ENTRY_POINT |
|
81 |
TRACE_EXIT_POINT |
|
82 |
} |
|
83 |
||
84 |
// ---------------------------------------------------------------------------- |
|
85 |
// CCalenMultipleDbListboxItemDrawer::CCalenMultipleDbListboxItemDrawer |
|
86 |
// ---------------------------------------------------------------------------- |
|
87 |
// |
|
88 |
CCalenMultipleDbListboxItemDrawer::~CCalenMultipleDbListboxItemDrawer() |
|
89 |
{ |
|
90 |
TRACE_ENTRY_POINT |
|
91 |
TRACE_EXIT_POINT |
|
92 |
} |
|
93 |
||
94 |
// ---------------------------------------------------------------------------- |
|
95 |
// CCalenMultipleDbListboxItemDrawer::DrawItem |
|
96 |
// ---------------------------------------------------------------------------- |
|
97 |
// |
|
98 |
void CCalenMultipleDbListboxItemDrawer::DrawItem(TInt aItemIndex, |
|
99 |
TPoint aItemRectPos, |
|
100 |
TBool aItemIsSelected, |
|
101 |
TBool aItemIsCurrent, |
|
102 |
TBool aViewIsEmphasized, |
|
103 |
TBool aViewIsDimmed) const |
|
104 |
{ |
|
105 |
TRACE_ENTRY_POINT |
|
106 |
TRect actualItemRect(aItemRectPos, iItemCellSize); |
|
107 |
SetupGc(aItemIndex); |
|
108 |
||
109 |
CFormattedCellListBoxItemDrawer::DrawItem(aItemIndex, |
|
110 |
aItemRectPos, |
|
111 |
aItemIsSelected, |
|
112 |
aItemIsCurrent, |
|
113 |
aViewIsEmphasized, |
|
114 |
aViewIsDimmed); |
|
115 |
||
116 |
iGc->Reset(); |
|
117 |
||
118 |
TAknWindowComponentLayout tempLayout = AknLayoutScalable_Apps::list_cale_time_pane_g6(0); |
|
119 |
||
120 |
TAknLayoutRect colourstrips; |
|
121 |
colourstrips.LayoutRect( actualItemRect, tempLayout.LayoutLine() ); |
|
122 |
||
123 |
iGc->SetPenColor( CGraphicsContext::ENullPen ); |
|
124 |
iGc->DrawRect( colourstrips.Rect() ); |
|
125 |
iGc->SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
126 |
iGc->SetBrushColor( TRgb(iColorUidArray[aItemIndex] )); |
|
127 |
iGc->DrawRect( colourstrips.Rect() ); |
|
128 |
||
129 |
iGc->Reset(); |
|
130 |
||
131 |
TRACE_EXIT_POINT |
|
132 |
} |
|
133 |
||
134 |
// ---------------------------------------------------------------------------- |
|
135 |
// CCalenMultipleDbListbox::DrawItem |
|
136 |
// ---------------------------------------------------------------------------- |
|
137 |
// |
|
138 |
CCalenMultipleDbListbox::CCalenMultipleDbListbox(const RArray<TInt32>& aColorUidArray) : |
|
139 |
iColorUidArray(aColorUidArray) |
|
140 |
{ |
|
141 |
TRACE_ENTRY_POINT |
|
142 |
TRACE_EXIT_POINT |
|
143 |
} |
|
144 |
||
145 |
// ---------------------------------------------------------------------------- |
|
146 |
// CCalenMultipleDbListbox::CreateItemDrawerL |
|
147 |
// ---------------------------------------------------------------------------- |
|
148 |
// |
|
149 |
void CCalenMultipleDbListbox::CreateItemDrawerL() |
|
150 |
{ |
|
151 |
TRACE_ENTRY_POINT |
|
152 |
CFormattedCellListBoxData* cellData=CFormattedCellListBoxData::NewL(); |
|
153 |
CleanupStack::PushL( cellData ); |
|
154 |
iItemDrawer=new(ELeave) CCalenMultipleDbListboxItemDrawer( |
|
155 |
Model(), iEikonEnv->NormalFont(), cellData, this,iColorUidArray); |
|
156 |
CleanupStack::Pop(); |
|
157 |
TRACE_EXIT_POINT |
|
158 |
} |
|
159 |
||
160 |
// ---------------------------------------------------------------------------- |
|
161 |
// CCalenMultipleDbListbox::CreateItemDrawerL |
|
162 |
// ---------------------------------------------------------------------------- |
|
163 |
// |
|
164 |
void CCalenMultipleDbListbox::SizeChanged() |
|
165 |
{ |
|
166 |
TRACE_ENTRY_POINT |
|
167 |
TRAP_IGNORE(SizeChangedL()); |
|
168 |
TRACE_EXIT_POINT |
|
169 |
} |
|
170 |
||
171 |
// ---------------------------------------------------------------------------- |
|
172 |
// CCalenMultipleDbListbox::SizeChangedL |
|
173 |
// ---------------------------------------------------------------------------- |
|
174 |
// |
|
175 |
void CCalenMultipleDbListbox::SizeChangedL() |
|
176 |
{ |
|
177 |
TRACE_ENTRY_POINT |
|
178 |
CAknDoubleGraphicStyleListBox::SizeChanged(); |
|
179 |
TRACE_EXIT_POINT |
|
180 |
} |
|
181 |
||
182 |
// ---------------------------------------------------------------------------- |
|
183 |
// CCalenMultipleDbUi::CCalenMultipleDbUi |
|
184 |
// Constructor |
|
185 |
// (other items were commented in a header). |
|
186 |
// ---------------------------------------------------------------------------- |
|
187 |
// |
|
188 |
CCalenMultipleDbUi::CCalenMultipleDbUi(CCalenController& aController) : |
|
189 |
iController(aController) |
|
190 |
{ |
|
191 |
TRACE_ENTRY_POINT; |
|
192 |
TRACE_EXIT_POINT; |
|
193 |
} |
|
194 |
||
195 |
// ---------------------------------------------------------------------------- |
|
196 |
// CCalenMultipleDbUi::CCalenEditUi |
|
197 |
// First stage construction |
|
198 |
// (other items were commented in a header). |
|
199 |
// ---------------------------------------------------------------------------- |
|
200 |
// |
|
201 |
CCalenMultipleDbUi* CCalenMultipleDbUi::NewL(CCalenController& aController) |
|
202 |
{ |
|
203 |
TRACE_ENTRY_POINT; |
|
204 |
CCalenMultipleDbUi* self = new(ELeave) CCalenMultipleDbUi(aController); |
|
205 |
CleanupStack::PushL(self); |
|
206 |
self->ConstructL(); |
|
207 |
CleanupStack::Pop(self); |
|
208 |
TRACE_EXIT_POINT; |
|
209 |
return self; |
|
210 |
} |
|
211 |
||
212 |
// ---------------------------------------------------------------------------- |
|
213 |
// CCalenMultipleDbUi::ConstructL |
|
214 |
// Second stage construction |
|
215 |
// (other items were commented in a header). |
|
216 |
// ---------------------------------------------------------------------------- |
|
217 |
// |
|
218 |
void CCalenMultipleDbUi::ConstructL() |
|
219 |
{ |
|
220 |
TRACE_ENTRY_POINT; |
|
221 |
CAknDialog::ConstructL( R_CALEN_MULTIPLEDB_MENUBAR ); |
|
222 |
SetTitlePaneL(); |
|
223 |
||
224 |
TCallBack actionCallBack(CCalenMultipleDbUi::AsyncCallBackL, this); |
|
225 |
iAsyncAction = new(ELeave) CAsyncCallBack(actionCallBack,CActive::EPriorityStandard); |
|
226 |
||
227 |
// register for calendar file change notifications |
|
228 |
RArray<TCalenNotification> notificationArray; |
|
229 |
notificationArray.Append(ECalenNotifyCalendarInfoCreated); |
|
230 |
notificationArray.Append(ECalenNotifyCalendarInfoUpdated); |
|
231 |
notificationArray.Append(ECalenNotifyCalendarFileDeleted); |
|
232 |
iController.RegisterForNotificationsL(this, notificationArray); |
|
233 |
||
234 |
notificationArray.Close(); |
|
235 |
||
236 |
iConflictOccured = EFalse; |
|
237 |
||
238 |
TRACE_EXIT_POINT; |
|
239 |
} |
|
240 |
||
241 |
// ---------------------------------------------------------------------------- |
|
242 |
// CCalenMultipleDbUi::~CCalenMultipleDbUi |
|
243 |
// (other items were commented in a header). |
|
244 |
// ---------------------------------------------------------------------------- |
|
245 |
// |
|
246 |
CCalenMultipleDbUi::~CCalenMultipleDbUi() |
|
247 |
{ |
|
248 |
TRACE_ENTRY_POINT; |
|
249 |
||
250 |
iController.CancelNotifications(this); |
|
251 |
||
252 |
if( iNaviContainer ) |
|
253 |
{ |
|
254 |
iNaviContainer->Pop(); // Remove navi pane used by settings view |
|
255 |
iNaviContainer = NULL; // iNaviContainer is not owned |
|
256 |
} |
|
257 |
||
258 |
delete iBgContext; |
|
259 |
iBgContext = NULL; |
|
260 |
||
261 |
iListBox->Reset(); |
|
262 |
delete iListBox; |
|
263 |
iListBox = NULL; |
|
264 |
||
265 |
delete iDesArray; |
|
266 |
iDesArray = NULL; |
|
267 |
||
268 |
iColorUidArray.Close(); |
|
269 |
||
270 |
iIconIndices.Reset(); |
|
271 |
iIconIndices.Close(); |
|
272 |
||
273 |
iAsyncAction->Cancel(); |
|
274 |
delete iAsyncAction; |
|
275 |
iAsyncAction = NULL; |
|
276 |
||
277 |
if(iCalendarInfoNew) |
|
278 |
{ |
|
279 |
delete iCalendarInfoNew; |
|
280 |
iCalendarInfoNew = NULL; |
|
281 |
} |
|
282 |
||
283 |
if(iCalendarInfoOriginal) |
|
284 |
{ |
|
285 |
delete iCalendarInfoOriginal; |
|
286 |
iCalendarInfoOriginal = NULL; |
|
287 |
} |
|
86
ed599363c2d7
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
288 |
|
66 | 289 |
TRACE_EXIT_POINT; |
290 |
} |
|
291 |
||
292 |
// ---------------------------------------------------------------------------- |
|
293 |
// CCalenMultipleDbUi::FocusChanged |
|
294 |
// (other items were commented in a header). |
|
295 |
// ---------------------------------------------------------------------------- |
|
296 |
// |
|
297 |
void CCalenMultipleDbUi::FocusChanged( TDrawNow aDrawNow ) |
|
298 |
{ |
|
299 |
TRACE_ENTRY_POINT; |
|
300 |
||
301 |
CAknDialog::FocusChanged( aDrawNow ); |
|
302 |
||
303 |
TRACE_EXIT_POINT; |
|
304 |
} |
|
305 |
||
306 |
// ---------------------------------------------------------------------------- |
|
307 |
// CCalenMultipleDbUi::ConstructListL |
|
308 |
// Construct listbox , model and icon |
|
309 |
// ---------------------------------------------------------------------------- |
|
310 |
// |
|
311 |
void CCalenMultipleDbUi::ConstructListL() |
|
312 |
{ |
|
313 |
TRACE_ENTRY_POINT; |
|
314 |
if(iDesArray && iListBox) |
|
315 |
{ |
|
316 |
return; |
|
317 |
} |
|
318 |
||
319 |
iDesArray = new (ELeave) CDesCArrayFlat(5); |
|
320 |
iListBox = new (ELeave) CCalenMultipleDbListbox(iColorUidArray); |
|
321 |
iListBox->SetContainerWindowL( *this ); |
|
322 |
iListBox->ConstructL(this, EAknListBoxSelectionList ); |
|
323 |
||
324 |
//Create scroll bar |
|
325 |
iListBox->CreateScrollBarFrameL(ETrue); |
|
326 |
iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
327 |
CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto); |
|
328 |
||
329 |
CTextListBoxModel* model = iListBox->Model(); |
|
330 |
model->SetItemTextArray(iDesArray); |
|
331 |
model->SetOwnershipType(ELbmDoesNotOwnItemArray); |
|
332 |
||
333 |
iListBox->View()->SetListEmptyTextL( _L("No Items") ); |
|
334 |
||
335 |
iListBox->SetListBoxObserver( this ); |
|
336 |
PrepareIconsL( ); |
|
337 |
TRACE_EXIT_POINT; |
|
338 |
} |
|
339 |
||
340 |
// ---------------------------------------------------------------------------- |
|
341 |
// CCalenMultipleDbUi::UpdateListboxL |
|
342 |
// Update listbox with latest data from metadb |
|
343 |
// ---------------------------------------------------------------------------- |
|
344 |
// |
|
345 |
void CCalenMultipleDbUi::UpdateListboxL() |
|
346 |
{ |
|
347 |
TRACE_ENTRY_POINT; |
|
348 |
||
349 |
if(!iListBox) |
|
350 |
return; |
|
351 |
||
352 |
iListBox->View()->SetDisableRedraw( ETrue ); |
|
353 |
iDesArray->Reset(); |
|
354 |
iColorUidArray.Close(); |
|
355 |
||
356 |
SetTitlePaneL(); |
|
357 |
RPointerArray<CCalCalendarInfo> calendarInfoList; |
|
358 |
CleanupClosePushL(calendarInfoList); |
|
359 |
iController.GetAllCalendarInfoL(calendarInfoList); |
|
360 |
||
361 |
TInt calendarInfoCount = calendarInfoList.Count(); |
|
362 |
||
363 |
if(calendarInfoCount) |
|
364 |
{ |
|
365 |
iListBox->ItemDrawer()->ColumnData()->SetIconArray( iIconList ); |
|
366 |
||
367 |
for(TInt i = 0 ; i < calendarInfoCount ; i++) |
|
368 |
{ |
|
369 |
TBuf<KMultiDbMaxLength> targetBuffer; |
|
370 |
CCalCalendarInfo* calendarInfo = calendarInfoList[i]; |
|
371 |
||
372 |
HBufC* calendarName = calendarInfo->NameL().AllocLC(); |
|
373 |
||
374 |
//"%d\t%S\t%S\t%d" |
|
375 |
targetBuffer.Append(KListSeparatorFormat); |
|
376 |
targetBuffer.Append(calendarName->Des()); |
|
377 |
targetBuffer.Append(KListSeparatorFormat); |
|
378 |
||
379 |
HBufC* calendarVisibility = NULL; |
|
380 |
if(calendarInfo->Enabled()) |
|
381 |
{ |
|
382 |
calendarVisibility = StringLoader::LoadLC( |
|
383 |
R_CALE_MULTIPLEDB_VISIBLE, iCoeEnv ); |
|
384 |
} |
|
385 |
else |
|
386 |
{ |
|
387 |
calendarVisibility = StringLoader::LoadLC( |
|
388 |
R_CALE_MULTIPLEDB_HIDDEN, iCoeEnv ); |
|
389 |
} |
|
390 |
||
391 |
targetBuffer.Append(calendarVisibility->Des()); |
|
392 |
CleanupStack::PopAndDestroy(calendarVisibility); |
|
393 |
||
394 |
targetBuffer.Append(KListSeparatorFormat); |
|
395 |
||
396 |
//Collect color info to be used in itemdrawer for painting strip |
|
397 |
iColorUidArray.Append(calendarInfo->Color().Value()); |
|
398 |
||
399 |
iDesArray->AppendL(targetBuffer); |
|
400 |
CleanupStack::PopAndDestroy(calendarName); |
|
401 |
} |
|
402 |
} |
|
403 |
CleanupStack::PopAndDestroy(&calendarInfoList); |
|
404 |
||
405 |
iListBox->View()->SetDisableRedraw( EFalse ); |
|
406 |
iListBox->HandleItemAdditionL(); //Update and draw listbox |
|
407 |
TRACE_EXIT_POINT; |
|
408 |
} |
|
409 |
||
410 |
// ---------------------------------------------------------------------------- |
|
411 |
// CCalenMultipleDbUi::PrepareIconsL |
|
412 |
// Load icon into memory |
|
413 |
// ---------------------------------------------------------------------------- |
|
414 |
// |
|
415 |
void CCalenMultipleDbUi::PrepareIconsL() |
|
416 |
{ |
|
417 |
TRACE_ENTRY_POINT; |
|
418 |
iIconIndices.Reset(); |
|
419 |
iIconIndices.AppendL( MCalenServices::ECalenSyncIcon ); |
|
420 |
||
421 |
iIconList = CreateIconsL(iIconIndices); |
|
422 |
||
423 |
TRACE_EXIT_POINT; |
|
424 |
} |
|
425 |
||
426 |
// ---------------------------------------------------------------------------- |
|
427 |
// CCalenMultipleDbUi::CreateIconsL |
|
428 |
// Create CGulIcon from mif |
|
429 |
// ---------------------------------------------------------------------------- |
|
430 |
// |
|
431 |
CAknIconArray* CCalenMultipleDbUi::CreateIconsL( |
|
432 |
RArray<MCalenServices::TCalenIcons>& aIndexArray ) |
|
433 |
{ |
|
434 |
TRACE_ENTRY_POINT; |
|
435 |
const TInt iconCount( aIndexArray.Count() ); |
|
436 |
||
437 |
CAknIconArray* icons = new(ELeave) CAknIconArray( iconCount ); |
|
438 |
CleanupStack::PushL( icons ); |
|
439 |
icons->SetReserveL( iconCount ); |
|
440 |
||
441 |
for( TInt i=0; i < iconCount; ++i ) |
|
442 |
{ |
|
443 |
icons->AppendL( iController.Services(). |
|
444 |
GetIconL( static_cast<MCalenServices::TCalenIcons>(aIndexArray[i]))); |
|
445 |
} |
|
446 |
||
447 |
CleanupStack::Pop( icons ); |
|
448 |
||
449 |
TRACE_EXIT_POINT; |
|
450 |
return icons; |
|
451 |
} |
|
452 |
||
453 |
// ---------------------------------------------------------------------------- |
|
454 |
// CCalenMultipleDbUi::SetTitlePaneL |
|
455 |
// Set title pane for calendar management view |
|
456 |
// ---------------------------------------------------------------------------- |
|
457 |
// |
|
458 |
void CCalenMultipleDbUi::SetTitlePaneL() |
|
459 |
{ |
|
460 |
TRACE_ENTRY_POINT; |
|
461 |
CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane(); |
|
462 |
||
463 |
// Set empty navi pane label |
|
464 |
iNaviContainer = static_cast<CAknNavigationControlContainer*>( |
|
465 |
sp->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) ); |
|
466 |
iNaviContainer->PushDefaultL(); |
|
467 |
||
468 |
// Set title text |
|
469 |
CAknTitlePane* tp = static_cast<CAknTitlePane*>( |
|
470 |
sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
|
471 |
HBufC* titleText; |
|
472 |
if(iIsDbEditorOpen) |
|
473 |
{ |
|
474 |
titleText = StringLoader::LoadLC( R_QTN_CALE_TITLE_CALENDAR , iCoeEnv ); |
|
475 |
} |
|
476 |
else |
|
477 |
{ |
|
478 |
titleText = StringLoader::LoadLC( R_QTN_CALE_TITLE_CALENDARS , iCoeEnv ); |
|
479 |
} |
|
480 |
tp->SetTextL( *titleText ); // r_qtn_cale_title_calendars |
|
481 |
CleanupStack::PopAndDestroy( titleText ); |
|
482 |
||
483 |
TRACE_EXIT_POINT; |
|
484 |
} |
|
485 |
||
486 |
||
487 |
||
488 |
||
489 |
// ---------------------------------------------------------------------------- |
|
490 |
// CCalenMultipleDbUi::DynInitMenuPaneL |
|
491 |
// Do functionalites before options menu execs |
|
492 |
// ---------------------------------------------------------------------------- |
|
493 |
// |
|
494 |
void CCalenMultipleDbUi::DynInitMenuPaneL( TInt aResourceId,CEikMenuPane* aMenuPane ) |
|
495 |
{ |
|
496 |
TRACE_ENTRY_POINT; |
|
497 |
switch(aResourceId) |
|
498 |
{ |
|
499 |
case R_CALEN_MULTIPLEDB_MENUPANE: |
|
500 |
{ |
|
501 |
if(!iListBox->Model()->ItemTextArray()->MdcaCount()) |
|
502 |
{ |
|
503 |
aMenuPane->DeleteMenuItem(ECalenCmdEdit); |
|
504 |
aMenuPane->DeleteMenuItem(ECalenCmdItemSelect); |
|
505 |
aMenuPane->DeleteMenuItem(ECalenCmdItemDeselect); |
|
506 |
aMenuPane->DeleteMenuItem(ECalenCmdDelete); |
|
507 |
} |
|
508 |
else |
|
509 |
{ |
|
510 |
RPointerArray<CCalCalendarInfo> calendarInfoList; |
|
511 |
iController.GetAllCalendarInfoL(calendarInfoList); |
|
512 |
CleanupClosePushL(calendarInfoList); |
|
513 |
TInt currentIndex = iListBox->CurrentItemIndex(); |
|
514 |
||
515 |
TInt cmd = calendarInfoList[currentIndex]->Enabled() ? |
|
516 |
ECalenCmdItemSelect : ECalenCmdItemDeselect; |
|
517 |
||
518 |
aMenuPane->DeleteMenuItem(cmd); |
|
519 |
||
520 |
HBufC* calendarFileName = |
|
521 |
calendarInfoList[currentIndex]->FileNameL().AllocLC(); |
|
522 |
if (!(calendarFileName->CompareF( |
|
523 |
iController.Services().SessionL().DefaultFileNameL()))) |
|
524 |
{ |
|
525 |
aMenuPane->DeleteMenuItem(ECalenCmdDelete); |
|
526 |
} |
|
527 |
CleanupStack::PopAndDestroy(calendarFileName); |
|
528 |
CleanupStack::PopAndDestroy(&calendarInfoList); |
|
529 |
} |
|
530 |
} |
|
531 |
break; |
|
532 |
default: |
|
533 |
break; |
|
534 |
} |
|
535 |
||
536 |
TRACE_EXIT_POINT; |
|
537 |
} |
|
538 |
||
539 |
// ---------------------------------------------------------------------------- |
|
540 |
// CCalenMultipleDbUi::ProcessCommandL |
|
541 |
// Handle options menu items command |
|
542 |
// ---------------------------------------------------------------------------- |
|
543 |
// |
|
544 |
void CCalenMultipleDbUi::ProcessCommandL( TInt aCommandId ) |
|
545 |
{ |
|
546 |
TRACE_ENTRY_POINT; |
|
547 |
CAknDialog::ProcessCommandL(aCommandId); |
|
548 |
||
549 |
switch(aCommandId) |
|
550 |
{ |
|
551 |
case ECalenCmdEdit: |
|
552 |
{ |
|
553 |
TInt retValue = EditItemL(); |
|
554 |
if(retValue == EAknCmdExit || retValue == EAknSoftkeyExit ) |
|
555 |
{ |
|
556 |
DoAsyncActionL(retValue); |
|
557 |
} |
|
558 |
} |
|
559 |
break; |
|
560 |
case ECalenCmdAdd: |
|
561 |
{ |
|
562 |
TInt retValue = AddItemL(); |
|
563 |
if(retValue == EAknCmdExit || retValue == EAknSoftkeyExit ) |
|
564 |
{ |
|
565 |
DoAsyncActionL(retValue); |
|
566 |
} |
|
567 |
} |
|
568 |
break; |
|
569 |
case ECalenCmdDelete: |
|
570 |
{ |
|
571 |
DoAsyncActionL(ECalenCmdDelete); |
|
572 |
} |
|
573 |
break; |
|
574 |
case ECalenCmdItemSelect: |
|
575 |
case ECalenCmdShow: |
|
576 |
{ |
|
577 |
DoSelectionL(ETrue); |
|
578 |
} |
|
579 |
break; |
|
580 |
case ECalenCmdItemDeselect: |
|
581 |
case ECalenCmdHide: |
|
582 |
{ |
|
583 |
DoSelectionL(EFalse); |
|
584 |
} |
|
585 |
break; |
|
586 |
case EAknCmdExit: |
|
587 |
case EAknSoftkeyExit: |
|
588 |
{ |
|
589 |
DoAsyncActionL(EAknSoftkeyExit); |
|
590 |
} |
|
591 |
break; |
|
592 |
case EAknCmdHelp: |
|
593 |
if (FeatureManager::FeatureSupported(KFeatureIdHelp)) |
|
594 |
{ |
|
595 |
HlpLauncher::LaunchHelpApplicationL( |
|
596 |
iCoeEnv->WsSession(),iAvkonAppUi->AppHelpContextL()); |
|
597 |
} |
|
598 |
break; |
|
599 |
default: |
|
600 |
break; |
|
601 |
} |
|
602 |
TRACE_EXIT_POINT; |
|
603 |
} |
|
604 |
||
605 |
// ---------------------------------------------------------------------------- |
|
606 |
// CCalenMultipleDbUi::GetHelpContext |
|
607 |
// Gets help context |
|
608 |
// (other items were commented in a header). |
|
609 |
// ---------------------------------------------------------------------------- |
|
610 |
// |
|
611 |
void CCalenMultipleDbUi::GetHelpContext( TCoeHelpContext& aContext ) const |
|
612 |
{ |
|
613 |
TRACE_ENTRY_POINT; |
|
614 |
||
615 |
aContext.iMajor = KUidCalendar; |
|
616 |
// This is specified in HRH file. |
|
617 |
aContext.iContext = KCALE_HLP_DAY_VIEW; //KCALE_HLP_DAY_VIEW should be replaced with MultipleDbUi related help id |
|
618 |
||
619 |
TRACE_EXIT_POINT; |
|
620 |
} |
|
621 |
||
622 |
// ---------------------------------------------------------------------------- |
|
623 |
// CCalenMultipleDbUi::DoSelectionL |
|
624 |
// Mark the listbox item as hidden/visible based on aMark status |
|
625 |
// ---------------------------------------------------------------------------- |
|
626 |
// |
|
627 |
void CCalenMultipleDbUi::DoSelectionL( TBool aMark ) |
|
628 |
{ |
|
629 |
TRACE_ENTRY_POINT; |
|
630 |
TInt currentIndex = iListBox->CurrentItemIndex(); |
|
631 |
||
632 |
RPointerArray<CCalCalendarInfo> calendarInfoList; |
|
633 |
iController.GetAllCalendarInfoL(calendarInfoList); |
|
634 |
CleanupClosePushL(calendarInfoList); |
|
635 |
||
636 |
CCalCalendarInfo* calendarInfo = calendarInfoList[currentIndex]; |
|
637 |
calendarInfo->SetEnabled(aMark); |
|
638 |
iController.UpdateCalendarL(calendarInfo); |
|
639 |
CleanupStack::PopAndDestroy(&calendarInfoList); |
|
640 |
UpdateListboxL(); |
|
641 |
||
642 |
TRACE_EXIT_POINT; |
|
643 |
} |
|
644 |
// ---------------------------------------------------------------------------- |
|
645 |
// CCalenMultipleDbUi::AddItemL |
|
646 |
// Add new item in listbox |
|
647 |
// ---------------------------------------------------------------------------- |
|
648 |
// |
|
649 |
TInt CCalenMultipleDbUi::AddItemL() |
|
650 |
{ |
|
651 |
TRACE_ENTRY_POINT |
|
652 |
TInt retValue = 0; |
|
653 |
||
654 |
if(iCalendarInfoNew) |
|
655 |
{ |
|
656 |
delete iCalendarInfoNew; |
|
657 |
iCalendarInfoNew = NULL; |
|
658 |
} |
|
659 |
||
660 |
iCalendarInfoNew = CCalCalendarInfo::NewL(); |
|
661 |
iCalendarInfoNew->SetNameL(KNullDesC16); |
|
662 |
iCalendarInfoNew->SetColor(KCalenBlue.Value()); |
|
663 |
iCalendarInfoNew->SetEnabled(ETrue); |
|
664 |
iDbEditor = CCalenMultiDBEditor::NewL(*this,*iCalendarInfoNew, iController, EFalse ); |
|
665 |
||
666 |
//Async dialog |
|
667 |
retValue = iDbEditor->ExecuteLD(); |
|
668 |
//iDbEditor = NULL; |
|
669 |
||
670 |
if(EAknCmdExit == retValue ) |
|
671 |
{ |
|
672 |
iController.BroadcastNotification(ECalenNotifyRealExit); |
|
673 |
} |
|
674 |
||
675 |
TRACE_EXIT_POINT |
|
676 |
return retValue; |
|
677 |
} |
|
678 |
||
679 |
||
680 |
// ---------------------------------------------------------------------------- |
|
681 |
// CCalenMultipleDbUi::UpdateAddOrEditL |
|
682 |
// ---------------------------------------------------------------------------- |
|
683 |
// |
|
684 |
TInt CCalenMultipleDbUi::UpdateOnAddOrEditL(TBool aItemAdded) |
|
685 |
{ |
|
686 |
TRACE_ENTRY_POINT |
|
687 |
TInt retError = KErrNone; |
|
688 |
||
689 |
iDbEditor = NULL; |
|
690 |
||
691 |
if(aItemAdded) |
|
692 |
{ |
|
693 |
TRAP(retError, |
|
694 |
// Set calendar properties for new calendar being created. |
|
695 |
SetCalendarAddPropertiesL(*iCalendarInfoNew); |
|
696 |
||
697 |
//This makes sure calendarInfo will get deleted anyway! |
|
698 |
iController.AddCalendarL(iCalendarInfoNew); |
|
699 |
); |
|
700 |
||
701 |
iCalendarInfoNew = NULL; |
|
702 |
||
703 |
//Highlight the newly created list item |
|
704 |
iListBox->ScrollToMakeItemVisible(iListBox->BottomItemIndex()); |
|
705 |
iListBox->SetCurrentItemIndexAndDraw(iDesArray->Count()-1); |
|
706 |
} |
|
707 |
else |
|
708 |
{ |
|
709 |
//Before checking for changes , check if any conflict occured i.e calendar updated / deleted. |
|
710 |
//if there is conflict iConflictOccured = true then skip below condition. |
|
711 |
if (!iConflictOccured && iCalendarInfoOriginal && |
|
712 |
CheckForChangesL(*iCalendarInfoOriginal, |
|
713 |
*iCalendarInfoEdited)) |
|
714 |
{ |
|
715 |
TRAP(retError, |
|
716 |
// update the calendar properties such as modification time, sync status. |
|
717 |
SetCalendarUpdatePropertiesL(*iCalendarInfoEdited); |
|
718 |
||
719 |
iController.UpdateCalendarL(iCalendarInfoEdited); |
|
720 |
); |
|
721 |
||
722 |
} |
|
723 |
||
724 |
iConflictOccured = EFalse; |
|
725 |
delete iCalendarInfoOriginal,iCalendarInfoOriginal = NULL; |
|
726 |
} |
|
727 |
||
728 |
iIsDbEditorOpen = EFalse ; //iIsDbEditorOpen should be set before calling UpdateListboxL() |
|
729 |
||
730 |
TRAP_IGNORE(UpdateListboxL()); |
|
731 |
||
732 |
||
733 |
TRACE_EXIT_POINT |
|
734 |
return retError; |
|
735 |
} |
|
736 |
||
737 |
// ---------------------------------------------------------------------------- |
|
738 |
// CCalenMultipleDbUi::ExitDialogL |
|
739 |
// Edit item from listbox |
|
740 |
// ---------------------------------------------------------------------------- |
|
741 |
// |
|
742 |
void CCalenMultipleDbUi::ExitDialogL() |
|
743 |
{ |
|
744 |
TRACE_ENTRY_POINT |
|
745 |
iAsyncActionCmd = EAknSoftkeyExit; |
|
746 |
iAsyncAction->CallBack(); |
|
747 |
TRACE_EXIT_POINT |
|
748 |
} |
|
749 |
||
750 |
// ---------------------------------------------------------------------------- |
|
751 |
// CCalenMultipleDbUi::EditItemL |
|
752 |
// Edit item from listbox |
|
753 |
// ---------------------------------------------------------------------------- |
|
754 |
// |
|
755 |
TInt CCalenMultipleDbUi::EditItemL() |
|
756 |
{ |
|
757 |
TRACE_ENTRY_POINT |
|
758 |
TInt retValue = KErrNotFound; |
|
759 |
TInt currentIndex = iListBox->CurrentItemIndex(); |
|
760 |
||
761 |
RPointerArray<CCalCalendarInfo> calendarInfoList; |
|
762 |
iController.GetAllCalendarInfoL(calendarInfoList); |
|
763 |
CleanupClosePushL(calendarInfoList); |
|
764 |
||
765 |
iCalendarInfoEdited = calendarInfoList[currentIndex]; |
|
766 |
||
767 |
CleanupStack::PopAndDestroy(&calendarInfoList); |
|
768 |
||
769 |
//Take a copy of original before editing |
|
770 |
if(iCalendarInfoOriginal) |
|
771 |
{ |
|
772 |
delete iCalendarInfoOriginal; |
|
773 |
iCalendarInfoOriginal = NULL; |
|
774 |
} |
|
775 |
iCalendarInfoOriginal = CCalCalendarInfo::NewL(); |
|
776 |
||
777 |
iCalendarInfoOriginal->SetNameL(iCalendarInfoEdited->NameL()); |
|
778 |
iCalendarInfoOriginal->SetColor(iCalendarInfoEdited->Color()); |
|
779 |
iCalendarInfoOriginal->SetEnabled(iCalendarInfoEdited->Enabled()); |
|
780 |
TBuf8<KBuffLength> keyBuff; |
|
781 |
||
782 |
||
783 |
iDbEditor = CCalenMultiDBEditor::NewL(*this,*iCalendarInfoEdited, iController, |
|
784 |
ETrue); |
|
785 |
||
786 |
//Async dialog |
|
787 |
retValue = iDbEditor->ExecuteLD(); |
|
788 |
//iDbEditor = NULL; |
|
789 |
||
790 |
return retValue; |
|
791 |
TRACE_EXIT_POINT |
|
792 |
} |
|
793 |
||
794 |
// ---------------------------------------------------------------------------- |
|
795 |
// CCalenMultipleDbUi::DeleteItemL |
|
796 |
// Delete item from listbox |
|
797 |
// ---------------------------------------------------------------------------- |
|
798 |
// |
|
799 |
TInt CCalenMultipleDbUi::DeleteItemL() |
|
800 |
{ |
|
801 |
TRACE_ENTRY_POINT; |
|
802 |
||
803 |
TInt currentIndex = iCurrentIndex; |
|
804 |
||
805 |
RPointerArray<CCalCalendarInfo> calendarInfoList; |
|
806 |
iController.GetAllCalendarInfoL(calendarInfoList); |
|
807 |
CleanupClosePushL(calendarInfoList); |
|
808 |
||
809 |
CCalCalendarInfo* calendarInfo = calendarInfoList[currentIndex]; |
|
810 |
HBufC* calendarName = calendarInfo->NameL().AllocLC(); |
|
811 |
||
812 |
CAknQueryDialog *dialog = CAknQueryDialog::NewL( ); |
|
813 |
CleanupStack::PushL( dialog ); |
|
814 |
HBufC* textMessage = StringLoader::LoadLC( |
|
815 |
R_CALE_MULTIPLEDB_DELETE , *calendarName, iCoeEnv ); |
|
816 |
dialog->SetPromptL( *textMessage ); |
|
817 |
CleanupStack::PopAndDestroy( textMessage ); |
|
818 |
CleanupStack::Pop( dialog ); |
|
819 |
||
820 |
if(dialog->ExecuteLD(R_CALEN_ERASEQUERY_NOTE)) |
|
821 |
{ |
|
822 |
//BroadcastNotification for whatever instanceView created gets deleted. |
|
823 |
iController.BroadcastNotification(ECalenNotifyDeleteInstanceView); |
|
824 |
iController.RemoveCalendarL(calendarInfo->FileNameL()); |
|
825 |
||
826 |
UpdateListboxL(); |
|
827 |
||
828 |
ReAdjustListItemFocusL(currentIndex); |
|
829 |
} |
|
830 |
||
831 |
CleanupStack::PopAndDestroy(calendarName); |
|
832 |
CleanupStack::PopAndDestroy(&calendarInfoList); |
|
833 |
return 0; |
|
834 |
TRACE_EXIT_POINT |
|
835 |
} |
|
836 |
||
837 |
// ---------------------------------------------------------------------------- |
|
838 |
// CCalenMultipleDbUi::ReAdjustListFocusL |
|
839 |
// Refocus the items in list when delete action happened. |
|
840 |
// ---------------------------------------------------------------------------- |
|
841 |
// |
|
842 |
void CCalenMultipleDbUi::ReAdjustListItemFocusL(const TInt aCurrentIndex) |
|
843 |
{ |
|
844 |
TRACE_ENTRY_POINT |
|
845 |
TInt currentIndex = aCurrentIndex; |
|
846 |
TInt count = iListBox->Model()->ItemTextArray()->MdcaCount(); |
|
847 |
if (count > 0) |
|
848 |
{ |
|
849 |
if (currentIndex == 1 && currentIndex == count) |
|
850 |
{ |
|
851 |
iListBox->SetCurrentItemIndexAndDraw(0); |
|
852 |
} |
|
853 |
else if (currentIndex == count && count > 1) |
|
854 |
{ |
|
855 |
iListBox->SetCurrentItemIndexAndDraw(--currentIndex); |
|
856 |
} |
|
857 |
else |
|
858 |
{ |
|
859 |
iListBox->SetCurrentItemIndexAndDraw(currentIndex); |
|
860 |
} |
|
861 |
} |
|
862 |
TRACE_EXIT_POINT |
|
863 |
} |
|
864 |
||
865 |
// ---------------------------------------------------------------------------- |
|
866 |
// CCalenMultipleDbUi::CheckForChangesL |
|
867 |
// Check if changes has occured between before and after editing |
|
868 |
// ---------------------------------------------------------------------------- |
|
869 |
// |
|
870 |
TBool CCalenMultipleDbUi::CheckForChangesL( CCalCalendarInfo& aCalendarInfoOriginal, |
|
871 |
CCalCalendarInfo& aCalendarInfoModified) |
|
872 |
{ |
|
873 |
TRACE_ENTRY_POINT; |
|
874 |
TBool changed = EFalse; |
|
875 |
||
876 |
HBufC* editedName = aCalendarInfoModified.NameL().AllocLC(); |
|
877 |
||
878 |
if (editedName->Compare(aCalendarInfoOriginal.NameL()) |
|
879 |
|| aCalendarInfoModified.Color() != aCalendarInfoOriginal.Color() |
|
880 |
|| aCalendarInfoModified.Enabled()!= aCalendarInfoOriginal.Enabled()) |
|
881 |
{ |
|
882 |
changed = ETrue; |
|
883 |
} |
|
884 |
||
885 |
CleanupStack::PopAndDestroy(editedName); |
|
886 |
TRACE_EXIT_POINT; |
|
887 |
return changed; |
|
888 |
} |
|
889 |
||
890 |
// ---------------------------------------------------------------------------- |
|
891 |
// CCalenMultipleDbUi::OfferKeyEventL |
|
892 |
// Handle key events for dialog |
|
893 |
// ---------------------------------------------------------------------------- |
|
894 |
// |
|
895 |
TKeyResponse CCalenMultipleDbUi::OfferKeyEventL(const TKeyEvent& aKeyEvent, |
|
896 |
TEventCode aType) |
|
897 |
{ |
|
898 |
TRACE_ENTRY_POINT; |
|
899 |
TKeyResponse exitCode(EKeyWasNotConsumed); |
|
900 |
if(aType == EEventKey ) |
|
901 |
{ |
|
902 |
if( aKeyEvent.iCode == EKeyEscape ) |
|
903 |
{ |
|
904 |
TryExitL( EKeyNo ); |
|
905 |
return exitCode; // Chain this one up to the main app so it closes calendar app. |
|
906 |
} |
|
907 |
else if(aType == EEventKey && TChar(aKeyEvent.iCode).IsPrint() ) |
|
908 |
{ |
|
909 |
ProcessCommandL(ECalenCmdAdd); |
|
910 |
} |
|
911 |
else if(aType == EKeyOK) |
|
912 |
{ |
|
913 |
// Single click integration |
|
914 |
iListBox->OfferKeyEventL( aKeyEvent, aType ); |
|
915 |
} |
|
916 |
else if(aKeyEvent.iCode == EKeyBackspace && |
|
917 |
iMenuBar->ItemSpecificCommandsEnabled()) |
|
918 |
{ |
|
919 |
RPointerArray<CCalCalendarInfo> calendarInfoList; |
|
920 |
iController.GetAllCalendarInfoL(calendarInfoList); |
|
921 |
CleanupClosePushL(calendarInfoList); |
|
922 |
if(calendarInfoList.Count()) |
|
923 |
{ |
|
924 |
TInt currentIndex = iCurrentIndex = iListBox->CurrentItemIndex(); |
|
925 |
HBufC* calendarFileName = |
|
926 |
calendarInfoList[currentIndex]->FileNameL().AllocLC(); |
|
927 |
if ((calendarFileName->CompareF( |
|
928 |
iController.Services().SessionL().DefaultFileNameL()))) |
|
929 |
{ |
|
930 |
DeleteItemL(); |
|
931 |
} |
|
932 |
CleanupStack::PopAndDestroy(calendarFileName); |
|
933 |
} |
|
934 |
CleanupStack::PopAndDestroy(&calendarInfoList); |
|
935 |
exitCode = EKeyWasConsumed; |
|
936 |
} |
|
937 |
else |
|
938 |
{ |
|
939 |
exitCode = EKeyWasConsumed; |
|
940 |
iListBox->OfferKeyEventL( aKeyEvent, aType ); |
|
941 |
||
942 |
// Draw because pressing up/down means we have to redraw the backgrouns skin. |
|
943 |
DrawDeferred(); |
|
944 |
} |
|
945 |
} |
|
946 |
TRACE_EXIT_POINT; |
|
947 |
return exitCode; |
|
948 |
} |
|
949 |
||
950 |
// ---------------------------------------------------------------------------- |
|
951 |
// CCalenMultipleDbUi::HandlePointerEventL |
|
952 |
// Handle pointer events for dialog |
|
953 |
// ---------------------------------------------------------------------------- |
|
954 |
// |
|
955 |
void CCalenMultipleDbUi::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
956 |
{ |
|
957 |
TRACE_ENTRY_POINT; |
|
958 |
//Single click integration |
|
959 |
if ( iListBox ) |
|
960 |
{ |
|
961 |
iListBox->HandlePointerEventL( aPointerEvent ); |
|
962 |
} |
|
963 |
TRACE_EXIT_POINT; |
|
964 |
} |
|
965 |
||
966 |
// ---------------------------------------------------------------------------- |
|
967 |
// CCalenMultipleDbUi::OkToExitL |
|
968 |
// Handle softkeys for the dialog |
|
969 |
// ---------------------------------------------------------------------------- |
|
970 |
// |
|
971 |
TBool CCalenMultipleDbUi::OkToExitL( TInt aButtonId ) |
|
972 |
{ |
|
973 |
TRACE_ENTRY_POINT; |
|
974 |
TBool okExit = EFalse; |
|
975 |
switch(aButtonId) |
|
976 |
{ |
|
977 |
case EAknSoftkeyChange: |
|
978 |
{ |
|
979 |
ProcessCommandL(ECalenCmdEdit); |
|
980 |
} |
|
981 |
break; |
|
982 |
case EAknSoftkeyBack: |
|
983 |
case EKeyEscape: |
|
984 |
{ |
|
985 |
iController.BroadcastNotification(ECalenNotifyDeleteInstanceView); |
|
986 |
okExit = ETrue; |
|
987 |
} |
|
988 |
break; |
|
989 |
case EKeyNo: |
|
990 |
{ |
|
991 |
iController.BroadcastNotification(ECalenNotifyDeleteInstanceView); |
|
992 |
okExit = CAknDialog::OkToExitL(aButtonId); |
|
993 |
break; |
|
994 |
} |
|
995 |
default: |
|
996 |
{ |
|
997 |
okExit = CAknDialog::OkToExitL(aButtonId); |
|
998 |
} |
|
999 |
break; |
|
1000 |
} |
|
1001 |
TRACE_EXIT_POINT; |
|
1002 |
return okExit; |
|
1003 |
} |
|
1004 |
||
1005 |
||
1006 |
// ---------------------------------------------------------------------------- |
|
1007 |
// CCalenMultipleDbUi::SizeChanged |
|
1008 |
// Set the rect to dialog and listbox |
|
1009 |
// ---------------------------------------------------------------------------- |
|
1010 |
// |
|
1011 |
void CCalenMultipleDbUi::SizeChanged() |
|
1012 |
{ |
|
1013 |
TRACE_ENTRY_POINT; |
|
1014 |
CAknDialog::SizeChanged(); |
|
1015 |
||
1016 |
TRect rect = iRect = Rect(); |
|
1017 |
if( iBgContext ) |
|
1018 |
{ |
|
1019 |
iBgContext->SetRect( rect ); |
|
1020 |
} |
|
1021 |
if( iListBox ) |
|
1022 |
{ |
|
1023 |
TInt orientation = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0; |
|
1024 |
TAknLayoutRect application_window; |
|
1025 |
||
1026 |
if( ( !orientation ) && AknLayoutUtils::PenEnabled() ) |
|
1027 |
{ |
|
1028 |
TRect appWindow; |
|
1029 |
TAknLayoutRect application_window; |
|
1030 |
AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EApplicationWindow, |
|
1031 |
appWindow ); |
|
1032 |
application_window.LayoutRect( |
|
1033 |
appWindow, |
|
1034 |
AknLayoutScalable_Apps::application_window().LayoutLine() ); |
|
1035 |
||
1036 |
// Find the size of the main pane. |
|
1037 |
TAknLayoutRect main_pane; |
|
1038 |
||
1039 |
main_pane.LayoutRect( |
|
1040 |
application_window.Rect(), |
|
1041 |
AknLayoutScalable_Apps::main_pane( orientation ).LayoutLine() ); |
|
1042 |
||
1043 |
TRect listboxRect; |
|
1044 |
listboxRect.SetWidth( main_pane.Rect().Width() ); |
|
1045 |
listboxRect.SetHeight( main_pane.Rect().Height() ); |
|
1046 |
iListBox->SetRect( listboxRect ); |
|
1047 |
} |
|
1048 |
else |
|
1049 |
{ |
|
1050 |
iListBox->SetRect( rect ); |
|
1051 |
} |
|
1052 |
} |
|
1053 |
||
1054 |
TRACE_EXIT_POINT; |
|
1055 |
} |
|
1056 |
||
1057 |
// ---------------------------------------------------------------------------- |
|
1058 |
// CCalenMultipleDbUi::ComponentControl |
|
1059 |
// (other items were commented in a header). |
|
1060 |
// ---------------------------------------------------------------------------- |
|
1061 |
// |
|
1062 |
CCoeControl* CCalenMultipleDbUi::ComponentControl( TInt /*aIndex*/) const |
|
1063 |
{ |
|
1064 |
TRACE_ENTRY_POINT; |
|
1065 |
if(iListBox) |
|
1066 |
{ |
|
1067 |
TRACE_EXIT_POINT; |
|
1068 |
return iListBox; |
|
1069 |
} |
|
1070 |
TRACE_EXIT_POINT; |
|
1071 |
return NULL; |
|
1072 |
} |
|
1073 |
||
1074 |
// ---------------------------------------------------------------------------- |
|
1075 |
// CCalenMultipleDbUi::CountComponentControls |
|
1076 |
// (other items were commented in a header). |
|
1077 |
// ---------------------------------------------------------------------------- |
|
1078 |
// |
|
1079 |
TInt CCalenMultipleDbUi::CountComponentControls() const |
|
1080 |
{ |
|
1081 |
TRACE_ENTRY_POINT; |
|
1082 |
if(iListBox) |
|
1083 |
{ |
|
1084 |
TRACE_EXIT_POINT; |
|
1085 |
return 1; |
|
1086 |
} |
|
1087 |
TRACE_EXIT_POINT; |
|
1088 |
return 0; |
|
1089 |
} |
|
1090 |
||
1091 |
// ---------------------------------------------------------------------------- |
|
1092 |
// CCalenMultipleDbUi::PreLayoutDynInitL |
|
1093 |
// (other items were commented in a header). |
|
1094 |
// ---------------------------------------------------------------------------- |
|
1095 |
// |
|
1096 |
void CCalenMultipleDbUi::PreLayoutDynInitL() |
|
1097 |
{ |
|
1098 |
TRACE_ENTRY_POINT; |
|
1099 |
iBgContext = CAknsBasicBackgroundControlContext::NewL( |
|
1100 |
KAknsIIDQsnBgAreaMain, iRect, ETrue); |
|
1101 |
||
1102 |
ConstructListL(); |
|
1103 |
UpdateListboxL(); |
|
1104 |
||
1105 |
TInt orientation = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0; |
|
1106 |
if (AknLayoutUtils::PenEnabled()) |
|
1107 |
{ |
|
1108 |
// Find the size of the main pane. |
|
1109 |
// Find the application window |
|
1110 |
TRect appWindow; |
|
1111 |
TAknLayoutRect application_window; |
|
1112 |
AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EApplicationWindow, |
|
1113 |
appWindow); |
|
1114 |
application_window.LayoutRect(appWindow, |
|
1115 |
AknLayoutScalable_Apps::application_window().LayoutLine()); |
|
1116 |
||
1117 |
// Find the size of the main pane. |
|
1118 |
TAknLayoutRect main_pane; |
|
1119 |
||
1120 |
main_pane.LayoutRect(application_window.Rect(), |
|
1121 |
AknLayoutScalable_Apps::main_pane(orientation).LayoutLine()); |
|
1122 |
||
1123 |
TRect listboxRect; |
|
1124 |
listboxRect.SetWidth(main_pane.Rect().Width()); |
|
1125 |
listboxRect.SetHeight(main_pane.Rect().Height()); |
|
1126 |
iListBox->SetRect(listboxRect); |
|
1127 |
}TRACE_EXIT_POINT; |
|
1128 |
} |
|
1129 |
||
1130 |
// ---------------------------------------------------------------------------- |
|
1131 |
// CCalenMultipleDbUi::PostLayoutDynInitL |
|
1132 |
// (other items were commented in a header). |
|
1133 |
// ---------------------------------------------------------------------------- |
|
1134 |
// |
|
1135 |
void CCalenMultipleDbUi::PostLayoutDynInitL() |
|
1136 |
{ |
|
1137 |
TRACE_ENTRY_POINT; |
|
1138 |
iListBox->UpdateScrollBarsL(); |
|
1139 |
TRACE_EXIT_POINT; |
|
1140 |
} |
|
1141 |
||
1142 |
// ---------------------------------------------------------------------------- |
|
1143 |
// CCalenMultipleDbUi::MopSupplyObject |
|
1144 |
// (other items were commented in a header). |
|
1145 |
// ---------------------------------------------------------------------------- |
|
1146 |
// |
|
1147 |
TTypeUid::Ptr CCalenMultipleDbUi::MopSupplyObject(TTypeUid aId) |
|
1148 |
{ |
|
1149 |
TRACE_ENTRY_POINT; |
|
1150 |
if(aId.iUid == MAknsControlContext::ETypeId ) |
|
1151 |
{ |
|
1152 |
MAknsControlContext* cc = iBgContext; |
|
1153 |
if ( cc ) |
|
1154 |
{ |
|
1155 |
return MAknsControlContext::SupplyMopObject( aId, cc ); |
|
1156 |
} |
|
1157 |
} |
|
1158 |
TRACE_EXIT_POINT; |
|
1159 |
return CAknDialog::MopSupplyObject( aId ); |
|
1160 |
} |
|
1161 |
||
1162 |
// ---------------------------------------------------------------------------- |
|
1163 |
// CCalenMultipleDbUi::HandleResourceChange |
|
1164 |
// (other items were commented in a header). |
|
1165 |
// ---------------------------------------------------------------------------- |
|
1166 |
// |
|
1167 |
void CCalenMultipleDbUi::HandleResourceChange(TInt aType) |
|
1168 |
{ |
|
1169 |
TRACE_ENTRY_POINT; |
|
1170 |
if ( aType == KAknsMessageSkinChange || aType == KEikDynamicLayoutVariantSwitch ) |
|
1171 |
{ |
|
1172 |
SizeChanged(); |
|
1173 |
TRAP_IGNORE(UpdateListboxL()); |
|
1174 |
} |
|
1175 |
CAknDialog::HandleResourceChange( aType ); |
|
1176 |
TRACE_EXIT_POINT; |
|
1177 |
} |
|
1178 |
||
1179 |
// ---------------------------------------------------------------------------- |
|
1180 |
// CCalenMultipleDbUi::AsyncCallBackL |
|
1181 |
// (other items were commented in a header). |
|
1182 |
// ---------------------------------------------------------------------------- |
|
1183 |
// |
|
1184 |
TInt CCalenMultipleDbUi::AsyncCallBackL(TAny* aThisPtr) |
|
1185 |
{ |
|
1186 |
TRACE_ENTRY_POINT |
|
1187 |
CCalenMultipleDbUi* self = static_cast<CCalenMultipleDbUi*>(aThisPtr); |
|
1188 |
self->HandleAsyncCommandL(self->iAsyncActionCmd); |
|
1189 |
TRACE_EXIT_POINT |
|
1190 |
return 0; |
|
1191 |
} |
|
1192 |
||
1193 |
// ---------------------------------------------------------------------------- |
|
1194 |
// CCalenMultipleDbUi::DoAsyncActionL |
|
1195 |
// (other items were commented in a header). |
|
1196 |
// ---------------------------------------------------------------------------- |
|
1197 |
// |
|
1198 |
void CCalenMultipleDbUi::DoAsyncActionL(const TInt aCommand) |
|
1199 |
{ |
|
1200 |
TRACE_ENTRY_POINT |
|
1201 |
iCurrentIndex = iListBox->CurrentItemIndex(); |
|
1202 |
iAsyncActionCmd = aCommand; |
|
1203 |
iAsyncAction->CallBack(); |
|
1204 |
TRACE_EXIT_POINT |
|
1205 |
} |
|
1206 |
||
1207 |
// ---------------------------------------------------------------------------- |
|
1208 |
// CCalenMultipleDbUi::DoAsyncActionL |
|
1209 |
// (other items were commented in a header). |
|
1210 |
// ---------------------------------------------------------------------------- |
|
1211 |
// |
|
1212 |
void CCalenMultipleDbUi::HandleAsyncCommandL(const TInt aCommand) |
|
1213 |
{ |
|
1214 |
TRACE_ENTRY_POINT |
|
1215 |
||
1216 |
switch(aCommand) |
|
1217 |
{ |
|
1218 |
case EAknSoftkeyExit: |
|
1219 |
case EAknCmdExit: |
|
1220 |
{ |
|
1221 |
TryExitL(aCommand); |
|
1222 |
} |
|
1223 |
break; |
|
1224 |
case ECalenCmdDelete: |
|
1225 |
{ |
|
1226 |
DeleteItemL(); |
|
1227 |
} |
|
1228 |
break; |
|
1229 |
default: |
|
1230 |
break; |
|
1231 |
} |
|
1232 |
||
1233 |
TRACE_EXIT_POINT |
|
1234 |
} |
|
1235 |
||
1236 |
// ---------------------------------------------------------------------------- |
|
1237 |
// CCalenMultipleDbUi::CreateButtonL |
|
1238 |
// (other items were commented in a header). |
|
1239 |
// ---------------------------------------------------------------------------- |
|
1240 |
// |
|
1241 |
CAknButton* CCalenMultipleDbUi::CreateButtonL( CGulIcon* aIcon, TInt aDisplayTextID, |
|
1242 |
TInt aTooltipID, CAknToolbar& aToolbar ) |
|
1243 |
{ |
|
1244 |
TRACE_ENTRY_POINT; |
|
1245 |
||
1246 |
TInt flags = 0; |
|
1247 |
CAknButton* button = NULL; |
|
1248 |
||
1249 |
CleanupStack::PushL( aIcon ); |
|
1250 |
HBufC* tooltipText = StringLoader::LoadLC( aTooltipID ); |
|
1251 |
CleanupStack::Pop( tooltipText ); |
|
1252 |
||
1253 |
HBufC* displayText = StringLoader::LoadLC( aDisplayTextID ); |
|
1254 |
CleanupStack::Pop( displayText ); |
|
1255 |
||
1256 |
// put icon onto cleanup stack before its ownership is transferred to CAknButton |
|
1257 |
CleanupStack::Pop( aIcon ); |
|
1258 |
CleanupStack::PushL( tooltipText ); |
|
1259 |
CleanupStack::PushL( displayText ); |
|
1260 |
button = CAknButton::NewL( aIcon, NULL, NULL, NULL, |
|
1261 |
displayText->Des(), tooltipText->Des(), flags, 0 ); |
|
1262 |
||
1263 |
CleanupStack::PopAndDestroy( displayText ); |
|
1264 |
CleanupStack::PopAndDestroy( tooltipText ); |
|
1265 |
||
1266 |
||
1267 |
button->SetIconScaleMode( EAspectRatioNotPreserved ); |
|
1268 |
button->SetFocusing( EFalse ); |
|
1269 |
button->SetBackground( &aToolbar ); |
|
1270 |
||
1271 |
TRACE_EXIT_POINT; |
|
1272 |
||
1273 |
return button; |
|
1274 |
} |
|
1275 |
||
1276 |
// ---------------------------------------------------------------------------- |
|
1277 |
// CCalenMultipleDbUi::SetCalendarAddPropertiesL |
|
1278 |
// (other items were commented in a header). |
|
1279 |
// ---------------------------------------------------------------------------- |
|
1280 |
// |
|
1281 |
void CCalenMultipleDbUi::SetCalendarAddPropertiesL(CCalCalendarInfo& aCalendarInfo) |
|
1282 |
{ |
|
1283 |
TRACE_ENTRY_POINT |
|
1284 |
||
1285 |
TBuf8<KBuffLength> keyBuff; |
|
1286 |
keyBuff.AppendNum(EFolderLUID); |
|
1287 |
TRAPD(err,aCalendarInfo.PropertyValueL(keyBuff)); |
|
1288 |
||
1289 |
if (KErrNotFound == err) |
|
1290 |
{ |
|
1291 |
TUint calValue = 0; |
|
1292 |
//Get the available offset value and set as property value. |
|
1293 |
calValue = CCalenMultiCalUtil::GetNextAvailableOffsetL(); |
|
1294 |
TPckgC<TUint> calValuePckg(calValue); |
|
1295 |
aCalendarInfo.SetPropertyL(keyBuff, calValuePckg); |
|
1296 |
} |
|
1297 |
||
1298 |
TTime currentTime; |
|
1299 |
currentTime.HomeTime(); |
|
1300 |
||
1301 |
keyBuff.Zero(); |
|
1302 |
keyBuff.AppendNum(ECreationTime); |
|
1303 |
TRAP( err, aCalendarInfo.PropertyValueL( keyBuff ) ); |
|
1304 |
||
1305 |
if (KErrNotFound == err) |
|
1306 |
{ |
|
1307 |
TPckgC<TTime> pkgCreationTime(currentTime); |
|
1308 |
aCalendarInfo.SetPropertyL(keyBuff, pkgCreationTime); |
|
1309 |
} |
|
1310 |
||
1311 |
keyBuff.Zero(); |
|
1312 |
keyBuff.AppendNum(EModificationTime); |
|
1313 |
||
1314 |
//At creation modification time will be same as creation time |
|
1315 |
TPckgC<TTime> pkgModificationTime(currentTime); |
|
1316 |
aCalendarInfo.SetPropertyL(keyBuff, pkgModificationTime); |
|
1317 |
||
1318 |
keyBuff.Zero(); |
|
1319 |
keyBuff.AppendNum(EIsSharedFolder); |
|
1320 |
||
1321 |
TPckgC<TBool> pkgIsSharedFolder(EFalse); |
|
1322 |
aCalendarInfo.SetPropertyL(keyBuff, pkgIsSharedFolder); |
|
1323 |
||
1324 |
//EGlobalUUID |
|
1325 |
keyBuff.Zero(); |
|
1326 |
keyBuff.AppendNum(EGlobalUUID); |
|
1327 |
TRAP(err,aCalendarInfo.PropertyValueL(keyBuff)); |
|
1328 |
||
1329 |
if (KErrNotFound == err) |
|
1330 |
{ |
|
1331 |
HBufC8* guuid = iController.Services().InterimUtilsL().GlobalUidL(); |
|
1332 |
TPtr8 guuidPtr = guuid->Des(); |
|
1333 |
CleanupStack::PushL( guuid ); |
|
1334 |
aCalendarInfo.SetPropertyL(keyBuff, guuidPtr); |
|
1335 |
CleanupStack::PopAndDestroy( guuid ); |
|
1336 |
} |
|
1337 |
||
1338 |
// EOwnerName |
|
1339 |
keyBuff.Zero(); |
|
1340 |
keyBuff.AppendNum(EOwnerName); |
|
1341 |
TRAP(err,aCalendarInfo.PropertyValueL(keyBuff)); |
|
1342 |
||
1343 |
if (KErrNotFound == err) |
|
1344 |
{ |
|
1345 |
_LIT8( KCalendarOwnerName, "myself" ); |
|
1346 |
aCalendarInfo.SetPropertyL(keyBuff, KCalendarOwnerName); |
|
1347 |
} |
|
1348 |
||
1349 |
TBool syncstatus = ETrue; |
|
1350 |
keyBuff.Zero(); |
|
1351 |
keyBuff.AppendNum( ESyncStatus ); |
|
1352 |
TPckgC<TBool> pckgSyncStatusValue(syncstatus); |
|
1353 |
aCalendarInfo.SetPropertyL( keyBuff, pckgSyncStatusValue ); |
|
1354 |
||
1355 |
TRACE_EXIT_POINT |
|
1356 |
} |
|
1357 |
||
1358 |
// ---------------------------------------------------------------------------- |
|
1359 |
// CCalenMultipleDbUi::SetCalendarUpdatePropertiesL |
|
1360 |
// (other items were commented in a header). |
|
1361 |
// ---------------------------------------------------------------------------- |
|
1362 |
// |
|
1363 |
void CCalenMultipleDbUi::SetCalendarUpdatePropertiesL(CCalCalendarInfo& aCalendarInfo) |
|
1364 |
{ |
|
1365 |
TRACE_ENTRY_POINT |
|
1366 |
TBuf8<KBuffLength> keyBuff; |
|
1367 |
keyBuff.AppendNum(EModificationTime); |
|
1368 |
||
1369 |
TTime modificationTime; |
|
1370 |
modificationTime.HomeTime(); |
|
1371 |
TPckgC<TTime> pkgModificationTime(modificationTime); |
|
1372 |
aCalendarInfo.SetPropertyL(keyBuff, pkgModificationTime); |
|
1373 |
||
1374 |
keyBuff.Zero(); |
|
1375 |
keyBuff.AppendNum(EIsSharedFolder); |
|
1376 |
||
1377 |
//TODO :Get the status from editor and set; |
|
1378 |
TPckgC<TBool> pkgIsSharedFolder(EFalse); |
|
1379 |
aCalendarInfo.SetPropertyL(keyBuff, pkgIsSharedFolder); |
|
1380 |
||
1381 |
TRACE_EXIT_POINT |
|
1382 |
} |
|
1383 |
||
1384 |
// ---------------------------------------------------------------------------- |
|
1385 |
// CCalenMultipleDbUi::Draw |
|
1386 |
// (other items were commented in a header). |
|
1387 |
// ---------------------------------------------------------------------------- |
|
1388 |
// |
|
1389 |
void CCalenMultipleDbUi::Draw(const TRect& aRect) const |
|
1390 |
{ |
|
1391 |
TRACE_ENTRY_POINT; |
|
1392 |
CWindowGc& gc = SystemGc(); |
|
1393 |
TRect mainPane; |
|
1394 |
AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPane ); |
|
1395 |
TRect zerodRect( TPoint(0, 0), mainPane.Size() ); |
|
1396 |
iBgContext->SetRect( zerodRect ); |
|
1397 |
iBgContext->SetParentPos( mainPane.iTl ); |
|
1398 |
AknsDrawUtils::Background( AknsUtils::SkinInstance(), iBgContext, this, gc, aRect ); |
|
1399 |
TRACE_EXIT_POINT; |
|
1400 |
} |
|
1401 |
||
1402 |
// ---------------------------------------------------------------------------- |
|
1403 |
// CCalenMultipleDbUi::HandleNotification |
|
1404 |
// Handle notifications |
|
1405 |
// (other items were commented in a header). |
|
1406 |
// ---------------------------------------------------------------------------- |
|
1407 |
// |
|
1408 |
void CCalenMultipleDbUi::HandleNotification( |
|
1409 |
const TCalenNotification aNotification ) |
|
1410 |
{ |
|
1411 |
TRACE_ENTRY_POINT; |
|
1412 |
switch (aNotification) |
|
1413 |
{ |
|
1414 |
case ECalenNotifyCalendarInfoCreated: |
|
1415 |
case ECalenNotifyCalendarInfoUpdated: |
|
1416 |
{ |
|
86
ed599363c2d7
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1417 |
if (iDbEditor) |
66 | 1418 |
{ |
1419 |
iConflictOccured = ETrue; |
|
1420 |
iDbEditor->SetConflict(CCalenMultiDBEditor::EConflictUpdate); |
|
1421 |
} |
|
1422 |
} |
|
1423 |
break; |
|
1424 |
case ECalenNotifyCalendarFileDeleted: |
|
1425 |
{ |
|
86
ed599363c2d7
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1426 |
if (iDbEditor) |
66 | 1427 |
{ |
1428 |
iConflictOccured = ETrue; |
|
1429 |
iDbEditor->SetConflict(CCalenMultiDBEditor::EConflictDelete); |
|
1430 |
} |
|
1431 |
} |
|
1432 |
break; |
|
1433 |
default: |
|
1434 |
break; |
|
1435 |
} |
|
1436 |
||
1437 |
// refresh calendar list |
|
86
ed599363c2d7
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1438 |
UpdateListboxL(); |
66 | 1439 |
|
1440 |
TRACE_EXIT_POINT; |
|
1441 |
} |
|
1442 |
||
1443 |
||
1444 |
// ---------------------------------------------------------------------------- |
|
1445 |
// CCalenMultipleDbUi::HandleListBoxEventL |
|
1446 |
// Handles listbox events. |
|
1447 |
// (other items were commented in a header). |
|
1448 |
// ---------------------------------------------------------------------------- |
|
1449 |
// |
|
1450 |
void CCalenMultipleDbUi::HandleListBoxEventL( CEikListBox* /*aListBox*/, |
|
1451 |
TListBoxEvent aEventType ) |
|
1452 |
{ |
|
1453 |
TRACE_ENTRY_POINT; |
|
1454 |
||
1455 |
if ( !MenuShowing() ) |
|
1456 |
{ |
|
1457 |
//Single click integration |
|
1458 |
if ( aEventType == EEventEnterKeyPressed || |
|
1459 |
||
1460 |
aEventType == EEventItemSingleClicked ) |
|
1461 |
{ |
|
1462 |
const TInt index(iListBox->CurrentItemIndex()); |
|
1463 |
if ( index != KErrNotFound && !iIsDbEditorOpen ) |
|
1464 |
{ |
|
1465 |
iIsDbEditorOpen = ETrue ; |
|
1466 |
ProcessCommandL( ECalenCmdEdit ); |
|
1467 |
||
1468 |
} |
|
1469 |
} |
|
1470 |
} |
|
1471 |
TRACE_EXIT_POINT; |
|
1472 |
} |
|
1473 |
||
1474 |
//EOF |