calendarui/views/src/calenpreviewpane.cpp
changeset 64 1881ad52dc45
parent 63 a3cb48f6c889
child 70 a5ed90760192
equal deleted inserted replaced
63:a3cb48f6c889 64:1881ad52dc45
    19 // System includes
    19 // System includes
    20 #include <QtGui>
    20 #include <QtGui>
    21 #include <qfont.h>
    21 #include <qfont.h>
    22 #include <qicon.h>
    22 #include <qicon.h>
    23 #include <qpainter.h>
    23 #include <qpainter.h>
       
    24 #include <qevent.h>
    24 #include <hblabel.h>
    25 #include <hblabel.h>
    25 #include <hbmainwindow.h>
    26 #include <hbmainwindow.h>
    26 #include <hbframeitem.h>
    27 #include <hbframeitem.h>
    27 #include <hbframedrawer.h>
    28 #include <hbframedrawer.h>
    28 #include <hbfontspec.h>
    29 #include <hbfontspec.h>
   125 	mScrollDirection = up;
   126 	mScrollDirection = up;
   126 	
   127 	
   127 	// Scroll contents to zero position before we display to the user
   128 	// Scroll contents to zero position before we display to the user
   128 	// if it was scrolling already or timer was running
   129 	// if it was scrolling already or timer was running
   129 	mNumOfScrolls = 0;
   130 	mNumOfScrolls = 0;
       
   131 	mScrollDuration = 0;
   130 	stopScrolling();
   132 	stopScrolling();
   131 	
   133 	
   132 	mDate = date;
   134 	mDate = date;
   133 	
   135 	
   134 	// Get Instances for the day
   136 	// Get Instances for the day
   297 	if (mIsNoEntriesAdded) {
   299 	if (mIsNoEntriesAdded) {
   298 		scrollContentsTo(QPointF(0.0,0.0));
   300 		scrollContentsTo(QPointF(0.0,0.0));
   299 		OstTraceFunctionExit0( CALENPREVIEWPANE_STARTAUTOSCROLL_EXIT );
   301 		OstTraceFunctionExit0( CALENPREVIEWPANE_STARTAUTOSCROLL_EXIT );
   300 		return;
   302 		return;
   301 	}
   303 	}
   302 
   304 	
       
   305 	// Stop the timer
       
   306 	mTwoSecTimer->stop();
       
   307 	
       
   308 	// Set the proper scroll direction
       
   309 	mScrollDirection = up;
       
   310 	
   303 	// Start the 2 seconds timer
   311 	// Start the 2 seconds timer
   304 	mTwoSecTimer->setSingleShot(true);
   312 	mTwoSecTimer->setSingleShot(true);
   305 	connect(mTwoSecTimer, SIGNAL(timeout()), this, SLOT(onTwoSecondsTimeout()));
   313 	connect(mTwoSecTimer, SIGNAL(timeout()), this, SLOT(onTwoSecondsTimeout()));
   306 	mTwoSecTimer->start(TWO_SECONDS_TIMER);
   314 	mTwoSecTimer->start(TWO_SECONDS_TIMER);
   307 	
   315 	
   329             mScrollDuration = mHtDiff / SCROLLING_SPEED;
   337             mScrollDuration = mHtDiff / SCROLLING_SPEED;
   330         }
   338         }
   331 	}
   339 	}
   332 	
   340 	
   333     // Start the scrolling in the proper direction
   341     // Start the scrolling in the proper direction
   334 	if (mScrollDirection == up) {
   342 	if (mScrollDirection == up && mScrollDuration) {
   335 		// Start scrolling upwards
   343 		// Start scrolling upwards
   336 		mScrollDirection = down;
   344 		mScrollDirection = down;
   337 		mNumOfScrolls++;
   345 		mNumOfScrolls++;
   338 		QPointF targetPos(0.0, -mHtDiff);
   346 		QPointF targetPos(0.0, -mHtDiff);
   339         scrollContentsTo(-targetPos, mScrollDuration * 1000);
   347         scrollContentsTo(-targetPos, mScrollDuration * 1000);
   340 	} else if (mScrollDirection == down) {
   348 	} else if (mScrollDirection == down && mScrollDuration) {
   341 		mScrollDirection = up;
   349 		mScrollDirection = up;
   342 		mNumOfScrolls++;
   350 		mNumOfScrolls++;
   343 		// Start scrolling downwards
   351 		// Start scrolling downwards
   344 		QPointF targetPos(0.0, 0.0);
   352 		QPointF targetPos(0.0, 0.0);
   345         scrollContentsTo(targetPos, mScrollDuration * 1000);
   353         scrollContentsTo(targetPos, mScrollDuration * 1000);
   436         }
   444         }
   437     } else if(QTapGesture *tapGesture = qobject_cast<QTapGesture *>(event->gesture(Qt::TapGesture))) {
   445     } else if(QTapGesture *tapGesture = qobject_cast<QTapGesture *>(event->gesture(Qt::TapGesture))) {
   438         if (tapGesture && tapGesture->state() == Qt::GestureFinished) {
   446         if (tapGesture && tapGesture->state() == Qt::GestureFinished) {
   439             	HbInstantFeedback::play(HbFeedback::Basic);
   447             	HbInstantFeedback::play(HbFeedback::Basic);
   440                 // Preview pane tapped
   448                 // Preview pane tapped
       
   449             	// Stop the scrolling first
       
   450             	stopScrolling();
       
   451             	// Issue command to launch agenda view
   441                 mServices.IssueCommandL(ECalenAgendaView);
   452                 mServices.IssueCommandL(ECalenAgendaView);
   442                 mView->disconnectAboutToQuitEvent();
   453                 mView->disconnectAboutToQuitEvent();
   443                 event->accept(Qt::TapGesture);
   454                 event->accept(Qt::TapGesture);
   444         }
   455         }
   445     }
   456     }
   464  */
   475  */
   465 void CalenPreviewPane::stopScrolling()
   476 void CalenPreviewPane::stopScrolling()
   466 {
   477 {
   467     OstTraceFunctionEntry0( CALENPREVIEWPANE_STOPSCROLLING_ENTRY );
   478     OstTraceFunctionEntry0( CALENPREVIEWPANE_STOPSCROLLING_ENTRY );
   468     
   479     
   469 	if (isScrolling() || mTwoSecTimer->isActive()) {
   480     mTwoSecTimer->stop();
       
   481 	if (isScrolling()) {
       
   482         mNumOfScrolls = 0; // required so that timer will not get started again in 
       
   483         // scrollingFinished() slot
       
   484         // Stop the scrolling by sending the foucs out event
       
   485         QFocusEvent* focusEvent = new QFocusEvent(QFocusEvent::FocusOut, Qt::MouseFocusReason);
       
   486         focusOutEvent(focusEvent); 
       
   487         
       
   488         // Set the contents position to zero
   470 		scrollContentsTo(QPointF(0.0,0.0));
   489 		scrollContentsTo(QPointF(0.0,0.0));
   471 		
       
   472 		// Call pan gesture with zero delta just to stop the scfrolling 
       
   473 		HbScrollArea::panGesture(QPointF(0.0,0.0));
       
   474 		mTwoSecTimer->stop();
       
   475 	}
   490 	}
   476 	
   491 	
   477 	OstTraceFunctionExit0( CALENPREVIEWPANE_STOPSCROLLING_EXIT );
   492 	OstTraceFunctionExit0( CALENPREVIEWPANE_STOPSCROLLING_EXIT );
   478 }
   493 }
   479 
   494