Qt 4.8
qdeclarativemousearea_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtDeclarative module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QDECLARATIVEMOUSEAREA_H
43 #define QDECLARATIVEMOUSEAREA_H
44 
45 #include "qdeclarativeitem.h"
46 
48 
50 
51 QT_MODULE(Declarative)
52 
54 {
55  Q_OBJECT
56 
57  Q_ENUMS(Axis)
58  QGraphicsObject *target;
59  Axis axis;
60  qreal minimumX;
61  qreal maximumX;
62  qreal minimumY;
63  qreal maximumY;
64  bool active;
65  bool filterChildren;
66  //### consider drag and drop
67 
68 public:
69  QDeclarativeDrag(QObject *parent=0);
71 
72  QGraphicsObject *target() const;
73  void setTarget(QGraphicsObject *);
74  void resetTarget();
75 
76  enum Axis { XAxis=0x01, YAxis=0x02, XandYAxis=0x03 };
77  Axis axis() const;
78  void setAxis(Axis);
79 
80  qreal xmin() const;
81  void setXmin(qreal);
82  qreal xmax() const;
83  void setXmax(qreal);
84  qreal ymin() const;
85  void setYmin(qreal);
86  qreal ymax() const;
87  void setYmax(qreal);
88 
89  bool active() const;
90  void setActive(bool);
91 
92  bool filterChildren() const;
93  void setFilterChildren(bool);
94 
95 Q_SIGNALS:
96  void targetChanged();
97  void axisChanged();
98  void minimumXChanged();
99  void maximumXChanged();
100  void minimumYChanged();
101  void maximumYChanged();
102  void activeChanged();
103  void filterChildrenChanged();
104 
105 private:
112  bool _active : 1;
115 };
116 
120 {
121  Q_OBJECT
122 
126  bool pressed;
127  bool enabled;
128  Qt::MouseButtons pressedButtons;
129  Qt::MouseButtons acceptedButtons;
131  QDeclarativeDrag *drag; //### add flicking to QDeclarativeDrag or add a QDeclarativeFlick ???
133 
134 public:
137 
138  qreal mouseX() const;
139  qreal mouseY() const;
140 
141  bool isEnabled() const;
142  void setEnabled(bool);
143 
144  bool hovered() const;
145  bool pressed() const;
146 
147  Qt::MouseButtons pressedButtons() const;
148 
149  Qt::MouseButtons acceptedButtons() const;
150  void setAcceptedButtons(Qt::MouseButtons buttons);
151 
152  bool hoverEnabled() const;
153  void setHoverEnabled(bool h);
154 
155  QDeclarativeDrag *drag();
156 
157  bool preventStealing() const;
158  void setPreventStealing(bool prevent);
159 
160 Q_SIGNALS:
161  void hoveredChanged();
162  void pressedChanged();
163  void enabledChanged();
164  void acceptedButtonsChanged();
165  void hoverEnabledChanged();
166  void positionChanged(QDeclarativeMouseEvent *mouse);
167  void mousePositionChanged(QDeclarativeMouseEvent *mouse);
168  Q_REVISION(1) void preventStealingChanged();
169 
170  void pressed(QDeclarativeMouseEvent *mouse);
171  void pressAndHold(QDeclarativeMouseEvent *mouse);
172  void released(QDeclarativeMouseEvent *mouse);
173  void clicked(QDeclarativeMouseEvent *mouse);
174  void doubleClicked(QDeclarativeMouseEvent *mouse);
175  void entered();
176  void exited();
177  void canceled();
178 
179 protected:
180  void setHovered(bool);
181  bool setPressed(bool);
182 
183  void mousePressEvent(QGraphicsSceneMouseEvent *event);
184  void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
185  void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
186  void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
187  void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
188  void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
189  void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
190 #ifndef QT_NO_CONTEXTMENU
192 #endif // QT_NO_CONTEXTMENU
193  bool sceneEvent(QEvent *);
194  bool sendMouseEvent(QGraphicsSceneMouseEvent *event);
196  void timerEvent(QTimerEvent *event);
197 
198  virtual void geometryChanged(const QRectF &newGeometry,
199  const QRectF &oldGeometry);
200  virtual QVariant itemChange(GraphicsItemChange change, const QVariant& value);
201 
202 private:
203  void handlePress();
204  void handleRelease();
205 
206 private:
209 };
210 
212 
215 
217 
218 #endif // QDECLARATIVEMOUSEAREA_H
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
double qreal
Definition: qglobal.h:1193
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
EventRef event
#define QT_MODULE(x)
Definition: qglobal.h:2783
QScopedPointer< QGraphicsItemPrivate > d_ptr
#define QML_DECLARE_TYPE(TYPE)
Definition: qdeclarative.h:56
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
Definition: qgraphicsitem.h:89
The QGraphicsSceneMouseEvent class provides mouse events in the graphics view framework.
static Qt::MouseButtons buttons
virtual void timerEvent(QTimerEvent *)
This event handler can be reimplemented in a subclass to receive timer events for the object...
Definition: qobject.cpp:1294
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
Definition: qglobal.h:2523
GraphicsItemChange
This enum describes the state changes that are notified by QGraphicsItem::itemChange().
bool isEnabled() const
Returns true if the item is enabled; otherwise, false is returned.
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_SIGNALS
Definition: qobjectdefs.h:72
#define Q_ENUMS(x)
Definition: qobjectdefs.h:84
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
The QDeclarativeItem class provides the most basic of all visual items in QML.
QVariant data(int key) const
Returns this item&#39;s custom data for the key key as a QVariant.
void enabledChanged()
This signal gets emitted whenever the item get&#39;s enabled or disabled.
virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
This event handler can be reimplemented in a subclass to process context menu events.
virtual void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
This function is called to handle this item&#39;s changes in geometry from oldGeometry to newGeometry...
#define Q_OBJECT
Definition: qobjectdefs.h:157
#define Q_DECLARE_PRIVATE_D(Dptr, Class)
Definition: qglobal.h:2472
virtual QVariant itemChange(GraphicsItemChange, const QVariant &)
Note that unlike QGraphicsItems, QDeclarativeItem::itemChange() is not called during initial widget p...
The QTimerEvent class contains parameters that describe a timer event.
Definition: qcoreevent.h:341
#define Q_AUTOTEST_EXPORT
Definition: qglobal.h:1510
virtual bool sceneEvent(QEvent *)
QGraphicsObject * _target
void setEnabled(bool enabled)
If enabled is true, the item is enabled; otherwise, it is disabled.
#define class
The QGraphicsObject class provides a base class for all graphics items that require signals...
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
virtual bool sceneEventFilter(QGraphicsItem *watched, QEvent *event)
Filters events for the item watched.
#define QT_END_HEADER
Definition: qglobal.h:137
The QGraphicsSceneHoverEvent class provides hover events in the graphics view framework.
The QGraphicsSceneContextMenuEvent class provides context menu events in the graphics view framework...