69 mIsAboutToQuitEventConnected(false) |
69 mIsAboutToQuitEventConnected(false) |
70 { |
70 { |
71 mIsWeekNumbersShown = 0; |
71 mIsWeekNumbersShown = 0; |
72 mOrientation = mServices.MainWindow().orientation(); |
72 mOrientation = mServices.MainWindow().orientation(); |
73 // Read the date from the context |
73 // Read the date from the context |
74 mDate = mServices.Context().focusDateAndTimeL(); |
74 mDate = mServices.Context().focusDateAndTime(); |
75 mCurrentDay = mDate; |
75 mCurrentDay = mDate; |
76 |
76 |
77 // Create the settings manager instance and settings key for week number |
77 // Create the settings manager instance and settings key for week number |
78 mSettingsManager = new XQSettingsManager(this); |
78 mSettingsManager = new XQSettingsManager(this); |
79 mWeekNumberCenrepKey |
79 mWeekNumberCenrepKey |
104 mTitleLabel |
104 mTitleLabel |
105 = qobject_cast<HbLabel *> ( |
105 = qobject_cast<HbLabel *> ( |
106 mDocLoader->findWidget(CALEN_MONTH_TITLE)); |
106 mDocLoader->findWidget(CALEN_MONTH_TITLE)); |
107 // Set the title text color |
107 // Set the title text color |
108 QColor monthTitleColor = HbColorScheme::color("qtc_cal_monthgrid_title"); |
108 QColor monthTitleColor = HbColorScheme::color("qtc_cal_monthgrid_title"); |
109 if (monthTitleColor.isValid()) { |
109 if (mTitleLabel && monthTitleColor.isValid()) { |
110 mTitleLabel->setTextColor(monthTitleColor); |
110 mTitleLabel->setTextColor(monthTitleColor); |
111 } |
111 } |
112 |
112 |
113 mDayNameWidget |
113 mDayNameWidget |
114 = qobject_cast<CalenThickLinesDrawer *> ( |
114 = qobject_cast<CalenThickLinesDrawer *> ( |
428 monthViewExceptPreviewPane->setBackgroundItem(frame->graphicsItem(), -2); |
428 monthViewExceptPreviewPane->setBackgroundItem(frame->graphicsItem(), -2); |
429 } |
429 } |
430 if (mTitleLabel) { |
430 if (mTitleLabel) { |
431 // The month title |
431 // The month title |
432 drawer = new HbFrameDrawer("qtg_fr_cal_monthgrid_title_bg", HbFrameDrawer::ThreePiecesHorizontal); |
432 drawer = new HbFrameDrawer("qtg_fr_cal_monthgrid_title_bg", HbFrameDrawer::ThreePiecesHorizontal); |
433 frame = new HbFrameItem(drawer, this); |
433 if (drawer) |
434 mTitleLabel->setBackgroundItem(frame->graphicsItem(), -2); |
434 frame = new HbFrameItem(drawer, this); |
|
435 if(frame) |
|
436 mTitleLabel->setBackgroundItem(frame->graphicsItem(), -2); |
435 } |
437 } |
436 |
438 |
437 // Set the frame to the preview pane |
439 // Set the frame to the preview pane |
438 drawer = new HbFrameDrawer("qtg_fr_cal_preview_bg", HbFrameDrawer::NinePieces); |
440 drawer = new HbFrameDrawer("qtg_fr_cal_preview_bg", HbFrameDrawer::NinePieces); |
439 frame = new HbFrameItem(drawer, this); |
441 if (drawer) |
440 mPrevPaneLayoutWidget->setBackgroundItem(frame->graphicsItem(), -5); |
442 frame = new HbFrameItem(drawer, this); |
|
443 if(frame) |
|
444 mPrevPaneLayoutWidget->setBackgroundItem(frame->graphicsItem(), -5); |
441 |
445 |
442 // Set the frame to the preview pane |
446 // Set the frame to the preview pane |
443 drawer = new HbFrameDrawer("qtg_fr_cal_preview_bg", HbFrameDrawer::NinePieces); |
447 drawer = new HbFrameDrawer("qtg_fr_cal_preview_bg", HbFrameDrawer::NinePieces); |
444 frame = new HbFrameItem(drawer, this); |
448 if(drawer) |
|
449 frame = new HbFrameItem(drawer, this); |
|
450 if(frame) |
445 mCurrPaneLayoutWidget->setBackgroundItem(frame->graphicsItem(), -5); |
451 mCurrPaneLayoutWidget->setBackgroundItem(frame->graphicsItem(), -5); |
446 |
452 |
447 // Set the frame to the preview pane |
453 // Set the frame to the preview pane |
448 drawer = new HbFrameDrawer("qtg_fr_cal_preview_bg", HbFrameDrawer::NinePieces); |
454 drawer = new HbFrameDrawer("qtg_fr_cal_preview_bg", HbFrameDrawer::NinePieces); |
|
455 if(drawer) |
449 frame = new HbFrameItem(drawer, this); |
456 frame = new HbFrameItem(drawer, this); |
450 mNextPaneLayoutWidget->setBackgroundItem(frame->graphicsItem(), -5); |
457 if(frame) |
|
458 mNextPaneLayoutWidget->setBackgroundItem(frame->graphicsItem(), -5); |
451 } |
459 } |
452 |
460 |
453 void CalenMonthView::showHideRegionalInformation() |
461 void CalenMonthView::showHideRegionalInformation() |
454 { |
462 { |
455 if (pluginEnabled()) { |
463 if (pluginEnabled()) { |
581 Populates the month view with today as focussed item |
589 Populates the month view with today as focussed item |
582 */ |
590 */ |
583 void CalenMonthView::goToToday() |
591 void CalenMonthView::goToToday() |
584 { |
592 { |
585 QDateTime today = CalenDateUtils::today(); |
593 QDateTime today = CalenDateUtils::today(); |
|
594 // Set the context and repopulate the view |
|
595 MCalenContext &context = mServices.Context(); |
|
596 context.setFocusDateAndTime(today); |
|
597 |
586 // First check if we are not alread |
598 // First check if we are not alread |
587 // showing today's month view |
599 // showing today's month view |
588 if (mDate == today) { |
600 if (mDate == today) { |
589 return; |
601 return; |
590 } else if (mActiveMonth.date().year() == today.date().year() && |
602 } else if (mActiveMonth.date().year() == today.date().year() && |
591 mActiveMonth.date().month() == today.date().month()) { |
603 mActiveMonth.date().month() == today.date().month()) { |
|
604 mDate = today; |
592 // User is in current month only, so just set the focus to current |
605 // User is in current month only, so just set the focus to current |
593 // date grid item and refresh the preview pane |
606 // date grid item and refresh the preview pane |
594 int currIndex = mFirstDayOfGrid.daysTo(today); |
607 int currIndex = mFirstDayOfGrid.daysTo(today); |
595 setCurrGridIndex(currIndex); |
608 setCurrGridIndex(currIndex); |
596 return; |
609 // Populate the preview panes |
597 } |
610 populatePreviewPane(mDate); |
598 |
611 } else { |
599 // Set the context and repopulate the view |
612 refreshViewOnGoToDate(); |
600 MCalenContext &context = mServices.Context(); |
613 } |
601 context.setFocusDateAndTimeL(today, KCalenMonthViewUidValue); |
|
602 |
|
603 refreshViewOnGoToDate(); |
|
604 } |
614 } |
605 |
615 |
606 /* |
616 /* |
607 Slot to handle adding / removing actions frm the menu when menu is about to |
617 Slot to handle adding / removing actions frm the menu when menu is about to |
608 shown to the user |
618 shown to the user |
704 /*! |
714 /*! |
705 Slot to handle gotodate action |
715 Slot to handle gotodate action |
706 */ |
716 */ |
707 void CalenMonthView::refreshViewOnGoToDate() |
717 void CalenMonthView::refreshViewOnGoToDate() |
708 { |
718 { |
709 setActiveDay(dateFromContext(mServices.Context())); |
719 prepareForPopulation(); |
710 setDate(); |
|
711 updateMonthDataArrayWithActiveDates(); |
|
712 setDateToLabel(); |
720 setDateToLabel(); |
713 // fetch list of required calendar instances |
721 // fetch list of required calendar instances |
714 populateWithInstanceView(); |
722 populateWithInstanceView(); |
715 |
723 |
716 populatePreviewPane(mDate); |
724 populatePreviewPane(mDate); |
729 QDateTime CalenMonthView::dateFromContext(const MCalenContext &context) |
737 QDateTime CalenMonthView::dateFromContext(const MCalenContext &context) |
730 { |
738 { |
731 QDateTime ret; |
739 QDateTime ret; |
732 if (AgendaEntry::TypeTodo == context.instanceId().mType) { |
740 if (AgendaEntry::TypeTodo == context.instanceId().mType) { |
733 QDateTime today = CalenDateUtils::today(); |
741 QDateTime today = CalenDateUtils::today(); |
734 if (context.focusDateAndTimeL() < today) { |
742 if (context.focusDateAndTime() < today) { |
735 ret = today; |
743 ret = today; |
736 } else { |
744 } else { |
737 ret = context.focusDateAndTimeL(); |
745 ret = context.focusDateAndTime(); |
738 } |
746 } |
739 } else { |
747 } else { |
740 ret = context.focusDateAndTimeL(); |
748 ret = context.focusDateAndTime(); |
741 } |
749 } |
742 return ret; |
750 return ret; |
743 } |
751 } |
744 |
752 |
745 /*! |
753 /*! |
757 // Get the first day of the month |
765 // Get the first day of the month |
758 QDate date = prevMonthDate.date(); |
766 QDate date = prevMonthDate.date(); |
759 date.setDate(date.year(), date.month(), 1); |
767 date.setDate(date.year(), date.month(), 1); |
760 QDateTime firstDayOfPrevMonth(date, day.time()); |
768 QDateTime firstDayOfPrevMonth(date, day.time()); |
761 |
769 |
762 // TODO: Need to consider the week start frm the locale object |
|
763 TLocale locale; |
|
764 int offset(firstDayOfPrevMonth.date().dayOfWeek() - (mLocale.startOfWeek() |
770 int offset(firstDayOfPrevMonth.date().dayOfWeek() - (mLocale.startOfWeek() |
765 + 1)); |
771 + 1)); |
766 if (offset < 0) { |
772 if (offset < 0) { |
767 offset += KCalenDaysInWeek; |
773 offset += KCalenDaysInWeek; |
768 } |
774 } |
965 QDateTime futureMonthDateTime = mActiveMonth.addMonths(2); |
971 QDateTime futureMonthDateTime = mActiveMonth.addMonths(2); |
966 QDate date = futureMonthDateTime.date(); |
972 QDate date = futureMonthDateTime.date(); |
967 date.setDate(date.year(), date.month(), 1); |
973 date.setDate(date.year(), date.month(), 1); |
968 // Get the first day of the future month |
974 // Get the first day of the future month |
969 QDateTime firstDayOfFutMonth(date, futureMonthDateTime.time()); |
975 QDateTime firstDayOfFutMonth(date, futureMonthDateTime.time()); |
970 TLocale locale; |
976 |
971 int offset = firstDayOfFutMonth.date().dayOfWeek() - (mLocale.startOfWeek() |
977 int offset = firstDayOfFutMonth.date().dayOfWeek() - (mLocale.startOfWeek() |
972 + 1); |
978 + 1); |
973 if (offset < 0) { |
979 if (offset < 0) { |
974 offset += KCalenDaysInWeek; |
980 offset += KCalenDaysInWeek; |
975 } |
981 } |
1062 Sets the active flag to the required dates in the array |
1068 Sets the active flag to the required dates in the array |
1063 */ |
1069 */ |
1064 void CalenMonthView::updateMonthDataArrayWithActiveDates() |
1070 void CalenMonthView::updateMonthDataArrayWithActiveDates() |
1065 { |
1071 { |
1066 int activeMonth = mActiveMonth.date().month(); |
1072 int activeMonth = mActiveMonth.date().month(); |
1067 for (int i = 0; i < mMonthDataArray.count(); i++) { |
1073 int monthDataCount = mMonthDataArray.count(); |
|
1074 for (int i = 0; i < monthDataCount; i++) { |
1068 if (mMonthDataArray[i].Day().date().month() == activeMonth) { |
1075 if (mMonthDataArray[i].Day().date().month() == activeMonth) { |
1069 // Set the active flag |
1076 // Set the active flag |
1070 mMonthDataArray[i].setActive(true); |
1077 mMonthDataArray[i].setActive(true); |
1071 } else { |
1078 } else { |
1072 // Disable the active flag |
1079 // Disable the active flag |
1106 // Get the list of dates which have events |
1113 // Get the list of dates which have events |
1107 QList<QDate> datesWithEvents; |
1114 QList<QDate> datesWithEvents; |
1108 getInstanceList(datesWithEvents,gridStart,gridEnd); |
1115 getInstanceList(datesWithEvents,gridStart,gridEnd); |
1109 |
1116 |
1110 // Parse thru the list of dates and set the required flags |
1117 // Parse thru the list of dates and set the required flags |
1111 for(int i(0); i < datesWithEvents.count(); i++) { |
1118 int datesEventsCount = datesWithEvents.count(); |
|
1119 for(int i(0); i < datesEventsCount; i++) { |
1112 int offset = mFirstDayOfGrid.date().daysTo(datesWithEvents.at(i)); |
1120 int offset = mFirstDayOfGrid.date().daysTo(datesWithEvents.at(i)); |
1113 mMonthDataArray[offset].SetHasEvents(true); |
1121 mMonthDataArray[offset].SetHasEvents(true); |
1114 } |
1122 } |
1115 |
1123 |
1116 datesWithEvents.clear(); |
1124 datesWithEvents.clear(); |
1133 // Get the list of dates which have events |
1141 // Get the list of dates which have events |
1134 QList<QDate> datesWithEvents; |
1142 QList<QDate> datesWithEvents; |
1135 getInstanceList(datesWithEvents,gridStart,gridEnd); |
1143 getInstanceList(datesWithEvents,gridStart,gridEnd); |
1136 |
1144 |
1137 // Parse thru the list of dates and set the required flags |
1145 // Parse thru the list of dates and set the required flags |
1138 for(int i(0); i < datesWithEvents.count(); i++) { |
1146 int datesEventsCount = datesWithEvents.count(); |
|
1147 for(int i(0); i < datesEventsCount; i++) { |
1139 int offset = mFirstDayOfGrid.date().daysTo(datesWithEvents.at(i)); |
1148 int offset = mFirstDayOfGrid.date().daysTo(datesWithEvents.at(i)); |
1140 mMonthDataArray[offset].SetHasEvents(true); |
1149 mMonthDataArray[offset].SetHasEvents(true); |
1141 } |
1150 } |
1142 datesWithEvents.clear(); |
1151 datesWithEvents.clear(); |
1143 } |
1152 } |
1160 // Get the list of dates which have events |
1169 // Get the list of dates which have events |
1161 QList<QDate> datesWithEvents; |
1170 QList<QDate> datesWithEvents; |
1162 getInstanceList(datesWithEvents,gridStart,gridEnd); |
1171 getInstanceList(datesWithEvents,gridStart,gridEnd); |
1163 |
1172 |
1164 // Parse thru the list of dates and set the required flags |
1173 // Parse thru the list of dates and set the required flags |
1165 for(int i(0); i < datesWithEvents.count(); i++) { |
1174 int datesEventsCount = datesWithEvents.count(); |
|
1175 for(int i(0); i < datesEventsCount; i++) { |
1166 int offset = mFirstDayOfGrid.date().daysTo(datesWithEvents.at(i)); |
1176 int offset = mFirstDayOfGrid.date().daysTo(datesWithEvents.at(i)); |
1167 mMonthDataArray[offset].SetHasEvents(true); |
1177 mMonthDataArray[offset].SetHasEvents(true); |
1168 } |
1178 } |
1169 datesWithEvents.clear(); |
1179 datesWithEvents.clear(); |
1170 } |
1180 } |
1218 */ |
1228 */ |
1219 void CalenMonthView::setContextForActiveDay(int index) |
1229 void CalenMonthView::setContextForActiveDay(int index) |
1220 { |
1230 { |
1221 QDateTime newActiveDay = mFirstDayOfGrid.addDays(index); |
1231 QDateTime newActiveDay = mFirstDayOfGrid.addDays(index); |
1222 // Set the context |
1232 // Set the context |
1223 mServices.Context().setFocusDateL(newActiveDay, KCalenMonthViewUidValue); |
1233 mServices.Context().setFocusDate(newActiveDay); |
1224 mDate = newActiveDay; |
1234 mDate = newActiveDay; |
1225 setDateToLabel(); |
1235 setDateToLabel(); |
1226 |
1236 |
1227 if(!mIsPrevPaneGesture) { |
1237 if(!mIsPrevPaneGesture) { |
1228 populatePreviewPane(mDate); |
1238 populatePreviewPane(mDate); |
1240 { |
1250 { |
1241 mServices.IssueCommandL(ECalenNewMeeting); |
1251 mServices.IssueCommandL(ECalenNewMeeting); |
1242 } |
1252 } |
1243 |
1253 |
1244 /*! |
1254 /*! |
1245 Slot to launch the agenda view |
1255 Slot to launch the Day view |
1246 */ |
1256 */ |
1247 void CalenMonthView::launchDayView() |
1257 void CalenMonthView::launchDayView() |
1248 { |
1258 { |
1249 mServices.IssueCommandL(ECalenDayView); |
1259 mServices.IssueCommandL(ECalenDayView); |
1250 // day view launched now, disconnect to get the call backs for saveActivity |
1260 // day view launched now, disconnect to get the call backs for saveActivity |