2
Copyright 2011 Marco Martin <notmart@gmail.com>
4
This library is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Library General Public
6
License as published by the Free Software Foundation; either
7
version 2 of the License, or (at your option) any later version.
9
This library is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
Library General Public License for more details.
14
You should have received a copy of the GNU Library General Public License
15
along with this library; see the file COPYING.LIB. If not, write to
16
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
Boston, MA 02110-1301, USA.
20
#ifndef MOUSEEVENTLISTENER_H
21
#define MOUSEEVENTLISTENER_H
23
#include <QDeclarativeItem>
25
class QDeclarativeMouseEvent : public QObject
28
Q_PROPERTY(int x READ x)
29
Q_PROPERTY(int y READ y)
30
Q_PROPERTY(int screenX READ screenX)
31
Q_PROPERTY(int screenY READ screenY)
32
Q_PROPERTY(int button READ button)
33
Q_PROPERTY(int buttons READ buttons)
34
Q_PROPERTY(int modifiers READ modifiers)
37
QDeclarativeMouseEvent(int x, int y, int screenX, int screenY,
38
Qt::MouseButton button,
39
Qt::MouseButtons buttons,
40
Qt::KeyboardModifiers modifiers)
47
m_modifiers(modifiers)
50
int x() const { return m_x; }
51
int y() const { return m_y; }
52
int screenX() const { return m_screenX; }
53
int screenY() const { return m_screenY; }
54
int button() const { return m_button; }
55
int buttons() const { return m_buttons; }
56
int modifiers() const { return m_modifiers; }
58
// only for internal usage
59
void setX(int x) { m_x = x; }
60
void setY(int y) { m_y = y; }
67
Qt::MouseButton m_button;
68
Qt::MouseButtons m_buttons;
69
Qt::KeyboardModifiers m_modifiers;
72
class MouseEventListener : public QDeclarativeItem
77
MouseEventListener(QDeclarativeItem *parent=0);
78
~MouseEventListener();
81
void mousePressEvent(QGraphicsSceneMouseEvent *event);
82
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
83
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
84
bool sceneEventFilter(QGraphicsItem *i, QEvent *e);
87
void pressed(QDeclarativeMouseEvent *mouse);
88
void positionChanged(QDeclarativeMouseEvent *mouse);
89
void released(QDeclarativeMouseEvent *mouse);