Qt 4.8
qdeclarativepincharea_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 QDECLARATIVEPINCHAREA_H
43 #define QDECLARATIVEPINCHAREA_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  qreal minimumScale;
60  qreal maximumScale;
61  qreal minimumRotation;
62  qreal maximumRotation;
63  Axis dragAxis;
64  qreal minimumX;
65  qreal maximumX;
66  qreal minimumY;
67  qreal maximumY;
68  bool active;
69 
70 public:
72 
73  QGraphicsObject *target() const { return m_target; }
74  void setTarget(QGraphicsObject *target) {
75  if (target == m_target)
76  return;
77  m_target = target;
78  emit targetChanged();
79  }
80  void resetTarget() {
81  if (!m_target)
82  return;
83  m_target = 0;
84  emit targetChanged();
85  }
86 
87  qreal minimumScale() const { return m_minScale; }
89  if (s == m_minScale)
90  return;
91  m_minScale = s;
92  emit minimumScaleChanged();
93  }
94  qreal maximumScale() const { return m_maxScale; }
96  if (s == m_maxScale)
97  return;
98  m_maxScale = s;
99  emit maximumScaleChanged();
100  }
101 
102  qreal minimumRotation() const { return m_minRotation; }
104  if (r == m_minRotation)
105  return;
106  m_minRotation = r;
107  emit minimumRotationChanged();
108  }
109  qreal maximumRotation() const { return m_maxRotation; }
111  if (r == m_maxRotation)
112  return;
113  m_maxRotation = r;
114  emit maximumRotationChanged();
115  }
116 
117  enum Axis { NoDrag=0x00, XAxis=0x01, YAxis=0x02, XandYAxis=0x03 };
118  Axis axis() const { return m_axis; }
119  void setAxis(Axis a) {
120  if (a == m_axis)
121  return;
122  m_axis = a;
123  emit dragAxisChanged();
124  }
125 
126  qreal xmin() const { return m_xmin; }
127  void setXmin(qreal x) {
128  if (x == m_xmin)
129  return;
130  m_xmin = x;
131  emit minimumXChanged();
132  }
133  qreal xmax() const { return m_xmax; }
134  void setXmax(qreal x) {
135  if (x == m_xmax)
136  return;
137  m_xmax = x;
138  emit maximumXChanged();
139  }
140  qreal ymin() const { return m_ymin; }
141  void setYmin(qreal y) {
142  if (y == m_ymin)
143  return;
144  m_ymin = y;
145  emit minimumYChanged();
146  }
147  qreal ymax() const { return m_ymax; }
148  void setYmax(qreal y) {
149  if (y == m_ymax)
150  return;
151  m_ymax = y;
152  emit maximumYChanged();
153  }
154 
155  bool active() const { return m_active; }
156  void setActive(bool a) {
157  if (a == m_active)
158  return;
159  m_active = a;
160  emit activeChanged();
161  }
162 
163 signals:
164  void targetChanged();
165  void minimumScaleChanged();
166  void maximumScaleChanged();
167  void minimumRotationChanged();
168  void maximumRotationChanged();
169  void dragAxisChanged();
170  void minimumXChanged();
171  void maximumXChanged();
172  void minimumYChanged();
173  void maximumYChanged();
174  void activeChanged();
175 
176 private:
187  bool m_active;
188 };
189 
191 {
192  Q_OBJECT
193 
207  bool accepted;
208 
209 public:
211  : QObject(), m_center(c), m_scale(s), m_angle(a), m_rotation(r)
212  , m_pointCount(0), m_accepted(true) {}
213 
214  QPointF center() const { return m_center; }
215  QPointF startCenter() const { return m_startCenter; }
216  void setStartCenter(QPointF c) { m_startCenter = c; }
217  QPointF previousCenter() const { return m_lastCenter; }
218  void setPreviousCenter(QPointF c) { m_lastCenter = c; }
219  qreal scale() const { return m_scale; }
220  qreal previousScale() const { return m_lastScale; }
221  void setPreviousScale(qreal s) { m_lastScale = s; }
222  qreal angle() const { return m_angle; }
223  qreal previousAngle() const { return m_lastAngle; }
224  void setPreviousAngle(qreal a) { m_lastAngle = a; }
225  qreal rotation() const { return m_rotation; }
226  QPointF point1() const { return m_point1; }
227  void setPoint1(QPointF p) { m_point1 = p; }
228  QPointF startPoint1() const { return m_startPoint1; }
229  void setStartPoint1(QPointF p) { m_startPoint1 = p; }
230  QPointF point2() const { return m_point2; }
231  void setPoint2(QPointF p) { m_point2 = p; }
232  QPointF startPoint2() const { return m_startPoint2; }
233  void setStartPoint2(QPointF p) { m_startPoint2 = p; }
234  int pointCount() const { return m_pointCount; }
235  void setPointCount(int count) { m_pointCount = count; }
236 
237  bool accepted() const { return m_accepted; }
238  void setAccepted(bool a) { m_accepted = a; }
239 
240 private:
255 };
256 
257 
261 {
262  Q_OBJECT
263 
264  bool enabled;
266 
267 public:
270 
271  bool isEnabled() const;
272  void setEnabled(bool);
273 
274  QDeclarativePinch *pinch();
275 
276 Q_SIGNALS:
277  void enabledChanged();
278  void pinchStarted(QDeclarativePinchEvent *pinch);
279  void pinchUpdated(QDeclarativePinchEvent *pinch);
280  void pinchFinished(QDeclarativePinchEvent *pinch);
281 
282 protected:
286  bool sceneEvent(QEvent *);
287  bool sendMouseEvent(QGraphicsSceneMouseEvent *event);
289  bool event(QEvent *);
290 
291  virtual void geometryChanged(const QRectF &newGeometry,
292  const QRectF &oldGeometry);
293  virtual QVariant itemChange(GraphicsItemChange change, const QVariant& value);
294 
295 private:
296  void updatePinch();
297  void handlePress();
298  void handleRelease();
299 
300 private:
303 };
304 
306 
310 
312 
313 #endif // QDECLARATIVEPINCHAREA_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
unsigned char c[8]
Definition: qnumeric_p.h:62
#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
virtual bool event(QEvent *)
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
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.
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
Definition: qglobal.h:2523
QDeclarativePinchEvent(QPointF c, qreal s, qreal a, qreal r)
long ASN1_INTEGER_get ASN1_INTEGER * a
GraphicsItemChange
This enum describes the state changes that are notified by QGraphicsItem::itemChange().
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event)
This event handler, for event event, can be reimplemented to receive mouse press events for this item...
bool isEnabled() const
Returns true if the item is enabled; otherwise, false is returned.
void setMaximumRotation(qreal r)
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.
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event)
This event handler, for event event, can be reimplemented to receive mouse move events for this item...
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.
#define emit
Definition: qobjectdefs.h:76
QGraphicsObject * m_target
void setTarget(QGraphicsObject *target)
void setMinimumRotation(qreal r)
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...
#define Q_AUTOTEST_EXPORT
Definition: qglobal.h:1510
virtual bool sceneEvent(QEvent *)
void setEnabled(bool enabled)
If enabled is true, the item is enabled; otherwise, it is disabled.
#define signals
Definition: qobjectdefs.h:69
#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
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
This event handler, for event event, can be reimplemented to receive mouse release events for this it...