1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation ([email protected])
|
---|
6 | **
|
---|
7 | ** This file is part of the QtGui module of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
14 | ** a written agreement between you and Nokia.
|
---|
15 | **
|
---|
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.
|
---|
23 | **
|
---|
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.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you have questions regarding the use of this file, please contact
|
---|
37 | ** Nokia at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | /*!
|
---|
43 | \class QGraphicsSceneEvent
|
---|
44 | \brief The QGraphicsSceneEvent class provides a base class for all
|
---|
45 | graphics view related events.
|
---|
46 | \since 4.2
|
---|
47 | \ingroup graphicsview-api
|
---|
48 |
|
---|
49 | When a QGraphicsView receives Qt mouse, keyboard, and drag and
|
---|
50 | drop events (QMouseEvent, QKeyEvent, QDragEvent, etc.), it
|
---|
51 | translates them into instances of QGraphicsSceneEvent subclasses
|
---|
52 | and forwards them to the QGraphicsScene it displays. The scene
|
---|
53 | then forwards the events to the relevant items.
|
---|
54 |
|
---|
55 | For example, when a QGraphicsView receives a QMouseEvent of type
|
---|
56 | MousePress as a response to a user click, the view sends a
|
---|
57 | QGraphicsSceneMouseEvent of type GraphicsSceneMousePress to the
|
---|
58 | underlying QGraphicsScene through its
|
---|
59 | \l{QGraphicsScene::}{mousePressEvent()} function. The default
|
---|
60 | QGraphicsScene::mousePressEvent() implementation determines which
|
---|
61 | item was clicked and forwards the event to
|
---|
62 | QGraphicsItem::mousePressEvent().
|
---|
63 |
|
---|
64 | \omit ### Beskrive widget() \endomit
|
---|
65 |
|
---|
66 | Subclasses such as QGraphicsSceneMouseEvent and
|
---|
67 | QGraphicsSceneContextMenuEvent provide the coordinates from the
|
---|
68 | original QEvent in screen, scene, and item coordinates (see
|
---|
69 | \l{QGraphicsSceneMouseEvent::}{screenPos()},
|
---|
70 | \l{QGraphicsSceneMouseEvent::}{scenePos()}, and
|
---|
71 | \l{QGraphicsSceneMouseEvent::}{pos()}). The item coordinates are
|
---|
72 | set by the QGraphicsScene before it forwards the event to the
|
---|
73 | event to a QGraphicsItem. The mouse events also add the
|
---|
74 | possibility to retrieve the coordinates from the last event
|
---|
75 | received by the view (see
|
---|
76 | \l{QGraphicsSceneMouseEvent::}{lastScreenPos()},
|
---|
77 | \l{QGraphicsSceneMouseEvent::}{lastScenePos()}, and
|
---|
78 | \l{QGraphicsSceneMouseEvent::}{lastPos()}).
|
---|
79 |
|
---|
80 | \sa QEvent
|
---|
81 | */
|
---|
82 |
|
---|
83 | /*!
|
---|
84 | \class QGraphicsSceneMouseEvent
|
---|
85 | \brief The QGraphicsSceneMouseEvent class provides mouse events
|
---|
86 | in the graphics view framework.
|
---|
87 | \since 4.2
|
---|
88 | \ingroup graphicsview-api
|
---|
89 |
|
---|
90 | When a QGraphicsView receives a QMouseEvent, it translates it to a
|
---|
91 | QGraphicsSceneMouseEvent. The event is then forwarded to the
|
---|
92 | QGraphicsScene associated with the view. If the event is not
|
---|
93 | handled by the scene, the view may use it, e.g., for the
|
---|
94 | \l{QGraphicsView::}{DragMode}.
|
---|
95 |
|
---|
96 | In addition to containing the item, scene, and screen coordinates
|
---|
97 | of the event (as pos(), scenePos(), and screenPos()), mouse
|
---|
98 | events also contain the coordinates of the previous mouse
|
---|
99 | event received by the view. These can be retrieved with
|
---|
100 | lastPos(), lastScreenPos(), and lastScenePos().
|
---|
101 |
|
---|
102 | \sa QGraphicsSceneContextMenuEvent,
|
---|
103 | QGraphicsSceneHoverEvent, QGraphicsSceneWheelEvent,
|
---|
104 | QMouseEvent
|
---|
105 | */
|
---|
106 |
|
---|
107 | /*!
|
---|
108 | \class QGraphicsSceneWheelEvent
|
---|
109 | \brief The QGraphicsSceneWheelEvent class provides wheel events
|
---|
110 | in the graphics view framework.
|
---|
111 | \brief The QGraphicsSceneWheelEvent class provides wheel events in the
|
---|
112 | graphics view framework.
|
---|
113 | \since 4.2
|
---|
114 | \ingroup graphicsview-api
|
---|
115 |
|
---|
116 | \l{QWheelEvent}{QWheelEvent}s received by a QGraphicsView are translated
|
---|
117 | into QGraphicsSceneWheelEvents; it translates the QWheelEvent::globalPos()
|
---|
118 | into item, scene, and screen coordinates (pos(), scenePos(), and
|
---|
119 | screenPos()).
|
---|
120 |
|
---|
121 | \sa QGraphicsSceneMouseEvent, QGraphicsSceneContextMenuEvent,
|
---|
122 | QGraphicsSceneHoverEvent, QWheelEvent
|
---|
123 | */
|
---|
124 |
|
---|
125 | /*!
|
---|
126 | \class QGraphicsSceneContextMenuEvent
|
---|
127 | \brief The QGraphicsSceneContextMenuEvent class provides context
|
---|
128 | menu events in the graphics view framework.
|
---|
129 | \since 4.2
|
---|
130 | \ingroup graphicsview-api
|
---|
131 |
|
---|
132 | A QContextMenuEvent received by a QGraphicsView is translated
|
---|
133 | into a QGraphicsSceneContextMenuEvent. The
|
---|
134 | QContextMenuEvent::globalPos() is translated into item, scene, and
|
---|
135 | screen coordinates (pos(), scenePos(), and screenPos()).
|
---|
136 |
|
---|
137 | \sa QGraphicsSceneMouseEvent, QGraphicsSceneWheelEvent,
|
---|
138 | QContextMenuEvent
|
---|
139 | */
|
---|
140 |
|
---|
141 | /*!
|
---|
142 | \enum QGraphicsSceneContextMenuEvent::Reason
|
---|
143 |
|
---|
144 | This enum describes the reason why the context event was sent.
|
---|
145 |
|
---|
146 | \value Mouse The mouse caused the event to be sent. On most
|
---|
147 | platforms, this means the right mouse button was clicked.
|
---|
148 |
|
---|
149 | \value Keyboard The keyboard caused this event to be sent. On
|
---|
150 | Windows and Mac OS X, this means the menu button was pressed.
|
---|
151 |
|
---|
152 | \value Other The event was sent by some other means (i.e. not
|
---|
153 | by the mouse or keyboard).
|
---|
154 | */
|
---|
155 |
|
---|
156 | /*!
|
---|
157 | \class QGraphicsSceneHoverEvent
|
---|
158 | \brief The QGraphicsSceneHoverEvent class provides hover events
|
---|
159 | in the graphics view framework.
|
---|
160 | \since 4.2
|
---|
161 | \ingroup graphicsview-api
|
---|
162 |
|
---|
163 | When a QGraphicsView receives a QHoverEvent event, it translates
|
---|
164 | it into QGraphicsSceneHoverEvent. The event is then forwarded to
|
---|
165 | the QGraphicsScene associated with the view.
|
---|
166 |
|
---|
167 | \sa QGraphicsSceneMouseEvent, QGraphicsSceneContextMenuEvent,
|
---|
168 | QGraphicsSceneWheelEvent, QHoverEvent
|
---|
169 | */
|
---|
170 |
|
---|
171 | /*!
|
---|
172 | \class QGraphicsSceneHelpEvent
|
---|
173 | \brief The QGraphicsSceneHelpEvent class provides events when a
|
---|
174 | tooltip is requested.
|
---|
175 | \since 4.2
|
---|
176 | \ingroup graphicsview-api
|
---|
177 |
|
---|
178 | When a QGraphicsView receives a QEvent of type
|
---|
179 | QEvent::ToolTip, it creates a QGraphicsSceneHelpEvent, which is
|
---|
180 | forwarded to the scene. You can set a tooltip on a QGraphicsItem
|
---|
181 | with \l{QGraphicsItem::}{setToolTip()}; by default QGraphicsScene
|
---|
182 | displays the tooltip of the QGraphicsItem with the highest
|
---|
183 | z-value (i.e, the top-most item) under the mouse position.
|
---|
184 |
|
---|
185 | QGraphicsView does not forward events when
|
---|
186 | \l{QWhatsThis}{"What's This"} and \l{QStatusTipEvent}{status tip}
|
---|
187 | help is requested. If you need this, you can reimplement
|
---|
188 | QGraphicsView::viewportEvent() and forward QStatusTipEvent
|
---|
189 | events and \l{QEvent}{QEvents} of type QEvent::WhatsThis to the
|
---|
190 | scene.
|
---|
191 |
|
---|
192 | \sa QEvent
|
---|
193 | */
|
---|
194 |
|
---|
195 | /*!
|
---|
196 | \class QGraphicsSceneDragDropEvent
|
---|
197 | \brief The QGraphicsSceneDragDropEvent class provides events for
|
---|
198 | drag and drop in the graphics view framework.
|
---|
199 | \since 4.2
|
---|
200 | \ingroup graphicsview-api
|
---|
201 |
|
---|
202 | QGraphicsView inherits the drag and drop functionality provided
|
---|
203 | by QWidget. When it receives a drag and drop event, it translates
|
---|
204 | it to a QGraphicsSceneDragDropEvent.
|
---|
205 |
|
---|
206 | QGraphicsSceneDragDropEvent stores events of type
|
---|
207 | GraphicsSceneDragEnter, GraphicsSceneDragLeave,
|
---|
208 | GraphicsSceneDragMove, or GraphicsSceneDrop.
|
---|
209 |
|
---|
210 | QGraphicsSceneDragDropEvent contains the position of the mouse
|
---|
211 | cursor in both item, scene, and screen coordinates; this can be
|
---|
212 | retrieved with pos(), scenePos(), and screenPos().
|
---|
213 |
|
---|
214 | The scene sends the event to the first QGraphicsItem under the
|
---|
215 | mouse cursor that accepts drops; a graphics item is set to accept
|
---|
216 | drops with \l{QGraphicsItem::}{setAcceptDrops()}.
|
---|
217 | */
|
---|
218 |
|
---|
219 | /*!
|
---|
220 | \class QGraphicsSceneResizeEvent
|
---|
221 | \brief The QGraphicsSceneResizeEvent class provides events for widget
|
---|
222 | resizing in the graphics view framework.
|
---|
223 | \since 4.4
|
---|
224 | \ingroup graphicsview-api
|
---|
225 |
|
---|
226 | A QGraphicsWidget sends itself a QGraphicsSceneResizeEvent immediately
|
---|
227 | when its geometry changes.
|
---|
228 |
|
---|
229 | It's similar to QResizeEvent, but its sizes, oldSize() and newSize(), use
|
---|
230 | QSizeF instead of QSize.
|
---|
231 |
|
---|
232 | \sa QGraphicsWidget::setGeometry(), QGraphicsWidget::resize()
|
---|
233 | */
|
---|
234 |
|
---|
235 | /*!
|
---|
236 | \class QGraphicsSceneMoveEvent
|
---|
237 | \brief The QGraphicsSceneMoveEvent class provides events for widget
|
---|
238 | moving in the graphics view framework.
|
---|
239 | \since 4.4
|
---|
240 | \ingroup graphicsview-api
|
---|
241 |
|
---|
242 | A QGraphicsWidget sends itself a QGraphicsSceneMoveEvent immediately when
|
---|
243 | its local position changes. The delivery is implemented as part of
|
---|
244 | QGraphicsItem::itemChange().
|
---|
245 |
|
---|
246 | It's similar to QMoveEvent, but its positions, oldPos() and newPos(), use
|
---|
247 | QPointF instead of QPoint.
|
---|
248 |
|
---|
249 | \sa QGraphicsItem::setPos(), QGraphicsItem::ItemPositionChange,
|
---|
250 | QGraphicsItem::ItemPositionHasChanged
|
---|
251 | */
|
---|
252 |
|
---|
253 | #include "qgraphicssceneevent.h"
|
---|
254 |
|
---|
255 | #ifndef QT_NO_GRAPHICSVIEW
|
---|
256 |
|
---|
257 | #ifndef QT_NO_DEBUG
|
---|
258 | #include <QtCore/qdebug.h>
|
---|
259 | #endif
|
---|
260 | #include <QtCore/qmap.h>
|
---|
261 | #include <QtCore/qpoint.h>
|
---|
262 | #include <QtCore/qsize.h>
|
---|
263 | #include <QtCore/qstring.h>
|
---|
264 | #include "qgraphicsview.h"
|
---|
265 | #include "qgraphicsitem.h"
|
---|
266 | #include <QtGui/qgesture.h>
|
---|
267 | #include <private/qevent_p.h>
|
---|
268 |
|
---|
269 | QT_BEGIN_NAMESPACE
|
---|
270 |
|
---|
271 | class QGraphicsSceneEventPrivate
|
---|
272 | {
|
---|
273 | public:
|
---|
274 | inline QGraphicsSceneEventPrivate()
|
---|
275 | : widget(0),
|
---|
276 | q_ptr(0)
|
---|
277 | { }
|
---|
278 |
|
---|
279 | inline virtual ~QGraphicsSceneEventPrivate()
|
---|
280 | { }
|
---|
281 |
|
---|
282 | QWidget *widget;
|
---|
283 | QGraphicsSceneEvent *q_ptr;
|
---|
284 | };
|
---|
285 |
|
---|
286 | /*!
|
---|
287 | \internal
|
---|
288 |
|
---|
289 | Constructs a generic graphics scene event of the specified \a type.
|
---|
290 | */
|
---|
291 | QGraphicsSceneEvent::QGraphicsSceneEvent(Type type)
|
---|
292 | : QEvent(type), d_ptr(new QGraphicsSceneEventPrivate)
|
---|
293 | {
|
---|
294 | d_ptr->q_ptr = this;
|
---|
295 | }
|
---|
296 |
|
---|
297 | /*!
|
---|
298 | \internal
|
---|
299 |
|
---|
300 | Constructs a generic graphics scene event.
|
---|
301 | */
|
---|
302 | QGraphicsSceneEvent::QGraphicsSceneEvent(QGraphicsSceneEventPrivate &dd, Type type)
|
---|
303 | : QEvent(type), d_ptr(&dd)
|
---|
304 | {
|
---|
305 | d_ptr->q_ptr = this;
|
---|
306 | }
|
---|
307 |
|
---|
308 | /*!
|
---|
309 | Destroys the event.
|
---|
310 | */
|
---|
311 | QGraphicsSceneEvent::~QGraphicsSceneEvent()
|
---|
312 | {
|
---|
313 | }
|
---|
314 |
|
---|
315 | /*!
|
---|
316 | Returns the widget where the event originated, or 0 if the event
|
---|
317 | originates from another application.
|
---|
318 | */
|
---|
319 | QWidget *QGraphicsSceneEvent::widget() const
|
---|
320 | {
|
---|
321 | return d_ptr->widget;
|
---|
322 | }
|
---|
323 |
|
---|
324 | /*!
|
---|
325 | \internal
|
---|
326 |
|
---|
327 | Sets the \a widget related to this event.
|
---|
328 |
|
---|
329 | \sa widget()
|
---|
330 | */
|
---|
331 | void QGraphicsSceneEvent::setWidget(QWidget *widget)
|
---|
332 | {
|
---|
333 | d_ptr->widget = widget;
|
---|
334 | }
|
---|
335 |
|
---|
336 | class QGraphicsSceneMouseEventPrivate : public QGraphicsSceneEventPrivate
|
---|
337 | {
|
---|
338 | Q_DECLARE_PUBLIC(QGraphicsSceneMouseEvent)
|
---|
339 | public:
|
---|
340 | inline QGraphicsSceneMouseEventPrivate()
|
---|
341 | : button(Qt::NoButton),
|
---|
342 | buttons(0), modifiers(0)
|
---|
343 | { }
|
---|
344 |
|
---|
345 | QPointF pos;
|
---|
346 | QPointF scenePos;
|
---|
347 | QPoint screenPos;
|
---|
348 | QPointF lastPos;
|
---|
349 | QPointF lastScenePos;
|
---|
350 | QPoint lastScreenPos;
|
---|
351 | QMap<Qt::MouseButton, QPointF> buttonDownPos;
|
---|
352 | QMap<Qt::MouseButton, QPointF> buttonDownScenePos;
|
---|
353 | QMap<Qt::MouseButton, QPoint> buttonDownScreenPos;
|
---|
354 | Qt::MouseButton button;
|
---|
355 | Qt::MouseButtons buttons;
|
---|
356 | Qt::KeyboardModifiers modifiers;
|
---|
357 | };
|
---|
358 |
|
---|
359 | /*!
|
---|
360 | \internal
|
---|
361 |
|
---|
362 | Constructs a generic graphics scene mouse event of the specified \a type.
|
---|
363 | */
|
---|
364 | QGraphicsSceneMouseEvent::QGraphicsSceneMouseEvent(Type type)
|
---|
365 | : QGraphicsSceneEvent(*new QGraphicsSceneMouseEventPrivate, type)
|
---|
366 | {
|
---|
367 | }
|
---|
368 |
|
---|
369 | /*!
|
---|
370 | Destroys the event.
|
---|
371 | */
|
---|
372 | QGraphicsSceneMouseEvent::~QGraphicsSceneMouseEvent()
|
---|
373 | {
|
---|
374 | }
|
---|
375 |
|
---|
376 | /*!
|
---|
377 | Returns the mouse cursor position in item coordinates.
|
---|
378 |
|
---|
379 | \sa scenePos(), screenPos(), lastPos()
|
---|
380 | */
|
---|
381 | QPointF QGraphicsSceneMouseEvent::pos() const
|
---|
382 | {
|
---|
383 | Q_D(const QGraphicsSceneMouseEvent);
|
---|
384 | return d->pos;
|
---|
385 | }
|
---|
386 |
|
---|
387 | /*!
|
---|
388 | \internal
|
---|
389 | */
|
---|
390 | void QGraphicsSceneMouseEvent::setPos(const QPointF &pos)
|
---|
391 | {
|
---|
392 | Q_D(QGraphicsSceneMouseEvent);
|
---|
393 | d->pos = pos;
|
---|
394 | }
|
---|
395 |
|
---|
396 | /*!
|
---|
397 | Returns the mouse cursor position in scene coordinates.
|
---|
398 |
|
---|
399 | \sa pos(), screenPos(), lastScenePos()
|
---|
400 | */
|
---|
401 | QPointF QGraphicsSceneMouseEvent::scenePos() const
|
---|
402 | {
|
---|
403 | Q_D(const QGraphicsSceneMouseEvent);
|
---|
404 | return d->scenePos;
|
---|
405 | }
|
---|
406 |
|
---|
407 | /*!
|
---|
408 | \internal
|
---|
409 | */
|
---|
410 | void QGraphicsSceneMouseEvent::setScenePos(const QPointF &pos)
|
---|
411 | {
|
---|
412 | Q_D(QGraphicsSceneMouseEvent);
|
---|
413 | d->scenePos = pos;
|
---|
414 | }
|
---|
415 |
|
---|
416 | /*!
|
---|
417 | Returns the mouse cursor position in screen coordinates.
|
---|
418 |
|
---|
419 | \sa pos(), scenePos(), lastScreenPos()
|
---|
420 | */
|
---|
421 | QPoint QGraphicsSceneMouseEvent::screenPos() const
|
---|
422 | {
|
---|
423 | Q_D(const QGraphicsSceneMouseEvent);
|
---|
424 | return d->screenPos;
|
---|
425 | }
|
---|
426 |
|
---|
427 | /*!
|
---|
428 | \internal
|
---|
429 | */
|
---|
430 | void QGraphicsSceneMouseEvent::setScreenPos(const QPoint &pos)
|
---|
431 | {
|
---|
432 | Q_D(QGraphicsSceneMouseEvent);
|
---|
433 | d->screenPos = pos;
|
---|
434 | }
|
---|
435 |
|
---|
436 | /*!
|
---|
437 | Returns the mouse cursor position in item coordinates where the specified
|
---|
438 | \a button was clicked.
|
---|
439 |
|
---|
440 | \sa buttonDownScenePos(), buttonDownScreenPos(), pos()
|
---|
441 | */
|
---|
442 | QPointF QGraphicsSceneMouseEvent::buttonDownPos(Qt::MouseButton button) const
|
---|
443 | {
|
---|
444 | Q_D(const QGraphicsSceneMouseEvent);
|
---|
445 | return d->buttonDownPos.value(button);
|
---|
446 | }
|
---|
447 |
|
---|
448 | /*!
|
---|
449 | \internal
|
---|
450 | */
|
---|
451 | void QGraphicsSceneMouseEvent::setButtonDownPos(Qt::MouseButton button, const QPointF &pos)
|
---|
452 | {
|
---|
453 | Q_D(QGraphicsSceneMouseEvent);
|
---|
454 | d->buttonDownPos.insert(button, pos);
|
---|
455 | }
|
---|
456 |
|
---|
457 | /*!
|
---|
458 | Returns the mouse cursor position in scene coordinates where the
|
---|
459 | specified \a button was clicked.
|
---|
460 |
|
---|
461 | \sa buttonDownPos(), buttonDownScreenPos(), scenePos()
|
---|
462 | */
|
---|
463 | QPointF QGraphicsSceneMouseEvent::buttonDownScenePos(Qt::MouseButton button) const
|
---|
464 | {
|
---|
465 | Q_D(const QGraphicsSceneMouseEvent);
|
---|
466 | return d->buttonDownScenePos.value(button);
|
---|
467 | }
|
---|
468 |
|
---|
469 | /*!
|
---|
470 | \internal
|
---|
471 | */
|
---|
472 | void QGraphicsSceneMouseEvent::setButtonDownScenePos(Qt::MouseButton button, const QPointF &pos)
|
---|
473 | {
|
---|
474 | Q_D(QGraphicsSceneMouseEvent);
|
---|
475 | d->buttonDownScenePos.insert(button, pos);
|
---|
476 | }
|
---|
477 |
|
---|
478 | /*!
|
---|
479 | Returns the mouse cursor position in screen coordinates where the
|
---|
480 | specified \a button was clicked.
|
---|
481 |
|
---|
482 | \sa screenPos(), buttonDownPos(), buttonDownScenePos()
|
---|
483 | */
|
---|
484 | QPoint QGraphicsSceneMouseEvent::buttonDownScreenPos(Qt::MouseButton button) const
|
---|
485 | {
|
---|
486 | Q_D(const QGraphicsSceneMouseEvent);
|
---|
487 | return d->buttonDownScreenPos.value(button);
|
---|
488 | }
|
---|
489 |
|
---|
490 | /*!
|
---|
491 | \internal
|
---|
492 | */
|
---|
493 | void QGraphicsSceneMouseEvent::setButtonDownScreenPos(Qt::MouseButton button, const QPoint &pos)
|
---|
494 | {
|
---|
495 | Q_D(QGraphicsSceneMouseEvent);
|
---|
496 | d->buttonDownScreenPos.insert(button, pos);
|
---|
497 | }
|
---|
498 |
|
---|
499 | /*!
|
---|
500 | Returns the last recorded mouse cursor position in item
|
---|
501 | coordinates.
|
---|
502 |
|
---|
503 | \sa lastScenePos(), lastScreenPos(), pos()
|
---|
504 | */
|
---|
505 | QPointF QGraphicsSceneMouseEvent::lastPos() const
|
---|
506 | {
|
---|
507 | Q_D(const QGraphicsSceneMouseEvent);
|
---|
508 | return d->lastPos;
|
---|
509 | }
|
---|
510 |
|
---|
511 | /*!
|
---|
512 | \internal
|
---|
513 | */
|
---|
514 | void QGraphicsSceneMouseEvent::setLastPos(const QPointF &pos)
|
---|
515 | {
|
---|
516 | Q_D(QGraphicsSceneMouseEvent);
|
---|
517 | d->lastPos = pos;
|
---|
518 | }
|
---|
519 |
|
---|
520 | /*!
|
---|
521 | Returns the last recorded mouse cursor position in scene
|
---|
522 | coordinates. The last recorded position is the position of
|
---|
523 | the previous mouse event received by the view that created
|
---|
524 | the event.
|
---|
525 |
|
---|
526 | \sa lastPos(), lastScreenPos(), scenePos()
|
---|
527 | */
|
---|
528 | QPointF QGraphicsSceneMouseEvent::lastScenePos() const
|
---|
529 | {
|
---|
530 | Q_D(const QGraphicsSceneMouseEvent);
|
---|
531 | return d->lastScenePos;
|
---|
532 | }
|
---|
533 |
|
---|
534 | /*!
|
---|
535 | \internal
|
---|
536 | */
|
---|
537 | void QGraphicsSceneMouseEvent::setLastScenePos(const QPointF &pos)
|
---|
538 | {
|
---|
539 | Q_D(QGraphicsSceneMouseEvent);
|
---|
540 | d->lastScenePos = pos;
|
---|
541 | }
|
---|
542 |
|
---|
543 | /*!
|
---|
544 | Returns the last recorded mouse cursor position in screen
|
---|
545 | coordinates. The last recorded position is the position of
|
---|
546 | the previous mouse event received by the view that created
|
---|
547 | the event.
|
---|
548 |
|
---|
549 | \sa lastPos(), lastScenePos(), screenPos()
|
---|
550 | */
|
---|
551 | QPoint QGraphicsSceneMouseEvent::lastScreenPos() const
|
---|
552 | {
|
---|
553 | Q_D(const QGraphicsSceneMouseEvent);
|
---|
554 | return d->lastScreenPos;
|
---|
555 | }
|
---|
556 |
|
---|
557 | /*!
|
---|
558 | \internal
|
---|
559 | */
|
---|
560 | void QGraphicsSceneMouseEvent::setLastScreenPos(const QPoint &pos)
|
---|
561 | {
|
---|
562 | Q_D(QGraphicsSceneMouseEvent);
|
---|
563 | d->lastScreenPos = pos;
|
---|
564 | }
|
---|
565 |
|
---|
566 | /*!
|
---|
567 | Returns the combination of mouse buttons that were pressed at the
|
---|
568 | time the event was sent.
|
---|
569 |
|
---|
570 | \sa button(), modifiers()
|
---|
571 | */
|
---|
572 | Qt::MouseButtons QGraphicsSceneMouseEvent::buttons() const
|
---|
573 | {
|
---|
574 | Q_D(const QGraphicsSceneMouseEvent);
|
---|
575 | return d->buttons;
|
---|
576 | }
|
---|
577 |
|
---|
578 | /*!
|
---|
579 | \internal
|
---|
580 | */
|
---|
581 | void QGraphicsSceneMouseEvent::setButtons(Qt::MouseButtons buttons)
|
---|
582 | {
|
---|
583 | Q_D(QGraphicsSceneMouseEvent);
|
---|
584 | d->buttons = buttons;
|
---|
585 | }
|
---|
586 |
|
---|
587 | /*!
|
---|
588 | Returns the mouse button (if any) that caused the event.
|
---|
589 |
|
---|
590 | \sa buttons(), modifiers()
|
---|
591 | */
|
---|
592 | Qt::MouseButton QGraphicsSceneMouseEvent::button() const
|
---|
593 | {
|
---|
594 | Q_D(const QGraphicsSceneMouseEvent);
|
---|
595 | return d->button;
|
---|
596 | }
|
---|
597 |
|
---|
598 | /*!
|
---|
599 | \internal
|
---|
600 | */
|
---|
601 | void QGraphicsSceneMouseEvent::setButton(Qt::MouseButton button)
|
---|
602 | {
|
---|
603 | Q_D(QGraphicsSceneMouseEvent);
|
---|
604 | d->button = button;
|
---|
605 | }
|
---|
606 |
|
---|
607 | /*!
|
---|
608 | Returns the keyboard modifiers in use at the time the event was
|
---|
609 | sent.
|
---|
610 |
|
---|
611 | \sa buttons(), button()
|
---|
612 | */
|
---|
613 | Qt::KeyboardModifiers QGraphicsSceneMouseEvent::modifiers() const
|
---|
614 | {
|
---|
615 | Q_D(const QGraphicsSceneMouseEvent);
|
---|
616 | return d->modifiers;
|
---|
617 | }
|
---|
618 |
|
---|
619 | /*!
|
---|
620 | \internal
|
---|
621 | */
|
---|
622 | void QGraphicsSceneMouseEvent::setModifiers(Qt::KeyboardModifiers modifiers)
|
---|
623 | {
|
---|
624 | Q_D(QGraphicsSceneMouseEvent);
|
---|
625 | d->modifiers = modifiers;
|
---|
626 | }
|
---|
627 |
|
---|
628 | class QGraphicsSceneWheelEventPrivate : public QGraphicsSceneEventPrivate
|
---|
629 | {
|
---|
630 | Q_DECLARE_PUBLIC(QGraphicsSceneWheelEvent)
|
---|
631 | public:
|
---|
632 | inline QGraphicsSceneWheelEventPrivate()
|
---|
633 | : buttons(0), modifiers(0), delta(0), orientation(Qt::Horizontal)
|
---|
634 | { }
|
---|
635 |
|
---|
636 | QPointF pos;
|
---|
637 | QPointF scenePos;
|
---|
638 | QPoint screenPos;
|
---|
639 | Qt::MouseButtons buttons;
|
---|
640 | Qt::KeyboardModifiers modifiers;
|
---|
641 | int delta;
|
---|
642 | Qt::Orientation orientation;
|
---|
643 | };
|
---|
644 |
|
---|
645 | /*!
|
---|
646 | \internal
|
---|
647 |
|
---|
648 | Constructs a QGraphicsSceneWheelEvent of type \a type, which
|
---|
649 | is always QEvent::GraphicsSceneWheel.
|
---|
650 | */
|
---|
651 | QGraphicsSceneWheelEvent::QGraphicsSceneWheelEvent(Type type)
|
---|
652 | : QGraphicsSceneEvent(*new QGraphicsSceneWheelEventPrivate, type)
|
---|
653 | {
|
---|
654 | }
|
---|
655 |
|
---|
656 | /*!
|
---|
657 | Destroys the QGraphicsSceneWheelEvent.
|
---|
658 | */
|
---|
659 | QGraphicsSceneWheelEvent::~QGraphicsSceneWheelEvent()
|
---|
660 | {
|
---|
661 | }
|
---|
662 |
|
---|
663 | /*!
|
---|
664 | Returns the position of the cursor in item coordinates when the
|
---|
665 | wheel event occurred.
|
---|
666 |
|
---|
667 | \sa scenePos(), screenPos()
|
---|
668 | */
|
---|
669 | QPointF QGraphicsSceneWheelEvent::pos() const
|
---|
670 | {
|
---|
671 | Q_D(const QGraphicsSceneWheelEvent);
|
---|
672 | return d->pos;
|
---|
673 | }
|
---|
674 |
|
---|
675 | /*!
|
---|
676 | \internal
|
---|
677 | */
|
---|
678 | void QGraphicsSceneWheelEvent::setPos(const QPointF &pos)
|
---|
679 | {
|
---|
680 | Q_D(QGraphicsSceneWheelEvent);
|
---|
681 | d->pos = pos;
|
---|
682 | }
|
---|
683 |
|
---|
684 | /*!
|
---|
685 | Returns the position of the cursor in scene coordinates when the wheel
|
---|
686 | event occurred.
|
---|
687 |
|
---|
688 | \sa pos(), screenPos()
|
---|
689 | */
|
---|
690 | QPointF QGraphicsSceneWheelEvent::scenePos() const
|
---|
691 | {
|
---|
692 | Q_D(const QGraphicsSceneWheelEvent);
|
---|
693 | return d->scenePos;
|
---|
694 | }
|
---|
695 |
|
---|
696 | /*!
|
---|
697 | \internal
|
---|
698 | */
|
---|
699 | void QGraphicsSceneWheelEvent::setScenePos(const QPointF &pos)
|
---|
700 | {
|
---|
701 | Q_D(QGraphicsSceneWheelEvent);
|
---|
702 | d->scenePos = pos;
|
---|
703 | }
|
---|
704 |
|
---|
705 | /*!
|
---|
706 | Returns the position of the cursor in screen coordinates when the wheel
|
---|
707 | event occurred.
|
---|
708 |
|
---|
709 | \sa pos(), scenePos()
|
---|
710 | */
|
---|
711 | QPoint QGraphicsSceneWheelEvent::screenPos() const
|
---|
712 | {
|
---|
713 | Q_D(const QGraphicsSceneWheelEvent);
|
---|
714 | return d->screenPos;
|
---|
715 | }
|
---|
716 |
|
---|
717 | /*!
|
---|
718 | \internal
|
---|
719 | */
|
---|
720 | void QGraphicsSceneWheelEvent::setScreenPos(const QPoint &pos)
|
---|
721 | {
|
---|
722 | Q_D(QGraphicsSceneWheelEvent);
|
---|
723 | d->screenPos = pos;
|
---|
724 | }
|
---|
725 |
|
---|
726 | /*!
|
---|
727 | Returns the mouse buttons that were pressed when the wheel event occurred.
|
---|
728 |
|
---|
729 | \sa modifiers()
|
---|
730 | */
|
---|
731 | Qt::MouseButtons QGraphicsSceneWheelEvent::buttons() const
|
---|
732 | {
|
---|
733 | Q_D(const QGraphicsSceneWheelEvent);
|
---|
734 | return d->buttons;
|
---|
735 | }
|
---|
736 |
|
---|
737 | /*!
|
---|
738 | \internal
|
---|
739 | */
|
---|
740 | void QGraphicsSceneWheelEvent::setButtons(Qt::MouseButtons buttons)
|
---|
741 | {
|
---|
742 | Q_D(QGraphicsSceneWheelEvent);
|
---|
743 | d->buttons = buttons;
|
---|
744 | }
|
---|
745 |
|
---|
746 | /*!
|
---|
747 | Returns the keyboard modifiers that were active when the wheel event
|
---|
748 | occurred.
|
---|
749 |
|
---|
750 | \sa buttons()
|
---|
751 | */
|
---|
752 | Qt::KeyboardModifiers QGraphicsSceneWheelEvent::modifiers() const
|
---|
753 | {
|
---|
754 | Q_D(const QGraphicsSceneWheelEvent);
|
---|
755 | return d->modifiers;
|
---|
756 | }
|
---|
757 |
|
---|
758 | /*!
|
---|
759 | \internal
|
---|
760 | */
|
---|
761 | void QGraphicsSceneWheelEvent::setModifiers(Qt::KeyboardModifiers modifiers)
|
---|
762 | {
|
---|
763 | Q_D(QGraphicsSceneWheelEvent);
|
---|
764 | d->modifiers = modifiers;
|
---|
765 | }
|
---|
766 |
|
---|
767 | /*!
|
---|
768 | Returns the distance that the wheel is rotated, in eighths (1/8s)
|
---|
769 | of a degree. A positive value indicates that the wheel was
|
---|
770 | rotated forwards away from the user; a negative value indicates
|
---|
771 | that the wheel was rotated backwards toward the user.
|
---|
772 |
|
---|
773 | Most mouse types work in steps of 15 degrees, in which case the delta
|
---|
774 | value is a multiple of 120 (== 15 * 8).
|
---|
775 | */
|
---|
776 | int QGraphicsSceneWheelEvent::delta() const
|
---|
777 | {
|
---|
778 | Q_D(const QGraphicsSceneWheelEvent);
|
---|
779 | return d->delta;
|
---|
780 | }
|
---|
781 |
|
---|
782 | /*!
|
---|
783 | \internal
|
---|
784 | */
|
---|
785 | void QGraphicsSceneWheelEvent::setDelta(int delta)
|
---|
786 | {
|
---|
787 | Q_D(QGraphicsSceneWheelEvent);
|
---|
788 | d->delta = delta;
|
---|
789 | }
|
---|
790 |
|
---|
791 | /*!
|
---|
792 | Returns the wheel orientation.
|
---|
793 | */
|
---|
794 | Qt::Orientation QGraphicsSceneWheelEvent::orientation() const
|
---|
795 | {
|
---|
796 | Q_D(const QGraphicsSceneWheelEvent);
|
---|
797 | return d->orientation;
|
---|
798 | }
|
---|
799 |
|
---|
800 | /*!
|
---|
801 | \internal
|
---|
802 | */
|
---|
803 | void QGraphicsSceneWheelEvent::setOrientation(Qt::Orientation orientation)
|
---|
804 | {
|
---|
805 | Q_D(QGraphicsSceneWheelEvent);
|
---|
806 | d->orientation = orientation;
|
---|
807 | }
|
---|
808 |
|
---|
809 | class QGraphicsSceneContextMenuEventPrivate : public QGraphicsSceneEventPrivate
|
---|
810 | {
|
---|
811 | Q_DECLARE_PUBLIC(QGraphicsSceneContextMenuEvent)
|
---|
812 | public:
|
---|
813 | inline QGraphicsSceneContextMenuEventPrivate()
|
---|
814 | : modifiers(0), reason(QGraphicsSceneContextMenuEvent::Other)
|
---|
815 | { }
|
---|
816 |
|
---|
817 | QPointF pos;
|
---|
818 | QPointF scenePos;
|
---|
819 | QPoint screenPos;
|
---|
820 | Qt::KeyboardModifiers modifiers;
|
---|
821 | QGraphicsSceneContextMenuEvent::Reason reason;
|
---|
822 | };
|
---|
823 |
|
---|
824 | /*!
|
---|
825 | \internal
|
---|
826 |
|
---|
827 | Constructs a graphics scene context menu event of the specified \a type.
|
---|
828 | */
|
---|
829 | QGraphicsSceneContextMenuEvent::QGraphicsSceneContextMenuEvent(Type type)
|
---|
830 | : QGraphicsSceneEvent(*new QGraphicsSceneContextMenuEventPrivate, type)
|
---|
831 | {
|
---|
832 | }
|
---|
833 |
|
---|
834 | /*!
|
---|
835 | Destroys the event.
|
---|
836 | */
|
---|
837 | QGraphicsSceneContextMenuEvent::~QGraphicsSceneContextMenuEvent()
|
---|
838 | {
|
---|
839 | }
|
---|
840 |
|
---|
841 | /*!
|
---|
842 | Returns the position of the mouse cursor in item coordinates at the moment
|
---|
843 | the context menu was requested.
|
---|
844 |
|
---|
845 | \sa scenePos(), screenPos()
|
---|
846 | */
|
---|
847 | QPointF QGraphicsSceneContextMenuEvent::pos() const
|
---|
848 | {
|
---|
849 | Q_D(const QGraphicsSceneContextMenuEvent);
|
---|
850 | return d->pos;
|
---|
851 | }
|
---|
852 |
|
---|
853 | /*!
|
---|
854 | \fn void QGraphicsSceneContextMenuEvent::setPos(const QPointF &point)
|
---|
855 | \internal
|
---|
856 |
|
---|
857 | Sets the position associated with the context menu to the given \a point
|
---|
858 | in item coordinates.
|
---|
859 | */
|
---|
860 | void QGraphicsSceneContextMenuEvent::setPos(const QPointF &pos)
|
---|
861 | {
|
---|
862 | Q_D(QGraphicsSceneContextMenuEvent);
|
---|
863 | d->pos = pos;
|
---|
864 | }
|
---|
865 |
|
---|
866 | /*!
|
---|
867 | Returns the position of the mouse cursor in scene coordinates at the moment the
|
---|
868 | the context menu was requested.
|
---|
869 |
|
---|
870 | \sa pos(), screenPos()
|
---|
871 | */
|
---|
872 | QPointF QGraphicsSceneContextMenuEvent::scenePos() const
|
---|
873 | {
|
---|
874 | Q_D(const QGraphicsSceneContextMenuEvent);
|
---|
875 | return d->scenePos;
|
---|
876 | }
|
---|
877 |
|
---|
878 | /*!
|
---|
879 | \fn void QGraphicsSceneContextMenuEvent::setScenePos(const QPointF &point)
|
---|
880 | \internal
|
---|
881 |
|
---|
882 | Sets the position associated with the context menu to the given \a point
|
---|
883 | in scene coordinates.
|
---|
884 | */
|
---|
885 | void QGraphicsSceneContextMenuEvent::setScenePos(const QPointF &pos)
|
---|
886 | {
|
---|
887 | Q_D(QGraphicsSceneContextMenuEvent);
|
---|
888 | d->scenePos = pos;
|
---|
889 | }
|
---|
890 |
|
---|
891 | /*!
|
---|
892 | Returns the position of the mouse cursor in screen coordinates at the moment the
|
---|
893 | the context menu was requested.
|
---|
894 |
|
---|
895 | \sa pos(), scenePos()
|
---|
896 | */
|
---|
897 | QPoint QGraphicsSceneContextMenuEvent::screenPos() const
|
---|
898 | {
|
---|
899 | Q_D(const QGraphicsSceneContextMenuEvent);
|
---|
900 | return d->screenPos;
|
---|
901 | }
|
---|
902 |
|
---|
903 | /*!
|
---|
904 | \fn void QGraphicsSceneContextMenuEvent::setScreenPos(const QPoint &point)
|
---|
905 | \internal
|
---|
906 |
|
---|
907 | Sets the position associated with the context menu to the given \a point
|
---|
908 | in screen coordinates.
|
---|
909 | */
|
---|
910 | void QGraphicsSceneContextMenuEvent::setScreenPos(const QPoint &pos)
|
---|
911 | {
|
---|
912 | Q_D(QGraphicsSceneContextMenuEvent);
|
---|
913 | d->screenPos = pos;
|
---|
914 | }
|
---|
915 |
|
---|
916 | /*!
|
---|
917 | Returns the keyboard modifiers in use when the context menu was requested.
|
---|
918 | */
|
---|
919 | Qt::KeyboardModifiers QGraphicsSceneContextMenuEvent::modifiers() const
|
---|
920 | {
|
---|
921 | Q_D(const QGraphicsSceneContextMenuEvent);
|
---|
922 | return d->modifiers;
|
---|
923 | }
|
---|
924 |
|
---|
925 | /*!
|
---|
926 | \internal
|
---|
927 |
|
---|
928 | Sets the keyboard modifiers associated with the context menu to the \a
|
---|
929 | modifiers specified.
|
---|
930 | */
|
---|
931 | void QGraphicsSceneContextMenuEvent::setModifiers(Qt::KeyboardModifiers modifiers)
|
---|
932 | {
|
---|
933 | Q_D(QGraphicsSceneContextMenuEvent);
|
---|
934 | d->modifiers = modifiers;
|
---|
935 | }
|
---|
936 |
|
---|
937 | /*!
|
---|
938 | Returns the reason for the context menu event.
|
---|
939 |
|
---|
940 | \sa QGraphicsSceneContextMenuEvent::Reason
|
---|
941 | */
|
---|
942 | QGraphicsSceneContextMenuEvent::Reason QGraphicsSceneContextMenuEvent::reason() const
|
---|
943 | {
|
---|
944 | Q_D(const QGraphicsSceneContextMenuEvent);
|
---|
945 | return d->reason;
|
---|
946 | }
|
---|
947 |
|
---|
948 | /*!
|
---|
949 | \internal
|
---|
950 | Sets the reason for the context menu event to \a reason.
|
---|
951 |
|
---|
952 | \sa reason()
|
---|
953 | */
|
---|
954 | void QGraphicsSceneContextMenuEvent::setReason(Reason reason)
|
---|
955 | {
|
---|
956 | Q_D(QGraphicsSceneContextMenuEvent);
|
---|
957 | d->reason = reason;
|
---|
958 | }
|
---|
959 |
|
---|
960 | class QGraphicsSceneHoverEventPrivate : public QGraphicsSceneEventPrivate
|
---|
961 | {
|
---|
962 | public:
|
---|
963 | QPointF pos;
|
---|
964 | QPointF scenePos;
|
---|
965 | QPoint screenPos;
|
---|
966 | QPointF lastPos;
|
---|
967 | QPointF lastScenePos;
|
---|
968 | QPoint lastScreenPos;
|
---|
969 | Qt::KeyboardModifiers modifiers;
|
---|
970 | };
|
---|
971 |
|
---|
972 | /*!
|
---|
973 | \internal
|
---|
974 |
|
---|
975 | Constructs a graphics scene hover event of the specified \a type.
|
---|
976 | */
|
---|
977 | QGraphicsSceneHoverEvent::QGraphicsSceneHoverEvent(Type type)
|
---|
978 | : QGraphicsSceneEvent(*new QGraphicsSceneHoverEventPrivate, type)
|
---|
979 | {
|
---|
980 | }
|
---|
981 |
|
---|
982 | /*!
|
---|
983 | Destroys the event.
|
---|
984 | */
|
---|
985 | QGraphicsSceneHoverEvent::~QGraphicsSceneHoverEvent()
|
---|
986 | {
|
---|
987 | }
|
---|
988 |
|
---|
989 | /*!
|
---|
990 | Returns the position of the mouse cursor in item coordinates at the moment
|
---|
991 | the hover event was sent.
|
---|
992 |
|
---|
993 | \sa scenePos(), screenPos()
|
---|
994 | */
|
---|
995 | QPointF QGraphicsSceneHoverEvent::pos() const
|
---|
996 | {
|
---|
997 | Q_D(const QGraphicsSceneHoverEvent);
|
---|
998 | return d->pos;
|
---|
999 | }
|
---|
1000 |
|
---|
1001 | /*!
|
---|
1002 | \fn void QGraphicsSceneHoverEvent::setPos(const QPointF &point)
|
---|
1003 | \internal
|
---|
1004 |
|
---|
1005 | Sets the position associated with the hover event to the given \a point in
|
---|
1006 | item coordinates.
|
---|
1007 | */
|
---|
1008 | void QGraphicsSceneHoverEvent::setPos(const QPointF &pos)
|
---|
1009 | {
|
---|
1010 | Q_D(QGraphicsSceneHoverEvent);
|
---|
1011 | d->pos = pos;
|
---|
1012 | }
|
---|
1013 |
|
---|
1014 | /*!
|
---|
1015 | Returns the position of the mouse cursor in scene coordinates at the
|
---|
1016 | moment the hover event was sent.
|
---|
1017 |
|
---|
1018 | \sa pos(), screenPos()
|
---|
1019 | */
|
---|
1020 | QPointF QGraphicsSceneHoverEvent::scenePos() const
|
---|
1021 | {
|
---|
1022 | Q_D(const QGraphicsSceneHoverEvent);
|
---|
1023 | return d->scenePos;
|
---|
1024 | }
|
---|
1025 |
|
---|
1026 | /*!
|
---|
1027 | \fn void QGraphicsSceneHoverEvent::setScenePos(const QPointF &point)
|
---|
1028 | \internal
|
---|
1029 |
|
---|
1030 | Sets the position associated with the hover event to the given \a point in
|
---|
1031 | scene coordinates.
|
---|
1032 | */
|
---|
1033 | void QGraphicsSceneHoverEvent::setScenePos(const QPointF &pos)
|
---|
1034 | {
|
---|
1035 | Q_D(QGraphicsSceneHoverEvent);
|
---|
1036 | d->scenePos = pos;
|
---|
1037 | }
|
---|
1038 |
|
---|
1039 | /*!
|
---|
1040 | Returns the position of the mouse cursor in screen coordinates at the
|
---|
1041 | moment the hover event was sent.
|
---|
1042 |
|
---|
1043 | \sa pos(), scenePos()
|
---|
1044 | */
|
---|
1045 | QPoint QGraphicsSceneHoverEvent::screenPos() const
|
---|
1046 | {
|
---|
1047 | Q_D(const QGraphicsSceneHoverEvent);
|
---|
1048 | return d->screenPos;
|
---|
1049 | }
|
---|
1050 |
|
---|
1051 | /*!
|
---|
1052 | \fn void QGraphicsSceneHoverEvent::setScreenPos(const QPoint &point)
|
---|
1053 | \internal
|
---|
1054 |
|
---|
1055 | Sets the position associated with the hover event to the given \a point in
|
---|
1056 | screen coordinates.
|
---|
1057 | */
|
---|
1058 | void QGraphicsSceneHoverEvent::setScreenPos(const QPoint &pos)
|
---|
1059 | {
|
---|
1060 | Q_D(QGraphicsSceneHoverEvent);
|
---|
1061 | d->screenPos = pos;
|
---|
1062 | }
|
---|
1063 |
|
---|
1064 | /*!
|
---|
1065 | \since 4.4
|
---|
1066 |
|
---|
1067 | Returns the last recorded mouse cursor position in item coordinates.
|
---|
1068 |
|
---|
1069 | \sa lastScenePos(), lastScreenPos(), pos()
|
---|
1070 | */
|
---|
1071 | QPointF QGraphicsSceneHoverEvent::lastPos() const
|
---|
1072 | {
|
---|
1073 | Q_D(const QGraphicsSceneHoverEvent);
|
---|
1074 | return d->lastPos;
|
---|
1075 | }
|
---|
1076 |
|
---|
1077 | /*!
|
---|
1078 | \internal
|
---|
1079 | */
|
---|
1080 | void QGraphicsSceneHoverEvent::setLastPos(const QPointF &pos)
|
---|
1081 | {
|
---|
1082 | Q_D(QGraphicsSceneHoverEvent);
|
---|
1083 | d->lastPos = pos;
|
---|
1084 | }
|
---|
1085 |
|
---|
1086 | /*!
|
---|
1087 | \since 4.4
|
---|
1088 |
|
---|
1089 | Returns the last recorded, the scene coordinates of the previous mouse or
|
---|
1090 | hover event received by the view, that created the event mouse cursor
|
---|
1091 | position in scene coordinates.
|
---|
1092 |
|
---|
1093 | \sa lastPos(), lastScreenPos(), scenePos()
|
---|
1094 | */
|
---|
1095 | QPointF QGraphicsSceneHoverEvent::lastScenePos() const
|
---|
1096 | {
|
---|
1097 | Q_D(const QGraphicsSceneHoverEvent);
|
---|
1098 | return d->lastScenePos;
|
---|
1099 | }
|
---|
1100 |
|
---|
1101 | /*!
|
---|
1102 | \internal
|
---|
1103 | */
|
---|
1104 | void QGraphicsSceneHoverEvent::setLastScenePos(const QPointF &pos)
|
---|
1105 | {
|
---|
1106 | Q_D(QGraphicsSceneHoverEvent);
|
---|
1107 | d->lastScenePos = pos;
|
---|
1108 | }
|
---|
1109 |
|
---|
1110 | /*!
|
---|
1111 | \since 4.4
|
---|
1112 |
|
---|
1113 | Returns the last recorded mouse cursor position in screen coordinates. The
|
---|
1114 | last recorded position is the position of the previous mouse or hover
|
---|
1115 | event received by the view that created the event.
|
---|
1116 |
|
---|
1117 | \sa lastPos(), lastScenePos(), screenPos()
|
---|
1118 | */
|
---|
1119 | QPoint QGraphicsSceneHoverEvent::lastScreenPos() const
|
---|
1120 | {
|
---|
1121 | Q_D(const QGraphicsSceneHoverEvent);
|
---|
1122 | return d->lastScreenPos;
|
---|
1123 | }
|
---|
1124 |
|
---|
1125 | /*!
|
---|
1126 | \internal
|
---|
1127 | */
|
---|
1128 | void QGraphicsSceneHoverEvent::setLastScreenPos(const QPoint &pos)
|
---|
1129 | {
|
---|
1130 | Q_D(QGraphicsSceneHoverEvent);
|
---|
1131 | d->lastScreenPos = pos;
|
---|
1132 | }
|
---|
1133 |
|
---|
1134 | /*!
|
---|
1135 | \since 4.4
|
---|
1136 |
|
---|
1137 | Returns the keyboard modifiers at the moment the hover event was sent.
|
---|
1138 | */
|
---|
1139 | Qt::KeyboardModifiers QGraphicsSceneHoverEvent::modifiers() const
|
---|
1140 | {
|
---|
1141 | Q_D(const QGraphicsSceneHoverEvent);
|
---|
1142 | return d->modifiers;
|
---|
1143 | }
|
---|
1144 |
|
---|
1145 | /*!
|
---|
1146 | \fn void QGraphicsSceneHoverEvent::setModifiers(Qt::KeyboardModifiers modifiers)
|
---|
1147 | \internal
|
---|
1148 |
|
---|
1149 | Sets the modifiers for the current hover event to \a modifiers.
|
---|
1150 | */
|
---|
1151 | void QGraphicsSceneHoverEvent::setModifiers(Qt::KeyboardModifiers modifiers)
|
---|
1152 | {
|
---|
1153 | Q_D(QGraphicsSceneHoverEvent);
|
---|
1154 | d->modifiers = modifiers;
|
---|
1155 | }
|
---|
1156 |
|
---|
1157 | class QGraphicsSceneHelpEventPrivate : public QGraphicsSceneEventPrivate
|
---|
1158 | {
|
---|
1159 | public:
|
---|
1160 | QPointF scenePos;
|
---|
1161 | QPoint screenPos;
|
---|
1162 | };
|
---|
1163 |
|
---|
1164 | /*!
|
---|
1165 | \internal
|
---|
1166 |
|
---|
1167 | Constructs a graphics scene help event of the specified \a type.
|
---|
1168 | */
|
---|
1169 | QGraphicsSceneHelpEvent::QGraphicsSceneHelpEvent(Type type)
|
---|
1170 | : QGraphicsSceneEvent(*new QGraphicsSceneHelpEventPrivate, type)
|
---|
1171 | {
|
---|
1172 | }
|
---|
1173 |
|
---|
1174 | /*!
|
---|
1175 | Destroys the event.
|
---|
1176 | */
|
---|
1177 | QGraphicsSceneHelpEvent::~QGraphicsSceneHelpEvent()
|
---|
1178 | {
|
---|
1179 | }
|
---|
1180 |
|
---|
1181 | /*!
|
---|
1182 | Returns the position of the mouse cursor in scene coordinates at the
|
---|
1183 | moment the help event was sent.
|
---|
1184 |
|
---|
1185 | \sa screenPos()
|
---|
1186 | */
|
---|
1187 | QPointF QGraphicsSceneHelpEvent::scenePos() const
|
---|
1188 | {
|
---|
1189 | Q_D(const QGraphicsSceneHelpEvent);
|
---|
1190 | return d->scenePos;
|
---|
1191 | }
|
---|
1192 |
|
---|
1193 | /*!
|
---|
1194 | \fn void QGraphicsSceneHelpEvent::setScenePos(const QPointF &point)
|
---|
1195 | \internal
|
---|
1196 |
|
---|
1197 | Sets the position associated with the context menu to the given \a point
|
---|
1198 | in scene coordinates.
|
---|
1199 | */
|
---|
1200 | void QGraphicsSceneHelpEvent::setScenePos(const QPointF &pos)
|
---|
1201 | {
|
---|
1202 | Q_D(QGraphicsSceneHelpEvent);
|
---|
1203 | d->scenePos = pos;
|
---|
1204 | }
|
---|
1205 |
|
---|
1206 | /*!
|
---|
1207 | Returns the position of the mouse cursor in screen coordinates at the
|
---|
1208 | moment the help event was sent.
|
---|
1209 |
|
---|
1210 | \sa scenePos()
|
---|
1211 | */
|
---|
1212 | QPoint QGraphicsSceneHelpEvent::screenPos() const
|
---|
1213 | {
|
---|
1214 | Q_D(const QGraphicsSceneHelpEvent);
|
---|
1215 | return d->screenPos;
|
---|
1216 | }
|
---|
1217 |
|
---|
1218 | /*!
|
---|
1219 | \fn void QGraphicsSceneHelpEvent::setScreenPos(const QPoint &point)
|
---|
1220 | \internal
|
---|
1221 |
|
---|
1222 | Sets the position associated with the context menu to the given \a point
|
---|
1223 | in screen coordinates.
|
---|
1224 | */
|
---|
1225 | void QGraphicsSceneHelpEvent::setScreenPos(const QPoint &pos)
|
---|
1226 | {
|
---|
1227 | Q_D(QGraphicsSceneHelpEvent);
|
---|
1228 | d->screenPos = pos;
|
---|
1229 | }
|
---|
1230 |
|
---|
1231 | class QGraphicsSceneDragDropEventPrivate : public QGraphicsSceneEventPrivate
|
---|
1232 | {
|
---|
1233 | Q_DECLARE_PUBLIC(QGraphicsSceneDragDropEvent)
|
---|
1234 | public:
|
---|
1235 | inline QGraphicsSceneDragDropEventPrivate()
|
---|
1236 | : source(0), mimeData(0)
|
---|
1237 | { }
|
---|
1238 |
|
---|
1239 | QPointF pos;
|
---|
1240 | QPointF scenePos;
|
---|
1241 | QPoint screenPos;
|
---|
1242 | Qt::MouseButtons buttons;
|
---|
1243 | Qt::KeyboardModifiers modifiers;
|
---|
1244 | Qt::DropActions possibleActions;
|
---|
1245 | Qt::DropAction proposedAction;
|
---|
1246 | Qt::DropAction dropAction;
|
---|
1247 | QWidget *source;
|
---|
1248 | const QMimeData *mimeData;
|
---|
1249 | };
|
---|
1250 |
|
---|
1251 | /*!
|
---|
1252 | \internal
|
---|
1253 |
|
---|
1254 | Constructs a new QGraphicsSceneDragDropEvent of the
|
---|
1255 | specified \a type. The type can be either
|
---|
1256 | QEvent::GraphicsSceneDragEnter, QEvent::GraphicsSceneDragLeave,
|
---|
1257 | QEvent::GraphicsSceneDragMove, or QEvent::GraphicsSceneDrop.
|
---|
1258 | */
|
---|
1259 | QGraphicsSceneDragDropEvent::QGraphicsSceneDragDropEvent(Type type)
|
---|
1260 | : QGraphicsSceneEvent(*new QGraphicsSceneDragDropEventPrivate, type)
|
---|
1261 | {
|
---|
1262 | }
|
---|
1263 |
|
---|
1264 | /*!
|
---|
1265 | Destroys the object.
|
---|
1266 | */
|
---|
1267 | QGraphicsSceneDragDropEvent::~QGraphicsSceneDragDropEvent()
|
---|
1268 | {
|
---|
1269 | }
|
---|
1270 |
|
---|
1271 | /*!
|
---|
1272 | Returns the mouse position of the event relative to the
|
---|
1273 | view that sent the event.
|
---|
1274 |
|
---|
1275 | \sa QGraphicsView, screenPos(), scenePos()
|
---|
1276 | */
|
---|
1277 | QPointF QGraphicsSceneDragDropEvent::pos() const
|
---|
1278 | {
|
---|
1279 | Q_D(const QGraphicsSceneDragDropEvent);
|
---|
1280 | return d->pos;
|
---|
1281 | }
|
---|
1282 |
|
---|
1283 | /*!
|
---|
1284 | \internal
|
---|
1285 | Sets the position of the mouse to \a pos; this should be
|
---|
1286 | relative to the widget that generated the event, which normally
|
---|
1287 | is a QGraphicsView.
|
---|
1288 |
|
---|
1289 | \sa pos(), setScenePos(), setScreenPos()
|
---|
1290 | */
|
---|
1291 |
|
---|
1292 | void QGraphicsSceneDragDropEvent::setPos(const QPointF &pos)
|
---|
1293 | {
|
---|
1294 | Q_D(QGraphicsSceneDragDropEvent);
|
---|
1295 | d->pos = pos;
|
---|
1296 | }
|
---|
1297 |
|
---|
1298 | /*!
|
---|
1299 | Returns the position of the mouse in scene coordinates.
|
---|
1300 |
|
---|
1301 | \sa pos(), screenPos()
|
---|
1302 | */
|
---|
1303 | QPointF QGraphicsSceneDragDropEvent::scenePos() const
|
---|
1304 | {
|
---|
1305 | Q_D(const QGraphicsSceneDragDropEvent);
|
---|
1306 | return d->scenePos;
|
---|
1307 | }
|
---|
1308 |
|
---|
1309 | /*!
|
---|
1310 | \internal
|
---|
1311 | Sets the scene position of the mouse to \a pos.
|
---|
1312 |
|
---|
1313 | \sa scenePos(), setScreenPos(), setPos()
|
---|
1314 | */
|
---|
1315 | void QGraphicsSceneDragDropEvent::setScenePos(const QPointF &pos)
|
---|
1316 | {
|
---|
1317 | Q_D(QGraphicsSceneDragDropEvent);
|
---|
1318 | d->scenePos = pos;
|
---|
1319 | }
|
---|
1320 |
|
---|
1321 | /*!
|
---|
1322 | Returns the position of the mouse relative to the screen.
|
---|
1323 |
|
---|
1324 | \sa pos(), scenePos()
|
---|
1325 | */
|
---|
1326 | QPoint QGraphicsSceneDragDropEvent::screenPos() const
|
---|
1327 | {
|
---|
1328 | Q_D(const QGraphicsSceneDragDropEvent);
|
---|
1329 | return d->screenPos;
|
---|
1330 | }
|
---|
1331 |
|
---|
1332 | /*!
|
---|
1333 | \internal
|
---|
1334 | Sets the mouse position relative to the screen to \a pos.
|
---|
1335 |
|
---|
1336 | \sa screenPos(), setScenePos(), setPos()
|
---|
1337 | */
|
---|
1338 | void QGraphicsSceneDragDropEvent::setScreenPos(const QPoint &pos)
|
---|
1339 | {
|
---|
1340 | Q_D(QGraphicsSceneDragDropEvent);
|
---|
1341 | d->screenPos = pos;
|
---|
1342 | }
|
---|
1343 |
|
---|
1344 | /*!
|
---|
1345 | Returns a Qt::MouseButtons value indicating which buttons
|
---|
1346 | were pressed on the mouse when this mouse event was
|
---|
1347 | generated.
|
---|
1348 |
|
---|
1349 | \sa Qt::MouseButtons
|
---|
1350 | */
|
---|
1351 | Qt::MouseButtons QGraphicsSceneDragDropEvent::buttons() const
|
---|
1352 | {
|
---|
1353 | Q_D(const QGraphicsSceneDragDropEvent);
|
---|
1354 | return d->buttons;
|
---|
1355 | }
|
---|
1356 |
|
---|
1357 | /*!
|
---|
1358 | \internal
|
---|
1359 | Sets the mouse buttons that were pressed when the event was
|
---|
1360 | created to \a buttons.
|
---|
1361 |
|
---|
1362 | \sa Qt::MouseButtons, buttons()
|
---|
1363 | */
|
---|
1364 | void QGraphicsSceneDragDropEvent::setButtons(Qt::MouseButtons buttons)
|
---|
1365 | {
|
---|
1366 | Q_D(QGraphicsSceneDragDropEvent);
|
---|
1367 | d->buttons = buttons;
|
---|
1368 | }
|
---|
1369 |
|
---|
1370 | /*!
|
---|
1371 | Returns the keyboard modifiers that were pressed when the drag
|
---|
1372 | and drop event was created.
|
---|
1373 |
|
---|
1374 | \sa Qt::KeyboardModifiers
|
---|
1375 | */
|
---|
1376 | Qt::KeyboardModifiers QGraphicsSceneDragDropEvent::modifiers() const
|
---|
1377 | {
|
---|
1378 | Q_D(const QGraphicsSceneDragDropEvent);
|
---|
1379 | return d->modifiers;
|
---|
1380 | }
|
---|
1381 |
|
---|
1382 | /*!
|
---|
1383 | \internal
|
---|
1384 | Sets the keyboard modifiers that were pressed when the event
|
---|
1385 | was created to \a modifiers.
|
---|
1386 |
|
---|
1387 | \sa Qt::KeyboardModifiers, modifiers()
|
---|
1388 | */
|
---|
1389 |
|
---|
1390 | void QGraphicsSceneDragDropEvent::setModifiers(Qt::KeyboardModifiers modifiers)
|
---|
1391 | {
|
---|
1392 | Q_D(QGraphicsSceneDragDropEvent);
|
---|
1393 | d->modifiers = modifiers;
|
---|
1394 | }
|
---|
1395 |
|
---|
1396 | /*!
|
---|
1397 | Returns the possible drop actions that the drag and
|
---|
1398 | drop can result in.
|
---|
1399 |
|
---|
1400 | \sa Qt::DropActions
|
---|
1401 | */
|
---|
1402 |
|
---|
1403 | Qt::DropActions QGraphicsSceneDragDropEvent::possibleActions() const
|
---|
1404 | {
|
---|
1405 | Q_D(const QGraphicsSceneDragDropEvent);
|
---|
1406 | return d->possibleActions;
|
---|
1407 | }
|
---|
1408 |
|
---|
1409 | /*!
|
---|
1410 | \internal
|
---|
1411 | Sets the possible drop actions that the drag can
|
---|
1412 | result in to \a actions.
|
---|
1413 |
|
---|
1414 | \sa Qt::DropActions, possibleActions()
|
---|
1415 | */
|
---|
1416 | void QGraphicsSceneDragDropEvent::setPossibleActions(Qt::DropActions actions)
|
---|
1417 | {
|
---|
1418 | Q_D(QGraphicsSceneDragDropEvent);
|
---|
1419 | d->possibleActions = actions;
|
---|
1420 | }
|
---|
1421 |
|
---|
1422 | /*!
|
---|
1423 | Returns the drop action that is proposed, i.e., preferred.
|
---|
1424 | The action must be one of the possible actions as defined by
|
---|
1425 | \c possibleActions().
|
---|
1426 |
|
---|
1427 | \sa Qt::DropAction, possibleActions()
|
---|
1428 | */
|
---|
1429 |
|
---|
1430 | Qt::DropAction QGraphicsSceneDragDropEvent::proposedAction() const
|
---|
1431 | {
|
---|
1432 | Q_D(const QGraphicsSceneDragDropEvent);
|
---|
1433 | return d->proposedAction;
|
---|
1434 | }
|
---|
1435 |
|
---|
1436 | /*!
|
---|
1437 | \internal
|
---|
1438 | Sets the proposed action to \a action. The proposed action
|
---|
1439 | is a Qt::DropAction that is one of the possible actions as
|
---|
1440 | given by \c possibleActions().
|
---|
1441 |
|
---|
1442 | \sa proposedAction(), Qt::DropAction, possibleActions()
|
---|
1443 | */
|
---|
1444 |
|
---|
1445 | void QGraphicsSceneDragDropEvent::setProposedAction(Qt::DropAction action)
|
---|
1446 | {
|
---|
1447 | Q_D(QGraphicsSceneDragDropEvent);
|
---|
1448 | d->proposedAction = action;
|
---|
1449 | }
|
---|
1450 |
|
---|
1451 | /*!
|
---|
1452 | Sets the proposed action as accepted, i.e, the drop action
|
---|
1453 | is set to the proposed action. This is equal to:
|
---|
1454 |
|
---|
1455 | \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicssceneevent.cpp 0
|
---|
1456 |
|
---|
1457 | When using this function, one should not call \c accept().
|
---|
1458 |
|
---|
1459 | \sa dropAction(), setDropAction(), proposedAction()
|
---|
1460 | */
|
---|
1461 |
|
---|
1462 | void QGraphicsSceneDragDropEvent::acceptProposedAction()
|
---|
1463 | {
|
---|
1464 | Q_D(QGraphicsSceneDragDropEvent);
|
---|
1465 | d->dropAction = d->proposedAction;
|
---|
1466 | }
|
---|
1467 |
|
---|
1468 | /*!
|
---|
1469 | Returns the action that was performed in this drag and drop.
|
---|
1470 | This should be set by the receiver of the drop and is
|
---|
1471 | returned by QDrag::exec().
|
---|
1472 |
|
---|
1473 | \sa setDropAction(), acceptProposedAction()
|
---|
1474 | */
|
---|
1475 |
|
---|
1476 | Qt::DropAction QGraphicsSceneDragDropEvent::dropAction() const
|
---|
1477 | {
|
---|
1478 | Q_D(const QGraphicsSceneDragDropEvent);
|
---|
1479 | return d->dropAction;
|
---|
1480 | }
|
---|
1481 |
|
---|
1482 | /*!
|
---|
1483 | This function lets the receiver of the drop set the drop
|
---|
1484 | action that was performed to \a action, which should be one
|
---|
1485 | of the
|
---|
1486 | \l{QGraphicsSceneDragDropEvent::possibleActions()}{possible
|
---|
1487 | actions}. Call \c accept() in stead of \c
|
---|
1488 | acceptProposedAction() if you use this function.
|
---|
1489 |
|
---|
1490 | \sa dropAction(), accept(), possibleActions()
|
---|
1491 | */
|
---|
1492 | void QGraphicsSceneDragDropEvent::setDropAction(Qt::DropAction action)
|
---|
1493 | {
|
---|
1494 | Q_D(QGraphicsSceneDragDropEvent);
|
---|
1495 | d->dropAction = action;
|
---|
1496 | }
|
---|
1497 |
|
---|
1498 | /*!
|
---|
1499 | This function returns the QGraphicsView that created the
|
---|
1500 | QGraphicsSceneDragDropEvent.
|
---|
1501 | */
|
---|
1502 | QWidget *QGraphicsSceneDragDropEvent::source() const
|
---|
1503 | {
|
---|
1504 | Q_D(const QGraphicsSceneDragDropEvent);
|
---|
1505 | return d->source;
|
---|
1506 | }
|
---|
1507 |
|
---|
1508 | /*!
|
---|
1509 | \internal
|
---|
1510 | This function set the source widget, i.e., the widget that
|
---|
1511 | created the drop event, to \a source.
|
---|
1512 | */
|
---|
1513 | void QGraphicsSceneDragDropEvent::setSource(QWidget *source)
|
---|
1514 | {
|
---|
1515 | Q_D(QGraphicsSceneDragDropEvent);
|
---|
1516 | d->source = source;
|
---|
1517 | }
|
---|
1518 |
|
---|
1519 | /*!
|
---|
1520 | This function returns the MIME data of the event.
|
---|
1521 | */
|
---|
1522 | const QMimeData *QGraphicsSceneDragDropEvent::mimeData() const
|
---|
1523 | {
|
---|
1524 | Q_D(const QGraphicsSceneDragDropEvent);
|
---|
1525 | return d->mimeData;
|
---|
1526 | }
|
---|
1527 |
|
---|
1528 | /*!
|
---|
1529 | \internal
|
---|
1530 | This function sets the MIME data for the event.
|
---|
1531 | */
|
---|
1532 | void QGraphicsSceneDragDropEvent::setMimeData(const QMimeData *data)
|
---|
1533 | {
|
---|
1534 | Q_D(QGraphicsSceneDragDropEvent);
|
---|
1535 | d->mimeData = data;
|
---|
1536 | }
|
---|
1537 |
|
---|
1538 | class QGraphicsSceneResizeEventPrivate : public QGraphicsSceneEventPrivate
|
---|
1539 | {
|
---|
1540 | Q_DECLARE_PUBLIC(QGraphicsSceneResizeEvent)
|
---|
1541 | public:
|
---|
1542 | inline QGraphicsSceneResizeEventPrivate()
|
---|
1543 | { }
|
---|
1544 |
|
---|
1545 | QSizeF oldSize;
|
---|
1546 | QSizeF newSize;
|
---|
1547 | };
|
---|
1548 |
|
---|
1549 | /*!
|
---|
1550 | Constructs a QGraphicsSceneResizeEvent.
|
---|
1551 | */
|
---|
1552 | QGraphicsSceneResizeEvent::QGraphicsSceneResizeEvent()
|
---|
1553 | : QGraphicsSceneEvent(*new QGraphicsSceneResizeEventPrivate, QEvent::GraphicsSceneResize)
|
---|
1554 | {
|
---|
1555 | }
|
---|
1556 |
|
---|
1557 | /*!
|
---|
1558 | Destroys the QGraphicsSceneResizeEvent.
|
---|
1559 | */
|
---|
1560 | QGraphicsSceneResizeEvent::~QGraphicsSceneResizeEvent()
|
---|
1561 | {
|
---|
1562 | }
|
---|
1563 |
|
---|
1564 | /*!
|
---|
1565 | Returns the old size (i.e., the size immediately before the widget was
|
---|
1566 | resized).
|
---|
1567 |
|
---|
1568 | \sa newSize(), QGraphicsWidget::resize()
|
---|
1569 | */
|
---|
1570 | QSizeF QGraphicsSceneResizeEvent::oldSize() const
|
---|
1571 | {
|
---|
1572 | Q_D(const QGraphicsSceneResizeEvent);
|
---|
1573 | return d->oldSize;
|
---|
1574 | }
|
---|
1575 |
|
---|
1576 | /*!
|
---|
1577 | \internal
|
---|
1578 | */
|
---|
1579 | void QGraphicsSceneResizeEvent::setOldSize(const QSizeF &size)
|
---|
1580 | {
|
---|
1581 | Q_D(QGraphicsSceneResizeEvent);
|
---|
1582 | d->oldSize = size;
|
---|
1583 | }
|
---|
1584 |
|
---|
1585 | /*!
|
---|
1586 | Returns the new size (i.e., the current size).
|
---|
1587 |
|
---|
1588 | \sa oldSize(), QGraphicsWidget::resize()
|
---|
1589 | */
|
---|
1590 | QSizeF QGraphicsSceneResizeEvent::newSize() const
|
---|
1591 | {
|
---|
1592 | Q_D(const QGraphicsSceneResizeEvent);
|
---|
1593 | return d->newSize;
|
---|
1594 | }
|
---|
1595 |
|
---|
1596 | /*!
|
---|
1597 | \internal
|
---|
1598 | */
|
---|
1599 | void QGraphicsSceneResizeEvent::setNewSize(const QSizeF &size)
|
---|
1600 | {
|
---|
1601 | Q_D(QGraphicsSceneResizeEvent);
|
---|
1602 | d->newSize = size;
|
---|
1603 | }
|
---|
1604 |
|
---|
1605 | class QGraphicsSceneMoveEventPrivate : public QGraphicsSceneEventPrivate
|
---|
1606 | {
|
---|
1607 | Q_DECLARE_PUBLIC(QGraphicsSceneMoveEvent)
|
---|
1608 | public:
|
---|
1609 | inline QGraphicsSceneMoveEventPrivate()
|
---|
1610 | { }
|
---|
1611 |
|
---|
1612 | QPointF oldPos;
|
---|
1613 | QPointF newPos;
|
---|
1614 | };
|
---|
1615 |
|
---|
1616 | /*!
|
---|
1617 | Constructs a QGraphicsSceneMoveEvent.
|
---|
1618 | */
|
---|
1619 | QGraphicsSceneMoveEvent::QGraphicsSceneMoveEvent()
|
---|
1620 | : QGraphicsSceneEvent(*new QGraphicsSceneMoveEventPrivate, QEvent::GraphicsSceneMove)
|
---|
1621 | {
|
---|
1622 | }
|
---|
1623 |
|
---|
1624 | /*!
|
---|
1625 | Destroys the QGraphicsSceneMoveEvent.
|
---|
1626 | */
|
---|
1627 | QGraphicsSceneMoveEvent::~QGraphicsSceneMoveEvent()
|
---|
1628 | {
|
---|
1629 | }
|
---|
1630 |
|
---|
1631 | /*!
|
---|
1632 | Returns the old position (i.e., the position immediatly before the widget
|
---|
1633 | was moved).
|
---|
1634 |
|
---|
1635 | \sa newPos(), QGraphicsItem::setPos()
|
---|
1636 | */
|
---|
1637 | QPointF QGraphicsSceneMoveEvent::oldPos() const
|
---|
1638 | {
|
---|
1639 | Q_D(const QGraphicsSceneMoveEvent);
|
---|
1640 | return d->oldPos;
|
---|
1641 | }
|
---|
1642 |
|
---|
1643 | /*!
|
---|
1644 | \internal
|
---|
1645 | */
|
---|
1646 | void QGraphicsSceneMoveEvent::setOldPos(const QPointF &pos)
|
---|
1647 | {
|
---|
1648 | Q_D(QGraphicsSceneMoveEvent);
|
---|
1649 | d->oldPos = pos;
|
---|
1650 | }
|
---|
1651 |
|
---|
1652 | /*!
|
---|
1653 | Returns the new position (i.e., the current position).
|
---|
1654 |
|
---|
1655 | \sa oldPos(), QGraphicsItem::setPos()
|
---|
1656 | */
|
---|
1657 | QPointF QGraphicsSceneMoveEvent::newPos() const
|
---|
1658 | {
|
---|
1659 | Q_D(const QGraphicsSceneMoveEvent);
|
---|
1660 | return d->newPos;
|
---|
1661 | }
|
---|
1662 |
|
---|
1663 | /*!
|
---|
1664 | \internal
|
---|
1665 | */
|
---|
1666 | void QGraphicsSceneMoveEvent::setNewPos(const QPointF &pos)
|
---|
1667 | {
|
---|
1668 | Q_D(QGraphicsSceneMoveEvent);
|
---|
1669 | d->newPos = pos;
|
---|
1670 | }
|
---|
1671 |
|
---|
1672 | QT_END_NAMESPACE
|
---|
1673 |
|
---|
1674 | #endif // QT_NO_GRAPHICSVIEW
|
---|