|
1 /* |
|
2 * Copyright (c) 2002 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 control for Week View . |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <calcommon.h> |
|
19 #include <caltime.h> |
|
20 #include <calinstance.h> |
|
21 #include <calentry.h> |
|
22 #include <calinstanceview.h> |
|
23 #include <calcalendarinfo.h> |
|
24 #include <AknIconArray.h> |
|
25 #include <AknsDrawUtils.h> |
|
26 #include <AknsFrameBackgroundControlContext.h> |
|
27 #include <AknUtils.h> |
|
28 #include <AknIconUtils.h> |
|
29 #include <eikenv.h> |
|
30 #include <eikfrlbd.h> |
|
31 #include <eiklabel.h> |
|
32 #include <gulicon.h> |
|
33 #include <StringLoader.h> |
|
34 #include <calencontext.h> |
|
35 #include <aknlayoutscalable_apps.cdl.h> |
|
36 #include <caleninstanceid.h> // TCalenInstanceId |
|
37 #include <layoutmetadata.cdl.h> |
|
38 #include <centralrepository.h> |
|
39 #include <calenviewutils.h> |
|
40 #include <calenservices.h> |
|
41 #include <calenagendautils.h> |
|
42 #include <calendateutils.h> |
|
43 #include <mcalenpreview.h> |
|
44 #include <Calendar.rsg> |
|
45 #include <csxhelp/cale.hlp.hrh> |
|
46 |
|
47 #include "calendarui_debug.h" |
|
48 #include "calenweekcontainer.h" |
|
49 #include "calencontainerlayoutmanager.h" |
|
50 #include "calencontroller.h" |
|
51 #include "calendrawutils.h" |
|
52 #include "calenicons.h" |
|
53 #include "calenpreview.h" |
|
54 #include "CalenUid.h" |
|
55 #include "CalendarPrivateCRKeys.h" |
|
56 #include "calenweeklistboxview.h" |
|
57 #include "calenweeklistbox.h" |
|
58 #include "calenweeklistboxlayout.h" |
|
59 #include "calenweekview.h" |
|
60 #include "CalenUid.h" |
|
61 #include "calendar.hrh" |
|
62 |
|
63 // LOCAL CONSTANTS AND MACROS |
|
64 const TInt KNonTimedNoteDefautDisplayTime(8); |
|
65 const TInt KNullMinutes = -1; |
|
66 const TInt KBeforeActiveTime(0); |
|
67 const TInt KHoursInADay( 24 ); |
|
68 |
|
69 |
|
70 // METHOD DEFINITIONS |
|
71 // ---------------------------------------------------------------------------- |
|
72 // ?classname::?member_function |
|
73 // ?implementation_description |
|
74 // (other items were commented in a header). |
|
75 // ---------------------------------------------------------------------------- |
|
76 // |
|
77 void CCalenWeekContainer::DrawBackground(CWindowGc& aGc) const |
|
78 { |
|
79 TRACE_ENTRY_POINT; |
|
80 |
|
81 MAknsControlContext* cc =AknsDrawUtils::ControlContext( this ); |
|
82 |
|
83 if( cc ) |
|
84 { |
|
85 TRect main_pane( Rect() ); |
|
86 AknsDrawUtils::Background( AknsUtils::SkinInstance(), |
|
87 cc, |
|
88 NULL, |
|
89 aGc, |
|
90 main_pane ); |
|
91 } |
|
92 |
|
93 TRACE_EXIT_POINT; |
|
94 } |
|
95 |
|
96 // ---------------------------------------------------------------------------- |
|
97 // Draws horizontal and vertical grid lines |
|
98 // (other items were commented in a header). |
|
99 // ---------------------------------------------------------------------------- |
|
100 // |
|
101 void CCalenWeekContainer::DrawGridLines(CWindowGc& aGc) const |
|
102 { |
|
103 TRACE_ENTRY_POINT; |
|
104 |
|
105 TRect main_pane_Rect = ReducePreview( Rect() ); |
|
106 |
|
107 TAknLayoutRect main_cale_week_pane; |
|
108 main_cale_week_pane.LayoutRect( main_pane_Rect, AknLayoutScalable_Apps::main_cale_week_pane().LayoutLine() ); |
|
109 |
|
110 // FIXME: use member variable? |
|
111 TAknLayoutRect listscroll_cale_week_pane; |
|
112 TWeekListBoxLayout lay( UseInfobar(), UseToolbar(), UsePreview(), main_pane_Rect ); |
|
113 TInt layoutVariant = lay.LayoutVariantIndex(TWeekListBoxLayout::EListScrollCaleWeekPane ); |
|
114 listscroll_cale_week_pane.LayoutRect( main_cale_week_pane.Rect(), AknLayoutScalable_Apps::listscroll_cale_week_pane(layoutVariant).LayoutLine() ); |
|
115 |
|
116 layoutVariant = lay.LayoutVariantIndex(TWeekListBoxLayout::ECaleWeekScrollPaneG1); |
|
117 const TRect parentRect = listscroll_cale_week_pane.Rect(); |
|
118 // Primary lines were drawn in different functions |
|
119 TAknLayoutRect horizontalPrimaryLine; |
|
120 horizontalPrimaryLine.LayoutRect( parentRect, AknLayoutScalable_Apps::cale_week_scroll_pane_g1( layoutVariant ).LayoutLine() ); |
|
121 |
|
122 TAknLayoutRect verticalPrimaryLine; |
|
123 verticalPrimaryLine.LayoutRect( parentRect, AknLayoutScalable_Apps::cale_week_scroll_pane_g2( layoutVariant ).LayoutLine() ); |
|
124 |
|
125 TRgb lineColor( verticalPrimaryLine.Color() ); |
|
126 AknsUtils::GetCachedColor(AknsUtils::SkinInstance(), lineColor, |
|
127 KAknsIIDQsnLineColors, |
|
128 EAknsCIQsnLineColorsCG1); |
|
129 aGc.SetBrushColor( lineColor ); |
|
130 aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
131 |
|
132 aGc.Clear( verticalPrimaryLine.Rect() ); |
|
133 aGc.Clear( horizontalPrimaryLine.Rect() ); |
|
134 |
|
135 // There are six secondary vertical lines |
|
136 const TInt verticalLineCount = 6; |
|
137 TAknLayoutRect verticalLines[ verticalLineCount ]; |
|
138 verticalLines[0].LayoutRect( parentRect, AknLayoutScalable_Apps::cale_week_scroll_pane_g3( layoutVariant ).LayoutLine() ); |
|
139 verticalLines[1].LayoutRect( parentRect, AknLayoutScalable_Apps::cale_week_scroll_pane_g4( layoutVariant ).LayoutLine() ); |
|
140 verticalLines[2].LayoutRect( parentRect, AknLayoutScalable_Apps::cale_week_scroll_pane_g5( layoutVariant ).LayoutLine() ); |
|
141 verticalLines[3].LayoutRect( parentRect, AknLayoutScalable_Apps::cale_week_scroll_pane_g6( layoutVariant ).LayoutLine() ); |
|
142 verticalLines[4].LayoutRect( parentRect, AknLayoutScalable_Apps::cale_week_scroll_pane_g7( layoutVariant ).LayoutLine() ); |
|
143 verticalLines[5].LayoutRect( parentRect, AknLayoutScalable_Apps::cale_week_scroll_pane_g8( layoutVariant ).LayoutLine() ); |
|
144 |
|
145 // and seven secondary horizontal lines |
|
146 const TInt horizontalLineCount = 7; |
|
147 TAknLayoutRect horizontalLines[ horizontalLineCount ]; |
|
148 horizontalLines[0].LayoutRect( parentRect, AknLayoutScalable_Apps::cale_week_scroll_pane_g9( layoutVariant ).LayoutLine() ); |
|
149 horizontalLines[1].LayoutRect( parentRect, AknLayoutScalable_Apps::cale_week_scroll_pane_g10( layoutVariant ).LayoutLine() ); |
|
150 horizontalLines[2].LayoutRect( parentRect, AknLayoutScalable_Apps::cale_week_scroll_pane_g11( layoutVariant ).LayoutLine() ); |
|
151 horizontalLines[3].LayoutRect( parentRect, AknLayoutScalable_Apps::cale_week_scroll_pane_g12( layoutVariant ).LayoutLine() ); |
|
152 horizontalLines[4].LayoutRect( parentRect, AknLayoutScalable_Apps::cale_week_scroll_pane_g13( layoutVariant ).LayoutLine() ); |
|
153 horizontalLines[5].LayoutRect( parentRect, AknLayoutScalable_Apps::cale_week_scroll_pane_g14( layoutVariant ).LayoutLine() ); |
|
154 horizontalLines[6].LayoutRect( parentRect, AknLayoutScalable_Apps::cale_week_scroll_pane_g15( layoutVariant ).LayoutLine() ); |
|
155 |
|
156 lineColor = verticalLines[0].Color(); |
|
157 AknsUtils::GetCachedColor(AknsUtils::SkinInstance(), lineColor, |
|
158 KAknsIIDQsnLineColors, |
|
159 EAknsCIQsnLineColorsCG2); |
|
160 aGc.SetBrushColor( lineColor ); |
|
161 aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
162 |
|
163 for (TInt i=0; i < verticalLineCount; ++i) |
|
164 { |
|
165 aGc.Clear( verticalLines[i].Rect() ); |
|
166 } |
|
167 |
|
168 for (TInt i=0; i < horizontalLineCount; ++i) |
|
169 { |
|
170 aGc.Clear( horizontalLines[i].Rect() ); |
|
171 } |
|
172 |
|
173 TRACE_EXIT_POINT; |
|
174 } |
|
175 |
|
176 |
|
177 |
|
178 // ================= MEMBER FUNCTIONS ======================= |
|
179 |
|
180 // ---------------------------------------------------------------------------- |
|
181 // CCalenWeekContainer::CCalenWeekContainer |
|
182 // C++ constructor can NOT contain any code, that might leave. |
|
183 // (other items were commented in a header). |
|
184 // ---------------------------------------------------------------------------- |
|
185 // |
|
186 CCalenWeekContainer::CCalenWeekContainer( CCalenNativeView* aView, |
|
187 TTime& aTime, |
|
188 TInt& aSelectedRowNumber, |
|
189 TTimeIntervalMinutes& aFirstRowTime, |
|
190 MCalenServices& aServices ) |
|
191 : CCalenContainer( aView, aServices ), |
|
192 // iCurrentDay( TInt64(0) ), |
|
193 iStartDay( TInt64(0) ), |
|
194 iViewPopulationComplete( EFalse ), |
|
195 iTime( aTime ), |
|
196 iSelectedRowNumber( aSelectedRowNumber ), |
|
197 iFirstRowTime( aFirstRowTime ) |
|
198 { |
|
199 TRACE_ENTRY_POINT; |
|
200 TRACE_EXIT_POINT; |
|
201 } |
|
202 |
|
203 // ---------------------------------------------------------------------------- |
|
204 // CCalenWeekContainer::~CCalenWeekContainer |
|
205 // Destructor |
|
206 // (other items were commented in a header). |
|
207 // ---------------------------------------------------------------------------- |
|
208 // |
|
209 CCalenWeekContainer::~CCalenWeekContainer() |
|
210 { |
|
211 TRACE_ENTRY_POINT; |
|
212 |
|
213 delete iListBox; |
|
214 if( iNativePreview && iPreview ) |
|
215 { |
|
216 delete iPreview; |
|
217 iPreview = NULL; |
|
218 } |
|
219 delete iDesArray; |
|
220 |
|
221 CleanupInstances(); |
|
222 |
|
223 ResetSlotTable(); |
|
224 delete iBackgroundSkinContext; |
|
225 |
|
226 TRACE_EXIT_POINT; |
|
227 } |
|
228 |
|
229 |
|
230 |
|
231 // --------------------------------------------------------- |
|
232 // CCalenWeekContainer::SetCursorToActiveDayL |
|
233 // Sets cursor in Active day |
|
234 // (other items were commented in a header). |
|
235 // ---------------------------------------------------------------------------- |
|
236 // |
|
237 void CCalenWeekContainer::SetCursorToActiveDayL() |
|
238 { |
|
239 TRACE_ENTRY_POINT; |
|
240 |
|
241 iTime = CCalenContainer::DateFromContextL( iServices.Context() ); |
|
242 |
|
243 TLocale locale; |
|
244 |
|
245 TInt column( iTime.DayNoInWeek() - locale.StartOfWeek() ); |
|
246 |
|
247 if( column < 0 ) |
|
248 { |
|
249 column += KCalenDaysInWeek; |
|
250 } |
|
251 iColumn = column; |
|
252 |
|
253 TTime startDay( iTime - TTimeIntervalDays( column ) ); |
|
254 |
|
255 if (iStartDay != startDay) |
|
256 { |
|
257 iStartDay = startDay; |
|
258 iView->BeginRepopulationL(); |
|
259 iListBox->View()->SetDisableRedraw(ETrue); |
|
260 } |
|
261 else if ( iViewPopulationComplete ) |
|
262 { |
|
263 iListBox->View()->SetDisableRedraw(ETrue); |
|
264 SelectHighlightedCellAndVisibleRangeL(); |
|
265 iListBox->View()->SetDisableRedraw(EFalse); |
|
266 FocusChangeForPopupL(); |
|
267 UpdateStatusPaneAndExtensionsL(); |
|
268 DrawNow(); |
|
269 } |
|
270 |
|
271 TRACE_EXIT_POINT; |
|
272 } |
|
273 |
|
274 // ---------------------------------------------------------------------------- |
|
275 // CCalenWeekContainer::RedrawLocaleChangeL |
|
276 // Redrawing when locale change |
|
277 // (other items were commented in a header). |
|
278 // ---------------------------------------------------------------------------- |
|
279 // |
|
280 void CCalenWeekContainer::RedrawLocaleChangeL(TLocaleChangeRedraw aFlag) // ERedrawAll | ERedrawWeek |
|
281 { |
|
282 TRACE_ENTRY_POINT; |
|
283 |
|
284 if (aFlag == ERedrawAll) |
|
285 { |
|
286 iStartDay = Time::NullTTime(); |
|
287 SetCursorToActiveDayL(); |
|
288 } |
|
289 FocusChangeForPopupL(); |
|
290 UpdateStatusPaneAndExtensionsL(); |
|
291 |
|
292 TRACE_EXIT_POINT; |
|
293 } |
|
294 |
|
295 // ---------------------------------------------------------------------------- |
|
296 // ?classname::?member_function |
|
297 // ?implementation_description |
|
298 // (other items were commented in a header). |
|
299 // ---------------------------------------------------------------------------- |
|
300 // |
|
301 TInt CCalenWeekContainer::HighlightRowFromActiveContextL(TInt aColumn) |
|
302 { |
|
303 TRACE_ENTRY_POINT; |
|
304 |
|
305 TInt row = KErrNotFound; |
|
306 |
|
307 MCalenContext& context = iServices.Context(); |
|
308 |
|
309 // row is selected while moving up/dowm left/right |
|
310 if ( iSelectedRowNumber != KErrNotFound ) |
|
311 { |
|
312 row = iSelectedRowNumber; |
|
313 iFirstRowTime = context.FocusTime(); |
|
314 |
|
315 if(iFirstRowTime != TTimeIntervalMinutes(KNullMinutes)) |
|
316 { |
|
317 iRow = EFalse; |
|
318 } |
|
319 else |
|
320 { |
|
321 iRow = ETrue; |
|
322 row = FindItemFromColumnL( context.InstanceId(),aColumn ); |
|
323 } |
|
324 |
|
325 if(iFirstRowTime == TTimeIntervalMinutes(0)) |
|
326 { |
|
327 row = KErrNotFound; |
|
328 iFirstRowTime = TTimeIntervalMinutes(KNullMinutes); |
|
329 } |
|
330 |
|
331 } |
|
332 else if ( !(context.InstanceId() == TCalenInstanceId::NullInstanceId() ) ) |
|
333 { |
|
334 // based on the instanceid |
|
335 row = FindItemFromColumnL( context.InstanceId(), |
|
336 aColumn ); |
|
337 |
|
338 } |
|
339 else if ( context.FocusDateAndTimeL().TimeUtcL() != Time::NullTTime() ) |
|
340 { |
|
341 // weekview is activated from other views/view switching |
|
342 if( iSelectedRowNumber == KErrNotFound && |
|
343 iFirstRowTime == TTimeIntervalMinutes(KNullMinutes) ) |
|
344 { |
|
345 row = KErrNotFound; |
|
346 } |
|
347 else |
|
348 { |
|
349 // based on the context time |
|
350 row = FindRowForTime( |
|
351 CalenDateUtils::RoundToPreviousHour( |
|
352 CalenDateUtils::TimeOfDay( |
|
353 context.FocusDateAndTimeL().TimeLocalL().DateTime() ) ) ); |
|
354 } |
|
355 } |
|
356 |
|
357 // if we still haven't found anything to highlight, |
|
358 // highlight to first entry or 8:00 row. |
|
359 if (row == KErrNotFound) |
|
360 { |
|
361 row = FindFirstItemOfColumn(aColumn); |
|
362 |
|
363 if (row == KErrNotFound) |
|
364 { |
|
365 TInt eightOclock = KNonTimedNoteDefautDisplayTime * KCalenMinutesInHour; |
|
366 row = FindRowForTime( eightOclock ); |
|
367 iTopRowDefault = ETrue; |
|
368 } |
|
369 } |
|
370 ASSERT( row != KErrNotFound ); |
|
371 |
|
372 TRACE_EXIT_POINT; |
|
373 return row; |
|
374 |
|
375 } |
|
376 |
|
377 // ---------------------------------------------------------------------------- |
|
378 // CCalenWeekContainer::SelectHighlightedCellAndVisibleRangeL() |
|
379 // Sets highlight item in ListBox at active time |
|
380 // (other items were commented in a header). |
|
381 // ---------------------------------------------------------------------------- |
|
382 // |
|
383 void CCalenWeekContainer::SelectHighlightedCellAndVisibleRangeL() |
|
384 { |
|
385 TRACE_ENTRY_POINT; |
|
386 |
|
387 TInt row = HighlightRowFromActiveContextL( iColumn ); |
|
388 TInt topRow = SearchTopIndexL( iColumn ); |
|
389 |
|
390 if (row == KErrNotFound) |
|
391 { |
|
392 // If not yet found, Then just take 8:00 row |
|
393 TInt eightOclock = KNonTimedNoteDefautDisplayTime * KCalenMinutesInHour; |
|
394 row = FindRowForTime(eightOclock); |
|
395 } |
|
396 |
|
397 SetHighlightAndVisibleRange( row, iColumn, topRow ); |
|
398 SetActiveContextFromHighlightL(); |
|
399 |
|
400 TRACE_EXIT_POINT; |
|
401 } |
|
402 |
|
403 // ---------------------------------------------------------------------------- |
|
404 // CCalenWeekContainer::SetActiveContextFromHighlightL |
|
405 // Set Active date and time |
|
406 // (other items were commented in a header). |
|
407 // ---------------------------------------------------------------------------- |
|
408 // |
|
409 void CCalenWeekContainer::SetActiveContextFromHighlightL() |
|
410 { |
|
411 TRACE_ENTRY_POINT; |
|
412 |
|
413 MCalenContext& context = iServices.Context(); |
|
414 TCalTime currentDayCalTime; |
|
415 TDateTime dt = iTime.DateTime(); |
|
416 currentDayCalTime.SetTimeLocalL( iTime ); |
|
417 context.SetFocusDateAndTimeL( currentDayCalTime, |
|
418 TVwsViewId( KUidCalendar, KUidCalenWeekView ) ); |
|
419 |
|
420 TInt row = iListBox->View()->CurrentItemIndex(); |
|
421 // In under processing of DoStepL(), row is -1. |
|
422 if (row >= 0) |
|
423 { |
|
424 CWeekSlotArrayPtr slotTable = iSlotTable[iColumn]; |
|
425 const CCalHourItem& itemInfo = *(*slotTable)[row]; |
|
426 // Focused item |
|
427 // 1. Non-timed item, 1 for each cell, on same/ different day |
|
428 // * Focus on instanceId and datetime |
|
429 // 2. Timed item, 1-n for each cell, on same/ different day |
|
430 // * Focus on datetime |
|
431 if( itemInfo.HasInstance() ) |
|
432 { |
|
433 TCalenInstanceId instId = TCalenInstanceId::CreateL( *itemInfo.iInstance ); |
|
434 if( !itemInfo.IsTimed() ) // todo/anniv/memo |
|
435 { |
|
436 dt.SetHour( KNonTimedNoteDefautDisplayTime ); |
|
437 currentDayCalTime.SetTimeLocalL( TTime( dt ) ); |
|
438 context.SetFocusDateAndTimeAndInstanceL( currentDayCalTime, instId, |
|
439 TVwsViewId( KUidCalendar, KUidCalenWeekView ) ); |
|
440 } |
|
441 else // meeting |
|
442 { |
|
443 TTime focusTime = CalenDateUtils::BeginningOfDay( iTime ) + itemInfo.iStartTime; |
|
444 currentDayCalTime.SetTimeLocalL( focusTime ); |
|
445 // context.SetFocusDateAndTimeL( currentDayCalTime, |
|
446 // TVwsViewId( KUidCalendar, KUidCalenWeekView ) ); |
|
447 context.SetFocusDateAndTimeAndInstanceL( currentDayCalTime, instId, |
|
448 TVwsViewId( KUidCalendar, KUidCalenWeekView ) ); |
|
449 |
|
450 TDateTime focusTimeTemp = focusTime.DateTime(); |
|
451 |
|
452 } |
|
453 } |
|
454 else if( itemInfo.iStartTime.Int() == KErrNotFound ) // empty non-timed cell |
|
455 { |
|
456 dt.SetHour( KNonTimedNoteDefautDisplayTime ); |
|
457 currentDayCalTime.SetTimeLocalL( TTime( dt ) ); |
|
458 context.SetFocusDateAndTimeL( currentDayCalTime, |
|
459 TVwsViewId( KUidCalendar, KUidCalenWeekView ) ); |
|
460 } |
|
461 else // empty timed cell |
|
462 { |
|
463 TTime focusTime = CalenDateUtils::BeginningOfDay( iTime ) + itemInfo.iStartTime; |
|
464 currentDayCalTime.SetTimeLocalL( focusTime ); |
|
465 context.SetFocusDateAndTimeL( currentDayCalTime, |
|
466 TVwsViewId( KUidCalendar, KUidCalenWeekView ) ); |
|
467 } |
|
468 FocusChangeForPopupL(); |
|
469 } |
|
470 // Hide/unhide "today" toolbar item based on the focused day |
|
471 UpdateTodayToolbarItemL(); |
|
472 TRACE_EXIT_POINT; |
|
473 } |
|
474 |
|
475 // ---------------------------------------------------------------------------- |
|
476 // CCalenWeekContainer::CalcDayFromColumn |
|
477 // Calculates and Sets day from ListBox column |
|
478 // (other items were commented in a header). |
|
479 // ---------------------------------------------------------------------------- |
|
480 // |
|
481 void CCalenWeekContainer::CalcDayFromColumn() |
|
482 { |
|
483 TRACE_ENTRY_POINT; |
|
484 |
|
485 iTime = iStartDay + TTimeIntervalDays( iColumn ); |
|
486 TDateTime dt = iStartDay.DateTime(); |
|
487 |
|
488 TRACE_EXIT_POINT; |
|
489 } |
|
490 |
|
491 |
|
492 // ---------------------------------------------------------------------------- |
|
493 // CCalenWeekContainer::PopulatesDayListsL |
|
494 // Populate whole week daylist from Agenda server |
|
495 // (other items were commented in a header). |
|
496 // ---------------------------------------------------------------------------- |
|
497 // |
|
498 void CCalenWeekContainer::PopulatesDayListsL() |
|
499 { |
|
500 TRACE_ENTRY_POINT; |
|
501 |
|
502 TTime indexDay( iStartDay ); |
|
503 TTimeIntervalDays oneDay( 1 ); |
|
504 |
|
505 RArray<TInt> colIdArray; |
|
506 CCalenNativeView::GetActiveCollectionidsL( iServices, colIdArray ); |
|
507 |
|
508 if(colIdArray.Count() > 0) |
|
509 { |
|
510 for( TInt i(0); i < KCalenDaysInWeek; ++i, indexDay+=oneDay ) |
|
511 { |
|
512 iIdList[i].ResetAndDestroy(); |
|
513 CalenAgendaUtils::CreateEntryIdListForDayL( iIdList[i], |
|
514 iServices.InstanceViewL(colIdArray), |
|
515 indexDay ); |
|
516 } |
|
517 } |
|
518 else |
|
519 { |
|
520 for( TInt i(0); i < KCalenDaysInWeek; ++i, indexDay+=oneDay ) |
|
521 { |
|
522 iIdList[i].ResetAndDestroy(); |
|
523 CalenAgendaUtils::CreateEntryIdListForDayL( iIdList[i], |
|
524 iServices.InstanceViewL(), |
|
525 indexDay ); |
|
526 } |
|
527 } |
|
528 |
|
529 colIdArray.Reset(); |
|
530 TRACE_EXIT_POINT; |
|
531 } |
|
532 |
|
533 // ---------------------------------------------------------------------------- |
|
534 // CCalenWeekContainer::InsertTimedNotesToSlotTableL |
|
535 // |
|
536 // After this function, slotTable for each column (weekday) |
|
537 // will contain: |
|
538 // 1) for each hour row without meetings: |
|
539 // SHourItem.iStartTime = hour as a minutes from beginning of day |
|
540 // SHourItem.iInstanceId = NullInstanceId |
|
541 // SHourItem.iTimedNote = EFalse |
|
542 // SHourItem.iHourData = -- (nothing set) |
|
543 // 2) for each hour row with at least one meeting: |
|
544 // SHourItem.iStartTime = hour as a minutes from beginning of day |
|
545 // SHourItem.iInstanceId = instance id of first entry falling to the hour |
|
546 // (sorting order as in day view) |
|
547 // SHourItem.iTimedNote = ETrue |
|
548 // SHourItem.iHourData = hour data as a table of six color values. |
|
549 // |
|
550 // (other items were commented in a header). |
|
551 // ---------------------------------------------------------------------------- |
|
552 // |
|
553 void CCalenWeekContainer::InsertTimedNotesToSlotTableL() |
|
554 { |
|
555 TRACE_ENTRY_POINT; |
|
556 //Parsing items for each day in week |
|
557 |
|
558 TTime instStart; |
|
559 TTime instEnd; |
|
560 |
|
561 TDateTime daybegin; |
|
562 TDateTime startDateTime; |
|
563 TDateTime endDateTime; |
|
564 TTimeIntervalMinutes durationInMinutes; |
|
565 |
|
566 TTimeIntervalHours instStartHour; |
|
567 TTimeIntervalHours instEndHour; |
|
568 TTimeIntervalMinutes instStartMin; |
|
569 TTimeIntervalMinutes instEndMin; |
|
570 |
|
571 TInt markStart; |
|
572 TInt markEnd; |
|
573 TInt instEndHourInt; |
|
574 TInt instStartMinInt; |
|
575 TInt instEndMinInt; |
|
576 TInt eventsInHour; |
|
577 TInt hours; |
|
578 |
|
579 TInt KEveryMinutes = KCalenMinutesInHour / KEventsInHour; //10min |
|
580 |
|
581 // For each day in a week |
|
582 for (TInt dayIx(0); dayIx < KCalenDaysInWeek; dayIx++) |
|
583 { |
|
584 TTime day((iStartDay + TTimeIntervalDays(dayIx))); |
|
585 CWeekSlotArrayPtr slotTable = iSlotTable[dayIx]; |
|
586 RPointerArray<CCalInstance>& dayList = iIdList[dayIx]; //Event for day |
|
587 |
|
588 //Get start time of day |
|
589 TTime dayBegin = CalenDateUtils::BeginningOfDay( day ); |
|
590 |
|
591 //Initialize the ptr list with empty items but take account the non timed events |
|
592 TInt beginMinutes(0); |
|
593 |
|
594 // For each hour in a day initialisation for the slot table and other hour item required. |
|
595 for(TInt i(0) ; i < KCalenHoursInDay; i++) |
|
596 { |
|
597 CCalHourItem* emptyInfo = CCalHourItem::NewL(); |
|
598 CleanupStack::PushL( emptyInfo ); |
|
599 emptyInfo->iInstance = NULL; |
|
600 emptyInfo->iStartTime = TTimeIntervalMinutes( beginMinutes ); |
|
601 emptyInfo->iTimedNote = EFalse; |
|
602 |
|
603 // For instances before non - timed notes |
|
604 if(i < KNonTimedNoteDefautDisplayTime) |
|
605 { |
|
606 slotTable->InsertL(i, emptyInfo); |
|
607 } |
|
608 else // For instances after non - timed notes |
|
609 { |
|
610 emptyInfo->iTimedNote=ETrue; |
|
611 slotTable->AppendL(emptyInfo); |
|
612 } |
|
613 CleanupStack::Pop(); |
|
614 beginMinutes = beginMinutes + KCalenMinutesInHour; |
|
615 } |
|
616 |
|
617 |
|
618 |
|
619 //Go through the whole instance list |
|
620 for(TInt item(0); item < dayList.Count(); item++) |
|
621 { |
|
622 RPointerArray<CCalCalendarInfo> calendarInfoList; |
|
623 iServices.GetAllCalendarInfoL(calendarInfoList); |
|
624 CleanupClosePushL(calendarInfoList); |
|
625 CCalInstance* inst = dayList[item]; |
|
626 CCalEntry& entry = inst->Entry(); |
|
627 TCalCollectionId colId = inst->InstanceIdL().iCollectionId; |
|
628 HBufC* calendarFileName = iServices.GetCalFileNameForCollectionId(colId).AllocLC(); |
|
629 TInt index = calendarInfoList.Find( *calendarFileName, |
|
630 CCalenWeekContainer::CalendarInfoIdentifierL); |
|
631 CleanupStack::PopAndDestroy(calendarFileName); |
|
632 |
|
633 //Handle only the timed node, ignore nontimed and non-allday |
|
634 if( ( IsTimedNoteL( entry ) || CalenViewUtils::IsAlldayEventL(*inst) ) |
|
635 && index != KErrNotFound && calendarInfoList[index]->Enabled() ) |
|
636 { |
|
637 //Get the start and end time of instance |
|
638 instStart = inst->Time().TimeLocalL(); |
|
639 entry.EndTimeL().TimeLocalL().MinutesFrom( entry.StartTimeL().TimeLocalL(), durationInMinutes ); |
|
640 instEnd = instStart + durationInMinutes; |
|
641 |
|
642 // Get the day' begin time, instance start time and |
|
643 // instance end time in TDateTime format. |
|
644 daybegin = dayBegin.DateTime(); |
|
645 startDateTime = instStart.DateTime(); |
|
646 endDateTime = instEnd.DateTime(); |
|
647 |
|
648 // If the instance start time is before the day begin, |
|
649 // then initialise it to day begin's time |
|
650 if(startDateTime.Year() != daybegin.Year() || |
|
651 startDateTime.Month() != daybegin.Month() || |
|
652 startDateTime.Day() != daybegin.Day() ) |
|
653 { |
|
654 startDateTime = daybegin; |
|
655 } |
|
656 |
|
657 // If the instance end day one or more days ahead than |
|
658 // day begin, then initialise it to end of day begin |
|
659 if(endDateTime.Year() != daybegin.Year() || |
|
660 endDateTime.Month() != daybegin.Month() || |
|
661 endDateTime.Day() != daybegin.Day() ) |
|
662 { |
|
663 endDateTime = daybegin; |
|
664 endDateTime.SetHour(23); |
|
665 endDateTime.SetMinute(59); |
|
666 } |
|
667 |
|
668 //Get time interval between beginning of day and instance start and end time |
|
669 // in minutes in TTimeIntervalMinutes format. |
|
670 TTime(startDateTime).HoursFrom(dayBegin, instStartHour); |
|
671 TTime(endDateTime).HoursFrom(dayBegin,instEndHour); |
|
672 |
|
673 //Get time interval between beginning of day and instance start and end time |
|
674 // in hours in TTimeIntervalHours format. |
|
675 TTime(startDateTime).MinutesFrom(dayBegin,instStartMin); |
|
676 TTime(endDateTime).MinutesFrom(dayBegin,instEndMin); |
|
677 |
|
678 // The no. of hours from day begin to instance end time |
|
679 instEndHourInt = instEndHour.Int(); //From Day Begin |
|
680 |
|
681 // The no. of min from day begin to instance start time. |
|
682 instStartMinInt = instStartMin.Int(); |
|
683 // The no. of min from day begin to instance end time |
|
684 instEndMinInt = instEndMin.Int(); |
|
685 |
|
686 // The hour to start with. |
|
687 hours = instStartHour.Int(); |
|
688 eventsInHour = startDateTime.Minute() / 10; |
|
689 |
|
690 // The minute to start with. |
|
691 markStart = instStartMin.Int(); |
|
692 |
|
693 // The minute to end with. |
|
694 markEnd = markStart + KEveryMinutes; |
|
695 |
|
696 // From instance start hour to end hour |
|
697 for( ; hours <= instEndHourInt; hours++ ) |
|
698 { |
|
699 TInt itemIndex(0); |
|
700 // Before non - timed notes |
|
701 if(hours < KNonTimedNoteDefautDisplayTime ) |
|
702 { |
|
703 itemIndex = hours; |
|
704 } |
|
705 else // After non-time notes |
|
706 { |
|
707 itemIndex = hours + iNonTimedAreaRowCount; |
|
708 } |
|
709 |
|
710 //Get correct item |
|
711 CCalHourItem& itemInfo = *(*slotTable)[itemIndex]; |
|
712 itemInfo.iInstance = inst; |
|
713 TUint32 color; |
|
714 |
|
715 // For all the events in this hour |
|
716 for( ; eventsInHour < KEventsInHour; eventsInHour++ ) // 6 times |
|
717 { |
|
718 // If this instance is there between mark start and end |
|
719 if( ( instStartMinInt >= markStart && instStartMinInt < markEnd) || |
|
720 ( instStartMinInt <= markStart && instEndMinInt > markStart) ) |
|
721 { |
|
722 if( itemInfo.iHourData.Event(eventsInHour) ) |
|
723 { |
|
724 // conflicting meeting from same/different db |
|
725 color = (TUint32)EManyEvents; |
|
726 } |
|
727 else |
|
728 { |
|
729 color = calendarInfoList[index]->Color().Value(); |
|
730 if(color == KRgbBlack.Value()) |
|
731 { |
|
732 color = EBlackColoredEvent; |
|
733 } |
|
734 } |
|
735 itemInfo.iHourData.SetEvent( eventsInHour, color ); |
|
736 } |
|
737 markStart += KEveryMinutes; |
|
738 markEnd += KEveryMinutes; |
|
739 } |
|
740 eventsInHour = 0; |
|
741 } |
|
742 } |
|
743 CleanupStack::PopAndDestroy(&calendarInfoList); |
|
744 } |
|
745 ClearOneDayEntryCache(); |
|
746 } |
|
747 TRACE_EXIT_POINT; |
|
748 |
|
749 } |
|
750 |
|
751 // ---------------------------------------------------------------------------- |
|
752 // CCalenWeekContainer::InsertNonTimedNotesToSlotTableL |
|
753 // |
|
754 // After this function, slotTable for each column (weekday) |
|
755 // will contain: |
|
756 // 1) for each empty non-timed note row (those days that have less |
|
757 // non-timed notes than others, contain empty rows): |
|
758 // SHourItem.iStartTime = KCalenActiveTimeNull |
|
759 // SHourItem.iInstanceId = NullInstanceId |
|
760 // SHourItem.iTimedNote = EFalse |
|
761 // SHourItem.iHourData = -- (nothing set) |
|
762 // 2) for each non-timed note row with note : |
|
763 // SHourItem.iStartTime = KCalenActiveTimeNull |
|
764 // SHourItem.iInstanceId = instance id of entry |
|
765 // SHourItem.iTimedNote = EFalse |
|
766 // SHourItem.iHourData = icon index representing non-timed note |
|
767 // |
|
768 // (other items were commented in a header). |
|
769 // ---------------------------------------------------------------------------- |
|
770 // |
|
771 void CCalenWeekContainer::InsertNonTimedNotesToSlotTableL() |
|
772 { |
|
773 TRACE_ENTRY_POINT; |
|
774 |
|
775 TInt maxNotes( 0 ); |
|
776 TInt nonTimedNotes[ KCalenDaysInWeek ]; |
|
777 |
|
778 TInt dayIx( 0 ); |
|
779 |
|
780 for( dayIx = 0; dayIx < KCalenDaysInWeek; ++dayIx ) |
|
781 { |
|
782 nonTimedNotes[dayIx] = 0; |
|
783 |
|
784 // instances |
|
785 RPointerArray<CCalInstance>& dayList = iIdList[dayIx]; |
|
786 |
|
787 |
|
788 for (TInt i(0); i < dayList.Count(); ++i) |
|
789 { |
|
790 CCalEntry& entry = dayList[i]->Entry(); |
|
791 CCalEntry::TType type = entry.EntryTypeL(); |
|
792 |
|
793 TCalCollectionId colId = dayList[i]->InstanceIdL().iCollectionId; |
|
794 |
|
795 |
|
796 if ( type != CCalEntry::EAppt && !CalenViewUtils::IsAlldayEventL( *( dayList[i] ) ) ) |
|
797 { |
|
798 nonTimedNotes[dayIx] += 1; |
|
799 } |
|
800 } |
|
801 maxNotes = Max( maxNotes, nonTimedNotes[dayIx] ); |
|
802 } |
|
803 iNonTimedAreaRowCount = maxNotes; |
|
804 |
|
805 |
|
806 for( dayIx = 0; dayIx < KCalenDaysInWeek; ++dayIx ) |
|
807 { |
|
808 CWeekSlotArrayPtr slotTable = iSlotTable[dayIx]; |
|
809 |
|
810 // Empty slots |
|
811 TInt nonTimedAreaRow( 0 ); |
|
812 for ( ; nonTimedAreaRow < iNonTimedAreaRowCount - nonTimedNotes[dayIx]; ++nonTimedAreaRow ) |
|
813 { |
|
814 // create new hour item |
|
815 CCalHourItem* itemInfo = CCalHourItem::NewL(); |
|
816 CleanupStack::PushL( itemInfo ); |
|
817 itemInfo->iStartTime = TTimeIntervalMinutes( KNullMinutes ); |
|
818 itemInfo->iTimedNote = EFalse; |
|
819 // Empty slots |
|
820 itemInfo->iInstance = NULL; |
|
821 slotTable->AppendL( itemInfo ); |
|
822 CleanupStack::Pop(); // iteminfo |
|
823 // we just put non-timed notes to slot table |
|
824 } |
|
825 |
|
826 // Slots with notes |
|
827 if (nonTimedAreaRow < iNonTimedAreaRowCount) |
|
828 { |
|
829 RPointerArray<CCalInstance>& dayList = iIdList[dayIx]; |
|
830 |
|
831 for( TInt item(0); item < dayList.Count(); ++item ) |
|
832 { |
|
833 CCalEntry& entry = dayList[item]->Entry(); |
|
834 TCalCollectionId colId = dayList[item]->InstanceIdL().iCollectionId; |
|
835 |
|
836 if( !IsTimedNoteL( entry ) && !CalenViewUtils::IsAlldayEventL( *( dayList[item] ) ) ) ///*&& index != KErrNotFound && infoArray[index]->GetCalendarStatus()*/) |
|
837 { |
|
838 ++nonTimedAreaRow; |
|
839 |
|
840 CCalHourItem* itemInfo = CCalHourItem::NewL(); |
|
841 CleanupStack::PushL( itemInfo ); |
|
842 itemInfo->iInstance = dayList[item]; |
|
843 // set icon index |
|
844 TInt iconIndex = static_cast<TInt>( IconIndexFromEntryL( entry , |
|
845 CalenViewUtils::IsAlldayEventL( *( dayList[ item ] ) ) ) ); |
|
846 itemInfo->iHourData.SetIconIndex( iconIndex ); |
|
847 slotTable->AppendL( itemInfo ); |
|
848 CleanupStack::Pop(); // iteminfo |
|
849 } |
|
850 } |
|
851 } |
|
852 } |
|
853 |
|
854 TRACE_EXIT_POINT; |
|
855 } |
|
856 |
|
857 // ---------------------------------------------------------------------------- |
|
858 // CCalenWeekContainer::SetListBoxDataL |
|
859 // Sets Week data to ListBox |
|
860 // (other items were commented in a header). |
|
861 // ---------------------------------------------------------------------------- |
|
862 // |
|
863 void CCalenWeekContainer::SetListBoxDataL() |
|
864 { |
|
865 TRACE_ENTRY_POINT; |
|
866 |
|
867 iListBox->View()->SetDisableRedraw(ETrue); |
|
868 |
|
869 TLocale locale; |
|
870 |
|
871 const TInt resID( locale.TimeFormat() == ETime24 ? |
|
872 R_QTN_TIME_USUAL : R_CALEN_WEEKVIEW_TIMEFORMAT_12 ); |
|
873 HBufC* timeFormat = StringLoader::LoadLC( resID, iEikonEnv ); |
|
874 |
|
875 iDesArray->Reset(); |
|
876 |
|
877 CWeekSlotArrayPtr firstDaySlotTable = iSlotTable[0]; |
|
878 TInt count( firstDaySlotTable->Count() ); |
|
879 |
|
880 for (TInt row(0); row < count; ++row) |
|
881 { |
|
882 TTime time(TInt64(0)); |
|
883 const CCalHourItem& hourItemInfo = *(*firstDaySlotTable)[row]; |
|
884 |
|
885 SDisplayData dispData; |
|
886 if( hourItemInfo.iStartTime.Int() >= 0 ) |
|
887 { |
|
888 time += hourItemInfo.iStartTime; |
|
889 time.FormatL(dispData.iHourDes, *timeFormat); |
|
890 } |
|
891 |
|
892 for (TInt day(0); day < KCalenDaysInWeek; ++day) |
|
893 { |
|
894 CWeekSlotArrayPtr daySlotTable = iSlotTable[day]; |
|
895 |
|
896 const CCalHourItem& itemInfo = *(*daySlotTable)[row]; |
|
897 dispData.iHourData[day] = itemInfo.iHourData; |
|
898 } |
|
899 |
|
900 TInt size((sizeof(dispData) / sizeof(TText))); |
|
901 TPtr16 ptr((TUint16 *)&dispData, size, size); |
|
902 iDesArray->AppendL(ptr); |
|
903 } |
|
904 |
|
905 CleanupStack::PopAndDestroy(timeFormat); |
|
906 |
|
907 iListBox->SetStartDay(iStartDay); |
|
908 iListBox->HandleItemAdditionL(); |
|
909 |
|
910 static_cast<CCalenWeekLBView*>(iListBox->View())->SetColumn(iColumn); |
|
911 SelectHighlightedCellAndVisibleRangeL(); |
|
912 |
|
913 iListBox->View()->SetDisableRedraw(EFalse); |
|
914 DrawDeferred(); |
|
915 |
|
916 TRACE_EXIT_POINT; |
|
917 } |
|
918 |
|
919 // ---------------------------------------------------------------------------- |
|
920 // CCalenWeekContainer::SearchMatchedNoteL |
|
921 // The note contained in within a time is searched. |
|
922 // (other items were commented in a header). |
|
923 // ---------------------------------------------------------------------------- |
|
924 // |
|
925 void CCalenWeekContainer::SearchMatchedNoteL(RPointerArray<CCalInstance>& aDayList,// InstanceId array |
|
926 TTime aTime) // Search Timezone |
|
927 { |
|
928 TRACE_ENTRY_POINT; |
|
929 |
|
930 TTime aTimeEnd( aTime ); |
|
931 aTimeEnd += TTimeIntervalHours( 1 ); |
|
932 |
|
933 for( TInt i(0); i < aDayList.Count(); ++i ) |
|
934 { |
|
935 CCalInstance* instance = aDayList[i]; |
|
936 CCalEntry& entry = instance->Entry(); |
|
937 |
|
938 if( IsTimedNoteL( entry ) ) |
|
939 { |
|
940 TTime start( instance->Time().TimeLocalL() ); |
|
941 TTimeIntervalMinutes duration; |
|
942 entry.EndTimeL().TimeLocalL().MinutesFrom( entry.StartTimeL().TimeLocalL(), duration ); |
|
943 TTime end = start +duration; |
|
944 |
|
945 if( (start >= aTime && start < aTimeEnd) || |
|
946 (start <= aTime && end > aTime) ) |
|
947 { |
|
948 CleanupStack::PushL( instance ); |
|
949 iEntryCache.AppendL( instance ); |
|
950 CleanupStack::Pop(); // instance |
|
951 } |
|
952 } |
|
953 } |
|
954 |
|
955 if( !iEntryCache.Count() ) |
|
956 { |
|
957 iEntryCache.Reset(); |
|
958 } |
|
959 |
|
960 TRACE_EXIT_POINT; |
|
961 } |
|
962 |
|
963 // ---------------------------------------------------------------------------- |
|
964 // CCalenWeekContainer::IsTimedNote |
|
965 // Check specified entry whether Timed Note. |
|
966 // (other items were commented in a header). |
|
967 // ---------------------------------------------------------------------------- |
|
968 // |
|
969 TBool CCalenWeekContainer::IsTimedNoteL(CCalEntry& aEntry) |
|
970 { |
|
971 TRACE_ENTRY_POINT; |
|
972 |
|
973 TRACE_EXIT_POINT; |
|
974 return( aEntry.EntryTypeL() == CCalEntry::EAppt ); |
|
975 } |
|
976 |
|
977 // ---------------------------------------------------------------------------- |
|
978 // CCalenWeekContainer::ResetSlotTable |
|
979 // Reset slot time table. |
|
980 // (other items were commented in a header). |
|
981 // ---------------------------------------------------------------------------- |
|
982 // |
|
983 void CCalenWeekContainer::ResetSlotTable() |
|
984 { |
|
985 TRACE_ENTRY_POINT; |
|
986 |
|
987 // loop through days |
|
988 for (TInt dayIx(0); dayIx < KCalenDaysInWeek; ++dayIx) |
|
989 { |
|
990 // current day |
|
991 CWeekSlotArrayPtr daySlotTable = iSlotTable[dayIx]; |
|
992 // go thorugh items in a day |
|
993 if (daySlotTable) |
|
994 { |
|
995 for (TInt i=0; i<daySlotTable->Count(); ++i) |
|
996 { |
|
997 // free instances on a day |
|
998 CCalHourItem* itemInfo = (*daySlotTable)[i]; |
|
999 delete itemInfo; |
|
1000 (*daySlotTable)[i]=NULL; |
|
1001 } |
|
1002 |
|
1003 // delete day |
|
1004 delete daySlotTable; |
|
1005 } |
|
1006 |
|
1007 iSlotTable[dayIx] = NULL; |
|
1008 } |
|
1009 |
|
1010 TRACE_EXIT_POINT; |
|
1011 } |
|
1012 |
|
1013 void CCalenWeekContainer::InitSlotTableL() |
|
1014 { |
|
1015 TRACE_ENTRY_POINT; |
|
1016 |
|
1017 ResetSlotTable(); |
|
1018 for (TInt dayIx(0); dayIx < KCalenDaysInWeek; ++dayIx) |
|
1019 { |
|
1020 iSlotTable[dayIx] = new(ELeave) CArrayFixFlat<CCalHourItem*>(10); |
|
1021 } |
|
1022 |
|
1023 TRACE_EXIT_POINT; |
|
1024 } |
|
1025 |
|
1026 TInt CCalenWeekContainer::FindFirstItemOfColumn(TInt aColumn) |
|
1027 { |
|
1028 TRACE_ENTRY_POINT; |
|
1029 |
|
1030 CWeekSlotArrayPtr slotTable = iSlotTable[aColumn]; |
|
1031 TInt count = slotTable->Count(); |
|
1032 for(TInt index = 0; index < count; ++index) |
|
1033 { |
|
1034 const CCalHourItem& itemInfo = *(*slotTable)[index]; |
|
1035 if (!(itemInfo.iInstance==NULL)) |
|
1036 { |
|
1037 TRACE_EXIT_POINT; |
|
1038 return index; |
|
1039 } |
|
1040 } |
|
1041 TRACE_EXIT_POINT; |
|
1042 return KErrNotFound; |
|
1043 } |
|
1044 |
|
1045 |
|
1046 TInt CCalenWeekContainer::FindItemFromColumnL( const TCalenInstanceId& aId, |
|
1047 TInt aColumn) |
|
1048 { |
|
1049 TRACE_ENTRY_POINT; |
|
1050 |
|
1051 CWeekSlotArrayPtr slotTable = iSlotTable[aColumn]; |
|
1052 TInt count = slotTable->Count(); |
|
1053 CCalEntry::TType type = aId.iType; |
|
1054 |
|
1055 if( type == CCalEntry::ETodo || |
|
1056 type == CCalEntry::EEvent || |
|
1057 type == CCalEntry::EReminder || |
|
1058 type == CCalEntry::EAnniv ) |
|
1059 { // non-timed entry, each entry should occupy 1 cell in the weekview |
|
1060 for(TInt index = 0; index < count; ++index) |
|
1061 { |
|
1062 const CCalHourItem& itemInfo = *(*slotTable)[index]; |
|
1063 CCalInstance * itemInstance = itemInfo.iInstance; |
|
1064 |
|
1065 if (itemInstance && (itemInstance->Entry().LocalUidL() == aId.iEntryLocalUid)) |
|
1066 { |
|
1067 TRACE_EXIT_POINT; |
|
1068 return index; |
|
1069 } |
|
1070 } |
|
1071 } |
|
1072 else if( aId.iType == CCalEntry::EAppt ) |
|
1073 { // timed entry, e.g Meeting, should search for it's timed cell |
|
1074 TInt hr = aId.iInstanceTime.DateTime().Hour(); |
|
1075 if( hr < KNonTimedNoteDefautDisplayTime ) |
|
1076 { |
|
1077 hr = hr; |
|
1078 } |
|
1079 else |
|
1080 { |
|
1081 hr = hr + count - KHoursInADay; |
|
1082 } |
|
1083 TRACE_EXIT_POINT; |
|
1084 return hr; |
|
1085 } |
|
1086 |
|
1087 // unknown entry type |
|
1088 TRACE_EXIT_POINT; |
|
1089 return KErrNotFound; |
|
1090 } |
|
1091 |
|
1092 // ---------------------------------------------------------------------------- |
|
1093 // CCalenWeekContainer::FindRowForTime |
|
1094 // Searches specified time |
|
1095 // (other items were commented in a header). |
|
1096 // ---------------------------------------------------------------------------- |
|
1097 // |
|
1098 TInt CCalenWeekContainer::FindRowForTime(TTimeIntervalMinutes aTime) |
|
1099 { |
|
1100 TRACE_ENTRY_POINT; |
|
1101 |
|
1102 // We can use first column, as all columns have same amount of non-timed |
|
1103 // rows. |
|
1104 CWeekSlotArrayPtr slotTable = iSlotTable[0]; |
|
1105 for(TInt row = 0; row < slotTable->Count(); ++row) |
|
1106 { |
|
1107 const CCalHourItem& item = *(*slotTable)[row]; |
|
1108 if (item.iStartTime == aTime) |
|
1109 { |
|
1110 return row; |
|
1111 } |
|
1112 } |
|
1113 |
|
1114 TRACE_EXIT_POINT; |
|
1115 return KErrNotFound; |
|
1116 } |
|
1117 |
|
1118 // ---------------------------------------------------------------------------- |
|
1119 // CCalenWeekContainer::SetHighlightAndVisibleRange |
|
1120 // Sets highlight item in ListBox |
|
1121 // (other items were commented in a header). |
|
1122 // ---------------------------------------------------------------------------- |
|
1123 // |
|
1124 void CCalenWeekContainer::SetHighlightAndVisibleRange( |
|
1125 TInt aRow, // Selected item index in ListBox |
|
1126 TInt aColumn, // Day of the week |
|
1127 TInt aTopRow) // Top item index in ListBox |
|
1128 { |
|
1129 TRACE_ENTRY_POINT; |
|
1130 |
|
1131 __ASSERT_ALWAYS(aRow != KErrNotFound, User::Invariant()); |
|
1132 __ASSERT_ALWAYS(aColumn >= 0, User::Invariant()); |
|
1133 __ASSERT_ALWAYS(aColumn < KCalenDaysInWeek, User::Invariant()); |
|
1134 // Purpose of the function is to set position of focus and |
|
1135 // set and select topmost visible row. |
|
1136 |
|
1137 // Set highlight |
|
1138 iListBox->SetCurrentItemIndex(aRow); |
|
1139 CCalenWeekLBView* view = |
|
1140 static_cast<CCalenWeekLBView*>( iListBox->View() ); |
|
1141 if (aColumn != view->Column()) |
|
1142 { |
|
1143 view->SetColumn(aColumn, ETrue); |
|
1144 } |
|
1145 |
|
1146 // Select topmost visible row |
|
1147 if (KErrNotFound == aTopRow) |
|
1148 { |
|
1149 aTopRow = aRow; |
|
1150 } |
|
1151 |
|
1152 // FIXME: Take middle SetTopItemIndex calls away |
|
1153 TInt top(aTopRow < 0 ? aRow - KBeforeActiveTime : aTopRow); |
|
1154 TInt items(view->NumberOfItemsThatFitInRect(view->ViewRect())); |
|
1155 CWeekSlotArrayPtr slotTable = iSlotTable[aColumn]; |
|
1156 top = Min(top, slotTable->Count() - items); |
|
1157 top = Max(top, 0); |
|
1158 iListBox->SetTopItemIndex(top); |
|
1159 if (top > aRow) |
|
1160 { |
|
1161 iListBox->SetTopItemIndex(aRow); |
|
1162 } |
|
1163 else if (iListBox->BottomItemIndex() <= aRow) |
|
1164 { |
|
1165 iListBox->SetTopItemIndex(aRow - items + 1); |
|
1166 CWeekSlotArrayPtr firstDaySlotTable = iSlotTable[0]; |
|
1167 const CCalHourItem& itemInfo = *(*firstDaySlotTable)[aRow]; |
|
1168 if ( (! itemInfo.IsTimed()) && aRow == iListBox->BottomItemIndex()) |
|
1169 { |
|
1170 TTimeIntervalMinutes bottomTime = |
|
1171 KNonTimedNoteDefautDisplayTime * KCalenMinutesInHour; |
|
1172 TInt bottomIndex = FindRowForTime(bottomTime) - (items - 1); |
|
1173 if (bottomIndex > aRow) |
|
1174 { |
|
1175 iListBox->SetCurrentItemIndex(bottomIndex); |
|
1176 } |
|
1177 } |
|
1178 } |
|
1179 |
|
1180 TRACE_EXIT_POINT; |
|
1181 } |
|
1182 |
|
1183 // ---------------------------------------------------------------------------- |
|
1184 // CCalenWeekContainer::ClearOneDayEntryCache |
|
1185 // Clear entry of array for cash |
|
1186 // (other items were commented in a header). |
|
1187 // ---------------------------------------------------------------------------- |
|
1188 // |
|
1189 void CCalenWeekContainer::ClearOneDayEntryCache() |
|
1190 { |
|
1191 TRACE_ENTRY_POINT; |
|
1192 |
|
1193 iOneDayEntryCache.ResetAndDestroy(); |
|
1194 |
|
1195 TRACE_EXIT_POINT; |
|
1196 } |
|
1197 |
|
1198 // ---------------------------------------------------------------------------- |
|
1199 // CCalenWeekContainer::TopTime |
|
1200 // Gets time of top item in ListBox |
|
1201 // (other items were commented in a header). |
|
1202 // ---------------------------------------------------------------------------- |
|
1203 // |
|
1204 TTimeIntervalMinutes CCalenWeekContainer::TopTime() const |
|
1205 { |
|
1206 TRACE_ENTRY_POINT; |
|
1207 |
|
1208 CWeekSlotArrayPtr slotTable = iSlotTable[0]; |
|
1209 TInt index(iListBox->TopItemIndex()); |
|
1210 const CCalHourItem& item = *(*slotTable)[index]; |
|
1211 |
|
1212 TRACE_EXIT_POINT; |
|
1213 return item.iStartTime; |
|
1214 } |
|
1215 |
|
1216 // ---------------------------------------------------------------------------- |
|
1217 // CCalenWeekContainer::UpdateSize |
|
1218 // Do layout changes after calendar settings are |
|
1219 // changed. No necessary actions for this view. |
|
1220 // ---------------------------------------------------------------------------- |
|
1221 // |
|
1222 void CCalenWeekContainer::UpdateSize() |
|
1223 { |
|
1224 TRACE_ENTRY_POINT; |
|
1225 |
|
1226 SizeChanged(); |
|
1227 |
|
1228 TRACE_EXIT_POINT; |
|
1229 } |
|
1230 |
|
1231 // ---------------------------------------------------------------------------- |
|
1232 // CCalenWeekContainer::ConstructImplL |
|
1233 // Third phase constructor. |
|
1234 // (other items were commented in a header). |
|
1235 // ---------------------------------------------------------------------------- |
|
1236 // |
|
1237 void CCalenWeekContainer::ConstructImplL() |
|
1238 { |
|
1239 TRACE_ENTRY_POINT; |
|
1240 |
|
1241 TLocale locale; |
|
1242 // Create preview pane |
|
1243 TRect aRect = PreviewRectL(); |
|
1244 iPreview = iServices.CustomPreviewPaneL(aRect); |
|
1245 if (iPreview == NULL) |
|
1246 { |
|
1247 iPreview = CCalenPreview::NewL( iView, locale, iServices ); |
|
1248 iNativePreview = ETrue; |
|
1249 } |
|
1250 // ownership of builder transferred |
|
1251 |
|
1252 // 3) Listbox |
|
1253 iListBox = new (ELeave) CCalenWeekListbox( *this ); |
|
1254 // compile error argument is (CCoeControl*, TInt aFlag) |
|
1255 iListBox->ConstructL(this); |
|
1256 iListBox->SetBorder(TGulBorder::ENone); |
|
1257 iListBox->DisableScrolling(ETrue); |
|
1258 // Single click integration |
|
1259 iListBox->DisableSingleClick( ETrue ); |
|
1260 |
|
1261 |
|
1262 // 4) Listbox model |
|
1263 iDesArray = new(ELeave) CDesCArrayFlat(5); |
|
1264 |
|
1265 CTextListBoxModel* model = iListBox->Model(); |
|
1266 model->SetItemTextArray(iDesArray); |
|
1267 model->SetOwnershipType(ELbmDoesNotOwnItemArray); |
|
1268 |
|
1269 iListBox->HandleItemAdditionL(); |
|
1270 |
|
1271 |
|
1272 // 5) Icons |
|
1273 CArrayPtr<CGulIcon>* iconArray = iListBox->ItemDrawer()->FormattedCellData()->IconArray(); |
|
1274 if(iconArray) |
|
1275 { |
|
1276 iconArray->ResetAndDestroy(); |
|
1277 delete iconArray; // owned by CFormattedCellListBoxData |
|
1278 iconArray = NULL; // to suppress codescanner error |
|
1279 iListBox->ItemDrawer()->FormattedCellData()->SetIconArray(NULL); |
|
1280 } |
|
1281 |
|
1282 CArrayPtr<CGulIcon>* icons = CreateIconsL( iIconIndices ); |
|
1283 iListBox->ItemDrawer()->FormattedCellData()->SetIconArray(icons); |
|
1284 |
|
1285 iListBox->SetCursorObserver(this); |
|
1286 |
|
1287 // 6) Scroll bar |
|
1288 iListBox->CreateScrollBarFrameL(ETrue); |
|
1289 iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
1290 CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto); |
|
1291 |
|
1292 |
|
1293 // 7) Background skin contexts |
|
1294 PIM_TRAPD_HANDLE( CCalenWeekContainer::ConstructBackgroundContextL() ); |
|
1295 |
|
1296 iRow = EFalse; |
|
1297 iTopRowDefault = EFalse; |
|
1298 |
|
1299 TRACE_EXIT_POINT; |
|
1300 } |
|
1301 |
|
1302 void CCalenWeekContainer::ConstructBackgroundContextL() |
|
1303 { |
|
1304 TRACE_ENTRY_POINT; |
|
1305 |
|
1306 TRect dummy(0,0,0,0); |
|
1307 if( AknLayoutUtils::ScalableLayoutInterfaceAvailable() ) |
|
1308 { |
|
1309 iBackgroundSkinContext = CAknsFrameBackgroundControlContext::NewL( |
|
1310 KAknsIIDQsnFrCale, dummy, dummy, EFalse ); |
|
1311 iHeadingBgContext = CAknsFrameBackgroundControlContext::NewL( |
|
1312 KAknsIIDQsnFrCaleHeading, dummy, dummy, EFalse ); |
|
1313 iSideBgContext = CAknsFrameBackgroundControlContext::NewL( |
|
1314 KAknsIIDQsnFrCaleSide, dummy, dummy, EFalse ); |
|
1315 } |
|
1316 |
|
1317 TRACE_EXIT_POINT; |
|
1318 } |
|
1319 |
|
1320 // ---------------------------------------------------------------------------- |
|
1321 // CCalenWeekContainer::NotifyChangeDateL |
|
1322 // Date change operation notification handler. |
|
1323 // (other items were commented in a header). |
|
1324 // ---------------------------------------------------------------------------- |
|
1325 // |
|
1326 void CCalenWeekContainer::NotifyChangeDateL() |
|
1327 { |
|
1328 TRACE_ENTRY_POINT; |
|
1329 |
|
1330 SetCursorToActiveDayL(); |
|
1331 |
|
1332 TRACE_EXIT_POINT; |
|
1333 } |
|
1334 |
|
1335 // ---------------------------------------------------------------------------- |
|
1336 // CCalenWeekContainer::SizeChanged |
|
1337 // Resizes child controls |
|
1338 // (other items were commented in a header). |
|
1339 // ---------------------------------------------------------------------------- |
|
1340 // |
|
1341 void CCalenWeekContainer::SizeChanged() |
|
1342 { |
|
1343 TRACE_ENTRY_POINT; |
|
1344 |
|
1345 /* LAF doesn't specify week view listbox directly. |
|
1346 * Calculation of listbox rect is done inside listbox. |
|
1347 */ |
|
1348 CCalenContainer::SizeChanged( Rect() ); |
|
1349 |
|
1350 TRAP_IGNORE(iLayoutManager->GetLayoutAndExtensionL()); |
|
1351 |
|
1352 TRect main_pane = ReducePreview( Rect() ); |
|
1353 |
|
1354 TAknLayoutRect main_cale_week_pane; |
|
1355 main_cale_week_pane.LayoutRect( main_pane, AknLayoutScalable_Apps::main_cale_week_pane().LayoutLine() ); |
|
1356 |
|
1357 TWeekListBoxLayout layToolBar( UseInfobar(), UseToolbar(), UsePreview(), main_pane ); |
|
1358 TInt layoutToolBarVariant = layToolBar.LayoutVariantIndex(TWeekListBoxLayout::EListScrollCaleWeekPane); |
|
1359 // Cached layout value: |
|
1360 i_listscroll_cale_week_pane.LayoutRect( main_cale_week_pane.Rect(), |
|
1361 AknLayoutScalable_Apps::listscroll_cale_week_pane(layoutToolBarVariant).LayoutLine() ); |
|
1362 |
|
1363 |
|
1364 TWeekListBoxLayout lay( UseInfobar(), UseToolbar(), ETrue, main_pane ); |
|
1365 |
|
1366 iListBox->SetRect( iListBox->LayoutRect() ); |
|
1367 TInt layoutVariant = lay.LayoutVariantIndex(TWeekListBoxLayout::EScrollPaneCp08); |
|
1368 AknLayoutUtils::LayoutVerticalScrollBar( iListBox->ScrollBarFrame(), |
|
1369 i_listscroll_cale_week_pane.Rect(), |
|
1370 AknLayoutScalable_Apps::scroll_pane_cp08( layoutVariant ).LayoutLine() ); |
|
1371 |
|
1372 if( iBgContext && iHeadingBgContext && iSideBgContext ) |
|
1373 { |
|
1374 TAknLayoutRect bg_cale_pane_cp01; |
|
1375 layoutVariant = lay.LayoutVariantIndex(TWeekListBoxLayout::EBgCalePaneCp01); |
|
1376 bg_cale_pane_cp01.LayoutRect( i_listscroll_cale_week_pane.Rect(), AknLayoutScalable_Apps::bg_cale_pane_cp01( layoutVariant ).LayoutLine() ); |
|
1377 |
|
1378 TAknLayoutRect cale_bg_pane_center; |
|
1379 cale_bg_pane_center.LayoutRect( bg_cale_pane_cp01.Rect(), AknLayoutScalable_Apps::cale_bg_pane_g1().LayoutLine() ); |
|
1380 |
|
1381 iBackgroundSkinContext->SetFrameRects( bg_cale_pane_cp01.Rect(), cale_bg_pane_center.Rect() ); |
|
1382 |
|
1383 // Heading pane layout |
|
1384 TAknLayoutRect bg_cale_heading_pane; |
|
1385 layoutVariant = lay.LayoutVariantIndex(TWeekListBoxLayout::EBgCaleHeadingPane); |
|
1386 bg_cale_heading_pane.LayoutRect( i_listscroll_cale_week_pane.Rect(), AknLayoutScalable_Apps::bg_cale_heading_pane( layoutVariant ).LayoutLine() ); |
|
1387 |
|
1388 // center |
|
1389 TAknLayoutRect bg_cale_heading_pane_g1; |
|
1390 bg_cale_heading_pane_g1.LayoutRect( bg_cale_heading_pane.Rect(), AknLayoutScalable_Apps::bg_cale_heading_pane_g1().LayoutLine() ); |
|
1391 |
|
1392 iHeadingBgContext->SetFrameRects( bg_cale_heading_pane.Rect(), bg_cale_heading_pane_g1.Rect() ); |
|
1393 |
|
1394 // Side pane layout |
|
1395 TAknLayoutRect cale_week_time_pane; |
|
1396 layoutVariant = lay.LayoutVariantIndex(TWeekListBoxLayout::ECaleWeekTimePane); |
|
1397 cale_week_time_pane.LayoutRect( i_listscroll_cale_week_pane.Rect(), AknLayoutScalable_Apps::cale_week_time_pane( layoutVariant ).LayoutLine() ); |
|
1398 |
|
1399 TAknLayoutRect bg_cale_side_pane; |
|
1400 layoutVariant = lay.LayoutVariantIndex(TWeekListBoxLayout::EBgCaleSidePane); |
|
1401 bg_cale_side_pane.LayoutRect( cale_week_time_pane.Rect(), AknLayoutScalable_Apps::bg_cale_side_pane(layoutVariant).LayoutLine() ); |
|
1402 |
|
1403 // center |
|
1404 TAknLayoutRect bg_cale_side_pane_g1; |
|
1405 bg_cale_side_pane_g1.LayoutRect( bg_cale_side_pane.Rect(), AknLayoutScalable_Apps::bg_cale_side_pane_g1().LayoutLine() ); |
|
1406 |
|
1407 iSideBgContext->SetFrameRects( bg_cale_side_pane.Rect(), bg_cale_side_pane_g1.Rect() ); |
|
1408 |
|
1409 iBackgroundSkinContext->SetParentContext( iBgContext ); |
|
1410 iHeadingBgContext->SetParentContext( iBackgroundSkinContext ); |
|
1411 iSideBgContext->SetParentContext( iHeadingBgContext ); |
|
1412 } |
|
1413 |
|
1414 PIM_TRAPD_HANDLE( UpdateStatusPaneAndExtensionsL() ); |
|
1415 |
|
1416 TRACE_EXIT_POINT; |
|
1417 } |
|
1418 |
|
1419 // ---------------------------------------------------------------------------- |
|
1420 // CCalenWeekContainer::FocusChanged |
|
1421 // (other items were commented in a header). |
|
1422 // ---------------------------------------------------------------------------- |
|
1423 // |
|
1424 void CCalenWeekContainer::FocusChanged( TDrawNow aDrawNow ) |
|
1425 { |
|
1426 TRACE_ENTRY_POINT; |
|
1427 |
|
1428 CCalenContainer::FocusChanged( aDrawNow ); |
|
1429 if( iListBox ) |
|
1430 { |
|
1431 iListBox->SetFocus( IsFocused() ); |
|
1432 } |
|
1433 |
|
1434 TRACE_EXIT_POINT; |
|
1435 } |
|
1436 |
|
1437 // ---------------------------------------------------------------------------- |
|
1438 // CCalenWeekContainer::HandleResourceChange(TInt aType) |
|
1439 // Called when layout or skin change occurs |
|
1440 // (other items were commented in a header). |
|
1441 // ---------------------------------------------------------------------------- |
|
1442 // |
|
1443 void CCalenWeekContainer::HandleResourceChange(TInt aType) |
|
1444 { |
|
1445 TRACE_ENTRY_POINT; |
|
1446 |
|
1447 CCalenContainer::HandleResourceChange( aType ); |
|
1448 |
|
1449 if ( aType == KAknsMessageSkinChange || aType == KEikDynamicLayoutVariantSwitch ) |
|
1450 { |
|
1451 CArrayPtr<CGulIcon>* iconArray = iListBox->ItemDrawer()->FormattedCellData()->IconArray(); |
|
1452 if(iconArray) |
|
1453 { |
|
1454 iconArray->ResetAndDestroy(); |
|
1455 delete iconArray; // owned by CFormattedCellListBoxData |
|
1456 iconArray = NULL; // to suppress codescanner error |
|
1457 iListBox->ItemDrawer()->FormattedCellData()->SetIconArray(NULL); |
|
1458 } |
|
1459 |
|
1460 TRAPD(leave, iconArray = CreateIconsL( iIconIndices ) ); |
|
1461 if(!leave && iconArray) |
|
1462 { |
|
1463 iListBox->ItemDrawer()->FormattedCellData()->SetIconArray(iconArray); |
|
1464 } |
|
1465 |
|
1466 SizeChanged(); |
|
1467 |
|
1468 // if layout change and res.change is allowed do the refresh |
|
1469 if ( aType == KEikDynamicLayoutVariantSwitch ) |
|
1470 { |
|
1471 iLayoutManager->HandleResourceChange( aType ); |
|
1472 TRAP_IGNORE(iView->BeginRepopulationL()); |
|
1473 } |
|
1474 } |
|
1475 |
|
1476 CCoeControl::HandleResourceChange( aType ); |
|
1477 |
|
1478 TRACE_EXIT_POINT; |
|
1479 } |
|
1480 |
|
1481 // ---------------------------------------------------------------------------- |
|
1482 // CCalenWeekContainer::CountComponentControls |
|
1483 // Return components count |
|
1484 // (other items were commented in a header). |
|
1485 // ---------------------------------------------------------------------------- |
|
1486 // |
|
1487 TInt CCalenWeekContainer::CountComponentControls() const |
|
1488 { |
|
1489 TRACE_ENTRY_POINT; |
|
1490 TInt controlCount; |
|
1491 |
|
1492 if ( iLayoutManager->ControlOrNull() ) |
|
1493 { |
|
1494 controlCount = 2; |
|
1495 } |
|
1496 else |
|
1497 { |
|
1498 controlCount = 1; |
|
1499 } |
|
1500 TRACE_EXIT_POINT; |
|
1501 return controlCount; |
|
1502 } |
|
1503 |
|
1504 // ---------------------------------------------------------------------------- |
|
1505 // CCalenWeekContainer::ComponentControl |
|
1506 // Retrun the component specified by aIndex |
|
1507 // (other items were commented in a header). |
|
1508 // ---------------------------------------------------------------------------- |
|
1509 // |
|
1510 CCoeControl* CCalenWeekContainer::ComponentControl |
|
1511 (TInt aIndex) const |
|
1512 { |
|
1513 TRACE_ENTRY_POINT; |
|
1514 |
|
1515 CCoeControl* control( NULL ); |
|
1516 |
|
1517 switch (aIndex) |
|
1518 { |
|
1519 case 0: |
|
1520 control = iListBox; |
|
1521 break; |
|
1522 |
|
1523 case 1: |
|
1524 control = iLayoutManager->ControlOrNull(); |
|
1525 break; |
|
1526 |
|
1527 default: |
|
1528 __ASSERT_DEBUG( 0, User::Invariant() ); |
|
1529 break; |
|
1530 } |
|
1531 |
|
1532 TRACE_EXIT_POINT; |
|
1533 return control; |
|
1534 } |
|
1535 |
|
1536 // ---------------------------------------------------------------------------- |
|
1537 // CCalenWeekContainer::OfferKeyEventL |
|
1538 // processing of a key event |
|
1539 // (other items were commented in a header). |
|
1540 // ---------------------------------------------------------------------------- |
|
1541 // |
|
1542 TKeyResponse CCalenWeekContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
1543 TEventCode aType ) |
|
1544 { |
|
1545 TRACE_ENTRY_POINT; |
|
1546 |
|
1547 // always hide popup on key events |
|
1548 if (aType == EEventKeyDown) |
|
1549 { |
|
1550 iPreview->Hide(); |
|
1551 } |
|
1552 |
|
1553 // common view key handling. |
|
1554 // NOTE! Common key handling has to be performed before custom handling |
|
1555 // otherwise view-cycling state handling breaks. |
|
1556 if (CCalenContainer::OfferKeyEventL(aKeyEvent, aType) == EKeyWasConsumed) |
|
1557 { |
|
1558 return EKeyWasConsumed; |
|
1559 } |
|
1560 |
|
1561 // month view specific key handling |
|
1562 TKeyResponse exitCode(EKeyWasNotConsumed); |
|
1563 if (aType == EEventKey) |
|
1564 { |
|
1565 switch (aKeyEvent.iCode) |
|
1566 { |
|
1567 case EKeyOK: |
|
1568 iServices.IssueCommandL( ECalenForwardsToDayView ); |
|
1569 exitCode = EKeyWasConsumed; |
|
1570 break; |
|
1571 case EKeyEnter: |
|
1572 iView->HandleCommandL(EAknSoftkeyOpen); |
|
1573 exitCode = EKeyWasConsumed; |
|
1574 break; |
|
1575 default: |
|
1576 break; |
|
1577 } |
|
1578 } |
|
1579 |
|
1580 // listbox key handling |
|
1581 if ( exitCode == EKeyWasConsumed || !iListBox || !iViewPopulationComplete ) |
|
1582 { // if DoDeactivate() is done, iListBox will be NULL. |
|
1583 // do nothing |
|
1584 } |
|
1585 else |
|
1586 { |
|
1587 TInt oldRow(iListBox->View()->CurrentItemIndex()); |
|
1588 TInt oldColumn(iColumn); |
|
1589 exitCode = iListBox->OfferKeyEventL(aKeyEvent, aType); |
|
1590 |
|
1591 if (exitCode == EKeyWasConsumed) |
|
1592 { |
|
1593 TInt newRow(iListBox->View()->CurrentItemIndex()); |
|
1594 TInt newColumn(iColumn); |
|
1595 if (newRow != oldRow || newColumn != oldColumn) |
|
1596 { |
|
1597 iFirstRowTime = TopTime(); |
|
1598 CalcDayFromColumn(); |
|
1599 SetActiveContextFromHighlightL(); |
|
1600 if (newColumn != oldColumn) |
|
1601 { |
|
1602 UpdateStatusPaneAndExtensionsL(); |
|
1603 } |
|
1604 } |
|
1605 } |
|
1606 } |
|
1607 |
|
1608 TRACE_EXIT_POINT; |
|
1609 return exitCode; |
|
1610 } |
|
1611 |
|
1612 // ---------------------------------------------------------------------------- |
|
1613 // CCalenWeekContainer::GetHelpContext |
|
1614 // Gets help context |
|
1615 // (other items were commented in a header). |
|
1616 // ---------------------------------------------------------------------------- |
|
1617 // |
|
1618 void CCalenWeekContainer::GetHelpContext( TCoeHelpContext& aContext ) const |
|
1619 { |
|
1620 TRACE_ENTRY_POINT; |
|
1621 |
|
1622 aContext.iMajor = KUidCalendar; |
|
1623 // This is specified in HRH file. |
|
1624 aContext.iContext = KCALE_HLP_WEEK_VIEW; |
|
1625 |
|
1626 TRACE_EXIT_POINT; |
|
1627 } |
|
1628 |
|
1629 // ---------------------------------------------------------------------------- |
|
1630 // ?classname::?member_function |
|
1631 // ?implementation_description |
|
1632 // (other items were commented in a header). |
|
1633 // ---------------------------------------------------------------------------- |
|
1634 // |
|
1635 TKeyResponse CCalenWeekContainer::CursorMovedL(MCalenWeekCursorObserver::TCursorMove aDir) |
|
1636 { |
|
1637 TRACE_ENTRY_POINT; |
|
1638 |
|
1639 TKeyResponse consumed(EKeyWasNotConsumed); |
|
1640 if (aDir == MCalenWeekCursorObserver::ECalenLeft) |
|
1641 { |
|
1642 consumed = HorizontalMoveL(-1); |
|
1643 } |
|
1644 else if (aDir == MCalenWeekCursorObserver::ECalenRight) |
|
1645 { |
|
1646 consumed = HorizontalMoveL(+1); |
|
1647 } |
|
1648 else |
|
1649 { |
|
1650 // up or down |
|
1651 iSelectedRowNumber = iListBox->View()->CurrentItemIndex(); |
|
1652 } |
|
1653 |
|
1654 TRACE_EXIT_POINT; |
|
1655 return consumed; |
|
1656 } |
|
1657 |
|
1658 // ---------------------------------------------------------------------------- |
|
1659 // ?classname::?member_function |
|
1660 // ?implementation_description |
|
1661 // (other items were commented in a header). |
|
1662 // ---------------------------------------------------------------------------- |
|
1663 // |
|
1664 TKeyResponse CCalenWeekContainer::HorizontalMoveL(TInt aDir) |
|
1665 { |
|
1666 TRACE_ENTRY_POINT; |
|
1667 |
|
1668 CCalenWeekLBView* view = |
|
1669 static_cast<CCalenWeekLBView*>( iListBox->View() ); |
|
1670 |
|
1671 TTime newDay = iTime + TTimeIntervalDays( aDir ); |
|
1672 |
|
1673 if (CalenDateUtils::IsValidDay(newDay)) |
|
1674 { |
|
1675 TInt newColumn = iColumn + aDir; |
|
1676 if (newColumn < 0 || KCalenDaysInWeek <= newColumn) // went over left or right border |
|
1677 { |
|
1678 if( newColumn < 0 ) |
|
1679 { |
|
1680 iColumn = KCalenDaysInWeek - 1; |
|
1681 } |
|
1682 else |
|
1683 { |
|
1684 iColumn = 0; |
|
1685 } |
|
1686 |
|
1687 view->SetColumn(iColumn); |
|
1688 iTime = newDay; |
|
1689 iStartDay = iTime - TTimeIntervalDays( iColumn ); |
|
1690 iSelectedRowNumber = KErrNotFound; // Recalculate when repopulation occurs |
|
1691 |
|
1692 // Refresh listbox |
|
1693 iView->BeginRepopulationL(); |
|
1694 iListBox->View()->SetDisableRedraw(ETrue); |
|
1695 |
|
1696 TRACE_EXIT_POINT; |
|
1697 return EKeyWasConsumed; |
|
1698 } |
|
1699 else if ( iViewPopulationComplete ) |
|
1700 { |
|
1701 // Actual processing is performed by the List box side. |
|
1702 iColumn += aDir; |
|
1703 |
|
1704 TRACE_EXIT_POINT; |
|
1705 return EKeyWasNotConsumed; |
|
1706 } |
|
1707 else |
|
1708 { |
|
1709 TRACE_EXIT_POINT; |
|
1710 return EKeyWasNotConsumed; |
|
1711 } |
|
1712 } |
|
1713 else |
|
1714 { |
|
1715 view->SetColumn(iColumn); |
|
1716 CalenViewUtils::ShowDateOutOfRangeErrorNoteL(); |
|
1717 |
|
1718 TRACE_EXIT_POINT; |
|
1719 return EKeyWasConsumed; |
|
1720 } |
|
1721 } |
|
1722 |
|
1723 // ---------------------------------------------------------------------------- |
|
1724 // CCalenWeekContainer::MopSupplyObject() |
|
1725 // Pass skin information if needed. |
|
1726 // ---------------------------------------------------------------------------- |
|
1727 // |
|
1728 TTypeUid::Ptr CCalenWeekContainer::MopSupplyObject(TTypeUid aId) |
|
1729 { |
|
1730 TRACE_ENTRY_POINT; |
|
1731 |
|
1732 if( aId.iUid == MAknsControlContext::ETypeId ) |
|
1733 { |
|
1734 MAknsControlContext* cc = iSideBgContext; |
|
1735 |
|
1736 if( !cc ) |
|
1737 { |
|
1738 cc = iBgContext; |
|
1739 } |
|
1740 if ( cc ) |
|
1741 { |
|
1742 TRACE_EXIT_POINT; |
|
1743 return MAknsControlContext::SupplyMopObject( aId, cc ); |
|
1744 } |
|
1745 } |
|
1746 |
|
1747 TRACE_EXIT_POINT; |
|
1748 return CCoeControl::MopSupplyObject( aId ); |
|
1749 } |
|
1750 |
|
1751 // ---------------------------------------------------------------------------- |
|
1752 // ?classname::?member_function |
|
1753 // ?implementation_description |
|
1754 // (other items were commented in a header). |
|
1755 // ---------------------------------------------------------------------------- |
|
1756 // |
|
1757 void CCalenWeekContainer::FocusChangeForPopupL() |
|
1758 { |
|
1759 TRACE_ENTRY_POINT; |
|
1760 |
|
1761 if( iViewPopulationComplete ) |
|
1762 { |
|
1763 CalcDayFromColumn(); |
|
1764 |
|
1765 CWeekSlotArrayPtr slotTable = iSlotTable[iColumn]; |
|
1766 CCalHourItem& itemInfo = *(*slotTable)[iListBox->CurrentItemIndex()]; |
|
1767 |
|
1768 // dont focus the preview popup/previewpane if any dialog or faster app is active |
|
1769 if(!iView->IsEditorActiveOrFasterAppExit()) |
|
1770 { |
|
1771 if( !itemInfo.IsTimed() ) |
|
1772 { |
|
1773 // Non-timed cell |
|
1774 iPreview->FocusChangedL(itemInfo.iInstance); |
|
1775 } |
|
1776 else |
|
1777 { |
|
1778 TDateTime dt = iTime.DateTime(); // TACOTEMP |
|
1779 iPreview->FocusChangedL( iServices.Context().FocusDateAndTimeL().TimeLocalL() ); |
|
1780 } |
|
1781 } |
|
1782 } |
|
1783 else |
|
1784 { |
|
1785 HidePopup(); |
|
1786 } |
|
1787 |
|
1788 TRACE_EXIT_POINT; |
|
1789 } |
|
1790 |
|
1791 // ---------------------------------------------------------------------------- |
|
1792 // CCalenWeekContainer::Draw |
|
1793 // Draws most of the main pane dependend parts of week view |
|
1794 // - skinned or normal background |
|
1795 // - Day names |
|
1796 // - grid lines |
|
1797 // - line between day names and grid |
|
1798 // - line between hours and grid (which is drawn also inside |
|
1799 // list, to make scrolling work) |
|
1800 // (other items were commented in a header). |
|
1801 // ---------------------------------------------------------------------------- |
|
1802 // |
|
1803 void CCalenWeekContainer::Draw(const TRect& /*aRect*/) const |
|
1804 { |
|
1805 TRACE_ENTRY_POINT; |
|
1806 |
|
1807 CWindowGc& gc = SystemGc(); |
|
1808 |
|
1809 DrawBackground(gc); |
|
1810 TRAPD(error,DrawDayNamesL(gc)); |
|
1811 if(error!=KErrNone) |
|
1812 { |
|
1813 // to avoid warning |
|
1814 } |
|
1815 DrawGridLines(gc); |
|
1816 |
|
1817 TRACE_EXIT_POINT; |
|
1818 } |
|
1819 |
|
1820 // ---------------------------------------------------------------------------- |
|
1821 // CCalenWeekListbox::DrawDayNames |
|
1822 // Draw day names |
|
1823 // (other items were commented in a header). |
|
1824 // ---------------------------------------------------------------------------- |
|
1825 // |
|
1826 void CCalenWeekContainer::DrawDayNamesL(CWindowGc& aGc) const // Window graphic context |
|
1827 { |
|
1828 TRACE_ENTRY_POINT; |
|
1829 |
|
1830 // No need to clear background in this function, because this is |
|
1831 // called only from Draw. |
|
1832 // If popup needs to call this from DrawDayNamesNow, clearing |
|
1833 // should be done there. |
|
1834 TRect mainPane = ReducePreview( Rect() ); |
|
1835 TWeekListBoxLayout lay( UseInfobar(), UseToolbar(), UsePreview(), mainPane ); |
|
1836 TInt layoutVariant = lay.LayoutVariantIndex(TWeekListBoxLayout::ECaleWeekDayHeadingPane); |
|
1837 TAknLayoutRect cale_week_day_heading_pane; |
|
1838 cale_week_day_heading_pane.LayoutRect( i_listscroll_cale_week_pane.Rect(), |
|
1839 AknLayoutScalable_Apps::cale_week_day_heading_pane( layoutVariant ).LayoutLine() ); |
|
1840 |
|
1841 TRect dayHeadingRect = cale_week_day_heading_pane.Rect(); |
|
1842 TAknLayoutText dayHeadingLayouts[ KCalenDaysInWeek ]; |
|
1843 layoutVariant = lay.LayoutVariantIndex(TWeekListBoxLayout::ECaleWeekDayHeadingPaneT1); |
|
1844 dayHeadingLayouts[0].LayoutText( dayHeadingRect, AknLayoutScalable_Apps::cale_week_day_heading_pane_t1(layoutVariant).LayoutLine() ); |
|
1845 dayHeadingLayouts[1].LayoutText( dayHeadingRect, AknLayoutScalable_Apps::cale_week_day_heading_pane_t2(layoutVariant).LayoutLine() ); |
|
1846 dayHeadingLayouts[2].LayoutText( dayHeadingRect, AknLayoutScalable_Apps::cale_week_day_heading_pane_t3(layoutVariant).LayoutLine() ); |
|
1847 dayHeadingLayouts[3].LayoutText( dayHeadingRect, AknLayoutScalable_Apps::cale_week_day_heading_pane_t4(layoutVariant).LayoutLine() ); |
|
1848 dayHeadingLayouts[4].LayoutText( dayHeadingRect, AknLayoutScalable_Apps::cale_week_day_heading_pane_t5(layoutVariant).LayoutLine() ); |
|
1849 dayHeadingLayouts[5].LayoutText( dayHeadingRect, AknLayoutScalable_Apps::cale_week_day_heading_pane_t6(layoutVariant).LayoutLine() ); |
|
1850 dayHeadingLayouts[6].LayoutText( dayHeadingRect, AknLayoutScalable_Apps::cale_week_day_heading_pane_t7(layoutVariant).LayoutLine() ); |
|
1851 |
|
1852 // Get drawing color |
|
1853 TRgb textColor = dayHeadingLayouts[0].Color(); |
|
1854 AknsUtils::GetCachedColor(AknsUtils::SkinInstance(), textColor, |
|
1855 KAknsIIDQsnTextColors, |
|
1856 EAknsCIQsnTextColorsCG23); |
|
1857 |
|
1858 TTime date( iStartDay ); |
|
1859 TLocale locale; |
|
1860 |
|
1861 for (TInt i=0; i < KCalenDaysInWeek; ++i) |
|
1862 { |
|
1863 TBool isToday = CalenDateUtils::OnSameDay( CalenDateUtils::Today(), date ); |
|
1864 aGc.SetUnderlineStyle( isToday ? EUnderlineOn : EUnderlineOff ); |
|
1865 TInt dayNoInWeek( i + locale.StartOfWeek() ); |
|
1866 if( dayNoInWeek >= KCalenDaysInWeek ) |
|
1867 { |
|
1868 dayNoInWeek -= KCalenDaysInWeek; |
|
1869 } |
|
1870 dayHeadingLayouts[ i ].DrawText( aGc, |
|
1871 WeekView().AbbreviatedDayArrayL()[dayNoInWeek], |
|
1872 ETrue, |
|
1873 textColor); |
|
1874 date += TTimeIntervalDays( 1 ); |
|
1875 } |
|
1876 |
|
1877 TRACE_EXIT_POINT; |
|
1878 } |
|
1879 |
|
1880 CCalenWeekView& CCalenWeekContainer::WeekView() const |
|
1881 { |
|
1882 TRACE_ENTRY_POINT; |
|
1883 |
|
1884 TRACE_EXIT_POINT; |
|
1885 return *(static_cast<CCalenWeekView*>(iView)); |
|
1886 } |
|
1887 |
|
1888 // ---------------- class CCHourItem ------------------------ // |
|
1889 |
|
1890 // ---------------------------------------------------------------------------- |
|
1891 // ?classname::?member_function |
|
1892 // ?implementation_description |
|
1893 // (other items were commented in a header). |
|
1894 // ---------------------------------------------------------------------------- |
|
1895 // |
|
1896 CCalHourItem::CCalHourItem() |
|
1897 { |
|
1898 TRACE_ENTRY_POINT; |
|
1899 |
|
1900 iStartTime = TTimeIntervalMinutes( KNullMinutes ); |
|
1901 iInstance = NULL; |
|
1902 iTimedNote = EFalse; |
|
1903 |
|
1904 TRACE_EXIT_POINT; |
|
1905 } |
|
1906 |
|
1907 // ---------------------------------------------------------------------------- |
|
1908 // ?classname::?member_function |
|
1909 // ?implementation_description |
|
1910 // (other items were commented in a header). |
|
1911 // ---------------------------------------------------------------------------- |
|
1912 // |
|
1913 CCalHourItem::~CCalHourItem() |
|
1914 { |
|
1915 TRACE_ENTRY_POINT; |
|
1916 |
|
1917 // not owned |
|
1918 // delete iInstance; |
|
1919 iInstance = NULL; |
|
1920 |
|
1921 TRACE_EXIT_POINT; |
|
1922 } |
|
1923 |
|
1924 // ---------------------------------------------------------------------------- |
|
1925 // ?classname::?member_function |
|
1926 // ?implementation_description |
|
1927 // (other items were commented in a header). |
|
1928 // ---------------------------------------------------------------------------- |
|
1929 // |
|
1930 void CCalHourItem::ConstructL() |
|
1931 { |
|
1932 TRACE_ENTRY_POINT; |
|
1933 TRACE_EXIT_POINT; |
|
1934 } |
|
1935 |
|
1936 // ---------------------------------------------------------------------------- |
|
1937 // ?classname::?member_function |
|
1938 // ?implementation_description |
|
1939 // (other items were commented in a header). |
|
1940 // ---------------------------------------------------------------------------- |
|
1941 // |
|
1942 void CCalHourItem::ConstructL(CCalInstance& aInstance) |
|
1943 { |
|
1944 TRACE_ENTRY_POINT; |
|
1945 |
|
1946 iInstance = &aInstance; |
|
1947 |
|
1948 TRACE_EXIT_POINT; |
|
1949 } |
|
1950 |
|
1951 // ---------------------------------------------------------------------------- |
|
1952 // ?classname::?member_function |
|
1953 // ?implementation_description |
|
1954 // (other items were commented in a header). |
|
1955 // ---------------------------------------------------------------------------- |
|
1956 // |
|
1957 CCalHourItem* CCalHourItem::NewL() |
|
1958 { |
|
1959 TRACE_ENTRY_POINT; |
|
1960 |
|
1961 CCalHourItem* self=new (ELeave) CCalHourItem(); |
|
1962 CleanupStack::PushL(self); |
|
1963 self->ConstructL(); |
|
1964 CleanupStack::Pop( self ); |
|
1965 |
|
1966 TRACE_EXIT_POINT; |
|
1967 return self; |
|
1968 } |
|
1969 |
|
1970 // ---------------------------------------------------------------------------- |
|
1971 // ?classname::?member_function |
|
1972 // ?implementation_description |
|
1973 // (other items were commented in a header). |
|
1974 // ---------------------------------------------------------------------------- |
|
1975 // |
|
1976 CCalHourItem* CCalHourItem::NewL(CCalInstance& aInstance) |
|
1977 { |
|
1978 TRACE_ENTRY_POINT; |
|
1979 |
|
1980 CCalHourItem* self=new (ELeave) CCalHourItem(); |
|
1981 CleanupStack::PushL(self); |
|
1982 self->ConstructL(aInstance); |
|
1983 CleanupStack::Pop(self); |
|
1984 |
|
1985 TRACE_EXIT_POINT; |
|
1986 return self; |
|
1987 } |
|
1988 |
|
1989 // ---------------------------------------------------------------------------- |
|
1990 // ?classname::?member_function |
|
1991 // ?implementation_description |
|
1992 // (other items were commented in a header). |
|
1993 // ---------------------------------------------------------------------------- |
|
1994 // |
|
1995 void CCalHourItem::SetDataL( CCalInstance& aInstance, |
|
1996 TTimeIntervalMinutes aStartTime, |
|
1997 TBool aTimedNote, |
|
1998 TCalenWeekHour aHourData ) |
|
1999 { |
|
2000 TRACE_ENTRY_POINT; |
|
2001 |
|
2002 ConstructL( aInstance ); |
|
2003 iStartTime = aStartTime; |
|
2004 iTimedNote = aTimedNote; |
|
2005 iHourData = aHourData; |
|
2006 |
|
2007 TRACE_EXIT_POINT; |
|
2008 } |
|
2009 |
|
2010 |
|
2011 TBool CCalHourItem::HasInstance() const |
|
2012 { |
|
2013 TRACE_ENTRY_POINT; |
|
2014 |
|
2015 TRACE_EXIT_POINT; |
|
2016 return iInstance != NULL; |
|
2017 } |
|
2018 |
|
2019 |
|
2020 TBool CCalHourItem::IsTimed() const |
|
2021 { |
|
2022 TRACE_ENTRY_POINT; |
|
2023 |
|
2024 TRACE_EXIT_POINT; |
|
2025 return iTimedNote; |
|
2026 } |
|
2027 |
|
2028 |
|
2029 // ---------------------------------------------------------------------------- |
|
2030 // CCalenWeekContainer::HorizontalWeekMoveL |
|
2031 // processing of a week move (from touch ui navi decoration) |
|
2032 // (other items were commented in a header). |
|
2033 // ---------------------------------------------------------------------------- |
|
2034 // |
|
2035 void CCalenWeekContainer::HorizontalWeekMoveL(TInt aDir) |
|
2036 { |
|
2037 TRACE_ENTRY_POINT; |
|
2038 |
|
2039 if(AknLayoutUtils::PenEnabled()) |
|
2040 { |
|
2041 __ASSERT_ALWAYS( (aDir == 1 || aDir == -1), User::Invariant()); |
|
2042 CCalenWeekLBView* view = |
|
2043 static_cast<CCalenWeekLBView*>( iListBox->View() ); |
|
2044 |
|
2045 TTime newDay = iTime + TTimeIntervalDays( aDir*KCalenDaysInWeek ); |
|
2046 |
|
2047 if ( CalenDateUtils::IsValidDay( newDay ) ) |
|
2048 { |
|
2049 iTime = newDay; |
|
2050 iStartDay = iTime - TTimeIntervalDays(iColumn); |
|
2051 // Refresh listbox |
|
2052 iListBox->View()->SetDisableRedraw(ETrue); |
|
2053 } |
|
2054 else |
|
2055 { |
|
2056 view->SetColumn(iColumn); |
|
2057 CalenViewUtils::ShowDateOutOfRangeErrorNoteL(); |
|
2058 } |
|
2059 } |
|
2060 |
|
2061 TRACE_EXIT_POINT; |
|
2062 } |
|
2063 |
|
2064 // ---------------------------------------------------------------------------- |
|
2065 // CCalenWeekContainer::HandleNaviDecorationPointerEventL |
|
2066 // processing of a navi decoration event |
|
2067 // (other items were commented in a header). |
|
2068 // ---------------------------------------------------------------------------- |
|
2069 // |
|
2070 void CCalenWeekContainer::HandleNaviDecoratorEventL(TInt aEventID) |
|
2071 { |
|
2072 TRACE_ENTRY_POINT; |
|
2073 |
|
2074 if(AknLayoutUtils::PenEnabled()) |
|
2075 { |
|
2076 TInt direction(0); |
|
2077 if(aEventID == EAknNaviDecoratorEventLeftTabArrow) |
|
2078 { |
|
2079 if(AknLayoutUtils::LayoutMirrored()) |
|
2080 { |
|
2081 direction = 1; |
|
2082 } |
|
2083 else |
|
2084 { |
|
2085 direction = -1; |
|
2086 } |
|
2087 } |
|
2088 |
|
2089 else if(aEventID == EAknNaviDecoratorEventRightTabArrow) |
|
2090 { |
|
2091 if(AknLayoutUtils::LayoutMirrored()) |
|
2092 { |
|
2093 direction = -1; |
|
2094 } |
|
2095 else |
|
2096 { |
|
2097 direction = 1; |
|
2098 } |
|
2099 } |
|
2100 else |
|
2101 return; |
|
2102 HorizontalWeekMoveL(direction); |
|
2103 SetActiveContextFromHighlightL(); |
|
2104 WeekView().SetStatusPaneFromActiveContextL(); |
|
2105 iView->BeginRepopulationL(); |
|
2106 } |
|
2107 |
|
2108 TRACE_EXIT_POINT; |
|
2109 } |
|
2110 |
|
2111 // ---------------------------------------------------------------------------- |
|
2112 // CCalenWeekContainer::PointerMovedL |
|
2113 // processing of a move to new column (from touch ui) |
|
2114 // (other items were commented in a header). |
|
2115 // ---------------------------------------------------------------------------- |
|
2116 // |
|
2117 void CCalenWeekContainer::PointerMovedL(TInt aNewColumn) |
|
2118 { |
|
2119 TRACE_ENTRY_POINT; |
|
2120 |
|
2121 if(AknLayoutUtils::PenEnabled()) |
|
2122 { |
|
2123 CCalenWeekLBView* view = |
|
2124 static_cast<CCalenWeekLBView*>( iListBox->View() ); |
|
2125 TInt indexDiff = aNewColumn-iColumn; |
|
2126 TTime newDay = iTime + TTimeIntervalDays(indexDiff); |
|
2127 if (!CalenDateUtils::IsValidDay(newDay)) |
|
2128 { |
|
2129 iValidDay=ETrue; |
|
2130 view->SetColumn(iColumn); |
|
2131 CalenViewUtils::ShowDateOutOfRangeErrorNoteL(); |
|
2132 return ; |
|
2133 } |
|
2134 else |
|
2135 { |
|
2136 iValidDay=EFalse; |
|
2137 view->PointerMoveToItemL(aNewColumn); |
|
2138 iColumn = aNewColumn; |
|
2139 } |
|
2140 } |
|
2141 |
|
2142 TRACE_EXIT_POINT; |
|
2143 } |
|
2144 |
|
2145 // ---------------------------------------------------------------------------- |
|
2146 // CCalenMonthContainer::HandleLongTapEventL |
|
2147 // processing of a long tap event |
|
2148 // (other items were commented in a header). |
|
2149 // ---------------------------------------------------------------------------- |
|
2150 // |
|
2151 void CCalenWeekContainer::HandleLongTapEventL( const TPoint& /*aPenEventLocation*/, |
|
2152 const TPoint& /*aPenEventScreenLocation*/ ) |
|
2153 { |
|
2154 TRACE_ENTRY_POINT; |
|
2155 |
|
2156 |
|
2157 TRACE_EXIT_POINT; |
|
2158 } |
|
2159 |
|
2160 // ---------------------------------------------------------------------------- |
|
2161 // CCalenWeekContainer::HandlePointerEventL |
|
2162 // processing of a navi decoration event |
|
2163 // (other items were commented in a header). |
|
2164 // ---------------------------------------------------------------------------- |
|
2165 // |
|
2166 void CCalenWeekContainer::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
2167 { |
|
2168 TRACE_ENTRY_POINT; |
|
2169 |
|
2170 if(AknLayoutUtils::PenEnabled()) |
|
2171 { |
|
2172 TInt pointerIndex(-1); |
|
2173 TInt oldRow(0); |
|
2174 TInt oldColumn(0); |
|
2175 TInt newRow(0); |
|
2176 TInt newColumn(0); |
|
2177 |
|
2178 TBool isItem (iListBox->View()->XYPosToItemIndex(aPointerEvent.iPosition, |
|
2179 pointerIndex)); |
|
2180 |
|
2181 if( !iListBox->IsValidPointer(aPointerEvent.iPosition) && |
|
2182 aPointerEvent.iType == TPointerEvent::EButton1Down ) |
|
2183 { |
|
2184 IgnoreEventsUntilNextPointerUp(); |
|
2185 return; |
|
2186 } |
|
2187 |
|
2188 switch(aPointerEvent.iType) |
|
2189 { |
|
2190 case TPointerEvent::EButton1Down: |
|
2191 { |
|
2192 if(isItem) |
|
2193 { |
|
2194 oldRow = iListBox->View()->CurrentItemIndex(); |
|
2195 oldColumn = iColumn; |
|
2196 iListBox->HandlePointerEventL(aPointerEvent); |
|
2197 newRow = iListBox->View()->CurrentItemIndex(); |
|
2198 newColumn = iColumn; |
|
2199 if (newRow != oldRow || newColumn != oldColumn) |
|
2200 { |
|
2201 CalcDayFromColumn(); |
|
2202 SetActiveContextFromHighlightL(); |
|
2203 if (newColumn != oldColumn) |
|
2204 { |
|
2205 UpdateStatusPaneAndExtensionsL(); |
|
2206 } |
|
2207 iFirstTap = ETrue; |
|
2208 } |
|
2209 else |
|
2210 iFirstTap = EFalse; |
|
2211 } |
|
2212 else |
|
2213 { |
|
2214 IgnoreEventsUntilNextPointerUp(); |
|
2215 } |
|
2216 break; |
|
2217 } |
|
2218 case TPointerEvent::EButtonRepeat: |
|
2219 { |
|
2220 if(isItem) |
|
2221 break; |
|
2222 } // else this is drag event |
|
2223 case TPointerEvent::EDrag: |
|
2224 { |
|
2225 // for themable support - clear Pressed Down State when dragging |
|
2226 oldRow = iListBox->View()->CurrentItemIndex(); |
|
2227 oldColumn = iColumn; |
|
2228 iListBox->HandlePointerEventL(aPointerEvent); |
|
2229 newRow = iListBox->View()->CurrentItemIndex(); |
|
2230 newColumn = iColumn; |
|
2231 if (newRow != oldRow || newColumn != oldColumn) |
|
2232 { |
|
2233 CalcDayFromColumn(); |
|
2234 SetActiveContextFromHighlightL(); |
|
2235 if (newColumn != oldColumn) |
|
2236 { |
|
2237 WeekView().SetStatusPaneFromActiveContextL(); |
|
2238 } |
|
2239 iFirstTap = ETrue; |
|
2240 } |
|
2241 break; |
|
2242 } |
|
2243 case TPointerEvent::EButton1Up: |
|
2244 if(isItem && iFirstTap == EFalse && |
|
2245 iView->MenuBar()->IsDisplayed() == EFalse) |
|
2246 { |
|
2247 iServices.IssueCommandL( ECalenForwardsToDayView ); |
|
2248 } |
|
2249 break; |
|
2250 default: |
|
2251 break; |
|
2252 } |
|
2253 } |
|
2254 |
|
2255 |
|
2256 TRACE_EXIT_POINT; |
|
2257 } |
|
2258 |
|
2259 |
|
2260 |
|
2261 // ---------------------------------------------------------------------------- |
|
2262 // CCalenWeekContainer::HidePopup |
|
2263 // Hides the popup window |
|
2264 // (other items were commented in a header). |
|
2265 // ---------------------------------------------------------------------------- |
|
2266 // |
|
2267 void CCalenWeekContainer::HidePopup() |
|
2268 { |
|
2269 TRACE_ENTRY_POINT; |
|
2270 |
|
2271 iPreview->Hide(); |
|
2272 |
|
2273 TRACE_EXIT_POINT; |
|
2274 } |
|
2275 |
|
2276 // ---------------------------------------------------------------------------- |
|
2277 // CCalenWeekContainer::BeginPopulationWithInstanceViewL |
|
2278 // Beings populating the view. First stage of view population. |
|
2279 // (other items were commented in a header). |
|
2280 // ---------------------------------------------------------------------------- |
|
2281 // |
|
2282 void CCalenWeekContainer::BeginPopulationWithInstanceViewL() |
|
2283 { |
|
2284 TRACE_ENTRY_POINT; |
|
2285 SizeChanged(); |
|
2286 iViewPopulationComplete = EFalse; |
|
2287 |
|
2288 iPreview->Hide(); |
|
2289 |
|
2290 iListBox->View()->SetDisableRedraw( ETrue ); |
|
2291 PopulatesDayListsL(); |
|
2292 |
|
2293 TRACE_EXIT_POINT; |
|
2294 } |
|
2295 |
|
2296 // ---------------------------------------------------------------------------- |
|
2297 // CCalenWeekContainer::FirstPopulateOfSlotTableL |
|
2298 // Prepares and puts non timed notes into the slot table. |
|
2299 // Second stage of view population. |
|
2300 // (other items were commented in a header). |
|
2301 // ---------------------------------------------------------------------------- |
|
2302 // |
|
2303 void CCalenWeekContainer::FirstPopulateOfSlotTableL() |
|
2304 { |
|
2305 TRACE_ENTRY_POINT; |
|
2306 |
|
2307 InitSlotTableL(); |
|
2308 InsertNonTimedNotesToSlotTableL(); |
|
2309 |
|
2310 TRACE_EXIT_POINT; |
|
2311 } |
|
2312 |
|
2313 // ---------------------------------------------------------------------------- |
|
2314 // CCalenWeekContainer::SecondPopulateOfSlotTableL |
|
2315 // Puts timed notes into the slot table. Third stage of view population. |
|
2316 // (other items were commented in a header). |
|
2317 // ---------------------------------------------------------------------------- |
|
2318 // |
|
2319 void CCalenWeekContainer::SecondPopulateOfSlotTableL() |
|
2320 { |
|
2321 TRACE_ENTRY_POINT; |
|
2322 |
|
2323 InsertTimedNotesToSlotTableL(); |
|
2324 |
|
2325 TRACE_EXIT_POINT; |
|
2326 } |
|
2327 |
|
2328 // ---------------------------------------------------------------------------- |
|
2329 // CCalenWeekContainer::CompletePopulationL |
|
2330 // Completes population. Fourth and final stage of view population. |
|
2331 // (other items were commented in a header). |
|
2332 // ---------------------------------------------------------------------------- |
|
2333 // |
|
2334 void CCalenWeekContainer::CompletePopulationL() |
|
2335 { |
|
2336 TRACE_ENTRY_POINT; |
|
2337 |
|
2338 iListBox->View()->SetDisableRedraw( EFalse ); |
|
2339 SetCursorToActiveDayL(); |
|
2340 SetListBoxDataL(); |
|
2341 AddToStackAndMakeVisibleL(); |
|
2342 iViewPopulationComplete = ETrue; |
|
2343 |
|
2344 iView->SetEditorActive( EFalse ); |
|
2345 |
|
2346 // Popup needs to check if iViewPopulationComplete is set |
|
2347 FocusChangeForPopupL(); |
|
2348 |
|
2349 UpdateStatusPaneAndExtensionsL(); |
|
2350 DrawDeferred(); |
|
2351 // Hide/unhide "today" toolbar item based on the focused day |
|
2352 UpdateTodayToolbarItemL(); |
|
2353 TRACE_EXIT_POINT; |
|
2354 } |
|
2355 |
|
2356 // ---------------------------------------------------------------------------- |
|
2357 // CCalenWeekContainer::CreateIconIndicesL |
|
2358 // Create icon index for day view |
|
2359 // ---------------------------------------------------------------------------- |
|
2360 // |
|
2361 void CCalenWeekContainer::CreateIconIndicesL( RArray<MCalenServices::TCalenIcons>& aIndexArray ) |
|
2362 { |
|
2363 TRACE_ENTRY_POINT; |
|
2364 // Icons needed for the week view |
|
2365 aIndexArray.Reset(); |
|
2366 aIndexArray.AppendL( MCalenServices::ECalenBirthdayIcon ); |
|
2367 aIndexArray.AppendL( MCalenServices::ECalenMeetingIcon ); |
|
2368 aIndexArray.AppendL( MCalenServices::ECalenDaynoteIcon ); |
|
2369 aIndexArray.AppendL( MCalenServices::ECalenToDoIcon ); |
|
2370 |
|
2371 TRACE_EXIT_POINT; |
|
2372 } |
|
2373 |
|
2374 // ---------------------------------------------------------------------------- |
|
2375 // CCalenWeekContainer::InfoBarRectL |
|
2376 // Returns the available info bar rect for this container |
|
2377 // ---------------------------------------------------------------------------- |
|
2378 TRect CCalenWeekContainer::InfoBarRectL( TBool aToolbarAvailable ) |
|
2379 { |
|
2380 TRACE_ENTRY_POINT; |
|
2381 |
|
2382 // Get the main pane |
|
2383 TAknLayoutRect main_cale_week_pane; |
|
2384 main_cale_week_pane.LayoutRect( Rect(), |
|
2385 AknLayoutScalable_Apps::main_cale_week_pane().LayoutLine() ); |
|
2386 |
|
2387 TAknLayoutRect listscroll_cale_week_pane; |
|
2388 listscroll_cale_week_pane.LayoutRect( main_cale_week_pane.Rect(), |
|
2389 AknLayoutScalable_Apps::listscroll_cale_week_pane(1).LayoutLine() ); |
|
2390 |
|
2391 // Create a dummy label to find the layout rect |
|
2392 CEikLabel* dummyLabel = new( ELeave ) CEikLabel; |
|
2393 CleanupStack::PushL( dummyLabel ); |
|
2394 |
|
2395 // Get the layout variant for the week view infobar. |
|
2396 // We assume that we have one for this check, as we need to |
|
2397 // find the size that would be available if we do have one. |
|
2398 TInt layoutVariant = 0; |
|
2399 if( aToolbarAvailable ) |
|
2400 { |
|
2401 layoutVariant = 1; |
|
2402 } |
|
2403 else |
|
2404 { |
|
2405 layoutVariant = 0; |
|
2406 } |
|
2407 |
|
2408 AknLayoutUtils::LayoutLabel( dummyLabel, listscroll_cale_week_pane.Rect(), |
|
2409 AknLayoutScalable_Apps::listscroll_cale_week_pane_t1( layoutVariant ).LayoutLine() ); |
|
2410 |
|
2411 TRect infoRect = dummyLabel->Rect(); |
|
2412 TRect rect; |
|
2413 // Discard the label |
|
2414 CleanupStack::PopAndDestroy( dummyLabel ); |
|
2415 |
|
2416 TRACE_EXIT_POINT; |
|
2417 return infoRect; |
|
2418 } |
|
2419 |
|
2420 // ---------------------------------------------------------------------------- |
|
2421 // CCalenWeekContainer::CheckLayoutAndExtensionsL |
|
2422 // check with layoutmanager for any layout changes |
|
2423 // ---------------------------------------------------------------------------- |
|
2424 void CCalenWeekContainer::CheckLayoutAndExtensionL() |
|
2425 { |
|
2426 TRACE_ENTRY_POINT; |
|
2427 |
|
2428 iLayoutManager->GetLayoutAndExtensionL(); |
|
2429 |
|
2430 TRACE_EXIT_POINT; |
|
2431 } |
|
2432 |
|
2433 // ---------------------------------------------------------------------------- |
|
2434 // CCalenWeekContainer::SearchTopIndexL |
|
2435 // Searches for the top index |
|
2436 // ---------------------------------------------------------------------------- |
|
2437 TInt CCalenWeekContainer::SearchTopIndexL(TInt /*aColumn*/) |
|
2438 { |
|
2439 TRACE_ENTRY_POINT; |
|
2440 |
|
2441 TInt row = KErrNotFound; |
|
2442 |
|
2443 MCalenContext& context = iServices.Context(); |
|
2444 |
|
2445 if( iSelectedRowNumber == KErrNotFound && iRow) |
|
2446 { |
|
2447 row = KErrNotFound; |
|
2448 } |
|
2449 else |
|
2450 { |
|
2451 if(iListBox->TopItemIndex()!=0 && !iTopRowDefault) |
|
2452 { |
|
2453 // row is top item index.. |
|
2454 row = iListBox->TopItemIndex(); |
|
2455 } |
|
2456 else |
|
2457 { |
|
2458 // row for the time |
|
2459 row = FindRowForTime(iFirstRowTime); |
|
2460 iTopRowDefault = EFalse; |
|
2461 } |
|
2462 } |
|
2463 |
|
2464 TRACE_EXIT_POINT; |
|
2465 |
|
2466 return row; |
|
2467 } |
|
2468 |
|
2469 // ---------------------------------------------------------------------------- |
|
2470 // CCalenWeekContainer::UpdatePreviewPaneL |
|
2471 // Updates preview pane whenever application comes to foreground |
|
2472 // ---------------------------------------------------------------------------- |
|
2473 void CCalenWeekContainer::UpdatePreviewPaneL() |
|
2474 { |
|
2475 TRACE_ENTRY_POINT; |
|
2476 |
|
2477 if( iViewPopulationComplete ) |
|
2478 { |
|
2479 CalcDayFromColumn(); |
|
2480 |
|
2481 CWeekSlotArrayPtr slotTable = iSlotTable[iColumn]; |
|
2482 CCalHourItem& itemInfo = *(*slotTable)[iListBox->CurrentItemIndex()]; |
|
2483 |
|
2484 // dont focus the preview popup/previewpane if any dialog or faster app is active |
|
2485 if(!iView->IsEditorActiveOrFasterAppExit()) |
|
2486 { |
|
2487 if( !itemInfo.IsTimed() ) |
|
2488 { |
|
2489 // Non-timed cell |
|
2490 iPreview->FocusChangedL(itemInfo.iInstance); |
|
2491 } |
|
2492 else |
|
2493 { |
|
2494 TDateTime dt = iTime.DateTime(); // TACOTEMP |
|
2495 iPreview->FocusChangedL( iServices.Context().FocusDateAndTimeL().TimeLocalL() ); |
|
2496 } |
|
2497 } |
|
2498 } |
|
2499 else |
|
2500 { |
|
2501 HidePopup(); |
|
2502 } |
|
2503 |
|
2504 TRACE_EXIT_POINT; |
|
2505 } |
|
2506 |
|
2507 // ----------------------------------------------------------------------------- |
|
2508 // CCalenWeekContainer::CalendarInfoIdentifierL |
|
2509 // Searches for the index in calendar info list based on calendar file name |
|
2510 // ----------------------------------------------------------------------------- |
|
2511 // |
|
2512 TBool CCalenWeekContainer::CalendarInfoIdentifierL( const HBufC* aName, |
|
2513 const CCalCalendarInfo& aCalendarInfo) |
|
2514 { |
|
2515 TRACE_ENTRY_POINT; |
|
2516 TBool retVal = EFalse; |
|
2517 HBufC* calendarFileName = aCalendarInfo.FileNameL().AllocLC(); |
|
2518 retVal = calendarFileName->CompareF(*aName); |
|
2519 CleanupStack::PopAndDestroy(calendarFileName); |
|
2520 TRACE_EXIT_POINT; |
|
2521 return (!retVal); |
|
2522 } |
|
2523 |
|
2524 // -------------------------------------------------------------------------- |
|
2525 // CCalenWeekContainer::CleanupInstancesL |
|
2526 // (other items were commented in a header). |
|
2527 // -------------------------------------------------------------------------- |
|
2528 // |
|
2529 void CCalenWeekContainer::CleanupInstances() |
|
2530 { |
|
2531 TRACE_ENTRY_POINT |
|
2532 for (TInt loop(0); loop < KCalenDaysInWeek; ++loop) |
|
2533 { |
|
2534 iIdList[loop].ResetAndDestroy(); |
|
2535 } |
|
2536 TRACE_EXIT_POINT |
|
2537 } |
|
2538 |
|
2539 |
|
2540 // End of File |