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