calendarui/views/src/calenmonthview.cpp
changeset 23 fd30d51f876b
parent 18 c198609911f9
child 26 a949c2543c15
child 45 b6db4fd4947b
equal deleted inserted replaced
18:c198609911f9 23:fd30d51f876b
    45 #include "calenpreviewpane.h"
    45 #include "calenpreviewpane.h"
    46 #include "calendocloader.h"
    46 #include "calendocloader.h"
    47 #include "calenthicklinesdrawer.h"
    47 #include "calenthicklinesdrawer.h"
    48 #include "calencommon.h"
    48 #include "calencommon.h"
    49 #include "CalendarInternalCRKeys.h"
    49 #include "CalendarInternalCRKeys.h"
    50 
    50 #include "calenpluginlabel.h"
    51 /*!
    51 /*!
    52  \class CalenMonthView
    52  \class CalenMonthView
    53 
    53 
    54  Class implementing calendar month view
    54  Class implementing calendar month view
    55  */
    55  */
    57 /*!
    57 /*!
    58  Default constructor.
    58  Default constructor.
    59  */
    59  */
    60 CalenMonthView::CalenMonthView(MCalenServices &services) :
    60 CalenMonthView::CalenMonthView(MCalenServices &services) :
    61 	CalenNativeView(services), mAgendaUtil(services.agendaInterface()), 
    61 	CalenNativeView(services), mAgendaUtil(services.agendaInterface()), 
    62 	mGoToTodayAction(0)
    62 	mGoToTodayAction(0),
       
    63 	mPrevRegionalInfo(0),
       
    64 	mCurrRegionalInfo(0),
       
    65 	mNextRegionalInfo(0)
    63 {
    66 {
    64 	mIsWeekNumbersShown = 0;
    67 	mIsWeekNumbersShown = 0;
    65 	mOrientation = mServices.MainWindow().orientation();
    68 	mOrientation = mServices.MainWindow().orientation();
    66 	// Read the date from the context
    69 	// Read the date from the context
    67 	mDate = mServices.Context().focusDateAndTimeL();
    70 	mDate = mServices.Context().focusDateAndTimeL();
    93 {
    96 {
    94 	mDocLoader = docLoader;
    97 	mDocLoader = docLoader;
    95 	mTitleLabel
    98 	mTitleLabel
    96 	        = qobject_cast<HbLabel *> (
    99 	        = qobject_cast<HbLabel *> (
    97 								   mDocLoader->findWidget(CALEN_MONTH_TITLE));
   100 								   mDocLoader->findWidget(CALEN_MONTH_TITLE));
       
   101 	// Set the title text color
       
   102 	QColor monthTitleColor = HbColorScheme::color("qtc_cal_monthgrid_title");
       
   103 	if (monthTitleColor.isValid()) {
       
   104 		mTitleLabel->setTextColor(monthTitleColor);
       
   105 	}
       
   106 		
    98 	mDayNameWidget
   107 	mDayNameWidget
    99 	        = qobject_cast<CalenThickLinesDrawer *> (
   108 	        = qobject_cast<CalenThickLinesDrawer *> (
   100 													mDocLoader->findWidget(
   109 													mDocLoader->findWidget(
   101 													CALEN_DAYNAMES_WIDGET));
   110 													CALEN_DAYNAMES_WIDGET));
   102 
   111 
   157 	HbLabel* currPaneNoEntriesLabel = static_cast<HbLabel *> (
   166 	HbLabel* currPaneNoEntriesLabel = static_cast<HbLabel *> (
   158 			docLoader->findWidget(CALEN_NOENTRIES_LABEL_CURR));
   167 			docLoader->findWidget(CALEN_NOENTRIES_LABEL_CURR));
   159 	mCurrPreviewPane->setView(this);
   168 	mCurrPreviewPane->setView(this);
   160 	mCurrPreviewPane->setNoEntriesLabel(currPaneNoEntriesLabel);
   169 	mCurrPreviewPane->setNoEntriesLabel(currPaneNoEntriesLabel);
   161 	
   170 	
       
   171 	mCurrPaneLayoutWidget = qobject_cast<HbWidget*>(docLoader->findWidget(CALEN_CURRPANELAYOUT));
       
   172 	mCurrPaneLayout = static_cast<QGraphicsLinearLayout*>(mCurrPaneLayoutWidget->layout());
       
   173 	
   162 	mPrevPaneParent = qobject_cast<HbWidget *> (
   174 	mPrevPaneParent = qobject_cast<HbWidget *> (
   163 			mDocLoader->findWidget(CALEN_PREVPREVIEWPARENT));
   175 			mDocLoader->findWidget(CALEN_PREVPREVIEWPARENT));
   164 	// Get previous day preview pane widget
   176 	// Get previous day preview pane widget
   165 	mPrevPreviewPane
   177 	mPrevPreviewPane
   166 			= static_cast<CalenPreviewPane *> (
   178 			= static_cast<CalenPreviewPane *> (
   171 			docLoader->findWidget(CALEN_NOENTRIES_LABEL_PREV));
   183 			docLoader->findWidget(CALEN_NOENTRIES_LABEL_PREV));
   172 	mPrevPreviewPane->setView(this);
   184 	mPrevPreviewPane->setView(this);
   173 	mPrevPreviewPane->setNoEntriesLabel(prevPaneNoEntriesLabel);
   185 	mPrevPreviewPane->setNoEntriesLabel(prevPaneNoEntriesLabel);
   174 	mPrevPaneParent->setVisible(false);
   186 	mPrevPaneParent->setVisible(false);
   175 	
   187 	
       
   188 	mPrevPaneLayoutWidget = qobject_cast<HbWidget*>(docLoader->findWidget(CALEN_PREVPANELAYOUT));
       
   189 	mPrevPaneLayout = static_cast<QGraphicsLinearLayout*>(mPrevPaneLayoutWidget->layout());
   176 	mNextPaneParent = qobject_cast<HbWidget *> (
   190 	mNextPaneParent = qobject_cast<HbWidget *> (
   177 			mDocLoader->findWidget(CALEN_NEXTPREVIEWPARENT));
   191 			mDocLoader->findWidget(CALEN_NEXTPREVIEWPARENT));
   178 	// Get next day preview pane widget
   192 	// Get next day preview pane widget
   179 	mNextPreviewPane
   193 	mNextPreviewPane
   180 			= static_cast<CalenPreviewPane *> (
   194 			= static_cast<CalenPreviewPane *> (
   184 	HbLabel* nextPaneNoEntriesLabel = static_cast<HbLabel *> (
   198 	HbLabel* nextPaneNoEntriesLabel = static_cast<HbLabel *> (
   185 			docLoader->findWidget(CALEN_NOENTRIES_LABEL_NEXT));
   199 			docLoader->findWidget(CALEN_NOENTRIES_LABEL_NEXT));
   186 	mNextPreviewPane->setView(this);
   200 	mNextPreviewPane->setView(this);
   187 	mNextPreviewPane->setNoEntriesLabel(nextPaneNoEntriesLabel);
   201 	mNextPreviewPane->setNoEntriesLabel(nextPaneNoEntriesLabel);
   188 	mNextPaneParent->setVisible(false);
   202 	mNextPaneParent->setVisible(false);
       
   203 	mNextPaneLayoutWidget = qobject_cast<HbWidget*>(docLoader->findWidget(CALEN_NEXTPANELAYOUT));
       
   204 	mNextPaneLayout = static_cast<QGraphicsLinearLayout*>(mNextPaneLayoutWidget->layout());
   189 	
   205 	
   190 	mMonthGridPlusWeekNumWidget
   206 	mMonthGridPlusWeekNumWidget
   191 	        = qobject_cast<HbWidget *> (
   207 	        = qobject_cast<HbWidget *> (
   192 					mDocLoader->findWidget(CALEN_MONTHGRID_WEEKNUMBERS_WIDGET));
   208 					mDocLoader->findWidget(CALEN_MONTHGRID_WEEKNUMBERS_WIDGET));
   193 
   209 
   213 
   229 
   214 	connect(goToDateAction, SIGNAL(triggered()), this, SLOT(goToDate()));
   230 	connect(goToDateAction, SIGNAL(triggered()), this, SLOT(goToDate()));
   215 
   231 
   216 	// TODO: Need to move this to docml
   232 	// TODO: Need to move this to docml
   217 	// Set the title to the submenu
   233 	// Set the title to the submenu
   218 	HbMenu
   234 	mDeleteSubMenu =
   219 	        *deleteSubMenu =
       
   220 	                qobject_cast<HbMenu *> (
   235 	                qobject_cast<HbMenu *> (
   221 						mDocLoader->findObject(CALEN_MONTVIEW_DELETE_SUBMENU));
   236 						mDocLoader->findObject(CALEN_MONTVIEW_DELETE_SUBMENU));
   222 	deleteSubMenu->setTitle(hbTrId("txt_calendar_opt_delete_entries"));
   237 	mDeleteSubMenu->setTitle(hbTrId("txt_calendar_opt_delete_entries"));
   223 
   238 
   224 	HbAction
   239 	HbAction
   225 	        *beforeDateAction =
   240 	        *beforeDateAction =
   226 	                qobject_cast<HbAction *> (
   241 	                qobject_cast<HbAction *> (
   227 						mDocLoader->findObject(CALEN_MONTVIEW_MENU_BEFOREDATE));
   242 						mDocLoader->findObject(CALEN_MONTVIEW_MENU_BEFOREDATE));
   248 
   263 
   249 	// Connect to the signal of change orientation.
   264 	// Connect to the signal of change orientation.
   250 	connect(&(mServices.MainWindow()),
   265 	connect(&(mServices.MainWindow()),
   251 	        SIGNAL(orientationChanged(Qt::Orientation)), this,
   266 	        SIGNAL(orientationChanged(Qt::Orientation)), this,
   252 	        SLOT(changeOrientation(Qt::Orientation)));
   267 	        SLOT(changeOrientation(Qt::Orientation)));
       
   268 	
       
   269 	// Connect to the signal when options menu is shown
       
   270 	// This is required to add/remove dynamically some options
       
   271 	connect(menu(), SIGNAL(aboutToShow ()), this,
       
   272 	        SLOT(addRemoveActionsInMenu()));
       
   273 	
   253 	mIsFirstTimeLoad = true;
   274 	mIsFirstTimeLoad = true;
   254 	
   275 	
   255 	// Add background items to all the widgets
   276 	// Add background items to all the widgets
   256 	addBackgroundFrame();
   277 	addBackgroundFrame();
   257 }
   278 }
   369  */
   390  */
   370 void CalenMonthView::addBackgroundFrame()
   391 void CalenMonthView::addBackgroundFrame()
   371 {
   392 {
   372     // Set the background items for all the widgets
   393     // Set the background items for all the widgets
   373     HbFrameItem* frame = NULL;
   394     HbFrameItem* frame = NULL;
   374     if (mMonthGrid) {
   395     HbWidget* monthViewExceptPreviewPane = qobject_cast<HbWidget *> (
       
   396 						 mDocLoader->findWidget(CALEN_MONTHVIEW_EXCEPT_PANE));
       
   397     if (monthViewExceptPreviewPane) {
   375         // The grid background
   398         // The grid background
   376         frame = new HbFrameItem(this);
   399         frame = new HbFrameItem(this);
   377         frame->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
   400         frame->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
   378 
   401 
   379         frame->frameDrawer().setFrameGraphicsName("qtg_fr_cal_monthgrid_bg");
   402         frame->frameDrawer().setFrameGraphicsName("qtg_fr_cal_monthgrid_bg");
   380         mMonthGrid->setBackgroundItem(frame->graphicsItem(), -2);
   403         monthViewExceptPreviewPane->setBackgroundItem(frame->graphicsItem(), -2);
   381     }
   404     }
   382     if (mTitleLabel) {
   405     if (mTitleLabel) {
   383         // The month title
   406         // The month title
   384         frame = new HbFrameItem(this);
   407         frame = new HbFrameItem(this);
   385         frame->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal);
   408         frame->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal);
   386 
   409 
   387         frame->frameDrawer().setFrameGraphicsName("qtg_fr_cal_monthgrid_title_bg");
   410         frame->frameDrawer().setFrameGraphicsName("qtg_fr_cal_monthgrid_title_bg");
   388         mTitleLabel->setBackgroundItem(frame->graphicsItem(), -2);
   411         mTitleLabel->setBackgroundItem(frame->graphicsItem(), -2);
   389     }
   412     }
   390   
   413     
       
   414     // Set the frame to the preview pane
       
   415     frame = new HbFrameItem(this);
       
   416     frame->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
   417 
       
   418     frame->frameDrawer().setFrameGraphicsName("qtg_fr_cal_preview_bg");
       
   419     mPrevPaneLayoutWidget->setBackgroundItem(frame->graphicsItem(), -5);
       
   420     
       
   421     // Set the frame to the preview pane
       
   422     frame = new HbFrameItem(this);
       
   423     frame->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
   424 
       
   425     frame->frameDrawer().setFrameGraphicsName("qtg_fr_cal_preview_bg");
       
   426     mCurrPaneLayoutWidget->setBackgroundItem(frame->graphicsItem(), -5);
       
   427     
       
   428     // Set the frame to the preview pane
       
   429     frame = new HbFrameItem(this);
       
   430     frame->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
   431 
       
   432     frame->frameDrawer().setFrameGraphicsName("qtg_fr_cal_preview_bg");
       
   433     mNextPaneLayoutWidget->setBackgroundItem(frame->graphicsItem(), -5);
       
   434 }
       
   435 
       
   436 void CalenMonthView::showHideRegionalInformation()
       
   437 {
       
   438     XQSettingsKey regionalInfo(XQSettingsKey::TargetCentralRepository,
       
   439                                KCRUidCalendar.iUid, KShowRegionalInformation);
       
   440     
       
   441     int showRegionalInfo = mSettingsManager->readItemValue(regionalInfo).toUInt();
       
   442     if (showRegionalInfo) {
       
   443 		
       
   444         // Add the regional information to the preview panes
       
   445         if (!mPrevRegionalInfo) {
       
   446             mPrevRegionalInfo = new CalenPluginLabel(mServices, this);
       
   447             mPrevPaneLayout->insertItem(0, mPrevRegionalInfo);
       
   448 
       
   449             HbFrameItem *frameCurr = new HbFrameItem(this);
       
   450             frameCurr->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal);
       
   451             frameCurr->frameDrawer().setFrameGraphicsName("qtg_fr_cal_preview_title_bg");
       
   452             mPrevRegionalInfo->setBackgroundItem(frameCurr->graphicsItem(), -2);
       
   453         }
       
   454         if (!mCurrRegionalInfo) {
       
   455             mCurrRegionalInfo = new CalenPluginLabel(mServices, this);
       
   456             mCurrPaneLayout->insertItem(0, mCurrRegionalInfo);
       
   457             
       
   458             HbFrameItem *frameCurr = new HbFrameItem(this);
       
   459             frameCurr->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal);
       
   460             frameCurr->frameDrawer().setFrameGraphicsName("qtg_fr_cal_preview_title_bg");
       
   461             mCurrRegionalInfo->setBackgroundItem(frameCurr->graphicsItem(), -2);
       
   462         }
       
   463         if (!mNextRegionalInfo) {
       
   464             mNextRegionalInfo = new CalenPluginLabel(mServices, this);
       
   465             mNextPaneLayout->insertItem(0, mNextRegionalInfo);
       
   466 
       
   467             HbFrameItem *frameCurr = new HbFrameItem(this);
       
   468             frameCurr->frameDrawer().setFrameType(HbFrameDrawer::ThreePiecesHorizontal);
       
   469             frameCurr->frameDrawer().setFrameGraphicsName("qtg_fr_cal_preview_title_bg");
       
   470             mNextRegionalInfo->setBackgroundItem(frameCurr->graphicsItem(), -2);
       
   471         }
       
   472         
       
   473         if (pluginEnabled()) {
       
   474 			QString *pluginString = pluginText();
       
   475 			mPrevRegionalInfo->setPlainText(*pluginString);
       
   476 			mCurrRegionalInfo->setPlainText(*pluginString);
       
   477 			mNextRegionalInfo->setPlainText(*pluginString);
       
   478 		}
       
   479     } else {
       
   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 }
       
   497 
       
   498 /*!
       
   499  Handles the context changed notification
       
   500  */
       
   501 void CalenMonthView::onContextChanged()
       
   502 {
       
   503 	//Update plugin label after setting context
       
   504 	if (mCurrRegionalInfo && mPrevRegionalInfo && mNextPaneLayout
       
   505 	        && pluginEnabled()) {
       
   506 		QString *pluginString = pluginText();
       
   507 		mPrevRegionalInfo->setPlainText(*pluginString);
       
   508 		mCurrRegionalInfo->setPlainText(*pluginString);
       
   509 		mNextRegionalInfo->setPlainText(*pluginString);
       
   510 	}
   391 }
   511 }
   392 
   512 
   393 /*!
   513 /*!
   394  Calculates the week numbers and sets them to the week labels
   514  Calculates the week numbers and sets them to the week labels
   395  */
   515  */
   438  Populates the month view with today as focussed item
   558  Populates the month view with today as focussed item
   439  */
   559  */
   440 void CalenMonthView::goToToday()
   560 void CalenMonthView::goToToday()
   441 {
   561 {
   442 	QDateTime today = CalenDateUtils::today();
   562 	QDateTime today = CalenDateUtils::today();
   443 	// First check if we are not already
   563 	// First check if we are not alread
   444 	// showing today's month view
   564 	// showing today's month view
   445 	if (mDate == today) {
   565 	if (mDate == today) {
   446 		return;
   566 		return;
       
   567 	} else if (mActiveMonth.date().year() == today.date().year() && 
       
   568 				mActiveMonth.date().month() == today.date().month()) {
       
   569 		// User is in current month only, so just set the focus to current
       
   570 		// date grid item and refresh the preview pane
       
   571 		int currIndex = mFirstDayOfGrid.daysTo(today);
       
   572 		setCurrGridIndex(currIndex);
       
   573 		return;
   447 	}
   574 	}
   448 	
   575 	
   449 	// Set the context and repopulate the view
   576 	// Set the context and repopulate the view
   450 	MCalenContext &context = mServices.Context();
   577 	MCalenContext &context = mServices.Context();
   451 	context.setFocusDateAndTimeL(today, KCalenMonthViewUidValue);
   578 	context.setFocusDateAndTimeL(today, KCalenMonthViewUidValue);
   452 	
   579 	
   453 	mServices.IssueCommandL(ECalenStartActiveStep);
   580 	refreshViewOnGoToDate();
       
   581 }
       
   582 
       
   583 /*
       
   584  Slot to handle adding / removing actions frm the menu when menu is about to
       
   585  shown to the user
       
   586  */
       
   587 void CalenMonthView::addRemoveActionsInMenu()
       
   588 {
       
   589 	HbAction* menuAction = mDeleteSubMenu->menuAction();
       
   590 	// Check if there are no entries in the database
       
   591 	if (mAgendaUtil->areNoEntriesInCalendar() && menuAction) {
       
   592 		// hide the delete entries option
       
   593 		menuAction->setVisible(false);
       
   594 	} else if (menuAction) {
       
   595 		// Show the option to delete
       
   596 		menuAction->setVisible(true);
       
   597 	}
       
   598 	
       
   599 	// Check if we are population for current day, if yes then disable the
       
   600 	// gototoday action
       
   601 	if ((CalenDateUtils::today().date() == mDate.date()) && mGoToTodayAction) {
       
   602 		mGoToTodayAction->setVisible(false);
       
   603 	} else if (mGoToTodayAction){
       
   604 		mGoToTodayAction->setVisible(true);
       
   605 	}
   454 }
   606 }
   455 
   607 
   456 /*!
   608 /*!
   457  Populates the view
   609  Populates the view
   458  */
   610  */
   475 
   627 
   476 	populatePreviewPane(mDate);
   628 	populatePreviewPane(mDate);
   477 
   629 
   478 	// Create the grid items with proper dates
   630 	// Create the grid items with proper dates
   479 	createGrid();
   631 	createGrid();
       
   632 	
       
   633 	// Check if regional information needs to be shown
       
   634 	// and add it or remove it
       
   635 	showHideRegionalInformation();
   480 
   636 
   481 	// Complete the population
   637 	// Complete the population
   482 	completePopulation();
   638 	completePopulation();
   483 
   639 
   484 	// Population is complete, inform it
   640 	// Population is complete, inform it
   493  */
   649  */
   494 void CalenMonthView::prepareForPopulation()
   650 void CalenMonthView::prepareForPopulation()
   495 {
   651 {
   496 	setActiveDay(dateFromContext(mServices.Context()));
   652 	setActiveDay(dateFromContext(mServices.Context()));
   497 	setDate();
   653 	setDate();
       
   654 }
       
   655 
       
   656 /*!
       
   657  Slot to handle gotodate action
       
   658  */
       
   659 void CalenMonthView::refreshViewOnGoToDate()
       
   660 {
       
   661 	setActiveDay(dateFromContext(mServices.Context()));
       
   662 	setDate();
       
   663 	setDateToLabel();
       
   664 	// fetch list of required calendar instances
       
   665 	populateWithInstanceView();
       
   666 
       
   667 	populatePreviewPane(mDate);
       
   668 	
       
   669 	mMonthGrid->updateMonthGridModel(mMonthDataArray, mIndexToBeScrolled);
       
   670 	
       
   671 	// Start the auto scroll on current preview pane
       
   672 	mCurrPreviewPane->startAutoScroll();
   498 }
   673 }
   499 
   674 
   500 /*!
   675 /*!
   501  Reads the date from the context and stores into mDate
   676  Reads the date from the context and stores into mDate
   502  */
   677  */
   520  Calculates the necesary parameters of the month view w.r.t mDate
   695  Calculates the necesary parameters of the month view w.r.t mDate
   521  */
   696  */
   522 void CalenMonthView::setActiveDay(QDateTime day)
   697 void CalenMonthView::setActiveDay(QDateTime day)
   523 {
   698 {
   524 	mDate = day;
   699 	mDate = day;
   525 	// Check if we are population for current day, if yes then disable the
       
   526 	// gototoday action
       
   527 	if ((CalenDateUtils::today().date() == mDate.date()) && mGoToTodayAction) {
       
   528 	    mGoToTodayAction->setVisible(false);
       
   529 	} else if (mGoToTodayAction){
       
   530 	    mGoToTodayAction->setVisible(true);
       
   531 	}
       
   532     
   700     
   533 	mActiveMonth = mDate;
   701 	mActiveMonth = mDate;
   534 	// Get the first day of the previous month
   702 	// Get the first day of the previous month
   535 	QDateTime prevMonthDate = mDate.addMonths(-1);
   703 	QDateTime prevMonthDate = mDate.addMonths(-1);
   536 	int prevMonth = prevMonthDate.date().month();
   704 	int prevMonth = prevMonthDate.date().month();
   580 	// previous month to future month
   748 	// previous month to future month
   581 	mTotalNumOfGridItems = mFirstDayOfGrid.daysTo(mLastDayOfGrid) + 1;
   749 	mTotalNumOfGridItems = mFirstDayOfGrid.daysTo(mLastDayOfGrid) + 1;
   582 
   750 
   583 	// Calculate the last visible day
   751 	// Calculate the last visible day
   584 	int index = (mNumOfRowsInPrevMonth + KNumOfVisibleRows) * KCalenDaysInWeek;
   752 	int index = (mNumOfRowsInPrevMonth + KNumOfVisibleRows) * KCalenDaysInWeek;
   585 	QDateTime lastVisibleDate = mFirstDayOfGrid.addDays(index);
   753 	QDateTime lastVisibleDate = mFirstDayOfGrid.addDays(index - 1);
   586 	QDateTime dateTimeToCalc = mLastDayOfGrid;
   754 	QDateTime dateTimeToCalc = mLastDayOfGrid;
   587 	mNumOfRowsInFutureMonth = 0;
   755 	mNumOfRowsInFutureMonth = 0;
   588 	while (dateTimeToCalc > lastVisibleDate) {
   756 	while (dateTimeToCalc > lastVisibleDate) {
   589 		mNumOfRowsInFutureMonth++;
   757 		mNumOfRowsInFutureMonth++;
   590 		dateTimeToCalc = dateTimeToCalc.addDays(-KCalenDaysInWeek);
   758 		dateTimeToCalc = dateTimeToCalc.addDays(-KCalenDaysInWeek);
   602 	for (int i(0); i < mTotalNumOfGridItems; ++i) {
   770 	for (int i(0); i < mTotalNumOfGridItems; ++i) {
   603 		QDateTime currentDay = CalenDateUtils::futureOf(mFirstDayOfGrid, i);
   771 		QDateTime currentDay = CalenDateUtils::futureOf(mFirstDayOfGrid, i);
   604 		CalenMonthData element(currentDay);
   772 		CalenMonthData element(currentDay);
   605 		mMonthDataArray.append(element);
   773 		mMonthDataArray.append(element);
   606 	}
   774 	}
   607 	// Update the dates with active flag
       
   608 	updateMonthDataArrayWithActiveDates();
       
   609 }
   775 }
   610 
   776 
   611 /*!
   777 /*!
   612  Returns the currDay(Today)
   778  Returns the currDay(Today)
   613  */
   779  */
   724 	}
   890 	}
   725 	// Update the week Numbers model
   891 	// Update the week Numbers model
   726 	if (mIsWeekNumbersShown) {
   892 	if (mIsWeekNumbersShown) {
   727 		updateWeekNumGridModel();
   893 		updateWeekNumGridModel();
   728 	}
   894 	}
   729 
       
   730 	// Update the dates with active flag
       
   731 	updateMonthDataArrayWithActiveDates();
       
   732 }
   895 }
   733 /*!
   896 /*!
   734  Called when up gesture is performed
   897  Called when up gesture is performed
   735  */
   898  */
   736 void CalenMonthView::updateModelWithFutureMonth()
   899 void CalenMonthView::updateModelWithFutureMonth()
   770 		QDateTime currentDay = previousLastDayOfGrid.addDays(i);
   933 		QDateTime currentDay = previousLastDayOfGrid.addDays(i);
   771 		CalenMonthData element(currentDay);
   934 		CalenMonthData element(currentDay);
   772 		mMonthDataArray.append(element);
   935 		mMonthDataArray.append(element);
   773 	}
   936 	}
   774 
   937 
   775 	// Update the mMonthDataArray with instances if any
   938 	
   776 	populateNextMonth();
       
   777 
   939 
   778 	// Update the necessary globals
   940 	// Update the necessary globals
   779 	mTotalNumOfGridItems += countToBeAdded;
   941 	mTotalNumOfGridItems += countToBeAdded;
   780 	mActiveMonth = mActiveMonth.addMonths(1);
   942 	mActiveMonth = mActiveMonth.addMonths(1);
   781 	mNumOfRowsInFutureMonth = (countToBeAdded / KCalenDaysInWeek);
   943 	mNumOfRowsInFutureMonth = (countToBeAdded / KCalenDaysInWeek);
   793 
   955 
   794 	// Update the week Numbers model
   956 	// Update the week Numbers model
   795 	if (mIsWeekNumbersShown) {
   957 	if (mIsWeekNumbersShown) {
   796 		updateWeekNumGridModel();
   958 		updateWeekNumGridModel();
   797 	}
   959 	}
   798 
   960 	
   799 	// Update the dates with active flag
   961 	// Update the mMonthDataArray with instances if any
   800 	updateMonthDataArrayWithActiveDates();
   962 	populateNextMonth();
       
   963 		
   801 }
   964 }
   802 
   965 
   803 /*!
   966 /*!
   804  Returns the numner of rows in previous month
   967  Returns the numner of rows in previous month
   805  */
   968  */
   877 	const int todayIndex(gridStart.daysTo(today)); 
  1040 	const int todayIndex(gridStart.daysTo(today)); 
   878 
  1041 
   879 	QDateTime gridEnd(mLastDayOfGrid.date(), QTime(23, 59, 59, 0));
  1042 	QDateTime gridEnd(mLastDayOfGrid.date(), QTime(23, 59, 59, 0));
   880 	QList<AgendaEntry> list;
  1043 	QList<AgendaEntry> list;
   881 
  1044 
   882 	getInstanceList(list, gridStart, gridEnd);
  1045 	AgendaUtil::FilterFlags filter =
   883 
  1046 		        AgendaUtil::FilterFlags(AgendaUtil::IncludeAnniversaries
   884 	//Parse fetched items
  1047 		                | AgendaUtil::IncludeAppointments
   885 	if (list.count()) {
  1048 		                | AgendaUtil::IncludeEvents
   886 		for (int i(0); i < list.count(); i++) {
  1049 		                | AgendaUtil::IncludeReminders
   887 			AgendaEntry entry = list[i];
  1050 		                | AgendaUtil::IncludeIncompletedTodos);
   888 
  1051 	
   889 			// Parse  Day Notes, Appointments and Remainders
  1052 	// Get the list of dates which have events
   890 			// Start and end time of Event/Appointment/Remainders has to be 
  1053 	QList<QDate> datesWithEvents;
   891 			// indentified before marking the tags
  1054 	mAgendaUtil->markDatesWithEvents(gridStart,gridEnd,filter,datesWithEvents);
   892 			// EEvents/Appointments can span multiple days, 
  1055 	
   893 			// while Anniversaries cannot.
  1056 	// Parse thru the list of dates and set the required flags
   894 			if ((entry.type() == AgendaEntry::TypeEvent) || (entry.type()
  1057 	for(int i(0); i < datesWithEvents.count(); i++) {
   895 			        == AgendaEntry::TypeAppoinment) || (entry.type()
  1058 		int offset = mFirstDayOfGrid.date().daysTo(datesWithEvents.at(i));
   896 			        == AgendaEntry::TypeReminder)) {
  1059 		mMonthDataArray[offset].SetHasEvents(true);
   897 				// The start time of the instance
  1060 	}
   898 				QDateTime startTime = entry.startTime();
  1061 
   899 				// The instance's start index from the grid start           
  1062 	datesWithEvents.clear();
   900 				int startIndex(gridStart.daysTo(startTime));
       
   901 				// The end time of the instance
       
   902 				QDateTime endTime = entry.endTime();
       
   903 
       
   904 				if (CalenAgendaUtils::endsAtStartOfDayL(entry, endTime)) {
       
   905 					// prevent problems with items ending tomorrow at 00:00
       
   906 					QTime time = endTime.time();
       
   907 					time.setHMS(time.hour(), time.minute() - 1, time.second(),
       
   908 					            time.msec());
       
   909 					endTime.setTime(time);
       
   910 
       
   911 					if (endTime <= gridStart) {
       
   912 						// ends at the start of the grid -> not visible
       
   913 						continue; // skip
       
   914 					}
       
   915 				}
       
   916 				// The instance's end index from the grid start             
       
   917 				int endIndex(gridStart.daysTo(endTime));
       
   918 
       
   919 				// Mark the days from start index to end index
       
   920 				for (; startIndex <= endIndex; startIndex++) {
       
   921 					if (startIndex >= 0 && 
       
   922 							startIndex < mMonthDataArray.count()) {
       
   923 						mMonthDataArray[startIndex].SetHasEvents(true);
       
   924 					}
       
   925 				} // Parse Anniversaries
       
   926 			} else if (entry.type() == AgendaEntry::TypeAnniversary) {
       
   927 				QDateTime startTime = entry.startTime();
       
   928 				// The instance's start index from the grid start           
       
   929 				int index(gridStart.daysTo(startTime));
       
   930 				// Mark the particular day
       
   931 				if (index >= 0 && index < mMonthDataArray.count()) {
       
   932 					mMonthDataArray[index].SetHasEvents(true);
       
   933 				} // Parse To DOs
       
   934 			} else if (entry.type() == AgendaEntry::TypeTodo) {
       
   935 				QDateTime startTime = entry.startTime();
       
   936 				;
       
   937 				int index;
       
   938 				// Mark the particular day if the instance's start 
       
   939 				// time is not in the past
       
   940 				if (startTime >= today) {
       
   941 					index = gridStart.daysTo(startTime);
       
   942 				} else {// Mark for today if the instance's 
       
   943 					// start time is in the past
       
   944 					index = todayIndex;
       
   945 				}
       
   946 				if (index >= 0 && index < mMonthDataArray.count()) {
       
   947 					mMonthDataArray[index].SetHasEvents(true);
       
   948 				}
       
   949 			}
       
   950 		}
       
   951 	}
       
   952 	list.clear();
       
   953 }
  1063 }
   954 
  1064 
   955 /*!
  1065 /*!
   956  Parses the fetched entries for previous month and 
  1066  Parses the fetched entries for previous month and 
   957  sets hasEvent attribute for necessary days
  1067  sets hasEvent attribute for necessary days
   964 
  1074 
   965 	const int todayIndex(gridStart.daysTo(today)); // grid index for "today"
  1075 	const int todayIndex(gridStart.daysTo(today)); // grid index for "today"
   966 	QDateTime end = gridStart.addDays(mNumOfRowsInPrevMonth * KCalenDaysInWeek);
  1076 	QDateTime end = gridStart.addDays(mNumOfRowsInPrevMonth * KCalenDaysInWeek);
   967 	QDateTime gridEnd(end.date(), QTime(23, 59, 59, 0));
  1077 	QDateTime gridEnd(end.date(), QTime(23, 59, 59, 0));
   968 
  1078 
   969 	getInstanceList(list, gridStart, gridEnd);
  1079 
   970 
  1080 	AgendaUtil::FilterFlags filter =
   971 	//Parse fetched items
  1081 		        AgendaUtil::FilterFlags(AgendaUtil::IncludeAnniversaries
   972 	if (list.count()) {
  1082 		                | AgendaUtil::IncludeAppointments
   973 		for (int i(0); i < list.count(); i++) {
  1083 		                | AgendaUtil::IncludeEvents
   974 			AgendaEntry entry = list[i];
  1084 		                | AgendaUtil::IncludeReminders
   975 
  1085 		                | AgendaUtil::IncludeIncompletedTodos);
   976 			// Parse  Day Notes, Appointments and Remainders
  1086 						
   977 			// Start and end time of Event/Appointment/Remainders 
  1087 	// Get the list of dates which have events
   978 			// has to be indentified before marking the tags
  1088 	QList<QDate> datesWithEvents;
   979 			// EEvents/Appointments can span multiple days, 
  1089 	mAgendaUtil->markDatesWithEvents(gridStart,gridEnd,filter,datesWithEvents);
   980 			// while Anniversaries cannot.
  1090 	
   981 			if ((entry.type() == AgendaEntry::TypeEvent) || (entry.type()
  1091 	// Parse thru the list of dates and set the required flags
   982 			        == AgendaEntry::TypeAppoinment) || (entry.type()
  1092 	for(int i(0); i < datesWithEvents.count(); i++) {
   983 			        == AgendaEntry::TypeReminder)) {
  1093 		int offset = mFirstDayOfGrid.date().daysTo(datesWithEvents.at(i));
   984 				// The start time of the instance
  1094 		mMonthDataArray[offset].SetHasEvents(true);
   985 				QDateTime startTime = entry.startTime();
  1095 	}
   986 				// The instance's start index from the grid start           
  1096 	
   987 				int startIndex(gridStart.daysTo(startTime));
  1097 	datesWithEvents.clear();
   988 				// The end time of the instance
       
   989 				QDateTime endTime = entry.endTime();
       
   990 
       
   991 				if (CalenAgendaUtils::endsAtStartOfDayL(entry, endTime)) {
       
   992 					// prevent problems with items ending tomorrow at 00:00
       
   993 					QTime time = endTime.time();
       
   994 					time.setHMS(time.hour(), time.minute() - 1, time.second(),
       
   995 					            time.msec());
       
   996 					endTime.setTime(time);
       
   997 
       
   998 					if (endTime <= gridStart) {
       
   999 						// ends at the start of the grid -> not visible
       
  1000 						continue; // skip
       
  1001 					}
       
  1002 				}
       
  1003 				// The instance's end index from the grid start             
       
  1004 				int endIndex(gridStart.daysTo(endTime));
       
  1005 
       
  1006 				// Mark the days from start index to end index
       
  1007 				for (; startIndex <= endIndex; startIndex++) {
       
  1008 					if (startIndex >= 0 && 
       
  1009 							startIndex < mMonthDataArray.count()) {
       
  1010 						mMonthDataArray[startIndex].SetHasEvents(true);
       
  1011 					}
       
  1012 				} // Parse Anniversaries
       
  1013 			} else if (entry.type() == AgendaEntry::TypeAnniversary) {
       
  1014 				QDateTime startTime = entry.startTime();
       
  1015 				// The instance's start index from the grid start           
       
  1016 				int index(gridStart.daysTo(startTime));
       
  1017 				// Mark the particular day
       
  1018 				if (index >= 0 && index < mMonthDataArray.count()) {
       
  1019 					mMonthDataArray[index].SetHasEvents(true);
       
  1020 				} // Parse To DOs
       
  1021 			} else if (entry.type() == AgendaEntry::TypeTodo) {
       
  1022 				QDateTime startTime = entry.startTime();
       
  1023 				;
       
  1024 				int index;
       
  1025 				// Mark the particular day if the instance's 
       
  1026 				// start time is not in the past
       
  1027 				if (startTime >= today) {
       
  1028 					index = gridStart.daysTo(startTime);
       
  1029 				} else {// Mark for today if the instance's 
       
  1030 					//start time is in the past
       
  1031 					index = todayIndex;
       
  1032 				}
       
  1033 				if (index >= 0 && index < mMonthDataArray.count()) {
       
  1034 					mMonthDataArray[index].SetHasEvents(true);
       
  1035 				}
       
  1036 			}
       
  1037 		}
       
  1038 	}
       
  1039 	list.clear();
       
  1040 }
  1098 }
  1041 
  1099 
  1042 /*!
  1100 /*!
  1043  Parses the fetched entries for future month and 
  1101  Parses the fetched entries for future month and 
  1044  sets hasEvent attribute for necessary days
  1102  sets hasEvent attribute for necessary days
  1052 	
  1110 	
  1053 	const QDateTime today(CalenDateUtils::today());
  1111 	const QDateTime today(CalenDateUtils::today());
  1054 	const int todayIndex(gridStart.daysTo(today)); // grid index for "today"
  1112 	const int todayIndex(gridStart.daysTo(today)); // grid index for "today"
  1055 	QDateTime gridEnd(mLastDayOfGrid.date(), QTime(23, 59, 59, 0));
  1113 	QDateTime gridEnd(mLastDayOfGrid.date(), QTime(23, 59, 59, 0));
  1056 
  1114 
  1057 	getInstanceList(list, gridStart, gridEnd);
  1115 
  1058 
  1116 	AgendaUtil::FilterFlags filter =
  1059 	//Parse fetched items
  1117 		        AgendaUtil::FilterFlags(AgendaUtil::IncludeAnniversaries
  1060 	if (list.count()) {
  1118 		                | AgendaUtil::IncludeAppointments
  1061 		for (int i(0); i < list.count(); i++) {
  1119 		                | AgendaUtil::IncludeEvents
  1062 			AgendaEntry entry = list[i];
  1120 		                | AgendaUtil::IncludeReminders
  1063 
  1121 		                | AgendaUtil::IncludeIncompletedTodos);
  1064 			// Parse  Day Notes, Appointments and Remainders
  1122 						
  1065 			// Start and end time of Event/Appointment/Remainders 
  1123 	// Get the list of dates which have events
  1066 			// has to be indentified before marking the tags
  1124 	QList<QDate> datesWithEvents;
  1067 			// EEvents/Appointments can span multiple days, 
  1125 	mAgendaUtil->markDatesWithEvents(gridStart,gridEnd,filter,datesWithEvents);
  1068 			// while Anniversaries cannot.
  1126 	
  1069 			if ((entry.type() == AgendaEntry::TypeEvent) || (entry.type()
  1127 	// Parse thru the list of dates and set the required flags
  1070 			        == AgendaEntry::TypeAppoinment) || (entry.type()
  1128 	for(int i(0); i < datesWithEvents.count(); i++) {
  1071 			        == AgendaEntry::TypeReminder)) {
  1129 		int offset = mFirstDayOfGrid.date().daysTo(datesWithEvents.at(i));
  1072 				// The start time of the instance
  1130 		mMonthDataArray[offset].SetHasEvents(true);
  1073 				QDateTime startTime = entry.startTime();
  1131 	}
  1074 				// The instance's start index from the grid start           
  1132 
  1075 				int startIndex(gridStart.daysTo(startTime));
  1133 
  1076 				// The end time of the instance
  1134 	
  1077 				QDateTime endTime = entry.endTime();
  1135 	datesWithEvents.clear();
  1078 
       
  1079 				if (CalenAgendaUtils::endsAtStartOfDayL(entry, endTime)) {
       
  1080 					// prevent problems with items ending tomorrow at 00:00
       
  1081 					QTime time = endTime.time();
       
  1082 					time.setHMS(time.hour(), time.minute() - 1, time.second(),
       
  1083 					            time.msec());
       
  1084 					endTime.setTime(time);
       
  1085 
       
  1086 					if (endTime <= gridStart) {
       
  1087 						// ends at the start of the grid -> not visible
       
  1088 						continue; // skip
       
  1089 					}
       
  1090 				}
       
  1091 				// The instance's end index from the grid start             
       
  1092 				int endIndex(gridStart.daysTo(endTime));
       
  1093 
       
  1094 				// Mark the days from start index to end index
       
  1095 				for (; startIndex <= endIndex; startIndex++) {
       
  1096 					if (startIndex >= 0 && 
       
  1097 							startIndex < mMonthDataArray.count()) {
       
  1098 						mMonthDataArray[actualIndex + startIndex].SetHasEvents(true);
       
  1099 					}
       
  1100 				} // Parse Anniversaries
       
  1101 			} else if (entry.type() == AgendaEntry::TypeAnniversary) {
       
  1102 				QDateTime startTime = entry.startTime();
       
  1103 				// The instance's start index from the grid start           
       
  1104 				int index(gridStart.daysTo(startTime));
       
  1105 				// Mark the particular day
       
  1106 				if (actualIndex +index >= 0 && (actualIndex + index) < mMonthDataArray.count()) {
       
  1107 					mMonthDataArray[actualIndex + index].SetHasEvents(true);
       
  1108 				} // Parse To DOs
       
  1109 			} else if (entry.type() == AgendaEntry::TypeTodo) {
       
  1110 				QDateTime startTime = entry.startTime();
       
  1111 				;
       
  1112 				int index;
       
  1113 				// Mark the particular day if the instance's 
       
  1114 				// start time is not in the past
       
  1115 				if (startTime >= today) {
       
  1116 					index = gridStart.daysTo(startTime);
       
  1117 				} else {// Mark for today if the instance's 
       
  1118 					// start time is in the past
       
  1119 					index = todayIndex;
       
  1120 				}
       
  1121 				if (actualIndex + index >= 0 && (actualIndex + index) < mMonthDataArray.count()) {
       
  1122 					mMonthDataArray[actualIndex + index].SetHasEvents(true);
       
  1123 				}
       
  1124 			}
       
  1125 		}
       
  1126 	}
       
  1127 	list.clear();
       
  1128 }
  1136 }
  1129 
  1137 
  1130 /*!
  1138 /*!
  1131  Populates the preview pane
  1139  Populates the preview pane
  1132  */
  1140  */
  1142  current view to the main window
  1150  current view to the main window
  1143  */
  1151  */
  1144 void CalenMonthView::completePopulation()
  1152 void CalenMonthView::completePopulation()
  1145 {
  1153 {
  1146 	setDateToLabel();
  1154 	setDateToLabel();
  1147 
       
  1148 	//Set this view as current view
       
  1149 	mServices.MainWindow().setCurrentView(this);
       
  1150 }
  1155 }
  1151 
  1156 
  1152 /*!
  1157 /*!
  1153  Launches the day view on tapping of the grid item
  1158  Launches the day view on tapping of the grid item
  1154  */
  1159  */
  1198 	} else {
  1203 	} else {
  1199 		// reset flag
  1204 		// reset flag
  1200 		mIsPrevPaneGesture = false;
  1205 		mIsPrevPaneGesture = false;
  1201 	}
  1206 	}
  1202 	
  1207 	
  1203 	// Check if we are population for current day, if yes then disable the
       
  1204     // gototoday action
       
  1205     if ((CalenDateUtils::today() == mDate) && mGoToTodayAction) {
       
  1206         mGoToTodayAction->setVisible(false);
       
  1207     } else if (mGoToTodayAction){
       
  1208         mGoToTodayAction->setVisible(true);
       
  1209     }
       
  1210 }
  1208 }
  1211 
  1209 
  1212 /*!
  1210 /*!
  1213  Slot to launch the event editor
  1211  Slot to launch the event editor
  1214  */
  1212  */
  1285 	// Append a single space
  1283 	// Append a single space
  1286 	monthString.append(" ");
  1284 	monthString.append(" ");
  1287 	mLocale.setNumberOptions(QLocale::OmitGroupSeparator);
  1285 	mLocale.setNumberOptions(QLocale::OmitGroupSeparator);
  1288 	QString yearString = mLocale.toString(mDate.date().year());
  1286 	QString yearString = mLocale.toString(mDate.date().year());
  1289 	mTitleLabel->setPlainText(hbTrId("txt_calendar_month_label_title_12").arg(monthString).arg(yearString));
  1287 	mTitleLabel->setPlainText(hbTrId("txt_calendar_month_label_title_12").arg(monthString).arg(yearString));
  1290 	QColor monthTitleColor = HbColorScheme::color("qtc_cal_monthgrid_title");
       
  1291 	if (monthTitleColor.isValid()) {
       
  1292 	    mTitleLabel->setTextColor(monthTitleColor);
       
  1293 	}
       
  1294 }
  1288 }
  1295 
  1289 
  1296 /*!
  1290 /*!
  1297  To handle previewpane swipe 
  1291  To handle previewpane swipe 
  1298  */
  1292  */
  1303 	if(rightGesture) {
  1297 	if(rightGesture) {
  1304 		// Need to bring up the previous day preview pane
  1298 		// Need to bring up the previous day preview pane
  1305 		// Create the effect on mCurrPreviewPane to slide to right side
  1299 		// Create the effect on mCurrPreviewPane to slide to right side
  1306 		mPrevPaneParent->setVisible(true);
  1300 		mPrevPaneParent->setVisible(true);
  1307 		if (mOrientation == Qt::Vertical) {
  1301 		if (mOrientation == Qt::Vertical) {
  1308 			HbEffect::add(mCurrPreviewPane,
  1302 			HbEffect::add(mCurrPaneLayoutWidget,
  1309 						  ":/fxml/portrait_preview_pane_hide_on_right_gesture",
  1303 						  ":/fxml/portrait_preview_pane_hide_on_right_gesture",
  1310 						  "hide");
  1304 						  "hide");
  1311 			HbEffect::add(mPrevPreviewPane,
  1305 			HbEffect::add(mPrevPaneLayoutWidget,
  1312 						  ":/fxml/portrait_preview_pane_show_on_right_gesture",
  1306 						  ":/fxml/portrait_preview_pane_show_on_right_gesture",
  1313 						  "show");
  1307 						  "show");
  1314 		} else {
  1308 		} else {
  1315 			HbEffect::add(mCurrPreviewPane,
  1309 			HbEffect::add(mCurrPaneLayoutWidget,
  1316 						  ":/fxml/landscape_preview_pane_hide_on_right_gesture",
  1310 						  ":/fxml/landscape_preview_pane_hide_on_right_gesture",
  1317 						  "hide");
  1311 						  "hide");
  1318 			HbEffect::add(mPrevPreviewPane,
  1312 			HbEffect::add(mPrevPaneLayoutWidget,
  1319 						  ":/fxml/landscape_preview_pane_show_on_right_gesture",
  1313 						  ":/fxml/landscape_preview_pane_show_on_right_gesture",
  1320 						  "show");
  1314 						  "show");
  1321 		}
  1315 		}
  1322 		// Start the effects
  1316 		// Start the effects
  1323 		HbEffect::start(mCurrPreviewPane, "hide");
  1317 		HbEffect::start(mCurrPaneLayoutWidget, "hide");
  1324 		HbEffect::start(mPrevPreviewPane, "show", 
  1318 		HbEffect::start(mPrevPaneLayoutWidget, "show", 
  1325 										this, "handleRightEffectCompleted");
  1319 										this, "handleRightEffectCompleted");
  1326 		
  1320 		
  1327 		//Remove the mCurrPreviewPane from the layout and add mPrevPreviewPane
  1321 		//Remove the mCurrPreviewPane from the layout and add mPrevPreviewPane
  1328 		// to the layout
  1322 		// to the layout
  1329 		viewLayout->removeAt(1);
  1323 		viewLayout->removeAt(1);
  1331 	} else {
  1325 	} else {
  1332 		// Need to bring up the previous day preview pane
  1326 		// Need to bring up the previous day preview pane
  1333 		// Create the effect on mCurrPreviewPane to slide to left side
  1327 		// Create the effect on mCurrPreviewPane to slide to left side
  1334 		mNextPaneParent->setVisible(true);
  1328 		mNextPaneParent->setVisible(true);
  1335 		if (mOrientation == Qt::Vertical) {
  1329 		if (mOrientation == Qt::Vertical) {
  1336 			HbEffect::add(mCurrPreviewPane,
  1330 			HbEffect::add(mCurrPaneLayoutWidget,
  1337 						  ":/fxml/portrait_preview_pane_hide_on_left_gesture",
  1331 						  ":/fxml/portrait_preview_pane_hide_on_left_gesture",
  1338 						  "hide");
  1332 						  "hide");
  1339 			HbEffect::add(mNextPreviewPane,
  1333 			HbEffect::add(mNextPaneLayoutWidget,
  1340 						  ":/fxml/portrait_preview_pane_show_on_left_gesture",
  1334 						  ":/fxml/portrait_preview_pane_show_on_left_gesture",
  1341 						  "show");
  1335 						  "show");
  1342 		} else {
  1336 		} else {
  1343 			HbEffect::add(mCurrPreviewPane,
  1337 			HbEffect::add(mCurrPaneLayoutWidget,
  1344 						  ":/fxml/landscape_preview_pane_hide_on_left_gesture",
  1338 						  ":/fxml/landscape_preview_pane_hide_on_left_gesture",
  1345 						  "hide");
  1339 						  "hide");
  1346 			HbEffect::add(mNextPreviewPane,
  1340 			HbEffect::add(mNextPaneLayoutWidget,
  1347 						  ":/fxml/landscape_preview_pane_show_on_left_gesture",
  1341 						  ":/fxml/landscape_preview_pane_show_on_left_gesture",
  1348 						  "show");
  1342 						  "show");
  1349 		}
  1343 		}
  1350 		
  1344 		
  1351 		// Start the effects
  1345 		// Start the effects
  1352 		HbEffect::start(mCurrPreviewPane, "hide");
  1346 		HbEffect::start(mCurrPaneLayoutWidget, "hide");
  1353 		HbEffect::start(mNextPreviewPane, "show", 
  1347 		HbEffect::start(mNextPaneLayoutWidget, "show", 
  1354 										this, "handleLeftEffectCompleted");
  1348 										this, "handleLeftEffectCompleted");
  1355 		
  1349 		
  1356 		//Remove the mCurrPreviewPane from the layout and add mNextPreviewPane
  1350 		//Remove the mCurrPreviewPane from the layout and add mNextPreviewPane
  1357 		// to the layout
  1351 		// to the layout
  1358 		viewLayout->removeAt(1);
  1352 		viewLayout->removeAt(1);
  1359 		viewLayout->addItem(mNextPaneParent);
  1353 		viewLayout->addItem(mNextPaneParent);
  1360 	}
  1354 	}
  1361 }
  1355 }
  1362 
  1356 
  1363 /*!
  1357 /*!
       
  1358  Returns the first date in the month grid
       
  1359  */
       
  1360 QDateTime CalenMonthView::firstDayOfGrid()
       
  1361 {
       
  1362 	return mFirstDayOfGrid;
       
  1363 }
       
  1364 
       
  1365 /*!
  1364  Function to handle any locale related changes
  1366  Function to handle any locale related changes
  1365  */
  1367  */
  1366 void CalenMonthView::onLocaleChanged(int reason)
  1368 void CalenMonthView::onLocaleChanged(int reason)
  1367 {
  1369 {
  1368 	Q_UNUSED(reason);
  1370 	Q_UNUSED(reason);
  1383 	mCurrPreviewPane->stopScrolling();
  1385 	mCurrPreviewPane->stopScrolling();
  1384 	
  1386 	
  1385 	// Swap the preview panes properly
  1387 	// Swap the preview panes properly
  1386 	CalenPreviewPane* pane = mCurrPreviewPane;
  1388 	CalenPreviewPane* pane = mCurrPreviewPane;
  1387 	HbWidget* paneParent = mCurrPaneParent;
  1389 	HbWidget* paneParent = mCurrPaneParent;
       
  1390 	HbWidget* paneLayoutWidget = mCurrPaneLayoutWidget;
  1388 	mCurrPreviewPane = mNextPreviewPane;
  1391 	mCurrPreviewPane = mNextPreviewPane;
  1389 	mCurrPaneParent = mNextPaneParent;
  1392 	mCurrPaneParent = mNextPaneParent;
       
  1393 	mCurrPaneLayoutWidget = mNextPaneLayoutWidget;
  1390 	mNextPreviewPane = mPrevPreviewPane;
  1394 	mNextPreviewPane = mPrevPreviewPane;
  1391 	mNextPaneParent = mPrevPaneParent;
  1395 	mNextPaneParent = mPrevPaneParent;
       
  1396 	mNextPaneLayoutWidget = mPrevPaneLayoutWidget;
  1392 	mPrevPreviewPane = pane;
  1397 	mPrevPreviewPane = pane;
  1393 	mPrevPaneParent = paneParent;
  1398 	mPrevPaneParent = paneParent;
       
  1399 	mPrevPaneLayoutWidget = paneLayoutWidget;
  1394 	
  1400 	
  1395 	// Set the focus to proper date
  1401 	// Set the focus to proper date
  1396 	setCurrGridIndex(index);
  1402 	setCurrGridIndex(index);
  1397 	// Start the auto scroll on current preview pane
  1403 	// Start the auto scroll on current preview pane
  1398 	mCurrPreviewPane->startAutoScroll();
  1404 	mCurrPreviewPane->startAutoScroll();
  1414 	mCurrPreviewPane->stopScrolling();
  1420 	mCurrPreviewPane->stopScrolling();
  1415 		
  1421 		
  1416 	// Swap the preview panes properly
  1422 	// Swap the preview panes properly
  1417 	CalenPreviewPane* pane = mCurrPreviewPane;
  1423 	CalenPreviewPane* pane = mCurrPreviewPane;
  1418 	HbWidget* paneParent = mCurrPaneParent;
  1424 	HbWidget* paneParent = mCurrPaneParent;
       
  1425 	HbWidget* paneLayoutWidget = mCurrPaneLayoutWidget;
  1419 	mCurrPreviewPane = mPrevPreviewPane;
  1426 	mCurrPreviewPane = mPrevPreviewPane;
  1420 	mCurrPaneParent = mPrevPaneParent;
  1427 	mCurrPaneParent = mPrevPaneParent;
       
  1428 	mCurrPaneLayoutWidget = mPrevPaneLayoutWidget;
  1421 	mPrevPreviewPane = mNextPreviewPane;
  1429 	mPrevPreviewPane = mNextPreviewPane;
  1422 	mPrevPaneParent = mNextPaneParent;
  1430 	mPrevPaneParent = mNextPaneParent;
       
  1431 	mPrevPaneLayoutWidget = mNextPaneLayoutWidget;
  1423 	mNextPreviewPane = pane;
  1432 	mNextPreviewPane = pane;
  1424 	mNextPaneParent = paneParent;
  1433 	mNextPaneParent = paneParent;
       
  1434 	mNextPaneLayoutWidget = paneLayoutWidget;
  1425 	
  1435 	
  1426 	// Set the focus to proper date
  1436 	// Set the focus to proper date
  1427 	setCurrGridIndex(index);
  1437 	setCurrGridIndex(index);
  1428 	// Start the auto scroll on current preview pane
  1438 	// Start the auto scroll on current preview pane
  1429 	mCurrPreviewPane->startAutoScroll();
  1439 	mCurrPreviewPane->startAutoScroll();