1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** No Commercial Usage
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU Lesser
18 ** General Public License version 2.1 as published by the Free Software
19 ** Foundation and appearing in the file LICENSE.LGPL included in the
20 ** packaging of this file. Please review the following information to
21 ** ensure the GNU Lesser General Public License version 2.1 requirements
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 ** In addition, as a special exception, Nokia gives you certain additional
25 ** rights. These rights are described in the Nokia Qt LGPL Exception
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
40 ****************************************************************************/
42 #ifndef QDECLARATIVEMOUSEREGION_P_H
43 #define QDECLARATIVEMOUSEREGION_P_H
49 // This file is not part of the Qt API. It exists purely as an
50 // implementation detail. This header file may change from version to
51 // version without notice, or even be removed.
56 #include "private/qdeclarativeitem_p.h"
58 #include <qdatetime.h>
59 #include <qbasictimer.h>
60 #include <qgraphicssceneevent.h>
64 class QDeclarativeMouseAreaPrivate : public QDeclarativeItemPrivate
66 Q_DECLARE_PUBLIC(QDeclarativeMouseArea)
69 QDeclarativeMouseAreaPrivate()
70 : absorb(true), hovered(false), pressed(false), longPress(false),
71 moved(false), stealMouse(false), doubleClick(false), preventStealing(false), drag(0)
73 Q_Q(QDeclarativeMouseArea);
74 forwardTo = QDeclarativeListProperty<QGraphicsObject>(q, forwardToList);
77 ~QDeclarativeMouseAreaPrivate();
81 Q_Q(QDeclarativeMouseArea);
82 q->setAcceptedMouseButtons(Qt::LeftButton);
83 q->setFiltersChildEvents(true);
86 void saveEvent(QGraphicsSceneMouseEvent *event) {
87 lastPos = event->pos();
88 lastScenePos = event->scenePos();
89 lastButton = event->button();
90 lastButtons = event->buttons();
91 lastModifiers = event->modifiers();
94 void forwardEvent(QGraphicsSceneMouseEvent* event)
96 Q_Q(QDeclarativeMouseArea);
97 for(int i=0; i < forwardToList.count(); i++){
98 event->setPos(forwardToList[i]->mapFromScene(event->scenePos()));
99 forwardToList[i]->scene()->sendEvent(forwardToList[i], event);
100 if(event->isAccepted())
103 event->setPos(q->mapFromScene(event->scenePos()));
106 bool isPressAndHoldConnected() {
107 Q_Q(QDeclarativeMouseArea);
108 static int idx = QObjectPrivate::get(q)->signalIndex("pressAndHold(QDeclarativeMouseEvent*)");
109 return QObjectPrivate::get(q)->isSignalConnected(idx);
112 bool isDoubleClickConnected() {
113 Q_Q(QDeclarativeMouseArea);
114 static int idx = QObjectPrivate::get(q)->signalIndex("doubleClicked(QDeclarativeMouseEvent*)");
115 return QObjectPrivate::get(q)->isSignalConnected(idx);
126 bool doubleClick : 1;
127 bool preventStealing : 1;
128 QDeclarativeDrag *drag;
133 QDeclarativeNullableValue<QPointF> lastScenePos;
134 Qt::MouseButton lastButton;
135 Qt::MouseButtons lastButtons;
136 Qt::KeyboardModifiers lastModifiers;
137 QBasicTimer pressAndHoldTimer;
139 QDeclarativeListProperty<QGraphicsObject> forwardTo;
140 QList<QGraphicsObject*> forwardToList;
145 #endif // QDECLARATIVEMOUSEREGION_P_H