~ubuntu-branches/ubuntu/raring/plasma-mobile/raring-proposed

« back to all changes in this revision

Viewing changes to components/mobilecomponents/mouseeventlistener.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2012-07-17 12:04:43 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20120717120443-q3ig9u2fnltx67yg
Tags: 2.0+git2012071701-0ubuntu1
* New upstream snapshot
* Remove build-dep on kde-runtime-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
    Copyright 2011 Marco Martin <notmart@gmail.com>
3
 
 
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.
8
 
 
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.
13
 
 
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.
18
 
*/
19
 
 
20
 
#ifndef MOUSEEVENTLISTENER_H
21
 
#define MOUSEEVENTLISTENER_H
22
 
 
23
 
#include <QDeclarativeItem>
24
 
 
25
 
class QDeclarativeMouseEvent : public QObject
26
 
{
27
 
    Q_OBJECT
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)
35
 
 
36
 
public:
37
 
    QDeclarativeMouseEvent(int x, int y, int screenX, int screenY,
38
 
                           Qt::MouseButton button,
39
 
                           Qt::MouseButtons buttons,
40
 
                           Qt::KeyboardModifiers modifiers)
41
 
        : m_x(x),
42
 
          m_y(y),
43
 
          m_screenX(screenX),
44
 
          m_screenY(screenY),
45
 
          m_button(button),
46
 
          m_buttons(buttons),
47
 
          m_modifiers(modifiers)
48
 
    {}
49
 
 
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; }
57
 
 
58
 
    // only for internal usage
59
 
    void setX(int x) { m_x = x; }
60
 
    void setY(int y) { m_y = y; }
61
 
 
62
 
private:
63
 
    int m_x;
64
 
    int m_y;
65
 
    int m_screenX;
66
 
    int m_screenY;
67
 
    Qt::MouseButton m_button;
68
 
    Qt::MouseButtons m_buttons;
69
 
    Qt::KeyboardModifiers m_modifiers;
70
 
};
71
 
 
72
 
class MouseEventListener : public QDeclarativeItem
73
 
{
74
 
    Q_OBJECT
75
 
 
76
 
public:
77
 
    MouseEventListener(QDeclarativeItem *parent=0);
78
 
    ~MouseEventListener();
79
 
 
80
 
protected:
81
 
    void mousePressEvent(QGraphicsSceneMouseEvent *event);
82
 
    void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
83
 
    void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
84
 
    bool sceneEventFilter(QGraphicsItem *i, QEvent *e);
85
 
 
86
 
Q_SIGNALS:
87
 
    void pressed(QDeclarativeMouseEvent *mouse);
88
 
    void positionChanged(QDeclarativeMouseEvent *mouse);
89
 
    void released(QDeclarativeMouseEvent *mouse);
90
 
};
91
 
 
92
 
#endif