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