homescreenapp/hsdomainmodel/src/hspagetoucharea.cpp
changeset 62 341166945d65
child 86 e4f038c420f7
equal deleted inserted replaced
57:2e2dc3d30ca8 62:341166945d65
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 #include <QGesture>
       
    19 
       
    20 #include "hspagetoucharea.h"
       
    21 #include "hsscene.h"
       
    22 
       
    23 HsPageTouchArea::HsPageTouchArea(QGraphicsItem *parent)
       
    24   : HbTouchArea(parent)
       
    25 {
       
    26     grabGesture(Qt::TapAndHoldGesture);
       
    27     grabGesture(Qt::PanGesture);
       
    28 }
       
    29   
       
    30 HsPageTouchArea::~HsPageTouchArea()
       
    31 {
       
    32 }
       
    33 
       
    34 void HsPageTouchArea::gestureEvent(QGestureEvent *event)
       
    35 {
       
    36     HsScene *scene = HsScene::instance();
       
    37     
       
    38     // Tap-and-hold gesture.
       
    39     QGesture *gesture = event->gesture(Qt::TapAndHoldGesture);
       
    40     if (gesture) {
       
    41         switch (gesture->state()) {
       
    42             case Qt::GestureFinished:
       
    43                 emit scene->pageTapAndHoldFinished(event);
       
    44                 break;
       
    45             default:
       
    46                 break;
       
    47         }
       
    48         return;
       
    49     } 
       
    50 
       
    51     // Pan gesture.
       
    52     gesture = event->gesture(Qt::PanGesture);
       
    53     if (gesture) {
       
    54         switch (gesture->state()) {
       
    55             case Qt::GestureStarted:
       
    56                 emit scene->pagePanStarted(event);
       
    57                 break;
       
    58             case Qt::GestureUpdated:
       
    59                 emit scene->pagePanUpdated(event);
       
    60                 break;
       
    61             case Qt::GestureFinished:
       
    62             case Qt::GestureCanceled:
       
    63                 emit scene->pagePanFinished(event);
       
    64                 break;
       
    65             default:
       
    66                 break;
       
    67         }
       
    68         return;
       
    69     }
       
    70 }