logsui/logsapp/src/logsrecentcallsview.cpp
changeset 10 b04270301d3b
parent 6 41c0a814d878
child 11 64a47b97e1e1
equal deleted inserted replaced
6:41c0a814d878 10:b04270301d3b
    40 #include <dialpad.h>
    40 #include <dialpad.h>
    41 #include <hblineedit.h>
    41 #include <hblineedit.h>
    42 #include <hbgroupbox.h>
    42 #include <hbgroupbox.h>
    43 #include <hbmessagebox.h>
    43 #include <hbmessagebox.h>
    44 #include <hbmainwindow.h>
    44 #include <hbmainwindow.h>
       
    45 #include <hbswipegesture.h>
    45 #include <QTimer>
    46 #include <QTimer>
    46 #include <hbactivitymanager.h>
    47 #include <hbactivitymanager.h>
    47 
    48 
    48 Q_DECLARE_METATYPE(LogsMatchesModel*)
    49 Q_DECLARE_METATYPE(LogsMatchesModel*)
    49 
    50 
    50 const int logsMissedCallsMarkingDelayMs = 1000;
    51 const int logsMissedCallsMarkingDelayMs = 1000;
    51 const int logsSwipeAngleDelta = 30; // angle is from 0 to 360
       
    52 
    52 
    53 // -----------------------------------------------------------------------------
    53 // -----------------------------------------------------------------------------
    54 // LogsRecentCallsView::LogsRecentCallsView
    54 // LogsRecentCallsView::LogsRecentCallsView
    55 // -----------------------------------------------------------------------------
    55 // -----------------------------------------------------------------------------
    56 //
    56 //
   534 //
   534 //
   535 void LogsRecentCallsView::gestureEvent(QGestureEvent *event)
   535 void LogsRecentCallsView::gestureEvent(QGestureEvent *event)
   536 {
   536 {
   537     QGesture* gesture = event->gesture(Qt::SwipeGesture);
   537     QGesture* gesture = event->gesture(Qt::SwipeGesture);
   538     if (gesture) {
   538     if (gesture) {
   539         QSwipeGesture* swipe = static_cast<QSwipeGesture *>(gesture);
   539         LOGS_QDEBUG( "logs [UI] -> LogsRecentCallsView::gestureEvent()" );
   540         if (swipe->state() == Qt::GestureFinished) {
   540         HbSwipeGesture* swipe = static_cast<HbSwipeGesture *>(gesture);
   541             QSwipeGesture::SwipeDirection direction = swipeAngleToDirection(
   541         if (swipe && swipe->state() == Qt::GestureFinished) {
   542                     swipe->swipeAngle(), logsSwipeAngleDelta);
   542             LOGS_QDEBUG_2( "logs [UI] sceneSwipeAngle: ", swipe->sceneSwipeAngle() );
   543             if (mViewManager.mainWindow().orientation() == Qt::Vertical) {
   543             LOGS_QDEBUG_2( "logs [UI] swipeAngle: ", swipe->swipeAngle() );
   544                 if (direction == QSwipeGesture::Left) {
   544             
   545                     leftFlick();
   545             QSwipeGesture::SwipeDirection direction = swipe->sceneHorizontalDirection(); 
   546                     event->accept(Qt::SwipeGesture);
   546             if (direction == QSwipeGesture::Left) {
   547                 } else if (direction == QSwipeGesture::Right) {
   547                 leftFlick();
   548                     rightFlick();
   548                 event->accept(Qt::SwipeGesture);
   549                     event->accept(Qt::SwipeGesture);
   549             } else if (direction == QSwipeGesture::Right) {
   550                 }
   550                 rightFlick();
   551             } else {
   551                 event->accept(Qt::SwipeGesture);
   552                 if (direction == QSwipeGesture::Down) {
       
   553                     rightFlick();
       
   554                     event->accept(Qt::SwipeGesture);
       
   555                 } else if (direction == QSwipeGesture::Up) {
       
   556                     leftFlick();
       
   557                     event->accept(Qt::SwipeGesture);
       
   558                 }
       
   559             }
   552             }
   560         }
   553         }
   561     }
   554     }
   562 }
       
   563 
       
   564 // -----------------------------------------------------------------------------
       
   565 // LogsRecentCallsView::swipeAngleToDirection
       
   566 // -----------------------------------------------------------------------------
       
   567 //
       
   568 QSwipeGesture::SwipeDirection LogsRecentCallsView::swipeAngleToDirection(
       
   569         int angle, int delta)
       
   570 {
       
   571     QSwipeGesture::SwipeDirection direction(QSwipeGesture::NoDirection);
       
   572     if ((angle > 90-delta) && (angle < 90+delta)) {
       
   573         direction = QSwipeGesture::Up;
       
   574     } else if ((angle > 270-delta) && (angle < 270+delta)) {
       
   575         direction = QSwipeGesture::Down;
       
   576     } else if (((angle >= 0) && (angle < delta)) 
       
   577             || ((angle > 360-delta) && (angle <= 360))) {
       
   578         direction = QSwipeGesture::Right;
       
   579     } else if ((angle > 180-delta) && (angle < 180+delta)) {
       
   580         direction = QSwipeGesture::Left;
       
   581     }
       
   582     LOGS_QDEBUG_4( "logs [UI] LogsRecentCallsView::swipeAngleToDirection() angle: ",
       
   583             angle, " direction: ", direction );
       
   584     return direction;    
       
   585 }
   555 }
   586 
   556 
   587 // -----------------------------------------------------------------------------
   557 // -----------------------------------------------------------------------------
   588 // LogsRecentCallsView::leftFlick
   558 // LogsRecentCallsView::leftFlick
   589 // -----------------------------------------------------------------------------
   559 // -----------------------------------------------------------------------------