393 } |
393 } |
394 // TODO: This work around till framework provides an api |
394 // TODO: This work around till framework provides an api |
395 // to know the direciton of the pan, until then we need |
395 // to know the direciton of the pan, until then we need |
396 // calculate the direction explicitly |
396 // calculate the direction explicitly |
397 // Get to know the direction of the gesture |
397 // Get to know the direction of the gesture |
398 QPointF delta = gesture->delta(); |
398 QPointF delta = gesture->sceneOffset(); |
399 // Check the current orientation of the device and |
399 // Check the horizontal and vertical offsets |
400 // swap the vertical and horizontal distances in landscape |
400 qreal horizontalDiff = delta.x(); |
401 qreal horizontalDiff = 0.0; |
401 qreal verticalDiff = delta.y(); |
402 qreal verticalDiff = 0.0; |
|
403 if (hbInstance->allMainWindows().at(0)->orientation() == Qt::Vertical) { |
|
404 horizontalDiff = delta.x(); |
|
405 verticalDiff = delta.y(); |
|
406 } else { |
|
407 horizontalDiff = delta.y(); |
|
408 verticalDiff = delta.x(); |
|
409 } |
|
410 if (abs(verticalDiff) > MAX_PAN_DIRECTION_THRESHOLD) { |
402 if (abs(verticalDiff) > MAX_PAN_DIRECTION_THRESHOLD) { |
411 // Now see if x coord diff has crossed threshold |
403 // Now see if x coord diff has crossed threshold |
412 if (horizontalDiff > MAX_PAN_DIRECTION_THRESHOLD) { |
404 if (horizontalDiff > MAX_PAN_DIRECTION_THRESHOLD) { |
413 mIsGestureHandled = true; |
|
414 // right gesture |
405 // right gesture |
415 mView->handlePreviewPaneGesture(true); |
406 mView->handlePreviewPaneGesture(true); |
416 event->accept(Qt::PanGesture); |
407 event->accept(Qt::PanGesture); |
417 } else if (horizontalDiff < -MAX_PAN_DIRECTION_THRESHOLD){ |
408 } else if (horizontalDiff < -MAX_PAN_DIRECTION_THRESHOLD){ |
418 mIsGestureHandled = true; |
|
419 // left gesture |
409 // left gesture |
420 mView->handlePreviewPaneGesture(false); |
410 mView->handlePreviewPaneGesture(false); |
421 event->accept(Qt::PanGesture); |
411 event->accept(Qt::PanGesture); |
422 } else { |
412 } else { |
423 event->accept(Qt::PanGesture); |
413 event->accept(Qt::PanGesture); |
427 OstTraceFunctionExit0( DUP1_CALENPREVIEWPANE_GESTUREEVENT_EXIT ); |
417 OstTraceFunctionExit0( DUP1_CALENPREVIEWPANE_GESTUREEVENT_EXIT ); |
428 return; |
418 return; |
429 } |
419 } |
430 } else if (abs(verticalDiff) < MAX_PAN_DIRECTION_THRESHOLD) { |
420 } else if (abs(verticalDiff) < MAX_PAN_DIRECTION_THRESHOLD) { |
431 if (horizontalDiff > MIN_PAN_DIRECTION_THRESHOLD) { |
421 if (horizontalDiff > MIN_PAN_DIRECTION_THRESHOLD) { |
432 mIsGestureHandled = true; |
|
433 // right gesture |
422 // right gesture |
434 mView->handlePreviewPaneGesture(true); |
423 mView->handlePreviewPaneGesture(true); |
435 event->accept(Qt::PanGesture); |
424 event->accept(Qt::PanGesture); |
436 } else if (horizontalDiff < -MIN_PAN_DIRECTION_THRESHOLD){ |
425 } else if (horizontalDiff < -MIN_PAN_DIRECTION_THRESHOLD){ |
437 mIsGestureHandled = true; |
|
438 // left gesture |
426 // left gesture |
439 mView->handlePreviewPaneGesture(false); |
427 mView->handlePreviewPaneGesture(false); |
440 event->accept(Qt::PanGesture); |
428 event->accept(Qt::PanGesture); |
441 }else { |
429 }else { |
442 event->accept(Qt::PanGesture); |
430 event->accept(Qt::PanGesture); |