49 #include "calenthicklinesdrawer.h" |
49 #include "calenthicklinesdrawer.h" |
50 #include "calencommon.h" |
50 #include "calencommon.h" |
51 #include "calendarprivatecrkeys.h" |
51 #include "calendarprivatecrkeys.h" |
52 #include "calenpluginlabel.h" |
52 #include "calenpluginlabel.h" |
53 #include "calenconstants.h" |
53 #include "calenconstants.h" |
|
54 #include "OstTraceDefinitions.h" |
|
55 #ifdef OST_TRACE_COMPILER_IN_USE |
|
56 #include "calenmonthviewTraces.h" |
|
57 #endif |
|
58 |
|
59 // CONSTANTS |
|
60 #define WEEKNUMWIDTH 6.41604 // in units, need to update this value if it |
|
61 // is changed in the docml |
54 /*! |
62 /*! |
55 \class CalenMonthView |
63 \class CalenMonthView |
56 |
64 |
57 Class implementing calendar month view |
65 Class implementing calendar month view |
58 */ |
66 */ |
83 mLocale = HbExtendedLocale::system(); |
93 mLocale = HbExtendedLocale::system(); |
84 mFirstWeekLabel = NULL; |
94 mFirstWeekLabel = NULL; |
85 mIsPrevPaneGesture = false; |
95 mIsPrevPaneGesture = false; |
86 // Get the week day color from the theme |
96 // Get the week day color from the theme |
87 mWeekDaysColor = HbColorScheme::color("qtc_cal_week_day"); |
97 mWeekDaysColor = HbColorScheme::color("qtc_cal_week_day"); |
|
98 |
|
99 OstTraceFunctionExit0( CALENMONTHVIEW_CALENMONTHVIEW_EXIT ); |
88 } |
100 } |
89 |
101 |
90 /*! |
102 /*! |
91 Destructor. |
103 Destructor. |
92 */ |
104 */ |
93 CalenMonthView::~CalenMonthView() |
105 CalenMonthView::~CalenMonthView() |
94 { |
106 { |
|
107 OstTraceFunctionEntry0( DUP1_CALENMONTHVIEW_CALENMONTHVIEW_ENTRY ); |
|
108 |
|
109 OstTraceFunctionExit0( DUP1_CALENMONTHVIEW_CALENMONTHVIEW_EXIT ); |
95 } |
110 } |
96 |
111 |
97 /*! |
112 /*! |
98 Called by the CalenViewManager after loading the view from the docml. |
113 Called by the CalenViewManager after loading the view from the docml. |
99 The initializaion/setup of the view is done here. |
114 The initializaion/setup of the view is done here. |
100 */ |
115 */ |
101 void CalenMonthView::setupView(CalenDocLoader *docLoader) |
116 void CalenMonthView::setupView(CalenDocLoader *docLoader) |
102 { |
117 { |
|
118 OstTraceFunctionEntry0( CALENMONTHVIEW_SETUPVIEW_ENTRY ); |
|
119 |
103 mDocLoader = docLoader; |
120 mDocLoader = docLoader; |
104 mTitleLabel |
121 mTitleLabel |
105 = qobject_cast<HbLabel *> ( |
122 = qobject_cast<HbLabel *> ( |
106 mDocLoader->findWidget(CALEN_MONTH_TITLE)); |
123 mDocLoader->findWidget(CALEN_MONTH_TITLE)); |
107 // Set the title text color |
124 // Set the title text color |
212 // clean up any previous versions of this activity, if any, i.e. activityName, from the activity manager. |
229 // clean up any previous versions of this activity, if any, i.e. activityName, from the activity manager. |
213 // Ignore return value, first boot would always return False. bool declared |
230 // Ignore return value, first boot would always return False. bool declared |
214 // only for debugging purpose. |
231 // only for debugging purpose. |
215 bool ok = activityManager->removeActivity(activityName); |
232 bool ok = activityManager->removeActivity(activityName); |
216 |
233 |
|
234 OstTraceFunctionExit0( CALENMONTHVIEW_SETUPVIEW_EXIT ); |
217 } |
235 } |
218 |
236 |
219 /*! |
237 /*! |
220 Constructs the remaining part of the month view that was kept as |
238 Constructs the remaining part of the month view that was kept as |
221 part if lazy loading |
239 part if lazy loading |
222 */ |
240 */ |
223 void CalenMonthView::doLazyLoading() |
241 void CalenMonthView::doLazyLoading() |
224 { |
242 { |
|
243 OstTraceFunctionEntry0( CALENMONTHVIEW_DOLAZYLOADING_ENTRY ); |
225 // Add background items to all the widgets |
244 // Add background items to all the widgets |
226 addBackgroundFrame(); |
245 addBackgroundFrame(); |
227 |
246 |
228 // Construct and add the previous month and next month items to the view |
247 // Construct and add the previous month and next month items to the view |
229 mMonthGrid->updateMonthGridWithInActiveMonths(mMonthDataArray); |
248 mMonthGrid->updateMonthGridWithInActiveMonths(mMonthDataArray); |
291 |
310 |
292 // Connect to the signal when options menu is shown |
311 // Connect to the signal when options menu is shown |
293 // This is required to add/remove dynamically some options |
312 // This is required to add/remove dynamically some options |
294 connect(menu(), SIGNAL(aboutToShow ()), this, |
313 connect(menu(), SIGNAL(aboutToShow ()), this, |
295 SLOT(addRemoveActionsInMenu())); |
314 SLOT(addRemoveActionsInMenu())); |
|
315 //add "show lunar data" action item ,if regional plugin is present |
|
316 //regional plugin will add the option itself and handles it accordingly |
|
317 //use this api after adding all action item to the menu |
|
318 //so that plugin add the "Show lunar data" item as a second last option |
|
319 // in all views |
|
320 mServices.OfferMenu(menu()); |
|
321 |
|
322 OstTraceFunctionExit0( CALENMONTHVIEW_DOLAZYLOADING_EXIT ); |
296 } |
323 } |
297 |
324 |
298 /*! |
325 /*! |
299 Adds the week numbers to the weeknumber widget |
326 Adds the week numbers to the weeknumber widget |
300 */ |
327 */ |
301 void CalenMonthView::addWeekNumbers() |
328 void CalenMonthView::addWeekNumbers() |
302 { |
329 { |
|
330 OstTraceFunctionEntry0( CALENMONTHVIEW_ADDWEEKNUMBERS_ENTRY ); |
|
331 |
303 if (!mFirstWeekLabel) { |
332 if (!mFirstWeekLabel) { |
304 // Get all the six week labels |
333 // Get all the six week labels |
305 mFirstWeekLabel |
334 mFirstWeekLabel |
306 = qobject_cast<HbLabel *> ( |
335 = qobject_cast<HbLabel *> ( |
307 mDocLoader->findWidget(CALEN_MONTVIEW_FIRST_WEEK_LABEL)); |
336 mDocLoader->findWidget(CALEN_MONTVIEW_FIRST_WEEK_LABEL)); |
336 // Get the day names layout |
365 // Get the day names layout |
337 QGraphicsLinearLayout *dayNamesLayout = |
366 QGraphicsLinearLayout *dayNamesLayout = |
338 static_cast<QGraphicsLinearLayout *> (mDayNameWidget->layout()); |
367 static_cast<QGraphicsLinearLayout *> (mDayNameWidget->layout()); |
339 |
368 |
340 if (KCalenDaysInWeek == dayNamesLayout->count()) { |
369 if (KCalenDaysInWeek == dayNamesLayout->count()) { |
341 // Add one item with text "Wk" in the day name grid |
370 // Add one empty label in the day name grid |
342 HbLabel *label = new HbLabel(mDayNameWidget); |
371 HbLabel *label = new HbLabel(mDayNameWidget); |
343 |
372 |
344 // Set the attributes same as that of other day names to make it |
373 // Set the attributes same as that of other day names to make it |
345 // look similar to the day names |
374 // look similar to the day names |
346 label->setPlainText(hbTrId("txt_calendar_grid_day_wk")); |
375 label->setPlainText(""); |
347 label->setFont(mFirstDayLabel->font()); |
376 label->setFont(mFirstDayLabel->font()); |
348 label->setFontSpec(mFirstDayLabel->fontSpec()); |
377 label->setFontSpec(mFirstDayLabel->fontSpec()); |
349 label->setAlignment(mFirstDayLabel->alignment()); |
378 label->setAlignment(mFirstDayLabel->alignment()); |
350 label->setElideMode(mFirstDayLabel->elideMode()); |
379 label->setElideMode(mFirstDayLabel->elideMode()); |
351 label->setZValue(mFirstDayLabel->zValue()); |
380 label->setZValue(mFirstDayLabel->zValue()); |
352 label->setPreferredHeight(mFirstDayLabel->preferredHeight()); |
381 // Set the proper width to this empty label so that |
353 label->setMinimumHeight(mFirstDayLabel->minimumHeight()); |
382 // day names are dislayed against the correct columns |
354 label->setMaximumHeight(mFirstDayLabel->maximumHeight()); |
383 HbDeviceProfile deviceProf; |
|
384 qreal unitValue = deviceProf.unitValue(); |
|
385 qreal widthInPixels = WEEKNUMWIDTH * unitValue; |
|
386 label->setPreferredWidth(widthInPixels); |
|
387 label->setMinimumWidth(widthInPixels); |
|
388 label->setMaximumWidth(widthInPixels); |
|
389 label->setContentsMargins(0,0,0,0); |
355 |
390 |
356 // Add this label into layout |
391 // Add this label into layout |
357 dayNamesLayout->insertItem(0, label); |
392 dayNamesLayout->insertItem(0, label); |
358 dayNamesLayout->invalidate(); |
393 dayNamesLayout->invalidate(); |
359 dayNamesLayout->activate(); |
394 dayNamesLayout->activate(); |
368 // Enable the item so that line seperator gets drawn |
403 // Enable the item so that line seperator gets drawn |
369 mWeekNumberWidget->setEnabled(true); |
404 mWeekNumberWidget->setEnabled(true); |
370 layout->invalidate(); |
405 layout->invalidate(); |
371 layout->activate(); |
406 layout->activate(); |
372 } |
407 } |
|
408 |
|
409 OstTraceFunctionExit0( CALENMONTHVIEW_ADDWEEKNUMBERS_EXIT ); |
373 } |
410 } |
374 |
411 |
375 /*! |
412 /*! |
376 Removes the week numbers from the view |
413 Removes the week numbers from the view |
377 */ |
414 */ |
378 void CalenMonthView::removeWeekNumbers() |
415 void CalenMonthView::removeWeekNumbers() |
379 |
416 |
380 { |
417 { |
|
418 OstTraceFunctionEntry0( CALENMONTHVIEW_REMOVEWEEKNUMBERS_ENTRY ); |
|
419 |
381 // Remove the week number grid if setting is off |
420 // Remove the week number grid if setting is off |
382 QGraphicsLinearLayout *layout = static_cast<QGraphicsLinearLayout *> |
421 QGraphicsLinearLayout *layout = static_cast<QGraphicsLinearLayout *> |
383 (mMonthGridPlusWeekNumWidget->layout()); |
422 (mMonthGridPlusWeekNumWidget->layout()); |
384 if (2 == layout->count()) { |
423 if (2 == layout->count()) { |
385 layout->removeItem(mWeekNumberWidget); |
424 layout->removeItem(mWeekNumberWidget); |
407 delete item; |
446 delete item; |
408 dayNamesLayout->invalidate(); |
447 dayNamesLayout->invalidate(); |
409 dayNamesLayout->activate(); |
448 dayNamesLayout->activate(); |
410 } |
449 } |
411 } |
450 } |
|
451 |
|
452 OstTraceFunctionExit0( CALENMONTHVIEW_REMOVEWEEKNUMBERS_EXIT ); |
412 } |
453 } |
413 |
454 |
414 /*! |
455 /*! |
415 Sets the background frame for the month view |
456 Sets the background frame for the month view |
416 */ |
457 */ |
417 void CalenMonthView::addBackgroundFrame() |
458 void CalenMonthView::addBackgroundFrame() |
418 { |
459 { |
|
460 OstTraceFunctionEntry0( CALENMONTHVIEW_ADDBACKGROUNDFRAME_ENTRY ); |
|
461 |
419 // Set the background items for all the widgets |
462 // Set the background items for all the widgets |
420 HbFrameItem* frame = NULL; |
463 HbFrameItem* frame = NULL; |
421 HbFrameDrawer *drawer = NULL; |
464 HbFrameDrawer *drawer = NULL; |
422 HbWidget* monthViewExceptPreviewPane = qobject_cast<HbWidget *> ( |
465 HbWidget* monthViewExceptPreviewPane = qobject_cast<HbWidget *> ( |
423 mDocLoader->findWidget(CALEN_MONTHVIEW_EXCEPT_PANE)); |
466 mDocLoader->findWidget(CALEN_MONTHVIEW_EXCEPT_PANE)); |
454 drawer = new HbFrameDrawer("qtg_fr_cal_preview_bg", HbFrameDrawer::NinePieces); |
497 drawer = new HbFrameDrawer("qtg_fr_cal_preview_bg", HbFrameDrawer::NinePieces); |
455 if(drawer) |
498 if(drawer) |
456 frame = new HbFrameItem(drawer, this); |
499 frame = new HbFrameItem(drawer, this); |
457 if(frame) |
500 if(frame) |
458 mNextPaneLayoutWidget->setBackgroundItem(frame->graphicsItem(), -5); |
501 mNextPaneLayoutWidget->setBackgroundItem(frame->graphicsItem(), -5); |
|
502 |
|
503 OstTraceFunctionExit0( CALENMONTHVIEW_ADDBACKGROUNDFRAME_EXIT ); |
459 } |
504 } |
460 |
505 |
461 void CalenMonthView::showHideRegionalInformation() |
506 void CalenMonthView::showHideRegionalInformation() |
462 { |
507 { |
|
508 OstTraceFunctionEntry0( CALENMONTHVIEW_SHOWHIDEREGIONALINFORMATION_ENTRY ); |
|
509 |
463 if (pluginEnabled()) { |
510 if (pluginEnabled()) { |
464 XQSettingsKey regionalInfo(XQSettingsKey::TargetCentralRepository, |
511 XQSettingsKey regionalInfo(XQSettingsKey::TargetCentralRepository, |
465 KCRUidCalendar, KCalendarShowRegionalInfo); |
512 KCRUidCalendar, KCalendarShowRegionalInfo); |
466 |
513 |
467 int showRegionalInfo = |
514 int showRegionalInfo = |
531 mNextRegionalInfo->hide(); |
578 mNextRegionalInfo->hide(); |
532 mNextRegionalInfo = NULL; |
579 mNextRegionalInfo = NULL; |
533 } |
580 } |
534 } |
581 } |
535 } |
582 } |
|
583 |
|
584 OstTraceFunctionExit0( CALENMONTHVIEW_SHOWHIDEREGIONALINFORMATION_EXIT ); |
536 } |
585 } |
537 |
586 |
538 /*! |
587 /*! |
539 Handles the context changed notification |
588 Handles the context changed notification |
540 */ |
589 */ |
541 void CalenMonthView::onContextChanged() |
590 void CalenMonthView::onContextChanged() |
542 { |
591 { |
|
592 OstTraceFunctionEntry0( CALENMONTHVIEW_ONCONTEXTCHANGED_ENTRY ); |
543 //Update plugin label after setting context |
593 //Update plugin label after setting context |
544 if (mCurrRegionalInfo && mPrevRegionalInfo && mNextPaneLayout |
594 if (mCurrRegionalInfo && mPrevRegionalInfo && mNextPaneLayout |
545 && pluginEnabled()) { |
595 && pluginEnabled()) { |
546 QString *pluginString = pluginText(); |
596 QString *pluginString = pluginText(); |
547 mPrevRegionalInfo->setPlainText(*pluginString); |
597 mPrevRegionalInfo->setPlainText(*pluginString); |
548 mCurrRegionalInfo->setPlainText(*pluginString); |
598 mCurrRegionalInfo->setPlainText(*pluginString); |
549 mNextRegionalInfo->setPlainText(*pluginString); |
599 mNextRegionalInfo->setPlainText(*pluginString); |
550 } |
600 } |
|
601 OstTraceFunctionExit0( CALENMONTHVIEW_ONCONTEXTCHANGED_EXIT ); |
551 } |
602 } |
552 |
603 |
553 /*! |
604 /*! |
554 Calculates the week numbers and sets them to the week labels |
605 Calculates the week numbers and sets them to the week labels |
555 */ |
606 */ |
556 void CalenMonthView::updateWeekNumGridModel() |
607 void CalenMonthView::updateWeekNumGridModel() |
557 |
608 |
558 { |
609 { |
|
610 OstTraceFunctionEntry0( CALENMONTHVIEW_UPDATEWEEKNUMGRIDMODEL_ENTRY ); |
|
611 |
559 // Get the visible date |
612 // Get the visible date |
560 QDateTime firstVisibleDate = mFirstDayOfGrid.addDays(KCalenDaysInWeek |
613 QDateTime firstVisibleDate = mFirstDayOfGrid.addDays(KCalenDaysInWeek |
561 * mNumOfRowsInPrevMonth); |
614 * mNumOfRowsInPrevMonth); |
562 // Go to the last day so that we get the proper week number for the first |
615 // Go to the last day so that we get the proper week number for the first |
563 // week of January |
616 // week of January |
581 mFourthWeekLabel->setPlainText(text); |
634 mFourthWeekLabel->setPlainText(text); |
582 text = QString::number(mWeekNumbers.at(4)); |
635 text = QString::number(mWeekNumbers.at(4)); |
583 mFifthWeekLabel->setPlainText(text); |
636 mFifthWeekLabel->setPlainText(text); |
584 text = QString::number(mWeekNumbers.at(5)); |
637 text = QString::number(mWeekNumbers.at(5)); |
585 mSixthWeekLabel->setPlainText(text); |
638 mSixthWeekLabel->setPlainText(text); |
|
639 |
|
640 OstTraceFunctionExit0( CALENMONTHVIEW_UPDATEWEEKNUMGRIDMODEL_EXIT ); |
586 } |
641 } |
587 |
642 |
588 /*! |
643 /*! |
589 Populates the month view with today as focussed item |
644 Populates the month view with today as focussed item |
590 */ |
645 */ |
591 void CalenMonthView::goToToday() |
646 void CalenMonthView::goToToday() |
592 { |
647 { |
|
648 OstTraceFunctionEntry0( CALENMONTHVIEW_GOTOTODAY_ENTRY ); |
|
649 |
593 QDateTime today = CalenDateUtils::today(); |
650 QDateTime today = CalenDateUtils::today(); |
594 // Set the context and repopulate the view |
651 // Set the context and repopulate the view |
595 MCalenContext &context = mServices.Context(); |
652 MCalenContext &context = mServices.Context(); |
596 context.setFocusDateAndTime(today); |
653 context.setFocusDateAndTime(today); |
597 |
654 |
598 // First check if we are not alread |
655 // First check if we are not alread |
599 // showing today's month view |
656 // showing today's month view |
600 if (mDate == today) { |
657 if (mDate == today) { |
|
658 OstTraceFunctionExit0( CALENMONTHVIEW_GOTOTODAY_EXIT ); |
601 return; |
659 return; |
602 } else if (mActiveMonth.date().year() == today.date().year() && |
660 } else if (mActiveMonth.date().year() == today.date().year() && |
603 mActiveMonth.date().month() == today.date().month()) { |
661 mActiveMonth.date().month() == today.date().month()) { |
604 mDate = today; |
662 mDate = today; |
605 // User is in current month only, so just set the focus to current |
663 // User is in current month only, so just set the focus to current |
609 // Populate the preview panes |
667 // Populate the preview panes |
610 populatePreviewPane(mDate); |
668 populatePreviewPane(mDate); |
611 } else { |
669 } else { |
612 refreshViewOnGoToDate(); |
670 refreshViewOnGoToDate(); |
613 } |
671 } |
|
672 |
|
673 OstTraceFunctionExit0( DUP1_CALENMONTHVIEW_GOTOTODAY_EXIT ); |
614 } |
674 } |
615 |
675 |
616 /* |
676 /* |
617 Slot to handle adding / removing actions frm the menu when menu is about to |
677 Slot to handle adding / removing actions frm the menu when menu is about to |
618 shown to the user |
678 shown to the user |
619 */ |
679 */ |
620 void CalenMonthView::addRemoveActionsInMenu() |
680 void CalenMonthView::addRemoveActionsInMenu() |
621 { |
681 { |
|
682 OstTraceFunctionEntry0( CALENMONTHVIEW_ADDREMOVEACTIONSINMENU_ENTRY ); |
622 HbAction* menuAction = mDeleteSubMenu->menuAction(); |
683 HbAction* menuAction = mDeleteSubMenu->menuAction(); |
623 // Check if there are no entries in the database |
684 if (menuAction) { |
624 if (mAgendaUtil->areNoEntriesInCalendar() && menuAction) { |
685 if (!mEntriesInDataBase && mAgendaUtil->areNoEntriesInCalendar()) { |
625 // hide the delete entries option |
686 // hide the delete entries option |
626 menuAction->setVisible(false); |
687 menuAction->setVisible(false); |
627 } else if (menuAction) { |
688 } else { |
628 // Show the option to delete |
689 mEntriesInDataBase = true; |
629 menuAction->setVisible(true); |
690 // Show the option to delete |
|
691 menuAction->setVisible(true); |
|
692 } |
630 } |
693 } |
631 |
694 |
632 // Check if we are population for current day, if yes then disable the |
695 // Check if we are population for current day, if yes then disable the |
633 // gototoday action |
696 // gototoday action |
634 if ((CalenDateUtils::today().date() == mDate.date()) && mGoToTodayAction) { |
697 if ((CalenDateUtils::today().date() == mDate.date()) && mGoToTodayAction) { |
635 mGoToTodayAction->setVisible(false); |
698 mGoToTodayAction->setVisible(false); |
636 } else if (mGoToTodayAction){ |
699 } else if (mGoToTodayAction){ |
637 mGoToTodayAction->setVisible(true); |
700 mGoToTodayAction->setVisible(true); |
638 } |
701 } |
|
702 OstTraceFunctionExit0( CALENMONTHVIEW_ADDREMOVEACTIONSINMENU_EXIT ); |
639 } |
703 } |
640 |
704 |
641 /*! |
705 /*! |
642 Populates the view |
706 Populates the view |
643 */ |
707 */ |
644 void CalenMonthView::doPopulation() |
708 void CalenMonthView::doPopulation() |
645 { |
709 { |
646 |
710 OstTraceFunctionEntry0( CALENMONTHVIEW_DOPOPULATION_ENTRY ); |
|
711 |
647 // Get the layout and add the preview pane layout. |
712 // Get the layout and add the preview pane layout. |
648 QGraphicsLinearLayout* viewLayout = static_cast<QGraphicsLinearLayout *> |
713 QGraphicsLinearLayout* viewLayout = static_cast<QGraphicsLinearLayout *> |
649 (widget()->layout()); |
714 (widget()->layout()); |
650 if (viewLayout->count() == 1) { |
715 if (viewLayout->count() == 1) { |
651 // Count is 1 implies view has only month grid. |
716 // Count is 1 implies view has only month grid. |
697 if (!mIsFirstTimeLoad) { |
762 if (!mIsFirstTimeLoad) { |
698 showHideRegionalInformation(); |
763 showHideRegionalInformation(); |
699 } |
764 } |
700 // Reset the first time load flag |
765 // Reset the first time load flag |
701 mIsFirstTimeLoad = false; |
766 mIsFirstTimeLoad = false; |
|
767 |
|
768 OstTraceFunctionExit0( CALENMONTHVIEW_DOPOPULATION_EXIT ); |
702 } |
769 } |
703 |
770 |
704 /*! |
771 /*! |
705 Reads the date from the context and calculates the grid item dates |
772 Reads the date from the context and calculates the grid item dates |
706 */ |
773 */ |
707 void CalenMonthView::prepareForPopulation() |
774 void CalenMonthView::prepareForPopulation() |
708 { |
775 { |
|
776 OstTraceFunctionEntry0( CALENMONTHVIEW_PREPAREFORPOPULATION_ENTRY ); |
|
777 |
709 setActiveDay(dateFromContext(mServices.Context())); |
778 setActiveDay(dateFromContext(mServices.Context())); |
710 setDate(); |
779 setDate(); |
711 updateMonthDataArrayWithActiveDates(); |
780 updateMonthDataArrayWithActiveDates(); |
|
781 |
|
782 OstTraceFunctionExit0( CALENMONTHVIEW_PREPAREFORPOPULATION_EXIT ); |
712 } |
783 } |
713 |
784 |
714 /*! |
785 /*! |
715 Slot to handle gotodate action |
786 Slot to handle gotodate action |
716 */ |
787 */ |
717 void CalenMonthView::refreshViewOnGoToDate() |
788 void CalenMonthView::refreshViewOnGoToDate() |
718 { |
789 { |
|
790 OstTraceFunctionEntry0( CALENMONTHVIEW_REFRESHVIEWONGOTODATE_ENTRY ); |
|
791 |
719 prepareForPopulation(); |
792 prepareForPopulation(); |
720 setDateToLabel(); |
793 setDateToLabel(); |
721 // fetch list of required calendar instances |
794 // fetch list of required calendar instances |
722 populateWithInstanceView(); |
795 populateWithInstanceView(); |
723 |
796 |
727 mIsFirstTimeLoad); |
800 mIsFirstTimeLoad); |
728 // Update the week Numbers model |
801 // Update the week Numbers model |
729 if (mIsWeekNumbersShown) { |
802 if (mIsWeekNumbersShown) { |
730 updateWeekNumGridModel(); |
803 updateWeekNumGridModel(); |
731 } |
804 } |
|
805 |
|
806 OstTraceFunctionExit0( CALENMONTHVIEW_REFRESHVIEWONGOTODATE_EXIT ); |
732 } |
807 } |
733 |
808 |
734 /*! |
809 /*! |
735 Reads the date from the context and stores into mDate |
810 Reads the date from the context and stores into mDate |
736 */ |
811 */ |
737 QDateTime CalenMonthView::dateFromContext(const MCalenContext &context) |
812 QDateTime CalenMonthView::dateFromContext(const MCalenContext &context) |
738 { |
813 { |
|
814 OstTraceFunctionEntry0( CALENMONTHVIEW_DATEFROMCONTEXT_ENTRY ); |
739 QDateTime ret; |
815 QDateTime ret; |
740 if (AgendaEntry::TypeTodo == context.instanceId().mType) { |
816 if (AgendaEntry::TypeTodo == context.instanceId().mType) { |
741 QDateTime today = CalenDateUtils::today(); |
817 QDateTime today = CalenDateUtils::today(); |
742 if (context.focusDateAndTime() < today) { |
818 if (context.focusDateAndTime() < today) { |
743 ret = today; |
819 ret = today; |
745 ret = context.focusDateAndTime(); |
821 ret = context.focusDateAndTime(); |
746 } |
822 } |
747 } else { |
823 } else { |
748 ret = context.focusDateAndTime(); |
824 ret = context.focusDateAndTime(); |
749 } |
825 } |
|
826 OstTraceFunctionExit0( CALENMONTHVIEW_DATEFROMCONTEXT_EXIT ); |
750 return ret; |
827 return ret; |
751 } |
828 } |
752 |
829 |
753 /*! |
830 /*! |
754 Calculates the necesary parameters of the month view w.r.t mDate |
831 Calculates the necesary parameters of the month view w.r.t mDate |
755 */ |
832 */ |
756 void CalenMonthView::setActiveDay(QDateTime day) |
833 void CalenMonthView::setActiveDay(QDateTime day) |
757 { |
834 { |
|
835 OstTraceFunctionEntry0( CALENMONTHVIEW_SETACTIVEDAY_ENTRY ); |
|
836 |
758 mDate = day; |
837 mDate = day; |
759 |
838 |
760 mActiveMonth = mDate; |
839 mActiveMonth = mDate; |
761 // Get the first day of the previous month |
840 // Get the first day of the previous month |
762 QDateTime prevMonthDate = mDate.addMonths(-1); |
841 QDateTime prevMonthDate = mDate.addMonths(-1); |
812 mNumOfRowsInFutureMonth = 0; |
891 mNumOfRowsInFutureMonth = 0; |
813 while (dateTimeToCalc > lastVisibleDate) { |
892 while (dateTimeToCalc > lastVisibleDate) { |
814 mNumOfRowsInFutureMonth++; |
893 mNumOfRowsInFutureMonth++; |
815 dateTimeToCalc = dateTimeToCalc.addDays(-KCalenDaysInWeek); |
894 dateTimeToCalc = dateTimeToCalc.addDays(-KCalenDaysInWeek); |
816 } |
895 } |
|
896 |
|
897 OstTraceFunctionExit0( CALENMONTHVIEW_SETACTIVEDAY_EXIT ); |
817 } |
898 } |
818 |
899 |
819 /*! |
900 /*! |
820 Calculates the dates that needs to be set to mMonthDataArray |
901 Calculates the dates that needs to be set to mMonthDataArray |
821 */ |
902 */ |
822 void CalenMonthView::setDate() |
903 void CalenMonthView::setDate() |
823 { |
904 { |
|
905 OstTraceFunctionEntry0( CALENMONTHVIEW_SETDATE_ENTRY ); |
|
906 |
824 mMonthDataArray.clear(); |
907 mMonthDataArray.clear(); |
825 // Calculate the actual number of dates to be populated from previous month |
908 // Calculate the actual number of dates to be populated from previous month |
826 // to future month |
909 // to future month |
827 for (int i(0); i < mTotalNumOfGridItems; ++i) { |
910 for (int i(0); i < mTotalNumOfGridItems; ++i) { |
828 QDateTime currentDay = CalenDateUtils::futureOf(mFirstDayOfGrid, i); |
911 QDateTime currentDay = CalenDateUtils::futureOf(mFirstDayOfGrid, i); |
829 CalenMonthData element(currentDay); |
912 CalenMonthData element(currentDay); |
830 mMonthDataArray.append(element); |
913 mMonthDataArray.append(element); |
831 } |
914 } |
|
915 |
|
916 OstTraceFunctionExit0( CALENMONTHVIEW_SETDATE_EXIT ); |
832 } |
917 } |
833 |
918 |
834 /*! |
919 /*! |
835 Returns the currDay(Today) |
920 Returns the currDay(Today) |
836 */ |
921 */ |
837 QDateTime CalenMonthView::getCurrentDay() |
922 QDateTime CalenMonthView::getCurrentDay() |
838 { |
923 { |
|
924 OstTraceFunctionEntry0( CALENMONTHVIEW_GETCURRENTDAY_ENTRY ); |
|
925 |
|
926 OstTraceFunctionExit0( CALENMONTHVIEW_GETCURRENTDAY_EXIT ); |
839 return mCurrentDay; |
927 return mCurrentDay; |
840 } |
928 } |
841 |
929 |
842 /*! |
930 /*! |
843 Returns the active day(currently focussed day) |
931 Returns the active day(currently focussed day) |
844 */ |
932 */ |
845 QDateTime CalenMonthView::getActiveDay() |
933 QDateTime CalenMonthView::getActiveDay() |
846 { |
934 { |
|
935 OstTraceFunctionEntry0( CALENMONTHVIEW_GETACTIVEDAY_ENTRY ); |
|
936 |
|
937 OstTraceFunctionExit0( CALENMONTHVIEW_GETACTIVEDAY_EXIT ); |
847 return mDate; |
938 return mDate; |
848 } |
939 } |
849 |
940 |
850 /*! |
941 /*! |
851 Returns the array of CalenMonthData items |
942 Returns the array of CalenMonthData items |
852 */ |
943 */ |
853 QList<CalenMonthData> CalenMonthView::monthDataList() |
944 QList<CalenMonthData>& CalenMonthView::monthDataList() |
854 { |
945 { |
|
946 OstTraceFunctionEntry0( CALENMONTHVIEW_MONTHDATALIST_ENTRY ); |
|
947 |
|
948 OstTraceFunctionExit0( CALENMONTHVIEW_MONTHDATALIST_EXIT ); |
855 return mMonthDataArray; |
949 return mMonthDataArray; |
856 } |
950 } |
857 |
951 |
858 /*! |
952 /*! |
859 Creates the grid and adds the week numbers depending on the week number setting |
953 Creates the grid and adds the week numbers depending on the week number setting |
860 */ |
954 */ |
861 void CalenMonthView::createGrid() |
955 void CalenMonthView::createGrid() |
862 { |
956 { |
|
957 OstTraceFunctionEntry0( CALENMONTHVIEW_CREATEGRID_ENTRY ); |
863 // Update the month grid |
958 // Update the month grid |
864 mMonthGrid->updateMonthGridModel(mMonthDataArray, mIndexToBeScrolled, |
959 mMonthGrid->updateMonthGridModel(mMonthDataArray, mIndexToBeScrolled, |
865 mIsFirstTimeLoad); |
960 mIsFirstTimeLoad); |
866 // Get start of week from the locale. |
961 // Get start of week from the locale. |
867 HbExtendedLocale locale = HbExtendedLocale::system(); |
962 HbExtendedLocale locale = HbExtendedLocale::system(); |
882 addWeekNumbers(); |
977 addWeekNumbers(); |
883 } else { |
978 } else { |
884 // remove the weeknumbergrid from the layout |
979 // remove the weeknumbergrid from the layout |
885 removeWeekNumbers(); |
980 removeWeekNumbers(); |
886 } |
981 } |
|
982 OstTraceFunctionExit0( CALENMONTHVIEW_CREATEGRID_EXIT ); |
887 } |
983 } |
888 |
984 |
889 /*! |
985 /*! |
890 Called when down gesture is performed |
986 Called when down gesture is performed |
891 Caluclates the necessary dates for the new previous month |
987 Caluclates the necessary dates for the new previous month |
892 */ |
988 */ |
893 void CalenMonthView::updateModelWithPrevMonth() |
989 void CalenMonthView::updateModelWithPrevMonth() |
894 { |
990 { |
|
991 OstTraceFunctionEntry0( CALENMONTHVIEW_UPDATEMODELWITHPREVMONTH_ENTRY ); |
|
992 |
895 // Get the new previous month |
993 // Get the new previous month |
896 QDateTime prevMonthDateTime = mActiveMonth.addMonths(-1); |
994 QDateTime prevMonthDateTime = mActiveMonth.addMonths(-1); |
897 QDateTime dateTime = mFirstDayOfGrid; |
995 QDateTime dateTime = mFirstDayOfGrid; |
898 if (prevMonthDateTime.date().month() == mFirstDayOfGrid.date().month()) { |
996 if (prevMonthDateTime.date().month() == mFirstDayOfGrid.date().month()) { |
899 // Month starts right on Monday(Start of the week), |
997 // Month starts right on Monday(Start of the week), |
958 } |
1056 } |
959 // Update the week Numbers model |
1057 // Update the week Numbers model |
960 if (mIsWeekNumbersShown) { |
1058 if (mIsWeekNumbersShown) { |
961 updateWeekNumGridModel(); |
1059 updateWeekNumGridModel(); |
962 } |
1060 } |
|
1061 |
|
1062 OstTraceFunctionExit0( CALENMONTHVIEW_UPDATEMODELWITHPREVMONTH_EXIT ); |
963 } |
1063 } |
964 /*! |
1064 /*! |
965 Called when up gesture is performed |
1065 Called when up gesture is performed |
966 */ |
1066 */ |
967 void CalenMonthView::updateModelWithFutureMonth() |
1067 void CalenMonthView::updateModelWithFutureMonth() |
968 { |
1068 { |
|
1069 OstTraceFunctionEntry0( CALENMONTHVIEW_UPDATEMODELWITHFUTUREMONTH_ENTRY ); |
|
1070 |
969 // Get the new future month |
1071 // Get the new future month |
970 QDateTime previousLastDayOfGrid = mLastDayOfGrid; |
1072 QDateTime previousLastDayOfGrid = mLastDayOfGrid; |
971 QDateTime futureMonthDateTime = mActiveMonth.addMonths(2); |
1073 QDateTime futureMonthDateTime = mActiveMonth.addMonths(2); |
972 QDate date = futureMonthDateTime.date(); |
1074 QDate date = futureMonthDateTime.date(); |
973 date.setDate(date.year(), date.month(), 1); |
1075 date.setDate(date.year(), date.month(), 1); |
1027 } |
1129 } |
1028 |
1130 |
1029 // Update the mMonthDataArray with instances if any |
1131 // Update the mMonthDataArray with instances if any |
1030 populateNextMonth(); |
1132 populateNextMonth(); |
1031 |
1133 |
|
1134 OstTraceFunctionExit0( CALENMONTHVIEW_UPDATEMODELWITHFUTUREMONTH_EXIT ); |
1032 } |
1135 } |
1033 |
1136 |
1034 /*! |
1137 /*! |
1035 Returns the numner of rows in previous month |
1138 Returns the numner of rows in previous month |
1036 */ |
1139 */ |
1037 int CalenMonthView::rowsInPrevMonth() |
1140 int CalenMonthView::rowsInPrevMonth() |
1038 { |
1141 { |
|
1142 OstTraceFunctionEntry0( CALENMONTHVIEW_ROWSINPREVMONTH_ENTRY ); |
|
1143 |
|
1144 OstTraceFunctionExit0( CALENMONTHVIEW_ROWSINPREVMONTH_EXIT ); |
1039 return mNumOfRowsInPrevMonth; |
1145 return mNumOfRowsInPrevMonth; |
1040 } |
1146 } |
1041 |
1147 |
1042 /*! |
1148 /*! |
1043 Returns the number of rows in future month |
1149 Returns the number of rows in future month |
1044 */ |
1150 */ |
1045 int CalenMonthView::rowsInFutMonth() |
1151 int CalenMonthView::rowsInFutMonth() |
1046 { |
1152 { |
|
1153 OstTraceFunctionEntry0( CALENMONTHVIEW_ROWSINFUTMONTH_ENTRY ); |
|
1154 |
|
1155 OstTraceFunctionExit0( CALENMONTHVIEW_ROWSINFUTMONTH_EXIT ); |
1047 return mNumOfRowsInFutureMonth; |
1156 return mNumOfRowsInFutureMonth; |
1048 } |
1157 } |
1049 |
1158 |
1050 /*! |
1159 /*! |
1051 Returns current Grid index |
1160 Returns current Grid index |
1052 */ |
1161 */ |
1053 int CalenMonthView::getCurrGridIndex() |
1162 int CalenMonthView::getCurrGridIndex() |
1054 { |
1163 { |
|
1164 OstTraceFunctionEntry0( CALENMONTHVIEW_GETCURRGRIDINDEX_ENTRY ); |
|
1165 |
|
1166 OstTraceFunctionExit0( CALENMONTHVIEW_GETCURRGRIDINDEX_EXIT ); |
1055 return mMonthGrid->getCurrentIndex(); |
1167 return mMonthGrid->getCurrentIndex(); |
1056 } |
1168 } |
1057 |
1169 |
1058 /*! |
1170 /*! |
1059 Set the currend Index of the Grid |
1171 Set the currend Index of the Grid |
1060 */ |
1172 */ |
1061 void CalenMonthView::setCurrGridIndex(int index) |
1173 void CalenMonthView::setCurrGridIndex(int index) |
1062 { |
1174 { |
|
1175 OstTraceFunctionEntry0( CALENMONTHVIEW_SETCURRGRIDINDEX_ENTRY ); |
1063 mIsPrevPaneGesture = true; |
1176 mIsPrevPaneGesture = true; |
1064 mMonthGrid->setCurrentIdex(index); |
1177 mMonthGrid->setCurrentIdex(index); |
|
1178 OstTraceFunctionExit0( CALENMONTHVIEW_SETCURRGRIDINDEX_EXIT ); |
1065 } |
1179 } |
1066 |
1180 |
1067 /*! |
1181 /*! |
1068 Sets the active flag to the required dates in the array |
1182 Sets the active flag to the required dates in the array |
1069 */ |
1183 */ |
1070 void CalenMonthView::updateMonthDataArrayWithActiveDates() |
1184 void CalenMonthView::updateMonthDataArrayWithActiveDates() |
1071 { |
1185 { |
|
1186 OstTraceFunctionEntry0( CALENMONTHVIEW_UPDATEMONTHDATAARRAYWITHACTIVEDATES_ENTRY ); |
|
1187 |
1072 int activeMonth = mActiveMonth.date().month(); |
1188 int activeMonth = mActiveMonth.date().month(); |
1073 int monthDataCount = mMonthDataArray.count(); |
1189 int monthDataCount = mMonthDataArray.count(); |
1074 for (int i = 0; i < monthDataCount; i++) { |
1190 for (int i = 0; i < monthDataCount; i++) { |
1075 if (mMonthDataArray[i].Day().date().month() == activeMonth) { |
1191 if (mMonthDataArray[i].Day().date().month() == activeMonth) { |
1076 // Set the active flag |
1192 // Set the active flag |
1078 } else { |
1194 } else { |
1079 // Disable the active flag |
1195 // Disable the active flag |
1080 mMonthDataArray[i].setActive(false); |
1196 mMonthDataArray[i].setActive(false); |
1081 } |
1197 } |
1082 } |
1198 } |
|
1199 |
|
1200 OstTraceFunctionExit0( CALENMONTHVIEW_UPDATEMONTHDATAARRAYWITHACTIVEDATES_EXIT ); |
1083 } |
1201 } |
1084 |
1202 |
1085 /*! |
1203 /*! |
1086 Fetches the calenda entries for a given range |
1204 Fetches the calenda entries for a given range |
1087 */ |
1205 */ |
1088 void CalenMonthView::getInstanceList(QList<QDate> &list, |
1206 void CalenMonthView::getInstanceList(QList<QDate> &list, |
1089 QDateTime rangeStart, QDateTime rangeEnd) |
1207 QDateTime rangeStart, QDateTime rangeEnd) |
1090 { |
1208 { |
|
1209 OstTraceFunctionEntry0( CALENMONTHVIEW_GETINSTANCELIST_ENTRY ); |
|
1210 |
1091 AgendaUtil::FilterFlags filter = |
1211 AgendaUtil::FilterFlags filter = |
1092 AgendaUtil::FilterFlags(AgendaUtil::IncludeAnniversaries |
1212 AgendaUtil::FilterFlags(AgendaUtil::IncludeAnniversaries |
1093 | AgendaUtil::IncludeAppointments |
1213 | AgendaUtil::IncludeAppointments |
1094 | AgendaUtil::IncludeEvents |
1214 | AgendaUtil::IncludeEvents |
1095 | AgendaUtil::IncludeReminders |
1215 | AgendaUtil::IncludeReminders |
1096 | AgendaUtil::IncludeIncompletedTodos); |
1216 | AgendaUtil::IncludeIncompletedTodos); |
1097 mAgendaUtil->markDatesWithEvents(rangeStart, rangeEnd, filter, list); |
1217 mAgendaUtil->markDatesWithEvents(rangeStart, rangeEnd, filter, list); |
|
1218 |
|
1219 OstTraceFunctionExit0( CALENMONTHVIEW_GETINSTANCELIST_EXIT ); |
1098 } |
1220 } |
1099 |
1221 |
1100 /*! |
1222 /*! |
1101 Parses the fetched entries and sets hasEvent attribute for necessary days |
1223 Parses the fetched entries and sets hasEvent attribute for necessary days |
1102 */ |
1224 */ |
1103 void CalenMonthView::populateWithInstanceView() |
1225 void CalenMonthView::populateWithInstanceView() |
1104 { |
1226 { |
|
1227 OstTraceFunctionEntry0( CALENMONTHVIEW_POPULATEWITHINSTANCEVIEW_ENTRY ); |
|
1228 |
1105 const QDateTime today(CalenDateUtils::today()); |
1229 const QDateTime today(CalenDateUtils::today()); |
1106 const QDateTime gridStart(CalenDateUtils::beginningOfDay(mFirstDayOfGrid)); |
1230 const QDateTime gridStart(CalenDateUtils::beginningOfDay(mFirstDayOfGrid)); |
1107 |
1231 |
1108 // grid index for "today" |
1232 // grid index for "today" |
1109 const int todayIndex(gridStart.daysTo(today)); |
1233 const int todayIndex(gridStart.daysTo(today)); |
1118 int datesEventsCount = datesWithEvents.count(); |
1242 int datesEventsCount = datesWithEvents.count(); |
1119 for(int i(0); i < datesEventsCount; i++) { |
1243 for(int i(0); i < datesEventsCount; i++) { |
1120 int offset = mFirstDayOfGrid.date().daysTo(datesWithEvents.at(i)); |
1244 int offset = mFirstDayOfGrid.date().daysTo(datesWithEvents.at(i)); |
1121 mMonthDataArray[offset].SetHasEvents(true); |
1245 mMonthDataArray[offset].SetHasEvents(true); |
1122 } |
1246 } |
1123 |
|
1124 datesWithEvents.clear(); |
1247 datesWithEvents.clear(); |
|
1248 |
|
1249 if (datesEventsCount) { |
|
1250 mEntriesInDataBase = true; |
|
1251 } |
|
1252 |
|
1253 OstTraceFunctionExit0( CALENMONTHVIEW_POPULATEWITHINSTANCEVIEW_EXIT ); |
1125 } |
1254 } |
1126 |
1255 |
1127 /*! |
1256 /*! |
1128 Parses the fetched entries for previous month and |
1257 Parses the fetched entries for previous month and |
1129 sets hasEvent attribute for necessary days |
1258 sets hasEvent attribute for necessary days |
1130 */ |
1259 */ |
1131 void CalenMonthView::populatePrevMonth() |
1260 void CalenMonthView::populatePrevMonth() |
1132 { |
1261 { |
|
1262 OstTraceFunctionEntry0( CALENMONTHVIEW_POPULATEPREVMONTH_ENTRY ); |
|
1263 |
1133 const QDateTime gridStart(CalenDateUtils::beginningOfDay(mFirstDayOfGrid)); |
1264 const QDateTime gridStart(CalenDateUtils::beginningOfDay(mFirstDayOfGrid)); |
1134 const QDateTime today(CalenDateUtils::today()); |
1265 const QDateTime today(CalenDateUtils::today()); |
1135 |
1266 |
1136 const int todayIndex(gridStart.daysTo(today)); // grid index for "today" |
1267 const int todayIndex(gridStart.daysTo(today)); // grid index for "today" |
1137 QDateTime end = gridStart.addDays(mNumOfRowsInPrevMonth * KCalenDaysInWeek); |
1268 QDateTime end = gridStart.addDays(mNumOfRowsInPrevMonth * KCalenDaysInWeek); |
1147 for(int i(0); i < datesEventsCount; i++) { |
1278 for(int i(0); i < datesEventsCount; i++) { |
1148 int offset = mFirstDayOfGrid.date().daysTo(datesWithEvents.at(i)); |
1279 int offset = mFirstDayOfGrid.date().daysTo(datesWithEvents.at(i)); |
1149 mMonthDataArray[offset].SetHasEvents(true); |
1280 mMonthDataArray[offset].SetHasEvents(true); |
1150 } |
1281 } |
1151 datesWithEvents.clear(); |
1282 datesWithEvents.clear(); |
|
1283 |
|
1284 if (datesEventsCount) { |
|
1285 mEntriesInDataBase = true; |
|
1286 } |
|
1287 |
|
1288 OstTraceFunctionExit0( CALENMONTHVIEW_POPULATEPREVMONTH_EXIT ); |
1152 } |
1289 } |
1153 |
1290 |
1154 /*! |
1291 /*! |
1155 Parses the fetched entries for future month and |
1292 Parses the fetched entries for future month and |
1156 sets hasEvent attribute for necessary days |
1293 sets hasEvent attribute for necessary days |
1157 */ |
1294 */ |
1158 void CalenMonthView::populateNextMonth() |
1295 void CalenMonthView::populateNextMonth() |
1159 { |
1296 { |
|
1297 OstTraceFunctionEntry0( CALENMONTHVIEW_POPULATENEXTMONTH_ENTRY ); |
1160 QList<AgendaEntry> list; |
1298 QList<AgendaEntry> list; |
1161 int actualIndex = mNumOfRowsInFutureMonth * KCalenDaysInWeek; |
1299 int actualIndex = mNumOfRowsInFutureMonth * KCalenDaysInWeek; |
1162 const QDateTime gridStart(mLastDayOfGrid.addDays(-actualIndex)); |
1300 const QDateTime gridStart(mLastDayOfGrid.addDays(-actualIndex)); |
1163 actualIndex = mMonthDataArray.count() - actualIndex -1; |
1301 actualIndex = mMonthDataArray.count() - actualIndex -1; |
1164 |
1302 |
1175 for(int i(0); i < datesEventsCount; i++) { |
1313 for(int i(0); i < datesEventsCount; i++) { |
1176 int offset = mFirstDayOfGrid.date().daysTo(datesWithEvents.at(i)); |
1314 int offset = mFirstDayOfGrid.date().daysTo(datesWithEvents.at(i)); |
1177 mMonthDataArray[offset].SetHasEvents(true); |
1315 mMonthDataArray[offset].SetHasEvents(true); |
1178 } |
1316 } |
1179 datesWithEvents.clear(); |
1317 datesWithEvents.clear(); |
|
1318 |
|
1319 if (datesEventsCount) { |
|
1320 mEntriesInDataBase = true; |
|
1321 } |
|
1322 OstTraceFunctionExit0( CALENMONTHVIEW_POPULATENEXTMONTH_EXIT ); |
1180 } |
1323 } |
1181 |
1324 |
1182 /*! |
1325 /*! |
1183 Function that gets called when instacne view is created, so that it can |
1326 Function that gets called when instacne view is created, so that it can |
1184 query agenda server for any entries |
1327 query agenda server for any entries |
1185 */ |
1328 */ |
1186 void CalenMonthView::fetchEntriesAndUpdateModel() |
1329 void CalenMonthView::fetchEntriesAndUpdateModel() |
1187 { |
1330 { |
|
1331 OstTraceFunctionEntry0( CALENMONTHVIEW_FETCHENTRIESANDUPDATEMODEL_ENTRY ); |
|
1332 |
1188 // Get to know if entries are there from the agenda server |
1333 // Get to know if entries are there from the agenda server |
1189 populateWithInstanceView(); |
1334 populateWithInstanceView(); |
1190 // Update the month grid model |
1335 // Update the month grid model |
1191 mMonthGrid->updateMonthGridWithEventIndicators(mMonthDataArray); |
1336 mMonthGrid->updateMonthGridWithEventIndicators(mMonthDataArray); |
1192 // Populate the preview panes |
1337 // Populate the preview panes |
1193 populatePreviewPane(mDate); |
1338 populatePreviewPane(mDate); |
|
1339 |
|
1340 OstTraceFunctionExit0( CALENMONTHVIEW_FETCHENTRIESANDUPDATEMODEL_EXIT ); |
1194 } |
1341 } |
1195 |
1342 |
1196 /*! |
1343 /*! |
1197 Populates the preview pane |
1344 Populates the preview pane |
1198 */ |
1345 */ |
1199 void CalenMonthView::populatePreviewPane(QDateTime &dateTime) |
1346 void CalenMonthView::populatePreviewPane(QDateTime &dateTime) |
1200 { |
1347 { |
|
1348 OstTraceFunctionEntry0( CALENMONTHVIEW_POPULATEPREVIEWPANE_ENTRY ); |
|
1349 |
1201 mPrevPreviewPane->populateLabel(dateTime.addDays(-1)); |
1350 mPrevPreviewPane->populateLabel(dateTime.addDays(-1)); |
1202 mCurrPreviewPane->populateLabel(dateTime); |
1351 mCurrPreviewPane->populateLabel(dateTime); |
1203 mNextPreviewPane->populateLabel(dateTime.addDays(1)); |
1352 mNextPreviewPane->populateLabel(dateTime.addDays(1)); |
1204 |
1353 |
1205 // Start the auto scroll on current preview pane |
1354 // Start the auto scroll on current preview pane |
1206 mCurrPreviewPane->startAutoScroll(); |
1355 mCurrPreviewPane->startAutoScroll(); |
|
1356 |
|
1357 OstTraceFunctionExit0( CALENMONTHVIEW_POPULATEPREVIEWPANE_EXIT ); |
1207 } |
1358 } |
1208 |
1359 |
1209 /*! |
1360 /*! |
1210 Completes the population after setting the view as |
1361 Completes the population after setting the view as |
1211 current view to the main window |
1362 current view to the main window |
1212 */ |
1363 */ |
1213 void CalenMonthView::completePopulation() |
1364 void CalenMonthView::completePopulation() |
1214 { |
1365 { |
|
1366 OstTraceFunctionEntry0( CALENMONTHVIEW_COMPLETEPOPULATION_ENTRY ); |
|
1367 |
1215 setDateToLabel(); |
1368 setDateToLabel(); |
|
1369 |
|
1370 OstTraceFunctionExit0( CALENMONTHVIEW_COMPLETEPOPULATION_EXIT ); |
1216 } |
1371 } |
1217 |
1372 |
1218 /*! |
1373 /*! |
1219 Launches the day view on tapping of the grid item |
1374 Launches the day view on tapping of the grid item |
1220 */ |
1375 */ |
1221 void CalenMonthView::handleGridItemActivated() |
1376 void CalenMonthView::handleGridItemActivated() |
1222 { |
1377 { |
|
1378 OstTraceFunctionEntry0( CALENMONTHVIEW_HANDLEGRIDITEMACTIVATED_ENTRY ); |
|
1379 |
1223 mServices.IssueCommandL(ECalenDayView); |
1380 mServices.IssueCommandL(ECalenDayView); |
|
1381 |
|
1382 OstTraceFunctionExit0( CALENMONTHVIEW_HANDLEGRIDITEMACTIVATED_EXIT ); |
1224 } |
1383 } |
1225 |
1384 |
1226 /*! |
1385 /*! |
1227 Sets the context w.r.t to the active day |
1386 Sets the context w.r.t to the active day |
1228 */ |
1387 */ |
1229 void CalenMonthView::setContextForActiveDay(int index) |
1388 void CalenMonthView::setContextForActiveDay(int index) |
1230 { |
1389 { |
|
1390 OstTraceFunctionEntry0( CALENMONTHVIEW_SETCONTEXTFORACTIVEDAY_ENTRY ); |
1231 QDateTime newActiveDay = mFirstDayOfGrid.addDays(index); |
1391 QDateTime newActiveDay = mFirstDayOfGrid.addDays(index); |
1232 // Set the context |
1392 // Set the context |
1233 mServices.Context().setFocusDate(newActiveDay); |
1393 mServices.Context().setFocusDate(newActiveDay); |
1234 mDate = newActiveDay; |
1394 mDate = newActiveDay; |
1235 setDateToLabel(); |
1395 setDateToLabel(); |
1239 } else { |
1399 } else { |
1240 // reset flag |
1400 // reset flag |
1241 mIsPrevPaneGesture = false; |
1401 mIsPrevPaneGesture = false; |
1242 } |
1402 } |
1243 |
1403 |
|
1404 OstTraceFunctionExit0( CALENMONTHVIEW_SETCONTEXTFORACTIVEDAY_EXIT ); |
1244 } |
1405 } |
1245 |
1406 |
1246 /*! |
1407 /*! |
1247 Slot to launch the event editor |
1408 Slot to launch the event editor |
1248 */ |
1409 */ |
1249 void CalenMonthView::createEditor() |
1410 void CalenMonthView::createEditor() |
1250 { |
1411 { |
|
1412 OstTraceFunctionEntry0( CALENMONTHVIEW_CREATEEDITOR_ENTRY ); |
|
1413 |
|
1414 captureScreenshot(true); |
1251 mServices.IssueCommandL(ECalenNewMeeting); |
1415 mServices.IssueCommandL(ECalenNewMeeting); |
|
1416 |
|
1417 OstTraceFunctionExit0( CALENMONTHVIEW_CREATEEDITOR_EXIT ); |
1252 } |
1418 } |
1253 |
1419 |
1254 /*! |
1420 /*! |
1255 Slot to launch the Day view |
1421 Slot to launch the Day view |
1256 */ |
1422 */ |
1257 void CalenMonthView::launchDayView() |
1423 void CalenMonthView::launchDayView() |
1258 { |
1424 { |
|
1425 OstTraceFunctionEntry0( CALENMONTHVIEW_LAUNCHDAYVIEW_ENTRY ); |
|
1426 |
1259 mServices.IssueCommandL(ECalenDayView); |
1427 mServices.IssueCommandL(ECalenDayView); |
1260 // day view launched now, disconnect to get the call backs for saveActivity |
1428 // day view launched now, disconnect to get the call backs for saveActivity |
1261 // on aboutToQuit signal |
1429 // on aboutToQuit signal |
1262 if (mIsAboutToQuitEventConnected) |
1430 if (mIsAboutToQuitEventConnected) |
1263 { |
1431 { |
1264 disconnect(qobject_cast<HbApplication*>(qApp), SIGNAL(aboutToQuit()), this, SLOT(saveActivity())); |
1432 disconnect(qobject_cast<HbApplication*>(qApp), SIGNAL(aboutToQuit()), this, SLOT(saveActivity())); |
1265 mIsAboutToQuitEventConnected = false; |
1433 mIsAboutToQuitEventConnected = false; |
1266 } |
1434 } |
|
1435 |
|
1436 OstTraceFunctionExit0( CALENMONTHVIEW_LAUNCHDAYVIEW_EXIT ); |
1267 } |
1437 } |
1268 |
1438 |
1269 /*! |
1439 /*! |
1270 Slot to handle the change in orientation |
1440 Slot to handle the change in orientation |
1271 */ |
1441 */ |
1272 void CalenMonthView::changeOrientation(Qt::Orientation orientation) |
1442 void CalenMonthView::changeOrientation(Qt::Orientation orientation) |
1273 { |
1443 { |
|
1444 OstTraceFunctionEntry0( CALENMONTHVIEW_CHANGEORIENTATION_ENTRY ); |
|
1445 |
1274 if (mOrientation != orientation) { |
1446 if (mOrientation != orientation) { |
1275 // change the orientation here |
1447 // change the orientation here |
1276 mOrientation = orientation; |
1448 mOrientation = orientation; |
1277 handleChangeOrientation(); |
1449 handleChangeOrientation(); |
1278 } |
1450 } |
|
1451 |
|
1452 OstTraceFunctionExit0( CALENMONTHVIEW_CHANGEORIENTATION_EXIT ); |
1279 } |
1453 } |
1280 |
1454 |
1281 /*! |
1455 /*! |
1282 Loads appropriate section from the docml dsepending on the current orientation |
1456 Loads appropriate section from the docml dsepending on the current orientation |
1283 of the device |
1457 of the device |
1284 */ |
1458 */ |
1285 void CalenMonthView::handleChangeOrientation() |
1459 void CalenMonthView::handleChangeOrientation() |
1286 { |
1460 { |
|
1461 OstTraceFunctionEntry0( CALENMONTHVIEW_HANDLECHANGEORIENTATION_ENTRY ); |
|
1462 |
1287 bool loadSuccess = false; |
1463 bool loadSuccess = false; |
1288 if (mOrientation == Qt::Horizontal) { |
1464 if (mOrientation == Qt::Horizontal) { |
1289 mDocLoader->load(CALEN_MONTHVIEW_XML_FILE, CALEN_LANDSCAPE, |
1465 mDocLoader->load(CALEN_MONTHVIEW_XML_FILE, CALEN_LANDSCAPE, |
1290 &loadSuccess); |
1466 &loadSuccess); |
1291 |
1467 |
1305 // if it is changed in other views, adding the preview pane here was |
1481 // if it is changed in other views, adding the preview pane here was |
1306 // overlapping with the month grid, hence, its been added in dopopulation() |
1482 // overlapping with the month grid, hence, its been added in dopopulation() |
1307 if (this == mServices.MainWindow().currentView()) { |
1483 if (this == mServices.MainWindow().currentView()) { |
1308 viewLayout->addItem(mCurrPaneParent); |
1484 viewLayout->addItem(mCurrPaneParent); |
1309 } |
1485 } |
|
1486 |
|
1487 OstTraceFunctionExit0( CALENMONTHVIEW_HANDLECHANGEORIENTATION_EXIT ); |
1310 } |
1488 } |
1311 |
1489 |
1312 /*! |
1490 /*! |
1313 Sets the appropriate date to the month title |
1491 Sets the appropriate date to the month title |
1314 */ |
1492 */ |
1315 void CalenMonthView::setDateToLabel() |
1493 void CalenMonthView::setDateToLabel() |
1316 { |
1494 { |
|
1495 OstTraceFunctionEntry0( CALENMONTHVIEW_SETDATETOLABEL_ENTRY ); |
|
1496 |
1317 // Get the localised string for month name from system locale |
1497 // Get the localised string for month name from system locale |
1318 QString monthString = mLocale.monthName(mDate.date().month(), HbExtendedLocale::LongFormat); |
1498 QString dateString = mLocale.monthName(mDate.date().month(), HbExtendedLocale::LongFormat); |
1319 // Append a single space |
1499 // Append a single space |
1320 monthString.append(" "); |
1500 dateString.append(" "); |
1321 mLocale.setNumberOptions(QLocale::OmitGroupSeparator); |
1501 mLocale.setNumberOptions(QLocale::OmitGroupSeparator); |
1322 QString yearString = mLocale.toString(mDate.date().year()); |
1502 // Append the year string also |
1323 mTitleLabel->setPlainText(hbTrId("txt_calendar_month_label_title_12").arg(monthString).arg(yearString)); |
1503 dateString.append(mLocale.toString(mDate.date().year())); |
|
1504 mTitleLabel->setPlainText(dateString); |
|
1505 |
|
1506 OstTraceFunctionExit0( CALENMONTHVIEW_SETDATETOLABEL_EXIT ); |
1324 } |
1507 } |
1325 |
1508 |
1326 /*! |
1509 /*! |
1327 To handle previewpane swipe |
1510 To handle previewpane swipe |
1328 */ |
1511 */ |
1329 void CalenMonthView::handlePreviewPaneGesture(bool rightGesture) |
1512 void CalenMonthView::handlePreviewPaneGesture(bool rightGesture) |
1330 { |
1513 { |
|
1514 OstTraceFunctionEntry0( CALENMONTHVIEW_HANDLEPREVIEWPANEGESTURE_ENTRY ); |
|
1515 |
1331 QGraphicsLinearLayout* viewLayout = static_cast<QGraphicsLinearLayout *> |
1516 QGraphicsLinearLayout* viewLayout = static_cast<QGraphicsLinearLayout *> |
1332 (widget()->layout()); |
1517 (widget()->layout()); |
|
1518 |
|
1519 // Set the effect in progress flags for next and previous panes |
|
1520 // For current pane, we would have set it in gestureEvent() function |
|
1521 mPrevPreviewPane->effectStarted(); |
|
1522 mNextPreviewPane->effectStarted(); |
|
1523 |
1333 if(rightGesture) { |
1524 if(rightGesture) { |
1334 // Need to bring up the previous day preview pane |
1525 // Need to bring up the previous day preview pane |
1335 // Create the effect on mCurrPreviewPane to slide to right side |
1526 // Create the effect on mCurrPreviewPane to slide to right side |
1336 mPrevPaneParent->setVisible(true); |
1527 mPrevPaneParent->setVisible(true); |
1337 if (mOrientation == Qt::Vertical) { |
1528 if (mOrientation == Qt::Vertical) { |
1386 //Remove the mCurrPreviewPane from the layout and add mNextPreviewPane |
1577 //Remove the mCurrPreviewPane from the layout and add mNextPreviewPane |
1387 // to the layout |
1578 // to the layout |
1388 viewLayout->removeAt(1); |
1579 viewLayout->removeAt(1); |
1389 viewLayout->addItem(mNextPaneParent); |
1580 viewLayout->addItem(mNextPaneParent); |
1390 } |
1581 } |
|
1582 |
|
1583 OstTraceFunctionExit0( CALENMONTHVIEW_HANDLEPREVIEWPANEGESTURE_EXIT ); |
1391 } |
1584 } |
1392 |
1585 |
1393 /*! |
1586 /*! |
1394 Returns the first date in the month grid |
1587 Returns the first date in the month grid |
1395 */ |
1588 */ |
1396 QDateTime CalenMonthView::firstDayOfGrid() |
1589 QDateTime CalenMonthView::firstDayOfGrid() |
1397 { |
1590 { |
|
1591 OstTraceFunctionEntry0( CALENMONTHVIEW_FIRSTDAYOFGRID_ENTRY ); |
|
1592 |
|
1593 OstTraceFunctionExit0( CALENMONTHVIEW_FIRSTDAYOFGRID_EXIT ); |
1398 return mFirstDayOfGrid; |
1594 return mFirstDayOfGrid; |
1399 } |
1595 } |
1400 |
1596 |
1401 /*! |
1597 /*! |
1402 Function to handle any locale related changes |
1598 Function to handle any locale related changes |
1403 */ |
1599 */ |
1404 void CalenMonthView::onLocaleChanged(int reason) |
1600 void CalenMonthView::onLocaleChanged(int reason) |
1405 { |
1601 { |
1406 Q_UNUSED(reason); |
1602 OstTraceFunctionEntry0( CALENMONTHVIEW_ONLOCALECHANGED_ENTRY ); |
|
1603 |
|
1604 if ((reason & EChangesSystemTime) |
|
1605 || (reason & EChangesMidnightCrossover)) { |
|
1606 mCurrentDay = CalenDateUtils::today(); |
|
1607 } |
|
1608 OstTraceFunctionExit0( CALENMONTHVIEW_ONLOCALECHANGED_EXIT ); |
1407 } |
1609 } |
1408 |
1610 |
1409 /*! |
1611 /*! |
1410 Slot to handle left gesture effects completion |
1612 Slot to handle left gesture effects completion |
1411 */ |
1613 */ |
1412 void CalenMonthView::handleLeftEffectCompleted( |
1614 void CalenMonthView::handleLeftEffectCompleted( |
1413 const HbEffect::EffectStatus &status) |
1615 const HbEffect::EffectStatus &status) |
1414 { |
1616 { |
|
1617 OstTraceFunctionEntry0( CALENMONTHVIEW_HANDLELEFTEFFECTCOMPLETED_ENTRY ); |
1415 Q_UNUSED(status); |
1618 Q_UNUSED(status); |
1416 |
1619 |
1417 int index = getCurrGridIndex(); |
1620 int index = getCurrGridIndex(); |
1418 index++; |
1621 index++; |
1419 |
1622 |
1432 mNextPaneLayoutWidget = mPrevPaneLayoutWidget; |
1635 mNextPaneLayoutWidget = mPrevPaneLayoutWidget; |
1433 mPrevPreviewPane = pane; |
1636 mPrevPreviewPane = pane; |
1434 mPrevPaneParent = paneParent; |
1637 mPrevPaneParent = paneParent; |
1435 mPrevPaneLayoutWidget = paneLayoutWidget; |
1638 mPrevPaneLayoutWidget = paneLayoutWidget; |
1436 |
1639 |
|
1640 // Reset the effect in progress flag |
|
1641 mCurrPreviewPane->effectFinished(); |
|
1642 mPrevPreviewPane->effectFinished(); |
|
1643 mNextPreviewPane->effectFinished(); |
|
1644 |
1437 // Set the focus to proper date |
1645 // Set the focus to proper date |
1438 setCurrGridIndex(index); |
1646 setCurrGridIndex(index); |
1439 // Start the auto scroll on current preview pane |
1647 // Start the auto scroll on current preview pane |
1440 mCurrPreviewPane->startAutoScroll(); |
1648 mCurrPreviewPane->startAutoScroll(); |
1441 mNextPreviewPane->populateLabel(mDate.addDays(1)); |
1649 mNextPreviewPane->populateLabel(mDate.addDays(1)); |
|
1650 OstTraceFunctionExit0( CALENMONTHVIEW_HANDLELEFTEFFECTCOMPLETED_EXIT ); |
1442 } |
1651 } |
1443 |
1652 |
1444 /*! |
1653 /*! |
1445 Slot to handle right gesture effects completion |
1654 Slot to handle right gesture effects completion |
1446 */ |
1655 */ |
1447 void CalenMonthView::handleRightEffectCompleted( |
1656 void CalenMonthView::handleRightEffectCompleted( |
1448 const HbEffect::EffectStatus &status) |
1657 const HbEffect::EffectStatus &status) |
1449 { |
1658 { |
|
1659 OstTraceFunctionEntry0( CALENMONTHVIEW_HANDLERIGHTEFFECTCOMPLETED_ENTRY ); |
|
1660 |
1450 Q_UNUSED(status); |
1661 Q_UNUSED(status); |
1451 |
1662 |
1452 int index = getCurrGridIndex(); |
1663 int index = getCurrGridIndex(); |
1453 index--; |
1664 index--; |
1454 |
1665 |
1467 mPrevPaneLayoutWidget = mNextPaneLayoutWidget; |
1678 mPrevPaneLayoutWidget = mNextPaneLayoutWidget; |
1468 mNextPreviewPane = pane; |
1679 mNextPreviewPane = pane; |
1469 mNextPaneParent = paneParent; |
1680 mNextPaneParent = paneParent; |
1470 mNextPaneLayoutWidget = paneLayoutWidget; |
1681 mNextPaneLayoutWidget = paneLayoutWidget; |
1471 |
1682 |
|
1683 // Reset the effect in progress flag |
|
1684 mCurrPreviewPane->effectFinished(); |
|
1685 mNextPreviewPane->effectFinished(); |
|
1686 mPrevPreviewPane->effectFinished(); |
|
1687 |
1472 // Set the focus to proper date |
1688 // Set the focus to proper date |
1473 setCurrGridIndex(index); |
1689 setCurrGridIndex(index); |
1474 // Start the auto scroll on current preview pane |
1690 // Start the auto scroll on current preview pane |
1475 mCurrPreviewPane->startAutoScroll(); |
1691 mCurrPreviewPane->startAutoScroll(); |
1476 mPrevPreviewPane->populateLabel(mDate.addDays(-1)); |
1692 mPrevPreviewPane->populateLabel(mDate.addDays(-1)); |
|
1693 |
|
1694 OstTraceFunctionExit0( CALENMONTHVIEW_HANDLERIGHTEFFECTCOMPLETED_EXIT ); |
1477 } |
1695 } |
1478 /*! |
1696 /*! |
1479 update the Day labels |
1697 update the Day labels |
1480 */ |
1698 */ |
1481 void CalenMonthView::updateDayLabel() |
1699 void CalenMonthView::updateDayLabel() |
1482 { |
1700 { |
|
1701 OstTraceFunctionEntry0( CALENMONTHVIEW_UPDATEDAYLABEL_ENTRY ); |
|
1702 |
1483 // Set the short day names to these labels |
1703 // Set the short day names to these labels |
1484 int startOfWeek = mLocale.startOfWeek(); |
1704 int startOfWeek = mLocale.startOfWeek(); |
1485 int weekDayIndex = startOfWeek; |
1705 int weekDayIndex = startOfWeek; |
1486 QStringList weekDayArray ; |
1706 QStringList weekDayArray ; |
1487 weekDayArray <<hbTrId("txt_calendar_grid_day_mo") |
1707 weekDayArray <<hbTrId("txt_calendar_grid_day_mo") |