calendarui/views/src/calenmonthgrid.cpp
changeset 83 5aadd1120515
parent 81 ce92091cbd61
child 89 b57382753122
equal deleted inserted replaced
82:dcd0ca396fa1 83:5aadd1120515
   375         setFocusToProperDay();
   375         setFocusToProperDay();
   376     }
   376     }
   377     
   377     
   378     // Start the scrolling
   378     // Start the scrolling
   379     QPointF targetPos(0.0, 0.0);
   379     QPointF targetPos(0.0, 0.0);
   380     scrollContentsTo(targetPos,500);
   380     if (floor(targetPos.y()) != floor(mContentWidget->pos().y())) {
       
   381         scrollContentsTo(targetPos,500);
       
   382     } else {
       
   383         scrollingFinished();
       
   384     }
   381     
   385     
   382     OstTraceFunctionExit0( CALENMONTHGRID_DOWNGESTURE_EXIT );
   386     OstTraceFunctionExit0( CALENMONTHGRID_DOWNGESTURE_EXIT );
   383 }
   387 }
   384 
   388 
   385 /*!
   389 /*!
   405     if (!mIsNonActiveDayFocused) {
   409     if (!mIsNonActiveDayFocused) {
   406         setFocusToProperDay();
   410         setFocusToProperDay();
   407     }
   411     }
   408     
   412     
   409     // Start the scrolling
   413     // Start the scrolling
   410     QPointF targetPos(0.0, mStartPos.y() - size().height());
   414     QPointF targetPos(0.0, mStartPos.y() - mFutureMonthHeight);
   411     scrollContentsTo(-targetPos,500);
   415     if (floor(targetPos.y()) != floor(mContentWidget->pos().y())) {\
   412 	
   416         scrollContentsTo(-targetPos,500);
       
   417     } else {
       
   418         scrollingFinished();
       
   419     }
       
   420     // scrollContentsTo(-targetPos,500);
   413     OstTraceFunctionExit0( CALENMONTHGRID_UPGESTURE_EXIT );
   421     OstTraceFunctionExit0( CALENMONTHGRID_UPGESTURE_EXIT );
   414 }
   422 }
   415 
   423 
   416 /*!
   424 /*!
   417  Function to listen mouse press events
   425  Function to listen mouse press events
   466         if (gesture->state() == Qt::GestureStarted) {
   474         if (gesture->state() == Qt::GestureStarted) {
   467             mIsAtomicScroll = false;
   475             mIsAtomicScroll = false;
   468             if (!mIsPanGesture) {
   476             if (!mIsPanGesture) {
   469                 mDirection = invalid;
   477                 mDirection = invalid;
   470                 mStartPos = mContentWidget->pos();
   478                 mStartPos = mContentWidget->pos();
       
   479                 mFutureMonthHeight = abs(mContentWidget->geometry().bottomRight().y() - geometry().bottomRight().y());
   471                 // TODO: This work around till framework provides an api
   480                 // TODO: This work around till framework provides an api
   472                 // to know the direciton of the pan, until then we need
   481                 // to know the direciton of the pan, until then we need
   473                 // calculate the direction explicitly
   482                 // calculate the direction explicitly
   474                 // Get to know the direction of the gesture
   483                 // Get to know the direction of the gesture
   475                 // Use our defined threshold temporarily till scrollarea 
   484                 // Use our defined threshold temporarily till scrollarea 
   588 			appendRows();
   597 			appendRows();
   589 		}
   598 		}
   590 		mDirection = invalid;
   599 		mDirection = invalid;
   591 		mActiveDatesSet = false;
   600 		mActiveDatesSet = false;
   592 	} else {
   601 	} else {
       
   602 	    mIsGridAdjusting = false;
   593         mIsAtomicScroll = false;
   603         mIsAtomicScroll = false;
   594         mDirection = invalid;
   604         mDirection = invalid;
   595 	}
   605 	}
   596 	mIgnoreItemActivated = false;
   606 	mIgnoreItemActivated = false;
   597 	
   607 	
   652 		}
   662 		}
   653 	} else if (month == prevMonth.addMonths(-1).date().month()) {
   663 	} else if (month == prevMonth.addMonths(-1).date().month()) {
   654 		// first visible date belong to previous to previous month
   664 		// first visible date belong to previous to previous month
   655 		// hence, scroll down to bring the previous month
   665 		// hence, scroll down to bring the previous month
   656 		downGesture();
   666 		downGesture();
   657 	} else if (month == nextMonth.date().month()) {
   667 	} else if (month == nextMonth.date().month() || 
   658 		// first visible item belongs to next month
   668 	        month == nextMonth.addMonths(1).date().month()) {
   659 		// Check if the date is more than half of the next month
   669 	    // up gesture to bring the next month
   660 		if (date.date().day() > (nextMonth.date().daysInMonth()) / 2) {
   670 	    upGesture();
   661 			// up gesture to bring the next month
   671 	}  else {
   662 			upGesture();
       
   663 		} else {
       
   664 			// we should again show the current month by scrolling upwards
       
   665 			mDirection = up;
       
   666 			mIsAtomicScroll = true;
       
   667 			scrollContentsTo(-mStartPos,500);
       
   668 		}
       
   669 	} else if (month == nextMonth.addMonths(1).date().month()) {
       
   670 		// first visible date belongs to next to next month
       
   671 		// hence, scroll up to show the next month
       
   672 		upGesture();
       
   673 	} else {
       
   674         // User has panned so that exact month has been scrolled
   672         // User has panned so that exact month has been scrolled
   675         // no need for any adjustment here, just append/prepend the rows
   673         // no need for any adjustment here, just append/prepend the rows
   676         mIsAtomicScroll = false;
   674         mIsAtomicScroll = false;
   677 	}
   675 	}
   678 	
   676 	
   971 			// Add one month to active month
   969 			// Add one month to active month
   972 			activeMonth = activeMonth.addMonths(1);
   970 			activeMonth = activeMonth.addMonths(1);
   973 			if (activeMonth.date().month() == 
   971 			if (activeMonth.date().month() == 
   974 			        nonActiveFocusedDay.date().month()) {
   972 			        nonActiveFocusedDay.date().month()) {
   975 				mDirection = up;
   973 				mDirection = up;
       
   974 				mFutureMonthHeight = abs(mContentWidget->geometry().bottomRight().y() - geometry().bottomRight().y());
   976 				// up gesture
   975 				// up gesture
   977 				upGesture();
   976 				upGesture();
   978 			} else {
   977 			} else if (nonActiveFocusedDay.date().month() ==
       
   978 			        activeMonth.addMonths(-2).date().month()){
   979 				mDirection = down;
   979 				mDirection = down;
   980 				// down gesture
   980 				// down gesture
   981 				downGesture();
   981 				downGesture();
   982 			}
   982 			}
   983 		} 
   983 		}