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