207 = qobject_cast<HbWidget *> ( |
201 = qobject_cast<HbWidget *> ( |
208 mDocLoader->findWidget(CALEN_MONTHGRID_WEEKNUMBERS_WIDGET)); |
202 mDocLoader->findWidget(CALEN_MONTHGRID_WEEKNUMBERS_WIDGET)); |
209 |
203 |
210 mMonthGrid->setView(this); |
204 mMonthGrid->setView(this); |
211 |
205 |
|
206 |
|
207 |
|
208 mIsFirstTimeLoad = true; |
|
209 // get a pointner to activity manager |
|
210 HbActivityManager* activityManager = qobject_cast<HbApplication*>(qApp)->activityManager(); |
|
211 |
|
212 // 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 |
|
214 // only for debugging purpose. |
|
215 bool ok = activityManager->removeActivity(activityName); |
|
216 |
|
217 } |
|
218 |
|
219 /*! |
|
220 Constructs the remaining part of the month view that was kept as |
|
221 part if lazy loading |
|
222 */ |
|
223 void CalenMonthView::doLazyLoading() |
|
224 { |
|
225 // Add background items to all the widgets |
|
226 addBackgroundFrame(); |
|
227 |
|
228 // Construct and add the previous month and next month items to the view |
|
229 mMonthGrid->updateMonthGridWithInActiveMonths(mMonthDataArray); |
|
230 |
|
231 // Check if regional information needs to be shown |
|
232 // and add it or remove it |
|
233 showHideRegionalInformation(); |
|
234 |
212 // Connect to the menu actions |
235 // Connect to the menu actions |
213 HbAction |
236 HbAction |
214 *newEventAction = |
237 *newEventAction = |
215 qobject_cast<HbAction *> ( |
238 qobject_cast<HbAction *> ( |
216 mDocLoader->findObject(CALEN_MONTVIEW_MENU_NEWEVENT)); |
239 mDocLoader->findObject(CALEN_MONTVIEW_MENU_NEWEVENT)); |
217 |
240 |
218 connect(newEventAction, SIGNAL(triggered()), this, SLOT(createEditor())); |
241 connect(newEventAction, SIGNAL(triggered()), this, SLOT(createEditor())); |
219 |
242 |
220 mGoToTodayAction = |
243 mGoToTodayAction = |
221 qobject_cast<HbAction *> ( |
244 qobject_cast<HbAction *> ( |
222 mDocLoader->findObject(CALEN_MONTVIEW_MENU_GOTOTODAY)); |
245 mDocLoader->findObject(CALEN_MONTVIEW_MENU_GOTOTODAY)); |
223 connect(mGoToTodayAction, SIGNAL(triggered()), this, SLOT(goToToday())); |
246 connect(mGoToTodayAction, SIGNAL(triggered()), this, SLOT(goToToday())); |
224 |
247 |
225 HbAction |
248 HbAction |
226 *goToDateAction = |
249 *goToDateAction = |
227 qobject_cast<HbAction *> ( |
250 qobject_cast<HbAction *> ( |
228 mDocLoader->findObject(CALEN_MONTVIEW_MENU_GOTODATE)); |
251 mDocLoader->findObject(CALEN_MONTVIEW_MENU_GOTODATE)); |
229 |
252 |
230 connect(goToDateAction, SIGNAL(triggered()), this, SLOT(goToDate())); |
253 connect(goToDateAction, SIGNAL(triggered()), this, SLOT(goToDate())); |
231 |
254 |
232 // TODO: Need to move this to docml |
255 // TODO: Need to move this to docml |
390 */ |
416 */ |
391 void CalenMonthView::addBackgroundFrame() |
417 void CalenMonthView::addBackgroundFrame() |
392 { |
418 { |
393 // Set the background items for all the widgets |
419 // Set the background items for all the widgets |
394 HbFrameItem* frame = NULL; |
420 HbFrameItem* frame = NULL; |
|
421 HbFrameDrawer *drawer = NULL; |
395 HbWidget* monthViewExceptPreviewPane = qobject_cast<HbWidget *> ( |
422 HbWidget* monthViewExceptPreviewPane = qobject_cast<HbWidget *> ( |
396 mDocLoader->findWidget(CALEN_MONTHVIEW_EXCEPT_PANE)); |
423 mDocLoader->findWidget(CALEN_MONTHVIEW_EXCEPT_PANE)); |
397 if (monthViewExceptPreviewPane) { |
424 if (monthViewExceptPreviewPane) { |
|
425 drawer = new HbFrameDrawer("qtg_fr_cal_monthgrid_bg", HbFrameDrawer::NinePieces); |
398 // The grid background |
426 // The grid background |
399 frame = new HbFrameItem(this); |
427 frame = new HbFrameItem(drawer, this); |
400 frame->frameDrawer().setFrameType(HbFrameDrawer::NinePieces); |
|
401 |
|
402 frame->frameDrawer().setFrameGraphicsName("qtg_fr_cal_monthgrid_bg"); |
|
403 monthViewExceptPreviewPane->setBackgroundItem(frame->graphicsItem(), -2); |
428 monthViewExceptPreviewPane->setBackgroundItem(frame->graphicsItem(), -2); |
404 } |
429 } |
405 if (mTitleLabel) { |
430 if (mTitleLabel) { |
406 // The month title |
431 // The month title |
407 frame = new HbFrameItem(this); |
432 drawer = new HbFrameDrawer("qtg_fr_cal_monthgrid_title_bg", HbFrameDrawer::ThreePiecesHorizontal); |
408 frame->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal); |
433 if (drawer) |
409 |
434 frame = new HbFrameItem(drawer, this); |
410 frame->frameDrawer().setFrameGraphicsName("qtg_fr_cal_monthgrid_title_bg"); |
435 if(frame) |
411 mTitleLabel->setBackgroundItem(frame->graphicsItem(), -2); |
436 mTitleLabel->setBackgroundItem(frame->graphicsItem(), -2); |
412 } |
437 } |
413 |
438 |
414 // Set the frame to the preview pane |
439 // Set the frame to the preview pane |
415 frame = new HbFrameItem(this); |
440 drawer = new HbFrameDrawer("qtg_fr_cal_preview_bg", HbFrameDrawer::NinePieces); |
416 frame->frameDrawer().setFrameType(HbFrameDrawer::NinePieces); |
441 if (drawer) |
417 |
442 frame = new HbFrameItem(drawer, this); |
418 frame->frameDrawer().setFrameGraphicsName("qtg_fr_cal_preview_bg"); |
443 if(frame) |
419 mPrevPaneLayoutWidget->setBackgroundItem(frame->graphicsItem(), -5); |
444 mPrevPaneLayoutWidget->setBackgroundItem(frame->graphicsItem(), -5); |
420 |
445 |
421 // Set the frame to the preview pane |
446 // Set the frame to the preview pane |
422 frame = new HbFrameItem(this); |
447 drawer = new HbFrameDrawer("qtg_fr_cal_preview_bg", HbFrameDrawer::NinePieces); |
423 frame->frameDrawer().setFrameType(HbFrameDrawer::NinePieces); |
448 if(drawer) |
424 |
449 frame = new HbFrameItem(drawer, this); |
425 frame->frameDrawer().setFrameGraphicsName("qtg_fr_cal_preview_bg"); |
450 if(frame) |
426 mCurrPaneLayoutWidget->setBackgroundItem(frame->graphicsItem(), -5); |
451 mCurrPaneLayoutWidget->setBackgroundItem(frame->graphicsItem(), -5); |
427 |
452 |
428 // Set the frame to the preview pane |
453 // Set the frame to the preview pane |
429 frame = new HbFrameItem(this); |
454 drawer = new HbFrameDrawer("qtg_fr_cal_preview_bg", HbFrameDrawer::NinePieces); |
430 frame->frameDrawer().setFrameType(HbFrameDrawer::NinePieces); |
455 if(drawer) |
431 |
456 frame = new HbFrameItem(drawer, this); |
432 frame->frameDrawer().setFrameGraphicsName("qtg_fr_cal_preview_bg"); |
457 if(frame) |
433 mNextPaneLayoutWidget->setBackgroundItem(frame->graphicsItem(), -5); |
458 mNextPaneLayoutWidget->setBackgroundItem(frame->graphicsItem(), -5); |
434 } |
459 } |
435 |
460 |
436 void CalenMonthView::showHideRegionalInformation() |
461 void CalenMonthView::showHideRegionalInformation() |
437 { |
462 { |
438 XQSettingsKey regionalInfo(XQSettingsKey::TargetCentralRepository, |
463 if (pluginEnabled()) { |
439 KCRUidCalendar.iUid, KShowRegionalInformation); |
464 XQSettingsKey regionalInfo(XQSettingsKey::TargetCentralRepository, |
440 |
465 KCRUidCalendar, KCalendarShowRegionalInfo); |
441 int showRegionalInfo = mSettingsManager->readItemValue(regionalInfo).toUInt(); |
466 |
442 if (showRegionalInfo) { |
467 int showRegionalInfo = |
443 |
468 mSettingsManager->readItemValue(regionalInfo).toUInt(); |
444 // Add the regional information to the preview panes |
469 if (showRegionalInfo) { |
445 if (!mPrevRegionalInfo) { |
470 |
446 mPrevRegionalInfo = new CalenPluginLabel(mServices, this); |
471 // Add the regional information to the preview panes |
447 mPrevPaneLayout->insertItem(0, mPrevRegionalInfo); |
472 if (!mPrevRegionalInfo) { |
448 |
473 mPrevRegionalInfo = qobject_cast<CalenPluginLabel *> |
449 HbFrameItem *frameCurr = new HbFrameItem(this); |
474 (mDocLoader->findWidget(CALEN_PREVREGIONALINFO)); |
450 frameCurr->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal); |
475 mPrevRegionalInfo->show(); |
451 frameCurr->frameDrawer().setFrameGraphicsName("qtg_fr_cal_preview_title_bg"); |
476 mPrevPaneLayout->insertItem(0, mPrevRegionalInfo); |
452 mPrevRegionalInfo->setBackgroundItem(frameCurr->graphicsItem(), -2); |
477 |
453 } |
478 HbFrameItem *frameCurr = new HbFrameItem(this); |
454 if (!mCurrRegionalInfo) { |
479 frameCurr->frameDrawer().setFrameType( |
455 mCurrRegionalInfo = new CalenPluginLabel(mServices, this); |
480 HbFrameDrawer::ThreePiecesHorizontal); |
456 mCurrPaneLayout->insertItem(0, mCurrRegionalInfo); |
481 frameCurr->frameDrawer().setFrameGraphicsName( |
457 |
482 "qtg_fr_cal_preview_title_bg"); |
458 HbFrameItem *frameCurr = new HbFrameItem(this); |
483 mPrevRegionalInfo->setBackgroundItem( |
459 frameCurr->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal); |
484 frameCurr->graphicsItem(), -2); |
460 frameCurr->frameDrawer().setFrameGraphicsName("qtg_fr_cal_preview_title_bg"); |
485 } |
461 mCurrRegionalInfo->setBackgroundItem(frameCurr->graphicsItem(), -2); |
486 if (!mCurrRegionalInfo) { |
462 } |
487 mCurrRegionalInfo = qobject_cast<CalenPluginLabel *> |
463 if (!mNextRegionalInfo) { |
488 (mDocLoader->findWidget(CALEN_CURRREGIONALINFO)); |
464 mNextRegionalInfo = new CalenPluginLabel(mServices, this); |
489 mCurrRegionalInfo->show(); |
465 mNextPaneLayout->insertItem(0, mNextRegionalInfo); |
490 mCurrPaneLayout->insertItem(0, mCurrRegionalInfo); |
466 |
491 |
467 HbFrameItem *frameCurr = new HbFrameItem(this); |
492 HbFrameItem *frameCurr = new HbFrameItem(this); |
468 frameCurr->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal); |
493 frameCurr->frameDrawer().setFrameType( |
469 frameCurr->frameDrawer().setFrameGraphicsName("qtg_fr_cal_preview_title_bg"); |
494 HbFrameDrawer::ThreePiecesHorizontal); |
470 mNextRegionalInfo->setBackgroundItem(frameCurr->graphicsItem(), -2); |
495 frameCurr->frameDrawer().setFrameGraphicsName( |
471 } |
496 "qtg_fr_cal_preview_title_bg"); |
472 |
497 mCurrRegionalInfo->setBackgroundItem( |
473 if (pluginEnabled()) { |
498 frameCurr->graphicsItem(), -2); |
|
499 } |
|
500 if (!mNextRegionalInfo) { |
|
501 mNextRegionalInfo = qobject_cast<CalenPluginLabel *> |
|
502 (mDocLoader->findWidget(CALEN_NEXTREGIONALINFO)); |
|
503 mNextRegionalInfo->show(); |
|
504 mNextPaneLayout->insertItem(0, mNextRegionalInfo); |
|
505 |
|
506 HbFrameItem *frameCurr = new HbFrameItem(this); |
|
507 frameCurr->frameDrawer().setFrameType( |
|
508 HbFrameDrawer::ThreePiecesHorizontal); |
|
509 frameCurr->frameDrawer().setFrameGraphicsName( |
|
510 "qtg_fr_cal_preview_title_bg"); |
|
511 mNextRegionalInfo->setBackgroundItem( |
|
512 frameCurr->graphicsItem(), -2); |
|
513 } |
474 QString *pluginString = pluginText(); |
514 QString *pluginString = pluginText(); |
475 mPrevRegionalInfo->setPlainText(*pluginString); |
515 mPrevRegionalInfo->setPlainText(*pluginString); |
476 mCurrRegionalInfo->setPlainText(*pluginString); |
516 mCurrRegionalInfo->setPlainText(*pluginString); |
477 mNextRegionalInfo->setPlainText(*pluginString); |
517 mNextRegionalInfo->setPlainText(*pluginString); |
|
518 } else { |
|
519 if (mPrevRegionalInfo) { |
|
520 mPrevPaneLayout->removeItem(mPrevRegionalInfo); |
|
521 mPrevRegionalInfo->hide(); |
|
522 mPrevRegionalInfo = NULL; |
|
523 } |
|
524 if (mCurrRegionalInfo) { |
|
525 mPrevPaneLayout->removeItem(mCurrRegionalInfo); |
|
526 mCurrRegionalInfo->hide(); |
|
527 mCurrRegionalInfo = NULL; |
|
528 } |
|
529 if (mNextRegionalInfo) { |
|
530 mPrevPaneLayout->removeItem(mNextRegionalInfo); |
|
531 mNextRegionalInfo->hide(); |
|
532 mNextRegionalInfo = NULL; |
|
533 } |
478 } |
534 } |
479 } else { |
535 } |
480 if (mPrevRegionalInfo) { |
|
481 mPrevPaneLayout->removeItem(mPrevRegionalInfo); |
|
482 delete mPrevRegionalInfo; |
|
483 mPrevRegionalInfo = NULL; |
|
484 } |
|
485 if (mCurrRegionalInfo) { |
|
486 mPrevPaneLayout->removeItem(mCurrRegionalInfo); |
|
487 delete mCurrRegionalInfo; |
|
488 mCurrRegionalInfo = NULL; |
|
489 } |
|
490 if (mNextRegionalInfo) { |
|
491 mPrevPaneLayout->removeItem(mNextRegionalInfo); |
|
492 delete mNextRegionalInfo; |
|
493 mNextRegionalInfo = NULL; |
|
494 } |
|
495 } |
|
496 } |
536 } |
497 |
537 |
498 /*! |
538 /*! |
499 Handles the context changed notification |
539 Handles the context changed notification |
500 */ |
540 */ |
527 // Get the week number |
567 // Get the week number |
528 QDateTime day = firstVisibleDate.addDays((KCalenDaysInWeek * i)); |
568 QDateTime day = firstVisibleDate.addDays((KCalenDaysInWeek * i)); |
529 long weekNumber(day.date().weekNumber()); |
569 long weekNumber(day.date().weekNumber()); |
530 mWeekNumbers.append(weekNumber); |
570 mWeekNumbers.append(weekNumber); |
531 } |
571 } |
532 |
|
533 // Get the week day color from the theme |
|
534 QColor weekDayColor = HbColorScheme::color("qtc_cal_week_day"); |
|
535 |
572 |
536 // Update the week labels text |
573 // Update the week labels text |
537 QString text = QString::number(mWeekNumbers.at(0)); |
574 QString text = QString::number(mWeekNumbers.at(0)); |
538 mFirstWeekLabel->setPlainText(text); |
575 mFirstWeekLabel->setPlainText(text); |
539 mFirstWeekLabel->setTextColor(weekDayColor); |
|
540 text = QString::number(mWeekNumbers.at(1)); |
576 text = QString::number(mWeekNumbers.at(1)); |
541 mSecondWeekLabel->setPlainText(text); |
577 mSecondWeekLabel->setPlainText(text); |
542 mSecondWeekLabel->setTextColor(weekDayColor); |
|
543 text = QString::number(mWeekNumbers.at(2)); |
578 text = QString::number(mWeekNumbers.at(2)); |
544 mThirdWeekLabel->setPlainText(text); |
579 mThirdWeekLabel->setPlainText(text); |
545 mThirdWeekLabel->setTextColor(weekDayColor); |
|
546 text = QString::number(mWeekNumbers.at(3)); |
580 text = QString::number(mWeekNumbers.at(3)); |
547 mFourthWeekLabel->setPlainText(text); |
581 mFourthWeekLabel->setPlainText(text); |
548 mFourthWeekLabel->setTextColor(weekDayColor); |
|
549 text = QString::number(mWeekNumbers.at(4)); |
582 text = QString::number(mWeekNumbers.at(4)); |
550 mFifthWeekLabel->setPlainText(text); |
583 mFifthWeekLabel->setPlainText(text); |
551 mFifthWeekLabel->setTextColor(weekDayColor); |
|
552 text = QString::number(mWeekNumbers.at(5)); |
584 text = QString::number(mWeekNumbers.at(5)); |
553 mSixthWeekLabel->setPlainText(text); |
585 mSixthWeekLabel->setPlainText(text); |
554 mSixthWeekLabel->setTextColor(weekDayColor); |
|
555 } |
586 } |
556 |
587 |
557 /*! |
588 /*! |
558 Populates the month view with today as focussed item |
589 Populates the month view with today as focussed item |
559 */ |
590 */ |
560 void CalenMonthView::goToToday() |
591 void CalenMonthView::goToToday() |
561 { |
592 { |
562 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 |
563 // First check if we are not alread |
598 // First check if we are not alread |
564 // showing today's month view |
599 // showing today's month view |
565 if (mDate == today) { |
600 if (mDate == today) { |
566 return; |
601 return; |
567 } else if (mActiveMonth.date().year() == today.date().year() && |
602 } else if (mActiveMonth.date().year() == today.date().year() && |
568 mActiveMonth.date().month() == today.date().month()) { |
603 mActiveMonth.date().month() == today.date().month()) { |
|
604 mDate = today; |
569 // 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 |
570 // date grid item and refresh the preview pane |
606 // date grid item and refresh the preview pane |
571 int currIndex = mFirstDayOfGrid.daysTo(today); |
607 int currIndex = mFirstDayOfGrid.daysTo(today); |
572 setCurrGridIndex(currIndex); |
608 setCurrGridIndex(currIndex); |
573 return; |
609 // Populate the preview panes |
574 } |
610 populatePreviewPane(mDate); |
575 |
611 } else { |
576 // Set the context and repopulate the view |
612 refreshViewOnGoToDate(); |
577 MCalenContext &context = mServices.Context(); |
613 } |
578 context.setFocusDateAndTimeL(today, KCalenMonthViewUidValue); |
|
579 |
|
580 refreshViewOnGoToDate(); |
|
581 } |
614 } |
582 |
615 |
583 /* |
616 /* |
584 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 |
585 shown to the user |
618 shown to the user |
608 /*! |
641 /*! |
609 Populates the view |
642 Populates the view |
610 */ |
643 */ |
611 void CalenMonthView::doPopulation() |
644 void CalenMonthView::doPopulation() |
612 { |
645 { |
613 if (!mIsFirstTimeLoad) { |
646 |
614 Qt::Orientation orientation = mServices.MainWindow().orientation(); |
647 // Get the layout and add the preview pane layout. |
615 if (mOrientation != orientation) { |
648 QGraphicsLinearLayout* viewLayout = static_cast<QGraphicsLinearLayout *> |
616 mOrientation = orientation; |
649 (widget()->layout()); |
617 handleChangeOrientation(); |
650 if (viewLayout->count() == 1) { |
618 } |
651 // Count is 1 implies view has only month grid. |
619 } |
652 // Add the preview pane at corresponding position. |
620 mIsFirstTimeLoad = false; |
653 viewLayout->addItem(mCurrPaneParent); |
|
654 } |
|
655 |
621 // prepare for the population like reading the date frm the context |
656 // prepare for the population like reading the date frm the context |
622 // calculating the start of the grid etc., |
657 // calculating the start of the grid etc., |
623 prepareForPopulation(); |
658 prepareForPopulation(); |
624 |
659 |
625 // fetch list of required calendar instances |
660 // Populate the view and preview panes only if we are not opening the calendar |
626 populateWithInstanceView(); |
661 if (!mIsFirstTimeLoad) { |
627 |
662 // fetch list of required calendar instances |
628 populatePreviewPane(mDate); |
663 populateWithInstanceView(); |
629 |
664 // Populate the preview panes |
630 // Create the grid items with proper dates |
665 populatePreviewPane(mDate); |
|
666 } |
|
667 |
|
668 |
|
669 //update the day label |
|
670 //if changes in locale setting |
|
671 updateDayLabel(); |
|
672 |
|
673 // Create the grid items with proper dates |
631 createGrid(); |
674 createGrid(); |
632 |
675 |
633 // Check if regional information needs to be shown |
|
634 // and add it or remove it |
|
635 showHideRegionalInformation(); |
|
636 |
676 |
637 // Complete the population |
677 // Complete the population |
638 completePopulation(); |
678 completePopulation(); |
639 |
679 |
|
680 //set Currect Activity to month view |
|
681 mActivityId = ECalenMonthView; |
|
682 |
|
683 // connect to receive a call back on Month View exit. Call back would result in saveActivity |
|
684 // to be called in Native View. |
|
685 if (!mIsAboutToQuitEventConnected) // check if not already connected |
|
686 { |
|
687 connect(qobject_cast<HbApplication*>(qApp), SIGNAL(aboutToQuit()), this, SLOT(saveActivity())); |
|
688 mIsAboutToQuitEventConnected = true; |
|
689 } |
|
690 |
|
691 |
640 // Population is complete, inform it |
692 // Population is complete, inform it |
641 populationComplete(); |
693 populationComplete(); |
642 |
694 |
643 // Start the auto scroll on current preview pane |
695 // Handle regional data here if we are not populating the month view for |
644 mCurrPreviewPane->startAutoScroll(); |
696 // the first time |
|
697 if (!mIsFirstTimeLoad) { |
|
698 showHideRegionalInformation(); |
|
699 } |
|
700 // Reset the first time load flag |
|
701 mIsFirstTimeLoad = false; |
645 } |
702 } |
646 |
703 |
647 /*! |
704 /*! |
648 Reads the date from the context and calculates the grid item dates |
705 Reads the date from the context and calculates the grid item dates |
649 */ |
706 */ |
650 void CalenMonthView::prepareForPopulation() |
707 void CalenMonthView::prepareForPopulation() |
651 { |
708 { |
652 setActiveDay(dateFromContext(mServices.Context())); |
709 setActiveDay(dateFromContext(mServices.Context())); |
653 setDate(); |
710 setDate(); |
|
711 updateMonthDataArrayWithActiveDates(); |
654 } |
712 } |
655 |
713 |
656 /*! |
714 /*! |
657 Slot to handle gotodate action |
715 Slot to handle gotodate action |
658 */ |
716 */ |
659 void CalenMonthView::refreshViewOnGoToDate() |
717 void CalenMonthView::refreshViewOnGoToDate() |
660 { |
718 { |
661 setActiveDay(dateFromContext(mServices.Context())); |
719 prepareForPopulation(); |
662 setDate(); |
|
663 setDateToLabel(); |
720 setDateToLabel(); |
664 // fetch list of required calendar instances |
721 // fetch list of required calendar instances |
665 populateWithInstanceView(); |
722 populateWithInstanceView(); |
666 |
723 |
667 populatePreviewPane(mDate); |
724 populatePreviewPane(mDate); |
668 |
725 |
669 mMonthGrid->updateMonthGridModel(mMonthDataArray, mIndexToBeScrolled); |
726 mMonthGrid->updateMonthGridModel(mMonthDataArray, mIndexToBeScrolled, |
670 |
727 mIsFirstTimeLoad); |
671 // Start the auto scroll on current preview pane |
728 // Update the week Numbers model |
672 mCurrPreviewPane->startAutoScroll(); |
729 if (mIsWeekNumbersShown) { |
|
730 updateWeekNumGridModel(); |
|
731 } |
673 } |
732 } |
674 |
733 |
675 /*! |
734 /*! |
676 Reads the date from the context and stores into mDate |
735 Reads the date from the context and stores into mDate |
677 */ |
736 */ |
678 QDateTime CalenMonthView::dateFromContext(const MCalenContext &context) |
737 QDateTime CalenMonthView::dateFromContext(const MCalenContext &context) |
679 { |
738 { |
680 QDateTime ret; |
739 QDateTime ret; |
681 if (AgendaEntry::TypeTodo == context.instanceId().mType) { |
740 if (AgendaEntry::TypeTodo == context.instanceId().mType) { |
682 QDateTime today = CalenDateUtils::today(); |
741 QDateTime today = CalenDateUtils::today(); |
683 if (context.focusDateAndTimeL() < today) { |
742 if (context.focusDateAndTime() < today) { |
684 ret = today; |
743 ret = today; |
685 } else { |
744 } else { |
686 ret = context.focusDateAndTimeL(); |
745 ret = context.focusDateAndTime(); |
687 } |
746 } |
688 } else { |
747 } else { |
689 ret = context.focusDateAndTimeL(); |
748 ret = context.focusDateAndTime(); |
690 } |
749 } |
691 return ret; |
750 return ret; |
692 } |
751 } |
693 |
752 |
694 /*! |
753 /*! |
1066 Parses the fetched entries for previous month and |
1128 Parses the fetched entries for previous month and |
1067 sets hasEvent attribute for necessary days |
1129 sets hasEvent attribute for necessary days |
1068 */ |
1130 */ |
1069 void CalenMonthView::populatePrevMonth() |
1131 void CalenMonthView::populatePrevMonth() |
1070 { |
1132 { |
1071 QList<AgendaEntry> list; |
|
1072 const QDateTime gridStart(CalenDateUtils::beginningOfDay(mFirstDayOfGrid)); |
1133 const QDateTime gridStart(CalenDateUtils::beginningOfDay(mFirstDayOfGrid)); |
1073 const QDateTime today(CalenDateUtils::today()); |
1134 const QDateTime today(CalenDateUtils::today()); |
1074 |
1135 |
1075 const int todayIndex(gridStart.daysTo(today)); // grid index for "today" |
1136 const int todayIndex(gridStart.daysTo(today)); // grid index for "today" |
1076 QDateTime end = gridStart.addDays(mNumOfRowsInPrevMonth * KCalenDaysInWeek); |
1137 QDateTime end = gridStart.addDays(mNumOfRowsInPrevMonth * KCalenDaysInWeek); |
1077 QDateTime gridEnd(end.date(), QTime(23, 59, 59, 0)); |
1138 QDateTime gridEnd(end.date(), QTime(23, 59, 59, 0)); |
1078 |
1139 |
1079 |
1140 |
1080 AgendaUtil::FilterFlags filter = |
|
1081 AgendaUtil::FilterFlags(AgendaUtil::IncludeAnniversaries |
|
1082 | AgendaUtil::IncludeAppointments |
|
1083 | AgendaUtil::IncludeEvents |
|
1084 | AgendaUtil::IncludeReminders |
|
1085 | AgendaUtil::IncludeIncompletedTodos); |
|
1086 |
|
1087 // Get the list of dates which have events |
1141 // Get the list of dates which have events |
1088 QList<QDate> datesWithEvents; |
1142 QList<QDate> datesWithEvents; |
1089 mAgendaUtil->markDatesWithEvents(gridStart,gridEnd,filter,datesWithEvents); |
1143 getInstanceList(datesWithEvents,gridStart,gridEnd); |
1090 |
1144 |
1091 // Parse thru the list of dates and set the required flags |
1145 // Parse thru the list of dates and set the required flags |
1092 for(int i(0); i < datesWithEvents.count(); i++) { |
1146 int datesEventsCount = datesWithEvents.count(); |
|
1147 for(int i(0); i < datesEventsCount; i++) { |
1093 int offset = mFirstDayOfGrid.date().daysTo(datesWithEvents.at(i)); |
1148 int offset = mFirstDayOfGrid.date().daysTo(datesWithEvents.at(i)); |
1094 mMonthDataArray[offset].SetHasEvents(true); |
1149 mMonthDataArray[offset].SetHasEvents(true); |
1095 } |
1150 } |
1096 |
|
1097 datesWithEvents.clear(); |
1151 datesWithEvents.clear(); |
1098 } |
1152 } |
1099 |
1153 |
1100 /*! |
1154 /*! |
1101 Parses the fetched entries for future month and |
1155 Parses the fetched entries for future month and |
1110 |
1164 |
1111 const QDateTime today(CalenDateUtils::today()); |
1165 const QDateTime today(CalenDateUtils::today()); |
1112 const int todayIndex(gridStart.daysTo(today)); // grid index for "today" |
1166 const int todayIndex(gridStart.daysTo(today)); // grid index for "today" |
1113 QDateTime gridEnd(mLastDayOfGrid.date(), QTime(23, 59, 59, 0)); |
1167 QDateTime gridEnd(mLastDayOfGrid.date(), QTime(23, 59, 59, 0)); |
1114 |
1168 |
1115 |
|
1116 AgendaUtil::FilterFlags filter = |
|
1117 AgendaUtil::FilterFlags(AgendaUtil::IncludeAnniversaries |
|
1118 | AgendaUtil::IncludeAppointments |
|
1119 | AgendaUtil::IncludeEvents |
|
1120 | AgendaUtil::IncludeReminders |
|
1121 | AgendaUtil::IncludeIncompletedTodos); |
|
1122 |
|
1123 // Get the list of dates which have events |
1169 // Get the list of dates which have events |
1124 QList<QDate> datesWithEvents; |
1170 QList<QDate> datesWithEvents; |
1125 mAgendaUtil->markDatesWithEvents(gridStart,gridEnd,filter,datesWithEvents); |
1171 getInstanceList(datesWithEvents,gridStart,gridEnd); |
1126 |
1172 |
1127 // Parse thru the list of dates and set the required flags |
1173 // Parse thru the list of dates and set the required flags |
1128 for(int i(0); i < datesWithEvents.count(); i++) { |
1174 int datesEventsCount = datesWithEvents.count(); |
|
1175 for(int i(0); i < datesEventsCount; i++) { |
1129 int offset = mFirstDayOfGrid.date().daysTo(datesWithEvents.at(i)); |
1176 int offset = mFirstDayOfGrid.date().daysTo(datesWithEvents.at(i)); |
1130 mMonthDataArray[offset].SetHasEvents(true); |
1177 mMonthDataArray[offset].SetHasEvents(true); |
1131 } |
1178 } |
1132 |
|
1133 |
|
1134 |
|
1135 datesWithEvents.clear(); |
1179 datesWithEvents.clear(); |
|
1180 } |
|
1181 |
|
1182 /*! |
|
1183 Function that gets called when instacne view is created, so that it can |
|
1184 query agenda server for any entries |
|
1185 */ |
|
1186 void CalenMonthView::fetchEntriesAndUpdateModel() |
|
1187 { |
|
1188 // Get to know if entries are there from the agenda server |
|
1189 populateWithInstanceView(); |
|
1190 // Update the month grid model |
|
1191 mMonthGrid->updateMonthGridWithEventIndicators(mMonthDataArray); |
|
1192 // Populate the preview panes |
|
1193 populatePreviewPane(mDate); |
1136 } |
1194 } |
1137 |
1195 |
1138 /*! |
1196 /*! |
1139 Populates the preview pane |
1197 Populates the preview pane |
1140 */ |
1198 */ |
1141 void CalenMonthView::populatePreviewPane(QDateTime &dateTime) |
1199 void CalenMonthView::populatePreviewPane(QDateTime &dateTime) |
1142 { |
1200 { |
1143 mPrevPreviewPane->populateLabel(dateTime.addDays(-1)); |
1201 mPrevPreviewPane->populateLabel(dateTime.addDays(-1)); |
1144 mCurrPreviewPane->populateLabel(dateTime); |
1202 mCurrPreviewPane->populateLabel(dateTime); |
1145 mNextPreviewPane->populateLabel(dateTime.addDays(1)); |
1203 mNextPreviewPane->populateLabel(dateTime.addDays(1)); |
|
1204 |
|
1205 // Start the auto scroll on current preview pane |
|
1206 mCurrPreviewPane->startAutoScroll(); |
1146 } |
1207 } |
1147 |
1208 |
1148 /*! |
1209 /*! |
1149 Completes the population after setting the view as |
1210 Completes the population after setting the view as |
1150 current view to the main window |
1211 current view to the main window |