304 /*! |
306 /*! |
305 Scrolls the content dowmwards |
307 Scrolls the content dowmwards |
306 */ |
308 */ |
307 void CalenMonthGrid::downGesture() |
309 void CalenMonthGrid::downGesture() |
308 { |
310 { |
|
311 // Make sure that content widget is properly placed |
|
312 if (mIsNonActiveDayFocused) { |
|
313 mIsAtomicScroll = true; |
|
314 int itemToBeScrolled = mView->rowsInPrevMonth() * KCalenDaysInWeek; |
|
315 QModelIndex indexToBeScrolled = mModel->index(itemToBeScrolled, 0); |
|
316 scrollTo(indexToBeScrolled); |
|
317 } |
309 mDirection = down; |
318 mDirection = down; |
310 mIsAtomicScroll = false; |
319 mIsAtomicScroll = false; |
311 setAttribute(Hb::InteractionDisabled); |
320 setAttribute(Hb::InteractionDisabled); |
312 QPointF targetPos(0.0, 0.0); |
321 QPointF targetPos(0.0, 0.0); |
313 scrollContentsTo(targetPos,500); |
322 scrollContentsTo(targetPos,500); |
316 /*! |
325 /*! |
317 Scrolls the content upwards |
326 Scrolls the content upwards |
318 */ |
327 */ |
319 void CalenMonthGrid::upGesture() |
328 void CalenMonthGrid::upGesture() |
320 { |
329 { |
|
330 // Make sure that content widget is properly placed |
|
331 if (mIsNonActiveDayFocused) { |
|
332 mIsAtomicScroll = true; |
|
333 int itemToBeScrolled = mView->rowsInPrevMonth() * KCalenDaysInWeek; |
|
334 itemToBeScrolled += KNumOfVisibleRows * KCalenDaysInWeek; |
|
335 QModelIndex indexToBeScrolled = mModel->index(itemToBeScrolled, 0); |
|
336 scrollTo(indexToBeScrolled); |
|
337 } |
321 mDirection = up; |
338 mDirection = up; |
322 mIsAtomicScroll = false; |
339 mIsAtomicScroll = false; |
323 setAttribute(Hb::InteractionDisabled); |
340 setAttribute(Hb::InteractionDisabled); |
324 QPointF targetPos(0.0, mStartPos.y() - size().height()); |
341 QPointF targetPos(0.0, mStartPos.y() - size().height()); |
325 scrollContentsTo(-targetPos,500); |
342 scrollContentsTo(-targetPos,500); |
359 if(HbPanGesture *gesture = qobject_cast<HbPanGesture *>(event->gesture(Qt::PanGesture))) { |
376 if(HbPanGesture *gesture = qobject_cast<HbPanGesture *>(event->gesture(Qt::PanGesture))) { |
360 if (gesture->state() == Qt::GestureStarted) { |
377 if (gesture->state() == Qt::GestureStarted) { |
361 setAttribute(Hb::InteractionDisabled); |
378 setAttribute(Hb::InteractionDisabled); |
362 mIsAtomicScroll = false; |
379 mIsAtomicScroll = false; |
363 if (!mIsPanGesture) { |
380 if (!mIsPanGesture) { |
364 mIsPanGesture = true; |
381 mDirection = invalid; |
365 mIgnoreItemActivated = true; |
|
366 mStartPos = mContentWidget->pos(); |
382 mStartPos = mContentWidget->pos(); |
|
383 // TODO: This work aroung till framework provides an api |
|
384 // to know the direciton of the pan, until then we need |
|
385 // calculate the direction explicitly |
367 // Get to know the direction of the gesture |
386 // Get to know the direction of the gesture |
368 QPointF velocity = gesture->velocity(); |
387 // Use our defined threshold temporarily till scrollarea |
369 if (velocity.y() > 0) { |
388 // frm orbit side is made clever enough not to scroll in other direction |
370 mDirection = down; |
389 // apart frm the registered scroll direction |
371 } else { |
390 QPointF delta = gesture->delta(); |
372 mDirection = up; |
391 if (abs(delta.x()) > MAX_PAN_DIRECTION_THRESHOLD) { |
373 } |
392 // Now see if y coord diff has crossed threshold |
|
393 if (delta.y() > MAX_PAN_DIRECTION_THRESHOLD) { |
|
394 mIsPanGesture = true; |
|
395 mIgnoreItemActivated = true; |
|
396 mDirection = down; |
|
397 } else if (delta.y() < -MAX_PAN_DIRECTION_THRESHOLD){ |
|
398 mIsPanGesture = true; |
|
399 mIgnoreItemActivated = true; |
|
400 mDirection = up; |
|
401 } else { |
|
402 event->accept(Qt::PanGesture); |
|
403 return; |
|
404 } |
|
405 } else if (abs(delta.x()) < MAX_PAN_DIRECTION_THRESHOLD) { |
|
406 if (delta.y() > MIN_PAN_DIRECTION_THRESHOLD) { |
|
407 mIsPanGesture = true; |
|
408 mIgnoreItemActivated = true; |
|
409 mDirection = down; |
|
410 } else if (delta.y() < -MIN_PAN_DIRECTION_THRESHOLD){ |
|
411 mIsPanGesture = true; |
|
412 mIgnoreItemActivated = true; |
|
413 mDirection = up; |
|
414 }else { |
|
415 event->accept(Qt::PanGesture); |
|
416 return; |
|
417 } |
|
418 } |
374 } |
419 } |
375 } else if(gesture->state() == Qt::GestureFinished) { |
|
376 // TODO: Need to handle here to avoid followOn animation |
|
377 } |
420 } |
378 } else if(HbSwipeGesture *gesture = qobject_cast<HbSwipeGesture *>(event->gesture(Qt::SwipeGesture))) { |
421 } else if(HbSwipeGesture *gesture = qobject_cast<HbSwipeGesture *>(event->gesture(Qt::SwipeGesture))) { |
379 if (gesture->state() == Qt::GestureStarted) { |
422 if (gesture->state() == Qt::GestureStarted) { |
380 setAttribute(Hb::InteractionDisabled); |
423 setAttribute(Hb::InteractionDisabled); |
381 mIsAtomicScroll = false; |
424 mIsAtomicScroll = false; |
382 if (gesture->swipeAngle() > 250 && gesture->swipeAngle() < 290 && |
425 mDirection = invalid; |
383 gesture->verticalDirection() == QSwipeGesture::Down) { |
426 if (gesture->sceneVerticalDirection() == QSwipeGesture::Down) { |
384 mDirection = down; |
427 mDirection = down; |
385 } else if (gesture->swipeAngle() > 70 && gesture->swipeAngle() < 110 && |
428 } else if (gesture->sceneVerticalDirection() == QSwipeGesture::Up) { |
386 gesture->verticalDirection() == QSwipeGesture::Up) { |
|
387 mDirection = up; |
429 mDirection = up; |
|
430 } else { |
|
431 event->accept(Qt::SwipeGesture); |
|
432 return; |
388 } |
433 } |
389 } |
434 } |
390 gesture->setSpeed(SCROLL_SPEEED); |
|
391 } |
435 } |
392 |
436 |
393 // Call the parent class to perform the pan gesture |
437 if (mDirection!= invalid) { |
394 // When scrolling finished, month grid will adjust to show the proper month |
438 // Call the parent class to perform the pan gesture |
395 HbScrollArea::gestureEvent(event); |
439 // When scrolling finished, month grid will adjust to show the proper month |
|
440 HbScrollArea::gestureEvent(event); |
|
441 } |
396 } |
442 } |
397 |
443 |
398 /*! |
444 /*! |
399 Gets called when scrolling finishes to update the model |
445 Gets called when scrolling finishes to update the model |
400 */ |
446 */ |
748 return; |
795 return; |
749 } |
796 } |
750 mIsNonActiveDayFocused = false; |
797 mIsNonActiveDayFocused = false; |
751 // Check if the same item has been tapped twice |
798 // Check if the same item has been tapped twice |
752 if (mCurrentRow == index.row()) { |
799 if (mCurrentRow == index.row()) { |
753 // Launch the agenda view |
800 // Launch the Day view |
754 mView->launchDayView(); |
801 mView->launchDayView(); |
755 } else { |
802 } else { |
756 // Reset the focus attribute to this item |
803 // Reset the focus attribute to this item |
757 QModelIndex itemIndex = mModel->index(mCurrentRow,0); |
804 QModelIndex itemIndex = mModel->index(mCurrentRow,0); |
758 if(itemIndex.row() < 0 || itemIndex.row() >= mModel->rowCount() || |
805 if(itemIndex.row() < 0 || itemIndex.row() >= mModel->rowCount() || |
994 if (mGridLineColor.isValid()) { |
1041 if (mGridLineColor.isValid()) { |
995 pen.setBrush(mGridLineColor); |
1042 pen.setBrush(mGridLineColor); |
996 } else { |
1043 } else { |
997 pen.setBrush(mGridBorderColor); |
1044 pen.setBrush(mGridBorderColor); |
998 } |
1045 } |
999 // Set the pen to the painter |
1046 //store the old pen first |
|
1047 QPen oldPen = painter->pen(); |
|
1048 // Set the new pen to the painter |
1000 painter->setPen(pen); |
1049 painter->setPen(pen); |
1001 |
1050 |
1002 // Get the sizes of content widget |
1051 // Get the sizes of content widget |
1003 qreal contentHeight = mContentWidget->size().height(); |
1052 qreal contentHeight = mContentWidget->size().height(); |
1004 qreal contentWidth = mContentWidget->size().width(); |
1053 qreal contentWidth = mContentWidget->size().width(); |