Remove deprecated inputItem and inputWindow from QInputMethod
[profile/ivi/qtbase.git] / src / gui / kernel / qevent.cpp
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
16 **
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
20 **
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
28 **
29 ** Other Usage
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
32 **
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #include "qevent.h"
43 #include "qcursor.h"
44 #include "private/qguiapplication_p.h"
45 #include "qpa/qplatformintegration.h"
46 #include "qpa/qplatformdrag.h"
47 #include "private/qevent_p.h"
48 #include "private/qkeysequence_p.h"
49 #include "qdebug.h"
50 #include "qmimedata.h"
51 #include "private/qdnd_p.h"
52 #include "qevent_p.h"
53 #include "qmath.h"
54
55
56 QT_BEGIN_NAMESPACE
57
58 /*!
59     \class QInputEvent
60     \ingroup events
61     \inmodule QtGui
62
63     \brief The QInputEvent class is the base class for events that
64     describe user input.
65 */
66
67 /*!
68   \internal
69 */
70 QInputEvent::QInputEvent(Type type, Qt::KeyboardModifiers modifiers)
71     : QEvent(type), modState(modifiers), ts(0)
72 {}
73
74 /*!
75   \internal
76 */
77 QInputEvent::~QInputEvent()
78 {
79 }
80
81 /*!
82     \fn Qt::KeyboardModifiers QInputEvent::modifiers() const
83
84     Returns the keyboard modifier flags that existed immediately
85     before the event occurred.
86
87     \sa QApplication::keyboardModifiers()
88 */
89
90 /*! \fn void QInputEvent::setModifiers(Qt::KeyboardModifiers modifiers)
91
92     \internal
93
94     Sets the keyboard modifiers flags for this event.
95 */
96
97 /*!
98     \class QMouseEvent
99     \ingroup events
100
101     \brief The QMouseEvent class contains parameters that describe a mouse event.
102
103     Mouse events occur when a mouse button is pressed or released
104     inside a widget, or when the mouse cursor is moved.
105
106     Mouse move events will occur only when a mouse button is pressed
107     down, unless mouse tracking has been enabled with
108     QWidget::setMouseTracking().
109
110     Qt automatically grabs the mouse when a mouse button is pressed
111     inside a widget; the widget will continue to receive mouse events
112     until the last mouse button is released.
113
114     A mouse event contains a special accept flag that indicates
115     whether the receiver wants the event. You should call ignore() if
116     the mouse event is not handled by your widget. A mouse event is
117     propagated up the parent widget chain until a widget accepts it
118     with accept(), or an event filter consumes it.
119
120     \note If a mouse event is propagated to a \l{QWidget}{widget} for
121     which Qt::WA_NoMousePropagation has been set, that mouse event
122     will not be propagated further up the parent widget chain.
123
124     The state of the keyboard modifier keys can be found by calling the
125     \l{QInputEvent::modifiers()}{modifiers()} function, inherited from
126     QInputEvent.
127
128     The functions pos(), x(), and y() give the cursor position
129     relative to the widget that receives the mouse event. If you
130     move the widget as a result of the mouse event, use the global
131     position returned by globalPos() to avoid a shaking motion.
132
133     The QWidget::setEnabled() function can be used to enable or
134     disable mouse and keyboard events for a widget.
135
136     Reimplement the QWidget event handlers, QWidget::mousePressEvent(),
137     QWidget::mouseReleaseEvent(), QWidget::mouseDoubleClickEvent(),
138     and QWidget::mouseMoveEvent() to receive mouse events in your own
139     widgets.
140
141     \sa QWidget::setMouseTracking(), QWidget::grabMouse(),
142     QCursor::pos()
143 */
144
145 /*!
146     Constructs a mouse event object.
147
148     The \a type parameter must be one of QEvent::MouseButtonPress,
149     QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick,
150     or QEvent::MouseMove.
151
152     The \a localPos is the mouse cursor's position relative to the
153     receiving widget or item. The window position is set to the same value
154     as \a localPos.
155     The \a button that caused the event is given as a value from
156     the Qt::MouseButton enum. If the event \a type is
157     \l MouseMove, the appropriate button for this event is Qt::NoButton.
158     The mouse and keyboard states at the time of the event are specified by
159     \a buttons and \a modifiers.
160
161     The screenPos() is initialized to QCursor::pos(), which may not
162     be appropriate. Use the other constructor to specify the global
163     position explicitly.
164 */
165 QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, Qt::MouseButton button,
166                          Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
167     : QInputEvent(type, modifiers), l(localPos), w(localPos), b(button), mouseState(buttons), caps(0)
168 {
169     s = QCursor::pos();
170 }
171
172
173 /*!
174     Constructs a mouse event object.
175
176     The \a type parameter must be QEvent::MouseButtonPress,
177     QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick,
178     or QEvent::MouseMove.
179
180     The \a localPos is the mouse cursor's position relative to the
181     receiving widget or item. The cursor's position in screen coordinates is
182     specified by \a screenPos. The window position is set to the same value
183     as \a localPos. The \a button that caused the event is
184     given as a value from the \l Qt::MouseButton enum. If the event \a
185     type is \l MouseMove, the appropriate button for this event is
186     Qt::NoButton. \a buttons is the state of all buttons at the
187     time of the event, \a modifiers the state of all keyboard
188     modifiers.
189
190 */
191 QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, const QPointF &screenPos,
192                          Qt::MouseButton button, Qt::MouseButtons buttons,
193                          Qt::KeyboardModifiers modifiers)
194     : QInputEvent(type, modifiers), l(localPos), w(localPos), s(screenPos), b(button), mouseState(buttons), caps(0)
195 {}
196
197 /*!
198     Constructs a mouse event object.
199
200     The \a type parameter must be QEvent::MouseButtonPress,
201     QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick,
202     or QEvent::MouseMove.
203
204     The \a pos is the mouse cursor's position relative to the
205     receiving widget. The cursor's position in global coordinates is
206     specified by \a globalPos.  The \a button that caused the event is
207     given as a value from the \l Qt::MouseButton enum. If the event \a
208     type is \l MouseMove, the appropriate button for this event is
209     Qt::NoButton. \a buttons is the state of all buttons at the
210     time of the event, \a modifiers the state of all keyboard
211     modifiers.
212
213 */
214 QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, const QPointF &windowPos, const QPointF &screenPos,
215                          Qt::MouseButton button, Qt::MouseButtons buttons,
216                          Qt::KeyboardModifiers modifiers)
217     : QInputEvent(type, modifiers), l(localPos), w(windowPos), s(screenPos), b(button), mouseState(buttons), caps(0)
218 {}
219
220 /*!
221     \internal
222 */
223 QMouseEvent::~QMouseEvent()
224 {
225 }
226
227
228 /*!
229     \fn QPointF QMouseEvent::localPos() const
230
231     \since 5.0
232
233     Returns the position of the mouse cursor as a QPointF, relative to the
234     widget or item that received the event.
235
236     If you move the widget as a result of the mouse event, use the
237     screen position returned by screenPos() to avoid a shaking
238     motion.
239
240     \sa x(), y(), windowPos(), screenPos()
241 */
242
243 /*!
244     \fn QPointF QMouseEvent::windowPos() const
245
246     \since 5.0
247
248     Returns the position of the mouse cursor as a QPointF, relative to the
249     window that received the event.
250
251     If you move the widget as a result of the mouse event, use the
252     global position returned by globalPos() to avoid a shaking
253     motion.
254
255     \sa x(), y(), pos(), localPos(), screenPos()
256 */
257
258 /*!
259     \fn QPointF QMouseEvent::screenPos() const
260
261     \since 5.0
262
263     Returns the position of the mouse cursor as a QPointF, relative to the
264     screen that received the event.
265
266     \sa x(), y(), pos(), localPos(), screenPos()
267 */
268
269 /*!
270     \fn const QPoint &QMouseEvent::pos() const
271
272     Returns the position of the mouse cursor, relative to the widget
273     that received the event.
274
275     If you move the widget as a result of the mouse event, use the
276     global position returned by globalPos() to avoid a shaking
277     motion.
278
279     \sa x(), y(), globalPos()
280 */
281
282 /*!
283     \fn const QPoint &QMouseEvent::globalPos() const
284
285     Returns the global position of the mouse cursor \e{at the time
286     of the event}. This is important on asynchronous window systems
287     like X11. Whenever you move your widgets around in response to
288     mouse events, globalPos() may differ a lot from the current
289     pointer position QCursor::pos(), and from
290     QWidget::mapToGlobal(pos()).
291
292     \sa globalX(), globalY()
293 */
294
295 /*!
296     \fn int QMouseEvent::x() const
297
298     Returns the x position of the mouse cursor, relative to the
299     widget that received the event.
300
301     \sa y(), pos()
302 */
303
304 /*!
305     \fn int QMouseEvent::y() const
306
307     Returns the y position of the mouse cursor, relative to the
308     widget that received the event.
309
310     \sa x(), pos()
311 */
312
313 /*!
314     \fn int QMouseEvent::globalX() const
315
316     Returns the global x position of the mouse cursor at the time of
317     the event.
318
319     \sa globalY(), globalPos()
320 */
321
322 /*!
323     \fn int QMouseEvent::globalY() const
324
325     Returns the global y position of the mouse cursor at the time of
326     the event.
327
328     \sa globalX(), globalPos()
329 */
330
331 /*!
332     \fn Qt::MouseButton QMouseEvent::button() const
333
334     Returns the button that caused the event.
335
336     Note that the returned value is always Qt::NoButton for mouse
337     move events.
338
339     \sa buttons(), Qt::MouseButton
340 */
341
342 /*!
343     \fn Qt::MouseButton QMouseEvent::buttons() const
344
345     Returns the button state when the event was generated. The button
346     state is a combination of Qt::LeftButton, Qt::RightButton,
347     Qt::MidButton using the OR operator. For mouse move events,
348     this is all buttons that are pressed down. For mouse press and
349     double click events this includes the button that caused the
350     event. For mouse release events this excludes the button that
351     caused the event.
352
353     \sa button(), Qt::MouseButton
354 */
355
356 /*!
357     \class QHoverEvent
358     \ingroup events
359
360     \brief The QHoverEvent class contains parameters that describe a mouse event.
361
362     Mouse events occur when a mouse cursor is moved into, out of, or within a
363     widget, and if the widget has the Qt::WA_Hover attribute.
364
365     The function pos() gives the current cursor position, while oldPos() gives
366     the old mouse position.
367
368     There are a few similarities between the events QEvent::HoverEnter
369     and QEvent::HoverLeave, and the events QEvent::Enter and QEvent::Leave.
370     However, they are slightly different because we do an update() in the event
371     handler of HoverEnter and HoverLeave.
372
373     QEvent::HoverMove is also slightly different from QEvent::MouseMove. Let us
374     consider a top-level window A containing a child B which in turn contains a
375     child C (all with mouse tracking enabled):
376
377     \image hoverevents.png
378
379     Now, if you move the cursor from the top to the bottom in the middle of A,
380     you will get the following QEvent::MouseMove events:
381
382     \list 1
383         \li A::MouseMove
384         \li B::MouseMove
385         \li C::MouseMove
386     \endlist
387
388     You will get the same events for QEvent::HoverMove, except that the event
389     always propagates to the top-level regardless whether the event is accepted
390     or not. It will only stop propagating with the Qt::WA_NoMousePropagation
391     attribute.
392
393     In this case the events will occur in the following way:
394
395     \list 1
396         \li A::HoverMove
397         \li A::HoverMove, B::HoverMove
398         \li A::HoverMove, B::HoverMove, C::HoverMove
399     \endlist
400
401 */
402
403 /*!
404     \fn const QPoint &QHoverEvent::pos() const
405
406     Returns the position of the mouse cursor, relative to the widget
407     that received the event.
408
409     On QEvent::HoverLeave events, this position will always be
410     QPoint(-1, -1).
411
412     \sa oldPos()
413 */
414
415 /*!
416     \fn const QPoint &QHoverEvent::oldPos() const
417
418     Returns the previous position of the mouse cursor, relative to the widget
419     that received the event. If there is no previous position, oldPos() will
420     return the same position as pos().
421
422     On QEvent::HoverEnter events, this position will always be
423     QPoint(-1, -1).
424
425     \sa pos()
426 */
427
428 /*!
429     Constructs a hover event object.
430
431     The \a type parameter must be QEvent::HoverEnter,
432     QEvent::HoverLeave, or QEvent::HoverMove.
433
434     The \a pos is the current mouse cursor's position relative to the
435     receiving widget, while \a oldPos is the previous mouse cursor's
436     position relative to the receiving widget.
437 */
438 QHoverEvent::QHoverEvent(Type type, const QPointF &pos, const QPointF &oldPos, Qt::KeyboardModifiers modifiers)
439     : QInputEvent(type, modifiers), p(pos), op(oldPos)
440 {
441 }
442
443 /*!
444     \internal
445 */
446 QHoverEvent::~QHoverEvent()
447 {
448 }
449
450
451 /*!
452     \class QWheelEvent
453     \brief The QWheelEvent class contains parameters that describe a wheel event.
454     \inmodule QtGui
455
456     \ingroup events
457
458     Wheel events are sent to the widget under the mouse cursor, but
459     if that widget does not handle the event they are sent to the
460     focus widget. Wheel events are generated for both mouse wheels
461     and trackpad scroll gestures. There are two ways to read the
462     wheel event delta: angleDelta() returns the delta in wheel
463     degrees. This value is always provided. pixelDelta() returns
464     the delta in screen pixels and is available on platforms that
465     have high-resolution trackpads, such as Mac OS X.
466
467     The functions pos() and globalPos() return the mouse cursor's
468     location at the time of the event.
469
470     A wheel event contains a special accept flag that indicates
471     whether the receiver wants the event. You should call ignore() if
472     you do not handle the wheel event; this ensures that it will be
473     sent to the parent widget.
474
475     The QWidget::setEnabled() function can be used to enable or
476     disable mouse and keyboard events for a widget.
477
478     The event handler QWidget::wheelEvent() receives wheel events.
479
480     \sa QMouseEvent, QWidget::grabMouse()
481 */
482
483 /*!
484     \fn Qt::MouseButtons QWheelEvent::buttons() const
485
486     Returns the mouse state when the event occurred.
487 */
488
489 /*!
490     \fn Qt::Orientation QWheelEvent::orientation() const
491
492     Returns the wheel's orientation.
493 */
494
495 /*!
496     \obsolete
497     Constructs a wheel event object.
498
499     Use the QPoint-based constructor instead.
500
501     The position, \a pos, is the location of the mouse cursor within
502     the widget. The globalPos() is initialized to QCursor::pos()
503     which is usually, but not always, correct.
504     Use the other constructor if you need to specify the global
505     position explicitly.
506
507     The \a buttons describe the state of the mouse buttons at the time
508     of the event, \a delta contains the rotation distance,
509     \a modifiers holds the keyboard modifier flags at the time of the
510     event, and \a orient holds the wheel's orientation.
511
512     \sa pos(), pixelDelta(), angleDelta(), state()
513 */
514 #ifndef QT_NO_WHEELEVENT
515 QWheelEvent::QWheelEvent(const QPointF &pos, int delta,
516                          Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
517                          Qt::Orientation orient)
518     : QInputEvent(Wheel, modifiers), p(pos), qt4D(delta), qt4O(orient), mouseState(buttons)
519 {
520     g = QCursor::pos();
521 }
522
523 /*!
524   \internal
525 */
526 QWheelEvent::~QWheelEvent()
527 {
528 }
529
530 /*!
531     \obsolete
532     Constructs a wheel event object.
533
534     Use the QPoint-based constructor instead.
535
536     The \a pos provides the location of the mouse cursor
537     within the widget. The position in global coordinates is specified
538     by \a globalPos. \a delta contains the rotation distance, \a modifiers
539     holds the keyboard modifier flags at the time of the event, and
540     \a orient holds the wheel's orientation.
541
542
543     \sa pos(), pixelDelta(), angleDelta(), state()
544 */
545 QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, int delta,
546                          Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
547                          Qt::Orientation orient)
548     : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), qt4D(delta), qt4O(orient), mouseState(buttons)
549 {}
550
551 /*!
552     Constructs a wheel event object.
553
554     The \a pos provides the location of the mouse cursor
555     within the window. The position in global coordinates is specified
556     by \a globalPos. \a pixelDelta contains the scrolling distance
557     in pixels on screen, \a angleDelta contains the wheel rotation distance.
558     \a pixelDelta is optional and can be null.
559
560     \a modifiers holds the keyboard modifier flags at the time of the event.
561
562     \a pixelDelta contains the scrolling delta in pixels,
563     \a angleDelta contains the rotation distance, and
564     \a orient holds the wheel's orientation.
565
566     \sa pos(), globalPos(), delta(), state()
567 */
568
569 QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos,
570             QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation,
571             Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
572     : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), pixelD(pixelDelta),
573       angleD(angleDelta), qt4D(qt4Delta), qt4O(qt4Orientation), mouseState(buttons)
574 {}
575
576
577 #endif // QT_NO_WHEELEVENT
578
579 /*!
580     \fn QPoint QWheelEvent::pixelDelta() const
581
582     Returns the scrolling distance in pixels on screen. This value is
583     provided on platforms that support high-resolution pixel-based
584     delta values, such as Mac OS X. The value should be used directly
585     to scroll content on screen.
586
587     Example:
588
589     \snippet code/src_gui_kernel_qevent.cpp 0
590 */
591
592 /*!
593     \fn QPoint QWheelEvent::angleDelta() const
594
595     Returns the distance that the wheel is rotated, in eighths of a
596     degree. A positive value indicates that the wheel was rotated
597     forwards away from the user; a negative value indicates that the
598     wheel was rotated backwards toward the user.
599
600     Most mouse types work in steps of 15 degrees, in which case the
601     delta value is a multiple of 120; i.e., 120 units * 1/8 = 15 degrees.
602
603     However, some mice have finer-resolution wheels and send delta values
604     that are less than 120 units (less than 15 degrees). To support this
605     possibility, you can either cumulatively add the delta values from events
606     until the value of 120 is reached, then scroll the widget, or you can
607     partially scroll the widget in response to each wheel event.
608
609     Example:
610
611     \snippet code/src_gui_kernel_qevent.cpp 0
612 */
613
614 /*!
615     \fn int QWheelEvent::delta() const
616
617     This function has been deprecated, use pixelDelta() or angleDelta() instead.
618 */
619
620 /*!
621     \fn const QPoint &QWheelEvent::pos() const
622
623     Returns the position of the mouse cursor relative to the widget
624     that received the event.
625
626     If you move your widgets around in response to mouse events,
627     use globalPos() instead of this function.
628
629     \sa x(), y(), globalPos()
630 */
631
632 /*!
633     \fn int QWheelEvent::x() const
634
635     Returns the x position of the mouse cursor, relative to the
636     widget that received the event.
637
638     \sa y(), pos()
639 */
640
641 /*!
642     \fn int QWheelEvent::y() const
643
644     Returns the y position of the mouse cursor, relative to the
645     widget that received the event.
646
647     \sa x(), pos()
648 */
649
650
651 /*!
652     \fn const QPoint &QWheelEvent::globalPos() const
653
654     Returns the global position of the mouse pointer \e{at the time
655     of the event}. This is important on asynchronous window systems
656     such as X11; whenever you move your widgets around in response to
657     mouse events, globalPos() can differ a lot from the current
658     cursor position returned by QCursor::pos().
659
660     \sa globalX(), globalY()
661 */
662
663 /*!
664     \fn int QWheelEvent::globalX() const
665
666     Returns the global x position of the mouse cursor at the time of
667     the event.
668
669     \sa globalY(), globalPos()
670 */
671
672 /*!
673     \fn int QWheelEvent::globalY() const
674
675     Returns the global y position of the mouse cursor at the time of
676     the event.
677
678     \sa globalX(), globalPos()
679 */
680
681 /*!
682     \class QKeyEvent
683     \brief The QKeyEvent class describes a key event.
684
685     \ingroup events
686
687     Key events are sent to the widget with keyboard input focus
688     when keys are pressed or released.
689
690     A key event contains a special accept flag that indicates whether
691     the receiver will handle the key event. You should call ignore()
692     if the key press or release event is not handled by your widget.
693     A key event is propagated up the parent widget chain until a
694     widget accepts it with accept() or an event filter consumes it.
695     Key events for multimedia keys are ignored by default. You should
696     call accept() if your widget handles those events.
697
698     The QWidget::setEnable() function can be used to enable or disable
699     mouse and keyboard events for a widget.
700
701     The event handlers QWidget::keyPressEvent(), QWidget::keyReleaseEvent(),
702     QGraphicsItem::keyPressEvent() and QGraphicsItem::keyReleaseEvent()
703     receive key events.
704
705     \sa QFocusEvent, QWidget::grabKeyboard()
706 */
707
708 /*!
709     Constructs a key event object.
710
711     The \a type parameter must be QEvent::KeyPress, QEvent::KeyRelease,
712     or QEvent::ShortcutOverride.
713
714     Int \a key is the code for the Qt::Key that the event loop should listen
715     for. If \a key is 0, the event is not a result of a known key; for
716     example, it may be the result of a compose sequence or keyboard macro.
717     The \a modifiers holds the keyboard modifiers, and the given \a text
718     is the Unicode text that the key generated. If \a autorep is true,
719     isAutoRepeat() will be true. \a count is the number of keys involved
720     in the event.
721 */
722 QKeyEvent::QKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers, const QString& text,
723                      bool autorep, ushort count)
724     : QInputEvent(type, modifiers), txt(text), k(key),
725       nScanCode(0), nVirtualKey(0), nModifiers(0),
726       c(count), autor(autorep)
727 {
728 }
729
730 /*!
731     Constructs a key event object.
732
733     The \a type parameter must be QEvent::KeyPress, QEvent::KeyRelease,
734     or QEvent::ShortcutOverride.
735
736     Int \a key is the code for the Qt::Key that the event loop should listen
737     for. If \a key is 0, the event is not a result of a known key; for
738     example, it may be the result of a compose sequence or keyboard macro.
739     The \a modifiers holds the keyboard modifiers, and the given \a text
740     is the Unicode text that the key generated. If \a autorep is true,
741     isAutoRepeat() will be true. \a count is the number of keys involved
742     in the event.
743
744     In addition to the normal key event data, also contains \a nativeScanCode,
745     \a nativeVirtualKey and \a nativeModifiers. This extra data is used by the
746     shortcut system, to determine which shortcuts to trigger.
747 */
748 QKeyEvent::QKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers,
749                      quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers,
750                      const QString &text, bool autorep, ushort count)
751     : QInputEvent(type, modifiers), txt(text), k(key),
752       nScanCode(nativeScanCode), nVirtualKey(nativeVirtualKey), nModifiers(nativeModifiers),
753       c(count), autor(autorep)
754 {
755 }
756
757
758 /*!
759   \internal
760 */
761 QKeyEvent::~QKeyEvent()
762 {
763 }
764
765 /*!
766     \fn QKeyEvent *QKeyEvent::createExtendedKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers, quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers, const QString& text, bool autorep, ushort count)
767     \internal
768 */
769
770 /*!
771     \fn bool QKeyEvent::hasExtendedInfo() const
772     \internal
773 */
774
775 /*!
776   \fn quint32 QKeyEvent::nativeScanCode() const
777   \since 4.2
778
779   Returns the native scan code of the key event.  If the key event
780   does not contain this data 0 is returned.
781
782   Note: The native scan code may be 0, even if the key event contains
783   extended information.
784
785   Note: On Mac OS/X, this function is not useful, because there is no
786   way to get the scan code from Carbon or Cocoa. The function always
787   returns 1 (or 0 in the case explained above).
788 */
789
790 /*!
791     \fn quint32 QKeyEvent::nativeVirtualKey() const
792     \since 4.2
793
794     Returns the native virtual key, or key sym of the key event.
795     If the key event does not contain this data 0 is returned.
796
797     Note: The native virtual key may be 0, even if the key event contains extended information.
798 */
799
800 /*!
801     \fn quint32 QKeyEvent::nativeModifiers() const
802     \since 4.2
803
804     Returns the native modifiers of a key event.
805     If the key event does not contain this data 0 is returned.
806
807     Note: The native modifiers may be 0, even if the key event contains extended information.
808 */
809
810 /*!
811     \fn int QKeyEvent::key() const
812
813     Returns the code of the key that was pressed or released.
814
815     See \l Qt::Key for the list of keyboard codes. These codes are
816     independent of the underlying window system. Note that this
817     function does not distinguish between capital and non-capital
818     letters, use the text() function (returning the Unicode text the
819     key generated) for this purpose.
820
821     A value of either 0 or Qt::Key_unknown means that the event is not
822     the result of a known key; for example, it may be the result of
823     a compose sequence, a keyboard macro, or due to key event
824     compression.
825
826     \sa Qt::WA_KeyCompression
827 */
828
829 /*!
830     \fn QString QKeyEvent::text() const
831
832     Returns the Unicode text that this key generated. The text
833     returned can be an empty string in cases
834     where modifier keys, such as Shift, Control, Alt, and Meta,
835     are being pressed or released. In such cases key() will contain
836     a valid value.
837
838     \sa Qt::WA_KeyCompression
839 */
840
841 /*!
842     Returns the keyboard modifier flags that existed immediately
843     after the event occurred.
844
845     \warning This function cannot always be trusted. The user can
846     confuse it by pressing both \uicontrol{Shift} keys simultaneously and
847     releasing one of them, for example.
848
849     \sa QApplication::keyboardModifiers()
850 */
851 //###### We must check with XGetModifierMapping
852 Qt::KeyboardModifiers QKeyEvent::modifiers() const
853 {
854     if (key() == Qt::Key_Shift)
855         return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::ShiftModifier);
856     if (key() == Qt::Key_Control)
857         return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::ControlModifier);
858     if (key() == Qt::Key_Alt)
859         return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::AltModifier);
860     if (key() == Qt::Key_Meta)
861         return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::MetaModifier);
862     return QInputEvent::modifiers();
863 }
864
865 #ifndef QT_NO_SHORTCUT
866 /*!
867     \fn bool QKeyEvent::matches(QKeySequence::StandardKey key) const
868     \since 4.2
869
870     Returns true if the key event matches the given standard \a key;
871     otherwise returns false.
872 */
873 bool QKeyEvent::matches(QKeySequence::StandardKey matchKey) const
874 {
875     uint searchkey = (modifiers() | key()) & ~(Qt::KeypadModifier); //The keypad modifier should not make a difference
876     const uint platform = QKeySequencePrivate::currentKeyPlatforms();
877
878
879     uint N = QKeySequencePrivate::numberOfKeyBindings;
880     int first = 0;
881     int last = N - 1;
882
883     while (first <= last) {
884         int mid = (first + last) / 2;
885         QKeyBinding midVal = QKeySequencePrivate::keyBindings[mid];
886
887         if (searchkey > midVal.shortcut){
888             first = mid + 1;  // Search in top half
889         }
890         else if (searchkey < midVal.shortcut){
891             last = mid - 1; // Search in bottom half
892         }
893         else {
894             //found correct shortcut value, now we must check for platform match
895             if ((midVal.platform & platform) && (midVal.standardKey == matchKey)) {
896                 return true;
897             } else { //We may have several equal values for different platforms, so we must search in both directions
898
899                 //search forward
900                 for ( unsigned int i = mid + 1 ; i < N - 1 ; ++i) {
901                     QKeyBinding current = QKeySequencePrivate::keyBindings[i];
902                     if (current.shortcut != searchkey)
903                         break;
904                     else if (current.platform & platform && current.standardKey == matchKey)
905                         return true;
906                 }
907
908                 //search back
909                 for ( int i = mid - 1 ; i >= 0 ; --i) {
910                     QKeyBinding current = QKeySequencePrivate::keyBindings[i];
911                     if (current.shortcut != searchkey)
912                         break;
913                     else if (current.platform & platform && current.standardKey == matchKey)
914                         return true;
915                 }
916                 return false; //we could not find it among the matching keySequences
917             }
918         }
919     }
920     return false; //we could not find matching keySequences at all
921 }
922 #endif // QT_NO_SHORTCUT
923
924
925 /*!
926     \fn bool QKeyEvent::isAutoRepeat() const
927
928     Returns true if this event comes from an auto-repeating key;
929     returns false if it comes from an initial key press.
930
931     Note that if the event is a multiple-key compressed event that is
932     partly due to auto-repeat, this function could return either true
933     or false indeterminately.
934 */
935
936 /*!
937     \fn int QKeyEvent::count() const
938
939     Returns the number of keys involved in this event. If text()
940     is not empty, this is simply the length of the string.
941
942     \sa Qt::WA_KeyCompression
943 */
944
945 /*!
946     \class QFocusEvent
947     \brief The QFocusEvent class contains event parameters for widget focus
948     events.
949     \inmodule QtGui
950
951     \ingroup events
952
953     Focus events are sent to widgets when the keyboard input focus
954     changes. Focus events occur due to mouse actions, key presses
955     (such as \uicontrol{Tab} or \uicontrol{Backtab}), the window system, popup
956     menus, keyboard shortcuts, or other application-specific reasons.
957     The reason for a particular focus event is returned by reason()
958     in the appropriate event handler.
959
960     The event handlers QWidget::focusInEvent(),
961     QWidget::focusOutEvent(), QGraphicsItem::focusInEvent and
962     QGraphicsItem::focusOutEvent() receive focus events.
963
964     \sa QWidget::setFocus(), QWidget::setFocusPolicy(), {Keyboard Focus}
965 */
966
967 /*!
968     Constructs a focus event object.
969
970     The \a type parameter must be either QEvent::FocusIn or
971     QEvent::FocusOut. The \a reason describes the cause of the change
972     in focus.
973 */
974 QFocusEvent::QFocusEvent(Type type, Qt::FocusReason reason)
975     : QEvent(type), m_reason(reason)
976 {}
977
978 /*!
979     \internal
980 */
981 QFocusEvent::~QFocusEvent()
982 {
983 }
984
985 /*!
986     Returns the reason for this focus event.
987  */
988 Qt::FocusReason QFocusEvent::reason() const
989 {
990     return m_reason;
991 }
992
993 /*!
994     \fn bool QFocusEvent::gotFocus() const
995
996     Returns true if type() is QEvent::FocusIn; otherwise returns
997     false.
998 */
999
1000 /*!
1001     \fn bool QFocusEvent::lostFocus() const
1002
1003     Returns true if type() is QEvent::FocusOut; otherwise returns
1004     false.
1005 */
1006
1007
1008 /*!
1009     \class QPaintEvent
1010     \brief The QPaintEvent class contains event parameters for paint events.
1011     \inmodule QtGui
1012
1013     \ingroup events
1014
1015     Paint events are sent to widgets that need to update themselves,
1016     for instance when part of a widget is exposed because a covering
1017     widget was moved.
1018
1019     The event contains a region() that needs to be updated, and a
1020     rect() that is the bounding rectangle of that region. Both are
1021     provided because many widgets can't make much use of region(),
1022     and rect() can be much faster than region().boundingRect().
1023
1024     \section1 Automatic Clipping
1025
1026     Painting is clipped to region() during the processing of a paint
1027     event. This clipping is performed by Qt's paint system and is
1028     independent of any clipping that may be applied to a QPainter used to
1029     draw on the paint device.
1030
1031     As a result, the value returned by QPainter::clipRegion() on
1032     a newly-constructed QPainter will not reflect the clip region that is
1033     used by the paint system.
1034
1035     \sa QPainter, QWidget::update(), QWidget::repaint(),
1036         QWidget::paintEvent()
1037 */
1038
1039 /*!
1040     Constructs a paint event object with the region that needs to
1041     be updated. The region is specified by \a paintRegion.
1042 */
1043 QPaintEvent::QPaintEvent(const QRegion& paintRegion)
1044     : QEvent(Paint), m_rect(paintRegion.boundingRect()), m_region(paintRegion), m_erased(false)
1045 {}
1046
1047 /*!
1048     Constructs a paint event object with the rectangle that needs
1049     to be updated. The region is specified by \a paintRect.
1050 */
1051 QPaintEvent::QPaintEvent(const QRect &paintRect)
1052     : QEvent(Paint), m_rect(paintRect),m_region(paintRect), m_erased(false)
1053 {}
1054
1055
1056 /*!
1057   \internal
1058 */
1059 QPaintEvent::~QPaintEvent()
1060 {
1061 }
1062
1063 /*!
1064     \fn const QRect &QPaintEvent::rect() const
1065
1066     Returns the rectangle that needs to be updated.
1067
1068     \sa region(), QPainter::setClipRect()
1069 */
1070
1071 /*!
1072     \fn const QRegion &QPaintEvent::region() const
1073
1074     Returns the region that needs to be updated.
1075
1076     \sa rect(), QPainter::setClipRegion()
1077 */
1078
1079
1080 /*!
1081     \class QMoveEvent
1082     \brief The QMoveEvent class contains event parameters for move events.
1083     \inmodule QtGui
1084
1085     \ingroup events
1086
1087     Move events are sent to widgets that have been moved to a new
1088     position relative to their parent.
1089
1090     The event handler QWidget::moveEvent() receives move events.
1091
1092     \sa QWidget::move(), QWidget::setGeometry()
1093 */
1094
1095 /*!
1096     Constructs a move event with the new and old widget positions,
1097     \a pos and \a oldPos respectively.
1098 */
1099 QMoveEvent::QMoveEvent(const QPoint &pos, const QPoint &oldPos)
1100     : QEvent(Move), p(pos), oldp(oldPos)
1101 {}
1102
1103 /*!
1104   \internal
1105 */
1106 QMoveEvent::~QMoveEvent()
1107 {
1108 }
1109
1110 /*!
1111     \fn const QPoint &QMoveEvent::pos() const
1112
1113     Returns the new position of the widget. This excludes the window
1114     frame for top level widgets.
1115 */
1116
1117 /*!
1118     \fn const QPoint &QMoveEvent::oldPos() const
1119
1120     Returns the old position of the widget.
1121 */
1122
1123 /*!
1124     \class QExposeEvent
1125     \since 5.0
1126     \brief The QExposeEvent class contains event parameters for expose events.
1127     \inmodule QtGui
1128
1129     \ingroup events
1130
1131     Expose events are sent to windows when an area of the window is invalidated
1132     or window visibility in the windowing system changes.
1133
1134     The event handler QWindow::exposeEvent() receives expose events.
1135 */
1136 QExposeEvent::QExposeEvent(const QRegion &exposeRegion)
1137     : QEvent(Expose)
1138     , rgn(exposeRegion)
1139 {
1140 }
1141
1142 /*!
1143   \internal
1144 */
1145 QExposeEvent::~QExposeEvent()
1146 {
1147 }
1148
1149 /*!
1150     \class QResizeEvent
1151     \brief The QResizeEvent class contains event parameters for resize events.
1152     \inmodule QtGui
1153
1154     \ingroup events
1155
1156     Resize events are sent to widgets that have been resized.
1157
1158     The event handler QWidget::resizeEvent() receives resize events.
1159
1160     \sa QWidget::resize(), QWidget::setGeometry()
1161 */
1162
1163 /*!
1164     Constructs a resize event with the new and old widget sizes, \a
1165     size and \a oldSize respectively.
1166 */
1167 QResizeEvent::QResizeEvent(const QSize &size, const QSize &oldSize)
1168     : QEvent(Resize), s(size), olds(oldSize)
1169 {}
1170
1171 /*!
1172   \internal
1173 */
1174 QResizeEvent::~QResizeEvent()
1175 {
1176 }
1177
1178 /*!
1179     \fn const QSize &QResizeEvent::size() const
1180
1181     Returns the new size of the widget. This is the same as
1182     QWidget::size().
1183 */
1184
1185 /*!
1186     \fn const QSize &QResizeEvent::oldSize() const
1187
1188     Returns the old size of the widget.
1189 */
1190
1191
1192 /*!
1193     \class QCloseEvent
1194     \brief The QCloseEvent class contains parameters that describe a close event.
1195
1196     \ingroup events
1197     \inmodule QtGui
1198
1199     Close events are sent to widgets that the user wants to close,
1200     usually by choosing "Close" from the window menu, or by clicking
1201     the \uicontrol{X} title bar button. They are also sent when you call
1202     QWidget::close() to close a widget programmatically.
1203
1204     Close events contain a flag that indicates whether the receiver
1205     wants the widget to be closed or not. When a widget accepts the
1206     close event, it is hidden (and destroyed if it was created with
1207     the Qt::WA_DeleteOnClose flag). If it refuses to accept the close
1208     event nothing happens. (Under X11 it is possible that the window
1209     manager will forcibly close the window; but at the time of writing
1210     we are not aware of any window manager that does this.)
1211
1212     The event handler QWidget::closeEvent() receives close events. The
1213     default implementation of this event handler accepts the close
1214     event. If you do not want your widget to be hidden, or want some
1215     special handing, you should reimplement the event handler and
1216     ignore() the event.
1217
1218     The \l{mainwindows/application#close event handler}{closeEvent() in the
1219     Application example} shows a close event handler that
1220     asks whether to save a document before closing.
1221
1222     If you want the widget to be deleted when it is closed, create it
1223     with the Qt::WA_DeleteOnClose flag. This is very useful for
1224     independent top-level windows in a multi-window application.
1225
1226     \l{QObject}s emits the \l{QObject::destroyed()}{destroyed()}
1227     signal when they are deleted.
1228
1229     If the last top-level window is closed, the
1230     QApplication::lastWindowClosed() signal is emitted.
1231
1232     The isAccepted() function returns true if the event's receiver has
1233     agreed to close the widget; call accept() to agree to close the
1234     widget and call ignore() if the receiver of this event does not
1235     want the widget to be closed.
1236
1237     \sa QWidget::close(), QWidget::hide(), QObject::destroyed(),
1238         QCoreApplication::exec(), QCoreApplication::quit(),
1239         QApplication::lastWindowClosed()
1240 */
1241
1242 /*!
1243     Constructs a close event object.
1244
1245     \sa accept()
1246 */
1247 QCloseEvent::QCloseEvent()
1248     : QEvent(Close)
1249 {}
1250
1251 /*! \internal
1252 */
1253 QCloseEvent::~QCloseEvent()
1254 {
1255 }
1256
1257 /*!
1258    \class QIconDragEvent
1259    \brief The QIconDragEvent class indicates that a main icon drag has begun.
1260     \inmodule QtGui
1261
1262    \ingroup events
1263
1264    Icon drag events are sent to widgets when the main icon of a window
1265    has been dragged away. On Mac OS X, this happens when the proxy
1266    icon of a window is dragged off the title bar.
1267
1268    It is normal to begin using drag and drop in response to this
1269    event.
1270
1271    \sa {Drag and Drop}, QMimeData, QDrag
1272 */
1273
1274 /*!
1275     Constructs an icon drag event object with the accept flag set to
1276     false.
1277
1278     \sa accept()
1279 */
1280 QIconDragEvent::QIconDragEvent()
1281     : QEvent(IconDrag)
1282 { ignore(); }
1283
1284 /*! \internal */
1285 QIconDragEvent::~QIconDragEvent()
1286 {
1287 }
1288
1289 /*!
1290     \class QContextMenuEvent
1291     \brief The QContextMenuEvent class contains parameters that describe a context menu event.
1292     \inmodule QtGui
1293
1294     \ingroup events
1295
1296     Context menu events are sent to widgets when a user performs
1297     an action associated with opening a context menu.
1298     The actions required to open context menus vary between platforms;
1299     for example, on Windows, pressing the menu button or clicking the
1300     right mouse button will cause this event to be sent.
1301
1302     When this event occurs it is customary to show a QMenu with a
1303     context menu, if this is relevant to the context.
1304
1305     Context menu events contain a special accept flag that indicates
1306     whether the receiver accepted the event. If the event handler does
1307     not accept the event then, if possible, whatever triggered the event will be
1308     handled as a regular input event.
1309 */
1310
1311 #ifndef QT_NO_CONTEXTMENU
1312 /*!
1313     Constructs a context menu event object with the accept parameter
1314     flag set to false.
1315
1316     The \a reason parameter must be QContextMenuEvent::Mouse or
1317     QContextMenuEvent::Keyboard.
1318
1319     The \a pos parameter specifies the mouse position relative to the
1320     receiving widget. \a globalPos is the mouse position in absolute
1321     coordinates.
1322 */
1323 QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos)
1324     : QInputEvent(ContextMenu), p(pos), gp(globalPos), reas(reason)
1325 {}
1326
1327 /*!
1328     Constructs a context menu event object with the accept parameter
1329     flag set to false.
1330
1331     The \a reason parameter must be QContextMenuEvent::Mouse or
1332     QContextMenuEvent::Keyboard.
1333
1334     The \a pos parameter specifies the mouse position relative to the
1335     receiving widget. \a globalPos is the mouse position in absolute
1336     coordinates. The \a modifiers holds the keyboard modifiers.
1337 */
1338 QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos,
1339                                      Qt::KeyboardModifiers modifiers)
1340     : QInputEvent(ContextMenu, modifiers), p(pos), gp(globalPos), reas(reason)
1341 {}
1342
1343
1344 /*! \internal */
1345 QContextMenuEvent::~QContextMenuEvent()
1346 {
1347 }
1348 /*!
1349     Constructs a context menu event object with the accept parameter
1350     flag set to false.
1351
1352     The \a reason parameter must be QContextMenuEvent::Mouse or
1353     QContextMenuEvent::Keyboard.
1354
1355     The \a pos parameter specifies the mouse position relative to the
1356     receiving widget.
1357
1358     The globalPos() is initialized to QCursor::pos(), which may not be
1359     appropriate. Use the other constructor to specify the global
1360     position explicitly.
1361 */
1362 QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos)
1363     : QInputEvent(ContextMenu), p(pos), reas(reason)
1364 {
1365     gp = QCursor::pos();
1366 }
1367
1368 /*!
1369     \fn const QPoint &QContextMenuEvent::pos() const
1370
1371     Returns the position of the mouse pointer relative to the widget
1372     that received the event.
1373
1374     \sa x(), y(), globalPos()
1375 */
1376
1377 /*!
1378     \fn int QContextMenuEvent::x() const
1379
1380     Returns the x position of the mouse pointer, relative to the
1381     widget that received the event.
1382
1383     \sa y(), pos()
1384 */
1385
1386 /*!
1387     \fn int QContextMenuEvent::y() const
1388
1389     Returns the y position of the mouse pointer, relative to the
1390     widget that received the event.
1391
1392     \sa x(), pos()
1393 */
1394
1395 /*!
1396     \fn const QPoint &QContextMenuEvent::globalPos() const
1397
1398     Returns the global position of the mouse pointer at the time of
1399     the event.
1400
1401     \sa x(), y(), pos()
1402 */
1403
1404 /*!
1405     \fn int QContextMenuEvent::globalX() const
1406
1407     Returns the global x position of the mouse pointer at the time of
1408     the event.
1409
1410     \sa globalY(), globalPos()
1411 */
1412
1413 /*!
1414     \fn int QContextMenuEvent::globalY() const
1415
1416     Returns the global y position of the mouse pointer at the time of
1417     the event.
1418
1419     \sa globalX(), globalPos()
1420 */
1421 #endif // QT_NO_CONTEXTMENU
1422
1423 /*!
1424     \enum QContextMenuEvent::Reason
1425
1426     This enum describes the reason why the event was sent.
1427
1428     \value Mouse The mouse caused the event to be sent. Normally this
1429     means the right mouse button was clicked, but this is platform
1430     dependent.
1431
1432     \value Keyboard The keyboard caused this event to be sent. On
1433     Windows, this means the menu button was pressed.
1434
1435     \value Other The event was sent by some other means (i.e. not by
1436     the mouse or keyboard).
1437 */
1438
1439
1440 /*!
1441     \fn QContextMenuEvent::Reason QContextMenuEvent::reason() const
1442
1443     Returns the reason for this context event.
1444 */
1445
1446
1447 /*!
1448     \class QInputMethodEvent
1449     \brief The QInputMethodEvent class provides parameters for input method events.
1450     \inmodule QtGui
1451
1452     \ingroup events
1453
1454     Input method events are sent to widgets when an input method is
1455     used to enter text into a widget. Input methods are widely used
1456     to enter text for languages with non-Latin alphabets.
1457
1458     Note that when creating custom text editing widgets, the
1459     Qt::WA_InputMethodEnabled window attribute must be set explicitly
1460     (using the QWidget::setAttribute() function) in order to receive
1461     input method events.
1462
1463     The events are of interest to authors of keyboard entry widgets
1464     who want to be able to correctly handle languages with complex
1465     character input. Text input in such languages is usually a three
1466     step process:
1467
1468     \list 1
1469     \li \b{Starting to Compose}
1470
1471        When the user presses the first key on a keyboard, an input
1472        context is created. This input context will contain a string
1473        of the typed characters.
1474
1475     \li \b{Composing}
1476
1477        With every new key pressed, the input method will try to create a
1478        matching string for the text typed so far called preedit
1479        string. While the input context is active, the user can only move
1480        the cursor inside the string belonging to this input context.
1481
1482     \li \b{Completing}
1483
1484        At some point, the user will activate a user interface component
1485        (perhaps using a particular key) where they can choose from a
1486        number of strings matching the text they have typed so far. The
1487        user can either confirm their choice cancel the input; in either
1488        case the input context will be closed.
1489     \endlist
1490
1491     QInputMethodEvent models these three stages, and transfers the
1492     information needed to correctly render the intermediate result. A
1493     QInputMethodEvent has two main parameters: preeditString() and
1494     commitString(). The preeditString() parameter gives the currently
1495     active preedit string. The commitString() parameter gives a text
1496     that should get added to (or replace parts of) the text of the
1497     editor widget. It usually is a result of the input operations and
1498     has to be inserted to the widgets text directly before the preedit
1499     string.
1500
1501     If the commitString() should replace parts of the of the text in
1502     the editor, replacementLength() will contain the number of
1503     characters to be replaced. replacementStart() contains the position
1504     at which characters are to be replaced relative from the start of
1505     the preedit string.
1506
1507     A number of attributes control the visual appearance of the
1508     preedit string (the visual appearance of text outside the preedit
1509     string is controlled by the widget only). The AttributeType enum
1510     describes the different attributes that can be set.
1511
1512     A class implementing QWidget::inputMethodEvent() or
1513     QGraphicsItem::inputMethodEvent() should at least understand and
1514     honor the \l TextFormat and \l Cursor attributes.
1515
1516     Since input methods need to be able to query certain properties
1517     from the widget or graphics item, subclasses must also implement
1518     QWidget::inputMethodQuery() and QGraphicsItem::inputMethodQuery(),
1519     respectively.
1520
1521     When receiving an input method event, the text widget has to performs the
1522     following steps:
1523
1524     \list 1
1525     \li If the widget has selected text, the selected text should get
1526        removed.
1527
1528     \li Remove the text starting at replacementStart() with length
1529        replacementLength() and replace it by the commitString(). If
1530        replacementLength() is 0, replacementStart() gives the insertion
1531        position for the commitString().
1532
1533        When doing replacement the area of the preedit
1534        string is ignored, thus a replacement starting at -1 with a length
1535        of 2 will remove the last character before the preedit string and
1536        the first character afterwards, and insert the commit string
1537        directly before the preedit string.
1538
1539        If the widget implements undo/redo, this operation gets added to
1540        the undo stack.
1541
1542     \li If there is no current preedit string, insert the
1543        preeditString() at the current cursor position; otherwise replace
1544        the previous preeditString with the one received from this event.
1545
1546        If the widget implements undo/redo, the preeditString() should not
1547        influence the undo/redo stack in any way.
1548
1549        The widget should examine the list of attributes to apply to the
1550        preedit string. It has to understand at least the TextFormat and
1551        Cursor attributes and render them as specified.
1552     \endlist
1553
1554     \sa QInputMethod
1555 */
1556
1557 /*!
1558     \enum QInputMethodEvent::AttributeType
1559
1560     \value TextFormat
1561     A QTextCharFormat for the part of the preedit string specified by
1562     start and length. value contains a QVariant of type QTextFormat
1563     specifying rendering of this part of the preedit string. There
1564     should be at most one format for every part of the preedit
1565     string. If several are specified for any character in the string the
1566     behaviour is undefined. A conforming implementation has to at least
1567     honor the backgroundColor, textColor and fontUnderline properties
1568     of the format.
1569
1570     \value Cursor If set, a cursor should be shown inside the preedit
1571     string at position start. The length variable determines whether
1572     the cursor is visible or not. If the length is 0 the cursor is
1573     invisible. If value is a QVariant of type QColor this color will
1574     be used for rendering the cursor, otherwise the color of the
1575     surrounding text will be used. There should be at most one Cursor
1576     attribute per event. If several are specified the behaviour is
1577     undefined.
1578
1579     \value Language
1580     The variant contains a QLocale object specifying the language of a
1581     certain part of the preedit string. There should be at most one
1582     language set for every part of the preedit string. If several are
1583     specified for any character in the string the behavior is undefined.
1584
1585     \value Ruby
1586     The ruby text for a part of the preedit string. There should be at
1587     most one ruby text set for every part of the preedit string. If
1588     several are specified for any character in the string the behaviour
1589     is undefined.
1590
1591     \value Selection
1592     If set, the edit cursor should be moved to the specified position
1593     in the editor text contents. In contrast with \c Cursor, this
1594     attribute does not work on the preedit text, but on the surrounding
1595     text. The cursor will be moved after the commit string has been
1596     committed, and the preedit string will be located at the new edit
1597     position.
1598     The start position specifies the new position and the length
1599     variable can be used to set a selection starting from that point.
1600     The value is unused.
1601
1602     \sa Attribute
1603 */
1604
1605 /*!
1606     \class QInputMethodEvent::Attribute
1607     \brief The QInputMethodEvent::Attribute class stores an input method attribute.
1608 */
1609
1610 /*!
1611     \fn QInputMethodEvent::Attribute::Attribute(AttributeType type, int start, int length, QVariant value)
1612
1613     Constructs an input method attribute. \a type specifies the type
1614     of attribute, \a start and \a length the position of the
1615     attribute, and \a value the value of the attribute.
1616 */
1617
1618 /*!
1619     Constructs an event of type QEvent::InputMethod. The
1620     attributes(), preeditString(), commitString(), replacementStart(),
1621     and replacementLength() are initialized to default values.
1622
1623     \sa setCommitString()
1624 */
1625 QInputMethodEvent::QInputMethodEvent()
1626     : QEvent(QEvent::InputMethod), replace_from(0), replace_length(0)
1627 {
1628 }
1629
1630 /*!
1631     Construcs an event of type QEvent::InputMethod. The
1632     preedit text is set to \a preeditText, the attributes to
1633     \a attributes.
1634
1635     The commitString(), replacementStart(), and replacementLength()
1636     values can be set using setCommitString().
1637
1638     \sa preeditString(), attributes()
1639 */
1640 QInputMethodEvent::QInputMethodEvent(const QString &preeditText, const QList<Attribute> &attributes)
1641     : QEvent(QEvent::InputMethod), preedit(preeditText), attrs(attributes),
1642       replace_from(0), replace_length(0)
1643 {
1644 }
1645
1646 /*!
1647     Constructs a copy of \a other.
1648 */
1649 QInputMethodEvent::QInputMethodEvent(const QInputMethodEvent &other)
1650     : QEvent(QEvent::InputMethod), preedit(other.preedit), attrs(other.attrs),
1651       commit(other.commit), replace_from(other.replace_from), replace_length(other.replace_length)
1652 {
1653 }
1654
1655 /*!
1656     Sets the commit string to \a commitString.
1657
1658     The commit string is the text that should get added to (or
1659     replace parts of) the text of the editor widget. It usually is a
1660     result of the input operations and has to be inserted to the
1661     widgets text directly before the preedit string.
1662
1663     If the commit string should replace parts of the of the text in
1664     the editor, \a replaceLength specifies the number of
1665     characters to be replaced. \a replaceFrom specifies the position
1666     at which characters are to be replaced relative from the start of
1667     the preedit string.
1668
1669     \sa commitString(), replacementStart(), replacementLength()
1670 */
1671 void QInputMethodEvent::setCommitString(const QString &commitString, int replaceFrom, int replaceLength)
1672 {
1673     commit = commitString;
1674     replace_from = replaceFrom;
1675     replace_length = replaceLength;
1676 }
1677
1678 /*!
1679     \fn const QList<Attribute> &QInputMethodEvent::attributes() const
1680
1681     Returns the list of attributes passed to the QInputMethodEvent
1682     constructor. The attributes control the visual appearance of the
1683     preedit string (the visual appearance of text outside the preedit
1684     string is controlled by the widget only).
1685
1686     \sa preeditString(), Attribute
1687 */
1688
1689 /*!
1690     \fn const QString &QInputMethodEvent::preeditString() const
1691
1692     Returns the preedit text, i.e. the text before the user started
1693     editing it.
1694
1695     \sa commitString(), attributes()
1696 */
1697
1698 /*!
1699     \fn const QString &QInputMethodEvent::commitString() const
1700
1701     Returns the text that should get added to (or replace parts of)
1702     the text of the editor widget. It usually is a result of the
1703     input operations and has to be inserted to the widgets text
1704     directly before the preedit string.
1705
1706     \sa setCommitString(), preeditString(), replacementStart(), replacementLength()
1707 */
1708
1709 /*!
1710     \fn int QInputMethodEvent::replacementStart() const
1711
1712     Returns the position at which characters are to be replaced relative
1713     from the start of the preedit string.
1714
1715     \sa replacementLength(), setCommitString()
1716 */
1717
1718 /*!
1719     \fn int QInputMethodEvent::replacementLength() const
1720
1721     Returns the number of characters to be replaced in the preedit
1722     string.
1723
1724     \sa replacementStart(), setCommitString()
1725 */
1726
1727 /*!
1728     \class QInputMethodQueryEvent
1729     \since 5.0
1730     \inmodule QtGui
1731
1732     \brief This event is sent by the input context to input objects.
1733
1734     It is used by the
1735     input method to query a set of properties of the object to be
1736     able to support complex input method operations as support for
1737     surrounding text and reconversions.
1738
1739     queries() specifies which properties are queried.
1740
1741     The object should call setValue() on the event to fill in the requested
1742     data before calling accept().
1743 */
1744
1745 /*!
1746     \fn Qt::InputMethodQueries QInputMethodQueryEvent::queries() const
1747
1748     Returns the properties queried by the event.
1749  */
1750
1751 /*!
1752     Constructs a query event for properties given by \a queries.
1753  */
1754 QInputMethodQueryEvent::QInputMethodQueryEvent(Qt::InputMethodQueries queries)
1755     : QEvent(InputMethodQuery),
1756       m_queries(queries)
1757 {
1758 }
1759
1760 /*!
1761     \internal
1762  */
1763 QInputMethodQueryEvent::~QInputMethodQueryEvent()
1764 {
1765 }
1766
1767 /*!
1768     Sets query property to given value.
1769  */
1770 void QInputMethodQueryEvent::setValue(Qt::InputMethodQuery query, const QVariant &value)
1771 {
1772     for (int i = 0; i < m_values.size(); ++i) {
1773         if (m_values.at(i).query == query) {
1774             m_values[i].value = value;
1775             return;
1776         }
1777     }
1778     QueryPair pair = { query, value };
1779     m_values.append(pair);
1780 }
1781
1782 /*!
1783     Returns value of a query property.
1784  */
1785 QVariant QInputMethodQueryEvent::value(Qt::InputMethodQuery query) const
1786 {
1787     for (int i = 0; i < m_values.size(); ++i)
1788         if (m_values.at(i).query == query)
1789             return m_values.at(i).value;
1790     return QVariant();
1791 }
1792
1793 #ifndef QT_NO_TABLETEVENT
1794
1795 /*!
1796     \class QTabletEvent
1797     \brief The QTabletEvent class contains parameters that describe a Tablet event.
1798     \inmodule QtGui
1799
1800     \ingroup events
1801
1802     Tablet Events are generated from a Wacom tablet. Most of the time you will
1803     want to deal with events from the tablet as if they were events from a
1804     mouse; for example, you would retrieve the cursor position with x(), y(),
1805     pos(), globalX(), globalY(), and globalPos(). In some situations you may
1806     wish to retrieve the extra information provided by the tablet device
1807     driver; for example, you might want to do subpixeling with higher
1808     resolution coordinates or you may want to adjust color brightness based on
1809     pressure.  QTabletEvent allows you to read the pressure(), the xTilt(), and
1810     yTilt(), as well as the type of device being used with device() (see
1811     \l{TabletDevice}). It can also give you the minimum and maximum values for
1812     each device's pressure and high resolution coordinates.
1813
1814     A tablet event contains a special accept flag that indicates whether the
1815     receiver wants the event. You should call QTabletEvent::accept() if you
1816     handle the tablet event; otherwise it will be sent to the parent widget.
1817     The exception are TabletEnterProximity and TabletLeaveProximity events,
1818     these are only sent to QApplication and don't check whether or not they are
1819     accepted.
1820
1821     The QWidget::setEnabled() function can be used to enable or
1822     disable mouse and keyboard events for a widget.
1823
1824     The event handler QWidget::tabletEvent() receives all three types of
1825     tablet events. Qt will first send a tabletEvent then, if it is not
1826     accepted, it will send a mouse event. This allows applications that
1827     don't utilize tablets to use a tablet like a mouse, while also
1828     enabling those who want to use both tablets and mouses differently.
1829
1830     \section1 Notes for X11 Users
1831
1832     Qt uses the following hard-coded names to identify tablet
1833     devices from the xorg.conf file on X11 (apart from IRIX):
1834     'stylus', 'pen', and 'eraser'. If the devices have other names,
1835     they will not be picked up Qt.
1836 */
1837
1838 /*!
1839     \enum QTabletEvent::TabletDevice
1840
1841     This enum defines what type of device is generating the event.
1842
1843     \value NoDevice    No device, or an unknown device.
1844     \value Puck    A Puck (a device that is similar to a flat mouse with
1845     a transparent circle with cross-hairs).
1846     \value Stylus  A Stylus.
1847     \value Airbrush An airbrush
1848     \value FourDMouse A 4D Mouse.
1849     \value RotationStylus A special stylus that also knows about rotation
1850            (a 6D stylus). \since 4.1
1851     \omitvalue XFreeEraser
1852 */
1853
1854 /*!
1855     \enum QTabletEvent::PointerType
1856
1857     This enum defines what type of point is generating the event.
1858
1859     \value UnknownPointer    An unknown device.
1860     \value Pen    Tip end of a stylus-like device (the narrow end of the pen).
1861     \value Cursor  Any puck-like device.
1862     \value Eraser  Eraser end of a stylus-like device (the broad end of the pen).
1863
1864     \sa pointerType()
1865 */
1866
1867 /*!
1868   Construct a tablet event of the given \a type.
1869
1870   The \a pos parameter indicates where the event occurred in the
1871   widget; \a globalPos is the corresponding position in absolute
1872   coordinates. The \a hiResGlobalPos contains a high resolution
1873   measurement of the position.
1874
1875   \a pressure contains the pressure exerted on the \a device.
1876
1877   \a pointerType describes the type of pen that is being used.
1878
1879   \a xTilt and \a yTilt contain the device's degree of tilt from the
1880   x and y axes respectively.
1881
1882   \a keyState specifies which keyboard modifiers are pressed (e.g.,
1883   \uicontrol{Ctrl}).
1884
1885   The \a uniqueID parameter contains the unique ID for the current device.
1886
1887   The \a z parameter contains the coordinate of the device on the tablet, this
1888   is usually given by a wheel on 4D mouse. If the device does not support a
1889   Z-axis, pass zero here.
1890
1891   The \a tangentialPressure parameter contins the tangential pressure of an air
1892   brush. If the device does not support tangential pressure, pass 0 here.
1893
1894   \a rotation contains the device's rotation in degrees. 4D mice support
1895   rotation. If the device does not support rotation, pass 0 here.
1896
1897   \sa pos(), globalPos(), device(), pressure(), xTilt(), yTilt(), uniqueId(), rotation(),
1898       tangentialPressure(), z()
1899 */
1900
1901 QTabletEvent::QTabletEvent(Type type, const QPointF &pos, const QPointF &globalPos,
1902                            int device, int pointerType,
1903                            qreal pressure, int xTilt, int yTilt, qreal tangentialPressure,
1904                            qreal rotation, int z, Qt::KeyboardModifiers keyState, qint64 uniqueID)
1905     : QInputEvent(type, keyState),
1906       mPos(pos),
1907       mGPos(globalPos),
1908       mDev(device),
1909       mPointerType(pointerType),
1910       mXT(xTilt),
1911       mYT(yTilt),
1912       mZ(z),
1913       mPress(pressure),
1914       mTangential(tangentialPressure),
1915       mRot(rotation),
1916       mUnique(uniqueID),
1917       mExtra(0)
1918 {
1919 }
1920
1921 /*!
1922     \internal
1923 */
1924 QTabletEvent::~QTabletEvent()
1925 {
1926 }
1927
1928 /*!
1929     \fn TabletDevices QTabletEvent::device() const
1930
1931     Returns the type of device that generated the event.
1932
1933     \sa TabletDevice
1934 */
1935
1936 /*!
1937     \fn PointerType QTabletEvent::pointerType() const
1938
1939     Returns the type of point that generated the event.
1940 */
1941
1942 /*!
1943     \fn qreal QTabletEvent::tangentialPressure() const
1944
1945     Returns the tangential pressure for the device.  This is typically given by a finger
1946     wheel on an airbrush tool.  The range is from -1.0 to 1.0. 0.0 indicates a
1947     neutral position.  Current airbrushes can only move in the positive
1948     direction from the neutrual position. If the device does not support
1949     tangential pressure, this value is always 0.0.
1950
1951     \sa pressure()
1952 */
1953
1954 /*!
1955     \fn qreal QTabletEvent::rotation() const
1956
1957     Returns the rotation of the current device in degress. This is usually
1958     given by a 4D Mouse. If the device doesn't support rotation this value is
1959     always 0.0.
1960
1961 */
1962
1963 /*!
1964     \fn qreal QTabletEvent::pressure() const
1965
1966     Returns the pressure for the device. 0.0 indicates that the stylus is not
1967     on the tablet, 1.0 indicates the maximum amount of pressure for the stylus.
1968
1969     \sa tangentialPressure()
1970 */
1971
1972 /*!
1973     \fn int QTabletEvent::xTilt() const
1974
1975     Returns the angle between the device (a pen, for example) and the
1976     perpendicular in the direction of the x axis.
1977     Positive values are towards the tablet's physical right. The angle
1978     is in the range -60 to +60 degrees.
1979
1980     \image qtabletevent-tilt.png
1981
1982     \sa yTilt()
1983 */
1984
1985 /*!
1986     \fn int QTabletEvent::yTilt() const
1987
1988     Returns the angle between the device (a pen, for example) and the
1989     perpendicular in the direction of the y axis.
1990     Positive values are towards the bottom of the tablet. The angle is
1991     within the range -60 to +60 degrees.
1992
1993     \sa xTilt()
1994 */
1995
1996 /*!
1997     \fn const QPoint &QTabletEvent::pos() const
1998
1999     Returns the position of the device, relative to the widget that
2000     received the event.
2001
2002     If you move widgets around in response to mouse events, use
2003     globalPos() instead of this function.
2004
2005     \sa x(), y(), globalPos()
2006 */
2007
2008 /*!
2009     \fn int QTabletEvent::x() const
2010
2011     Returns the x position of the device, relative to the widget that
2012     received the event.
2013
2014     \sa y(), pos()
2015 */
2016
2017 /*!
2018     \fn int QTabletEvent::y() const
2019
2020     Returns the y position of the device, relative to the widget that
2021     received the event.
2022
2023     \sa x(), pos()
2024 */
2025
2026 /*!
2027     \fn int QTabletEvent::z() const
2028
2029     Returns the z position of the device. Typically this is represented by a
2030     wheel on a 4D Mouse. If the device does not support a Z-axis, this value is
2031     always zero. This is \b not the same as pressure.
2032
2033     \sa pressure()
2034 */
2035
2036 /*!
2037     \fn const QPoint &QTabletEvent::globalPos() const
2038
2039     Returns the global position of the device \e{at the time of the
2040     event}. This is important on asynchronous windows systems like X11;
2041     whenever you move your widgets around in response to mouse events,
2042     globalPos() can differ significantly from the current position
2043     QCursor::pos().
2044
2045     \sa globalX(), globalY(), hiResGlobalPos()
2046 */
2047
2048 /*!
2049     \fn int QTabletEvent::globalX() const
2050
2051     Returns the global x position of the mouse pointer at the time of
2052     the event.
2053
2054     \sa globalY(), globalPos(), hiResGlobalX()
2055 */
2056
2057 /*!
2058     \fn int QTabletEvent::globalY() const
2059
2060     Returns the global y position of the tablet device at the time of
2061     the event.
2062
2063     \sa globalX(), globalPos(), hiResGlobalY()
2064 */
2065
2066 /*!
2067     \fn qint64 QTabletEvent::uniqueId() const
2068
2069     Returns a unique ID for the current device, making it possible
2070     to differentiate between multiple devices being used at the same
2071     time on the tablet.
2072
2073     Support of this feature is dependent on the tablet.
2074
2075     Values for the same device may vary from OS to OS.
2076
2077     Later versions of the Wacom driver for Linux will now report
2078     the ID information. If you have a tablet that supports unique ID
2079     and are not getting the information on Linux, consider upgrading
2080     your driver.
2081
2082     As of Qt 4.2, the unique ID is the same regardless of the orientation
2083     of the pen. Earlier versions would report a different value when using
2084     the eraser-end versus the pen-end of the stylus on some OS's.
2085
2086     \sa pointerType()
2087 */
2088
2089 /*!
2090     \fn const QPointF &QTabletEvent::hiResGlobalPos() const
2091
2092     The high precision coordinates delivered from the tablet expressed.
2093     Sub pixeling information is in the fractional part of the QPointF.
2094
2095     \sa globalPos(), hiResGlobalX(), hiResGlobalY()
2096 */
2097
2098 /*!
2099     \fn qreal &QTabletEvent::hiResGlobalX() const
2100
2101     The high precision x position of the tablet device.
2102 */
2103
2104 /*!
2105     \fn qreal &QTabletEvent::hiResGlobalY() const
2106
2107     The high precision y position of the tablet device.
2108 */
2109
2110 #endif // QT_NO_TABLETEVENT
2111
2112 #ifndef QT_NO_DRAGANDDROP
2113 /*!
2114     Creates a QDragMoveEvent of the required \a type indicating
2115     that the mouse is at position \a pos given within a widget.
2116
2117     The mouse and keyboard states are specified by \a buttons and
2118     \a modifiers, and the \a actions describe the types of drag
2119     and drop operation that are possible.
2120     The drag data is passed as MIME-encoded information in \a data.
2121
2122     \warning Do not attempt to create a QDragMoveEvent yourself.
2123     These objects rely on Qt's internal state.
2124 */
2125 QDragMoveEvent::QDragMoveEvent(const QPoint& pos, Qt::DropActions actions, const QMimeData *data,
2126                                Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type)
2127     : QDropEvent(pos, actions, data, buttons, modifiers, type)
2128     , rect(pos, QSize(1, 1))
2129 {}
2130
2131 /*!
2132     Destroys the event.
2133 */
2134 QDragMoveEvent::~QDragMoveEvent()
2135 {
2136 }
2137
2138 /*!
2139     \fn void QDragMoveEvent::accept(const QRect &rectangle)
2140
2141     The same as accept(), but also notifies that future moves will
2142     also be acceptable if they remain within the \a rectangle
2143     given on the widget. This can improve performance, but may
2144     also be ignored by the underlying system.
2145
2146     If the rectangle is empty, drag move events will be sent
2147     continuously. This is useful if the source is scrolling in a
2148     timer event.
2149 */
2150
2151 /*!
2152     \fn void QDragMoveEvent::accept()
2153
2154     \overload
2155
2156     Calls QDropEvent::accept().
2157 */
2158
2159 /*!
2160     \fn void QDragMoveEvent::ignore()
2161
2162     \overload
2163
2164     Calls QDropEvent::ignore().
2165 */
2166
2167 /*!
2168     \fn void QDragMoveEvent::ignore(const QRect &rectangle)
2169
2170     The opposite of the accept(const QRect&) function.
2171     Moves within the \a rectangle are not acceptable, and will be
2172     ignored.
2173 */
2174
2175 /*!
2176     \fn QRect QDragMoveEvent::answerRect() const
2177
2178     Returns the rectangle in the widget where the drop will occur if accepted.
2179     You can use this information to restrict drops to certain places on the
2180     widget.
2181 */
2182
2183
2184 /*!
2185     \class QDropEvent
2186     \ingroup events
2187     \ingroup draganddrop
2188     \inmodule QtGui
2189
2190     \brief The QDropEvent class provides an event which is sent when a
2191     drag and drop action is completed.
2192
2193     When a widget \l{QWidget::setAcceptDrops()}{accepts drop events}, it will
2194     receive this event if it has accepted the most recent QDragEnterEvent or
2195     QDragMoveEvent sent to it.
2196
2197     The drop event contains a proposed action, available from proposedAction(), for
2198     the widget to either accept or ignore. If the action can be handled by the
2199     widget, you should call the acceptProposedAction() function. Since the
2200     proposed action can be a combination of \l Qt::DropAction values, it may be
2201     useful to either select one of these values as a default action or ask
2202     the user to select their preferred action.
2203
2204     If the proposed drop action is not suitable, perhaps because your custom
2205     widget does not support that action, you can replace it with any of the
2206     \l{possibleActions()}{possible drop actions} by calling setDropAction()
2207     with your preferred action. If you set a value that is not present in the
2208     bitwise OR combination of values returned by possibleActions(), the default
2209     copy action will be used. Once a replacement drop action has been set, call
2210     accept() instead of acceptProposedAction() to complete the drop operation.
2211
2212     The mimeData() function provides the data dropped on the widget in a QMimeData
2213     object. This contains information about the MIME type of the data in addition to
2214     the data itself.
2215
2216     \sa QMimeData, QDrag, {Drag and Drop}
2217 */
2218
2219 /*!
2220     \fn const QMimeData *QDropEvent::mimeData() const
2221
2222     Returns the data that was dropped on the widget and its associated MIME
2223     type information.
2224 */
2225
2226 /*!
2227     Constructs a drop event of a certain \a type corresponding to a
2228     drop at the point specified by \a pos in the destination widget's
2229     coordinate system.
2230
2231     The \a actions indicate which types of drag and drop operation can
2232     be performed, and the drag data is stored as MIME-encoded data in \a data.
2233
2234     The states of the mouse buttons and keyboard modifiers at the time of
2235     the drop are specified by \a buttons and \a modifiers.
2236 */ // ### pos is in which coordinate system?
2237 QDropEvent::QDropEvent(const QPointF& pos, Qt::DropActions actions, const QMimeData *data,
2238                        Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type)
2239     : QEvent(type), p(pos), mouseState(buttons),
2240       modState(modifiers), act(actions),
2241       mdata(data)
2242 {
2243     default_action = QGuiApplicationPrivate::platformIntegration()->drag()->defaultAction(act, modifiers);
2244     drop_action = default_action;
2245     ignore();
2246 }
2247
2248 /*! \internal */
2249 QDropEvent::~QDropEvent()
2250 {
2251 }
2252
2253
2254 /*!
2255     If the source of the drag operation is a widget in this
2256     application, this function returns that source; otherwise it
2257     returns 0. The source of the operation is the first parameter to
2258     the QDrag object used instantiate the drag.
2259
2260     This is useful if your widget needs special behavior when dragging
2261     to itself.
2262
2263     \sa QDrag::QDrag()
2264 */
2265 QObject* QDropEvent::source() const
2266 {
2267     if (const QDragManager *manager = QDragManager::self())
2268         return manager->source();
2269     return 0;
2270 }
2271
2272
2273 void QDropEvent::setDropAction(Qt::DropAction action)
2274 {
2275     if (!(action & act) && action != Qt::IgnoreAction)
2276         action = default_action;
2277     drop_action = action;
2278 }
2279
2280 /*!
2281     \fn const QPoint& QDropEvent::pos() const
2282
2283     Returns the position where the drop was made.
2284 */
2285
2286 /*!
2287     \fn Qt::MouseButtons QDropEvent::mouseButtons() const
2288
2289     Returns the mouse buttons that are pressed..
2290 */
2291
2292 /*!
2293     \fn Qt::KeyboardModifiers QDropEvent::keyboardModifiers() const
2294
2295     Returns the modifier keys that are pressed.
2296 */
2297
2298 /*!
2299     \fn void QDropEvent::setDropAction(Qt::DropAction action)
2300
2301     Sets the \a action to be performed on the data by the target.
2302     Use this to override the \l{proposedAction()}{proposed action}
2303     with one of the \l{possibleActions()}{possible actions}.
2304
2305     If you set a drop action that is not one of the possible actions, the
2306     drag and drop operation will default to a copy operation.
2307
2308     Once you have supplied a replacement drop action, call accept()
2309     instead of acceptProposedAction().
2310
2311     \sa dropAction()
2312 */
2313
2314 /*!
2315     \fn Qt::DropAction QDropEvent::dropAction() const
2316
2317     Returns the action to be performed on the data by the target. This may be
2318     different from the action supplied in proposedAction() if you have called
2319     setDropAction() to explicitly choose a drop action.
2320
2321     \sa setDropAction()
2322 */
2323
2324 /*!
2325     \fn Qt::DropActions QDropEvent::possibleActions() const
2326
2327     Returns an OR-combination of possible drop actions.
2328
2329     \sa dropAction()
2330 */
2331
2332 /*!
2333     \fn Qt::DropAction QDropEvent::proposedAction() const
2334
2335     Returns the proposed drop action.
2336
2337     \sa dropAction()
2338 */
2339
2340 /*!
2341     \fn void QDropEvent::acceptProposedAction()
2342
2343     Sets the drop action to be the proposed action.
2344
2345     \sa setDropAction(), proposedAction(), {QEvent::accept()}{accept()}
2346 */
2347
2348 /*!
2349     \class QDragEnterEvent
2350     \brief The QDragEnterEvent class provides an event which is sent
2351     to a widget when a drag and drop action enters it.
2352
2353     \ingroup events
2354     \ingroup draganddrop
2355     \inmodule QtGui
2356
2357     A widget must accept this event in order to receive the \l
2358     {QDragMoveEvent}{drag move events} that are sent while the drag
2359     and drop action is in progress. The drag enter event is always
2360     immediately followed by a drag move event.
2361
2362     QDragEnterEvent inherits most of its functionality from
2363     QDragMoveEvent, which in turn inherits most of its functionality
2364     from QDropEvent.
2365
2366     \sa QDragLeaveEvent, QDragMoveEvent, QDropEvent
2367 */
2368
2369 /*!
2370     Constructs a QDragEnterEvent that represents a drag entering a
2371     widget at the given \a point with mouse and keyboard states specified by
2372     \a buttons and \a modifiers.
2373
2374     The drag data is passed as MIME-encoded information in \a data, and the
2375     specified \a actions describe the possible types of drag and drop
2376     operation that can be performed.
2377
2378     \warning Do not create a QDragEnterEvent yourself since these
2379     objects rely on Qt's internal state.
2380 */
2381 QDragEnterEvent::QDragEnterEvent(const QPoint& point, Qt::DropActions actions, const QMimeData *data,
2382                                  Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
2383     : QDragMoveEvent(point, actions, data, buttons, modifiers, DragEnter)
2384 {}
2385
2386 /*! \internal
2387 */
2388 QDragEnterEvent::~QDragEnterEvent()
2389 {
2390 }
2391
2392 /*!
2393     \class QDragMoveEvent
2394     \brief The QDragMoveEvent class provides an event which is sent while a drag and drop action is in progress.
2395
2396     \ingroup events
2397     \ingroup draganddrop
2398     \inmodule QtGui
2399
2400     A widget will receive drag move events repeatedly while the drag
2401     is within its boundaries, if it accepts
2402     \l{QWidget::setAcceptDrops()}{drop events} and \l
2403     {QWidget::dragEnterEvent()}{enter events}. The widget should
2404     examine the event to see what kind of data it
2405     \l{QDragMoveEvent::provides()}{provides}, and call the accept()
2406     function to accept the drop if appropriate.
2407
2408     The rectangle supplied by the answerRect() function can be used to restrict
2409     drops to certain parts of the widget. For example, we can check whether the
2410     rectangle intersects with the geometry of a certain child widget and only
2411     call \l{QDropEvent::acceptProposedAction()}{acceptProposedAction()} if that
2412     is the case.
2413
2414     Note that this class inherits most of its functionality from
2415     QDropEvent.
2416
2417     \sa QDragEnterEvent, QDragLeaveEvent, QDropEvent
2418 */
2419
2420 /*!
2421     \class QDragLeaveEvent
2422     \brief The QDragLeaveEvent class provides an event that is sent to a widget when a drag and drop action leaves it.
2423
2424     \ingroup events
2425     \ingroup draganddrop
2426     \inmodule QtGui
2427
2428     This event is always preceded by a QDragEnterEvent and a series
2429     of \l{QDragMoveEvent}s. It is not sent if a QDropEvent is sent
2430     instead.
2431
2432     \sa QDragEnterEvent, QDragMoveEvent, QDropEvent
2433 */
2434
2435 /*!
2436     Constructs a QDragLeaveEvent.
2437
2438     \warning Do not create a QDragLeaveEvent yourself since these
2439     objects rely on Qt's internal state.
2440 */
2441 QDragLeaveEvent::QDragLeaveEvent()
2442     : QEvent(DragLeave)
2443 {}
2444
2445 /*! \internal
2446 */
2447 QDragLeaveEvent::~QDragLeaveEvent()
2448 {
2449 }
2450 #endif // QT_NO_DRAGANDDROP
2451
2452 /*!
2453     \class QHelpEvent
2454     \brief The QHelpEvent class provides an event that is used to request helpful information
2455     about a particular point in a widget.
2456
2457     \ingroup events
2458     \ingroup helpsystem
2459     \inmodule QtGui
2460
2461     This event can be intercepted in applications to provide tooltips
2462     or "What's This?" help for custom widgets. The type() can be
2463     either QEvent::ToolTip or QEvent::WhatsThis.
2464
2465     \sa QToolTip, QWhatsThis, QStatusTipEvent, QWhatsThisClickedEvent
2466 */
2467
2468 /*!
2469     Constructs a help event with the given \a type corresponding to the
2470     widget-relative position specified by \a pos and the global position
2471     specified by \a globalPos.
2472
2473     \a type must be either QEvent::ToolTip or QEvent::WhatsThis.
2474
2475     \sa pos(), globalPos()
2476 */
2477 QHelpEvent::QHelpEvent(Type type, const QPoint &pos, const QPoint &globalPos)
2478     : QEvent(type), p(pos), gp(globalPos)
2479 {}
2480
2481 /*!
2482     \fn int QHelpEvent::x() const
2483
2484     Same as pos().x().
2485
2486     \sa y(), pos(), globalPos()
2487 */
2488
2489 /*!
2490     \fn int QHelpEvent::y() const
2491
2492     Same as pos().y().
2493
2494     \sa x(), pos(), globalPos()
2495 */
2496
2497 /*!
2498     \fn int QHelpEvent::globalX() const
2499
2500     Same as globalPos().x().
2501
2502     \sa x(), globalY(), globalPos()
2503 */
2504
2505 /*!
2506     \fn int QHelpEvent::globalY() const
2507
2508     Same as globalPos().y().
2509
2510     \sa y(), globalX(), globalPos()
2511 */
2512
2513 /*!
2514     \fn const QPoint &QHelpEvent::pos()  const
2515
2516     Returns the mouse cursor position when the event was generated,
2517     relative to the widget to which the event is dispatched.
2518
2519     \sa globalPos(), x(), y()
2520 */
2521
2522 /*!
2523     \fn const QPoint &QHelpEvent::globalPos() const
2524
2525     Returns the mouse cursor position when the event was generated
2526     in global coordinates.
2527
2528     \sa pos(), globalX(), globalY()
2529 */
2530
2531 /*! \internal
2532 */
2533 QHelpEvent::~QHelpEvent()
2534 {
2535 }
2536
2537 #ifndef QT_NO_STATUSTIP
2538
2539 /*!
2540     \class QStatusTipEvent
2541     \brief The QStatusTipEvent class provides an event that is used to show messages in a status bar.
2542
2543     \ingroup events
2544     \ingroup helpsystem
2545     \inmodule QtGui
2546
2547     Status tips can be set on a widget using the
2548     QWidget::setStatusTip() function.  They are shown in the status
2549     bar when the mouse cursor enters the widget. For example:
2550
2551     \table 100%
2552     \row
2553     \li
2554     \snippet qstatustipevent/main.cpp 1
2555     \dots
2556     \snippet qstatustipevent/main.cpp 3
2557     \li
2558     \image qstatustipevent-widget.png Widget with status tip.
2559     \endtable
2560
2561     Status tips can also be set on actions using the
2562     QAction::setStatusTip() function:
2563
2564     \table 100%
2565     \row
2566     \li
2567     \snippet qstatustipevent/main.cpp 0
2568     \snippet qstatustipevent/main.cpp 2
2569     \dots
2570     \snippet qstatustipevent/main.cpp 3
2571     \li
2572     \image qstatustipevent-action.png Action with status tip.
2573     \endtable
2574
2575     Finally, status tips are supported for the item view classes
2576     through the Qt::StatusTipRole enum value.
2577
2578     \sa QStatusBar, QHelpEvent, QWhatsThisClickedEvent
2579 */
2580
2581 /*!
2582     Constructs a status tip event with the text specified by \a tip.
2583
2584     \sa tip()
2585 */
2586 QStatusTipEvent::QStatusTipEvent(const QString &tip)
2587     : QEvent(StatusTip), s(tip)
2588 {}
2589
2590 /*! \internal
2591 */
2592 QStatusTipEvent::~QStatusTipEvent()
2593 {
2594 }
2595
2596 /*!
2597     \fn QString QStatusTipEvent::tip() const
2598
2599     Returns the message to show in the status bar.
2600
2601     \sa QStatusBar::showMessage()
2602 */
2603
2604 #endif // QT_NO_STATUSTIP
2605
2606 #ifndef QT_NO_WHATSTHIS
2607
2608 /*!
2609     \class QWhatsThisClickedEvent
2610     \brief The QWhatsThisClickedEvent class provides an event that
2611     can be used to handle hyperlinks in a "What's This?" text.
2612
2613     \ingroup events
2614     \ingroup helpsystem
2615     \inmodule QtGui
2616
2617     \sa QWhatsThis, QHelpEvent, QStatusTipEvent
2618 */
2619
2620 /*!
2621     Constructs an event containing a URL specified by \a href when a link
2622     is clicked in a "What's This?" message.
2623
2624     \sa href()
2625 */
2626 QWhatsThisClickedEvent::QWhatsThisClickedEvent(const QString &href)
2627     : QEvent(WhatsThisClicked), s(href)
2628 {}
2629
2630 /*! \internal
2631 */
2632 QWhatsThisClickedEvent::~QWhatsThisClickedEvent()
2633 {
2634 }
2635
2636 /*!
2637     \fn QString QWhatsThisClickedEvent::href() const
2638
2639     Returns the URL that was clicked by the user in the "What's
2640     This?" text.
2641 */
2642
2643 #endif // QT_NO_WHATSTHIS
2644
2645 #ifndef QT_NO_ACTION
2646
2647 /*!
2648     \class QActionEvent
2649     \brief The QActionEvent class provides an event that is generated
2650     when a QAction is added, removed, or changed.
2651
2652     \ingroup events
2653     \inmodule QtGui
2654
2655     Actions can be added to widgets using QWidget::addAction(). This
2656     generates an \l ActionAdded event, which you can handle to provide
2657     custom behavior. For example, QToolBar reimplements
2658     QWidget::actionEvent() to create \l{QToolButton}s for the
2659     actions.
2660
2661     \sa QAction, QWidget::addAction(), QWidget::removeAction(), QWidget::actions()
2662 */
2663
2664 /*!
2665     Constructs an action event. The \a type can be \l ActionChanged,
2666     \l ActionAdded, or \l ActionRemoved.
2667
2668     \a action is the action that is changed, added, or removed. If \a
2669     type is ActionAdded, the action is to be inserted before the
2670     action \a before. If \a before is 0, the action is appended.
2671 */
2672 QActionEvent::QActionEvent(int type, QAction *action, QAction *before)
2673     : QEvent(static_cast<QEvent::Type>(type)), act(action), bef(before)
2674 {}
2675
2676 /*! \internal
2677 */
2678 QActionEvent::~QActionEvent()
2679 {
2680 }
2681
2682 /*!
2683     \fn QAction *QActionEvent::action() const
2684
2685     Returns the action that is changed, added, or removed.
2686
2687     \sa before()
2688 */
2689
2690 /*!
2691     \fn QAction *QActionEvent::before() const
2692
2693     If type() is \l ActionAdded, returns the action that should
2694     appear before action(). If this function returns 0, the action
2695     should be appended to already existing actions on the same
2696     widget.
2697
2698     \sa action(), QWidget::actions()
2699 */
2700
2701 #endif // QT_NO_ACTION
2702
2703 /*!
2704     \class QHideEvent
2705     \brief The QHideEvent class provides an event which is sent after a widget is hidden.
2706
2707     \ingroup events
2708     \inmodule QtGui
2709
2710     This event is sent just before QWidget::hide() returns, and also
2711     when a top-level window has been hidden (iconified) by the user.
2712
2713     If spontaneous() is true, the event originated outside the
2714     application. In this case, the user hid the window using the
2715     window manager controls, either by iconifying the window or by
2716     switching to another virtual desktop where the window isn't
2717     visible. The window will become hidden but not withdrawn. If the
2718     window was iconified, QWidget::isMinimized() returns true.
2719
2720     \sa QShowEvent
2721 */
2722
2723 /*!
2724     Constructs a QHideEvent.
2725 */
2726 QHideEvent::QHideEvent()
2727     : QEvent(Hide)
2728 {}
2729
2730 /*! \internal
2731 */
2732 QHideEvent::~QHideEvent()
2733 {
2734 }
2735
2736 /*!
2737     \class QShowEvent
2738     \brief The QShowEvent class provides an event that is sent when a widget is shown.
2739
2740     \ingroup events
2741     \inmodule QtGui
2742
2743     There are two kinds of show events: show events caused by the
2744     window system (spontaneous), and internal show events. Spontaneous (QEvent::spontaneous())
2745     show events are sent just after the window system shows the
2746     window; they are also sent when a top-level window is redisplayed
2747     after being iconified. Internal show events are delivered just
2748     before the widget becomes visible.
2749
2750     \sa QHideEvent
2751 */
2752
2753 /*!
2754     Constructs a QShowEvent.
2755 */
2756 QShowEvent::QShowEvent()
2757     : QEvent(Show)
2758 {}
2759
2760 /*! \internal
2761 */
2762 QShowEvent::~QShowEvent()
2763 {
2764 }
2765
2766 /*!
2767     \class QFileOpenEvent
2768     \brief The QFileOpenEvent class provides an event that will be
2769     sent when there is a request to open a file or a URL.
2770
2771     \ingroup events
2772     \inmodule QtGui
2773
2774     File open events will be sent to the QApplication::instance()
2775     when the operating system requests that a file or URL should be opened.
2776     This is a high-level event that can be caused by different user actions
2777     depending on the user's desktop environment; for example, double
2778     clicking on an file icon in the Finder on Mac OS X.
2779
2780     This event is only used to notify the application of a request.
2781     It may be safely ignored.
2782
2783     \note This class is currently supported for Mac OS X only.
2784 */
2785
2786 /*!
2787     \internal
2788
2789     Constructs a file open event for the given \a file.
2790 */
2791 QFileOpenEvent::QFileOpenEvent(const QString &file)
2792     : QEvent(FileOpen), f(file), m_url(QUrl::fromLocalFile(file))
2793 {
2794 }
2795
2796 /*!
2797     \internal
2798
2799     Constructs a file open event for the given \a url.
2800 */
2801 QFileOpenEvent::QFileOpenEvent(const QUrl &url)
2802     : QEvent(FileOpen), f(url.toLocalFile()), m_url(url)
2803 {
2804 }
2805
2806
2807 /*! \internal
2808 */
2809 QFileOpenEvent::~QFileOpenEvent()
2810 {
2811 }
2812
2813 /*!
2814     \fn QString QFileOpenEvent::file() const
2815
2816     Returns the file that is being opened.
2817 */
2818
2819 /*!
2820     \fn QUrl QFileOpenEvent::url() const
2821
2822     Returns the url that is being opened.
2823
2824     \since 4.6
2825 */
2826
2827 /*!
2828     \fn bool QFileOpenEvent::openFile(QFile &file, QIODevice::OpenMode flags) const
2829
2830     Opens a QFile on the \a file referenced by this event in the mode specified
2831     by \a flags. Returns true if successful; otherwise returns false.
2832
2833     This is necessary as some files cannot be opened by name, but require specific
2834     information stored in this event.
2835
2836     \since 4.8
2837 */
2838 bool QFileOpenEvent::openFile(QFile &file, QIODevice::OpenMode flags) const
2839 {
2840     file.setFileName(f);
2841     return file.open(flags);
2842 }
2843
2844 #ifndef QT_NO_TOOLBAR
2845 /*!
2846     \internal
2847     \class QToolBarChangeEvent
2848     \brief The QToolBarChangeEvent class provides an event that is
2849     sent whenever a the toolbar button is clicked on Mac OS X.
2850
2851     \ingroup events
2852     \inmodule QtGui
2853
2854     The QToolBarChangeEvent is sent when the toolbar button is clicked. On Mac
2855     OS X, this is the long oblong button on the right side of the window
2856     title bar. The default implementation is to toggle the appearance (hidden or
2857     shown) of the associated toolbars for the window.
2858 */
2859
2860 /*!
2861     \internal
2862
2863     Construct a QToolBarChangeEvent given the current button state in \a state.
2864 */
2865 QToolBarChangeEvent::QToolBarChangeEvent(bool t)
2866     : QEvent(ToolBarChange), tog(t)
2867 {}
2868
2869 /*! \internal
2870 */
2871 QToolBarChangeEvent::~QToolBarChangeEvent()
2872 {
2873 }
2874
2875 /*!
2876     \fn bool QToolBarChangeEvent::toggle() const
2877     \internal
2878 */
2879
2880 /*
2881     \fn Qt::ButtonState QToolBarChangeEvent::state() const
2882
2883     Returns the keyboard modifier flags at the time of the event.
2884
2885     The returned value is a selection of the following values,
2886     combined using the OR operator:
2887     Qt::ShiftButton, Qt::ControlButton, Qt::MetaButton, and Qt::AltButton.
2888 */
2889
2890 #endif // QT_NO_TOOLBAR
2891
2892 #ifndef QT_NO_SHORTCUT
2893
2894 /*!
2895     Constructs a shortcut event for the given \a key press,
2896     associated with the QShortcut ID \a id.
2897
2898     \a ambiguous specifies whether there is more than one QShortcut
2899     for the same key sequence.
2900 */
2901 QShortcutEvent::QShortcutEvent(const QKeySequence &key, int id, bool ambiguous)
2902     : QEvent(Shortcut), sequence(key), ambig(ambiguous), sid(id)
2903 {
2904 }
2905
2906 /*!
2907     Destroys the event object.
2908 */
2909 QShortcutEvent::~QShortcutEvent()
2910 {
2911 }
2912
2913 #endif // QT_NO_SHORTCUT
2914
2915 #ifndef QT_NO_DEBUG_STREAM
2916 QDebug operator<<(QDebug dbg, const QEvent *e) {
2917     // More useful event output could be added here
2918     if (!e)
2919         return dbg << "QEvent(this = 0x0)";
2920     const char *n = 0;
2921     switch (e->type()) {
2922     case QEvent::Timer:
2923         n = "Timer";
2924         break;
2925     case QEvent::MouseButtonPress:
2926     case QEvent::MouseMove:
2927     case QEvent::MouseButtonRelease:
2928     case QEvent::MouseButtonDblClick:
2929     {
2930         const QMouseEvent *me = static_cast<const QMouseEvent*>(e);
2931         switch(me->type()) {
2932         case QEvent::MouseButtonPress:
2933             n = "MouseButtonPress";
2934             break;
2935         case QEvent::MouseMove:
2936             n = "MouseMove";
2937             break;
2938         case QEvent::MouseButtonRelease:
2939             n = "MouseButtonRelease";
2940             break;
2941         case QEvent::MouseButtonDblClick:
2942         default:
2943             n = "MouseButtonDblClick";
2944             break;
2945         }
2946         dbg.nospace() << "QMouseEvent("  << n
2947                       << ", " << me->button()
2948                       << ", " << hex << (int)me->buttons()
2949                       << ", " << hex << (int)me->modifiers()
2950                       << ')';
2951     }
2952     return dbg.space();
2953
2954 #ifndef QT_NO_TOOLTIP
2955     case QEvent::ToolTip:
2956         n = "ToolTip";
2957         break;
2958 #endif
2959     case QEvent::WindowActivate:
2960         n = "WindowActivate";
2961         break;
2962     case QEvent::WindowDeactivate:
2963         n = "WindowDeactivate";
2964         break;
2965     case QEvent::ActivationChange:
2966         n = "ActivationChange";
2967         break;
2968 #ifndef QT_NO_WHEELEVENT
2969     case QEvent::Wheel:
2970         dbg.nospace() << "QWheelEvent("
2971                       << static_cast<const QWheelEvent *>(e)->pixelDelta()
2972                       << static_cast<const QWheelEvent *>(e)->angleDelta()
2973                       << ')';
2974         return dbg.space();
2975 #endif
2976     case QEvent::KeyPress:
2977     case QEvent::KeyRelease:
2978     case QEvent::ShortcutOverride:
2979         {
2980             const QKeyEvent *ke = static_cast<const QKeyEvent*>(e);
2981             switch(ke->type()) {
2982             case QEvent::ShortcutOverride:
2983                 n = "ShortcutOverride";
2984                 break;
2985             case QEvent::KeyRelease:
2986                 n = "KeyRelease";
2987                 break;
2988             case QEvent::KeyPress:
2989             default:
2990                 n = "KeyPress";
2991                 break;
2992             }
2993             dbg.nospace() << "QKeyEvent("  << n
2994                           << ", " << hex << ke->key()
2995                           << ", " << hex << (int)ke->modifiers()
2996                           << ", \"" << ke->text()
2997                           << "\", " << ke->isAutoRepeat()
2998                           << ", " << ke->count()
2999                           << ')';
3000         }
3001         return dbg.space();
3002     case QEvent::FocusIn:
3003         n = "FocusIn";
3004         break;
3005     case QEvent::FocusOut:
3006         n = "FocusOut";
3007         break;
3008     case QEvent::Enter:
3009         n = "Enter";
3010         break;
3011     case QEvent::Leave:
3012         n = "Leave";
3013         break;
3014     case QEvent::PaletteChange:
3015         n = "PaletteChange";
3016         break;
3017     case QEvent::PolishRequest:
3018         n = "PolishRequest";
3019         break;
3020     case QEvent::Polish:
3021         n = "Polish";
3022         break;
3023     case QEvent::UpdateRequest:
3024         n = "UpdateRequest";
3025         break;
3026     case QEvent::Paint:
3027         n = "Paint";
3028         break;
3029     case QEvent::Move:
3030         n = "Move";
3031         break;
3032     case QEvent::Resize:
3033         n = "Resize";
3034         break;
3035     case QEvent::Create:
3036         n = "Create";
3037         break;
3038     case QEvent::Destroy:
3039         n = "Destroy";
3040         break;
3041     case QEvent::Close:
3042         n = "Close";
3043         break;
3044     case QEvent::Quit:
3045         n = "Quit";
3046         break;
3047     case QEvent::FileOpen:
3048         n = "FileOpen";
3049         break;
3050     case QEvent::Show:
3051         n = "Show";
3052         break;
3053     case QEvent::ShowToParent:
3054         n = "ShowToParent";
3055         break;
3056     case QEvent::Hide:
3057         n = "Hide";
3058         break;
3059     case QEvent::HideToParent:
3060         n = "HideToParent";
3061         break;
3062     case QEvent::None:
3063         n = "None";
3064         break;
3065     case QEvent::ParentChange:
3066         n = "ParentChange";
3067         break;
3068     case QEvent::ParentAboutToChange:
3069         n = "ParentAboutToChange";
3070         break;
3071     case QEvent::HoverEnter:
3072         n = "HoverEnter";
3073         break;
3074     case QEvent::HoverMove:
3075         n = "HoverMove";
3076         break;
3077     case QEvent::HoverLeave:
3078         n = "HoverLeave";
3079         break;
3080     case QEvent::ZOrderChange:
3081         n = "ZOrderChange";
3082         break;
3083     case QEvent::StyleChange:
3084         n = "StyleChange";
3085         break;
3086     case QEvent::DragEnter:
3087         n = "DragEnter";
3088         break;
3089     case QEvent::DragMove:
3090         n = "DragMove";
3091         break;
3092     case QEvent::DragLeave:
3093         n = "DragLeave";
3094         break;
3095     case QEvent::Drop:
3096         n = "Drop";
3097         break;
3098     case QEvent::GraphicsSceneMouseMove:
3099         n = "GraphicsSceneMouseMove";
3100         break;
3101     case QEvent::GraphicsSceneMousePress:
3102         n = "GraphicsSceneMousePress";
3103         break;
3104     case QEvent::GraphicsSceneMouseRelease:
3105         n = "GraphicsSceneMouseRelease";
3106         break;
3107     case QEvent::GraphicsSceneMouseDoubleClick:
3108         n = "GraphicsSceneMouseDoubleClick";
3109         break;
3110     case QEvent::GraphicsSceneContextMenu:
3111         n = "GraphicsSceneContextMenu";
3112         break;
3113     case QEvent::GraphicsSceneHoverEnter:
3114         n = "GraphicsSceneHoverEnter";
3115         break;
3116     case QEvent::GraphicsSceneHoverMove:
3117         n = "GraphicsSceneHoverMove";
3118         break;
3119     case QEvent::GraphicsSceneHoverLeave:
3120         n = "GraphicsSceneHoverLeave";
3121         break;
3122     case QEvent::GraphicsSceneHelp:
3123         n = "GraphicsSceneHelp";
3124         break;
3125     case QEvent::GraphicsSceneDragEnter:
3126         n = "GraphicsSceneDragEnter";
3127         break;
3128     case QEvent::GraphicsSceneDragMove:
3129         n = "GraphicsSceneDragMove";
3130         break;
3131     case QEvent::GraphicsSceneDragLeave:
3132         n = "GraphicsSceneDragLeave";
3133         break;
3134     case QEvent::GraphicsSceneDrop:
3135         n = "GraphicsSceneDrop";
3136         break;
3137     case QEvent::GraphicsSceneWheel:
3138         n = "GraphicsSceneWheel";
3139         break;
3140     case QEvent::GraphicsSceneResize:
3141         n = "GraphicsSceneResize";
3142         break;
3143     case QEvent::GraphicsSceneMove:
3144         n = "GraphicsSceneMove";
3145         break;
3146     case QEvent::CursorChange:
3147         n = "CursorChange";
3148         break;
3149     case QEvent::ToolTipChange:
3150         n = "ToolTipChange";
3151         break;
3152     case QEvent::StatusTip:
3153         n = "StatusTip";
3154         break;
3155     case QEvent::WhatsThis:
3156         n = "WhatsThis";
3157         break;
3158     case QEvent::FontChange:
3159         n = "FontChange";
3160         break;
3161     case QEvent::Style:
3162         n = "Style";
3163         break;
3164     case QEvent::KeyboardLayoutChange:
3165         n = "KeyboardLayoutChange";
3166         break;
3167     case QEvent::DynamicPropertyChange:
3168         n = "DynamicPropertyChange";
3169         break;
3170     case QEvent::GrabMouse:
3171         n = "GrabMouse";
3172         break;
3173     case QEvent::UngrabMouse:
3174         n = "UngrabMouse";
3175         break;
3176     case QEvent::GrabKeyboard:
3177         n = "GrabKeyboard";
3178         break;
3179     case QEvent::UngrabKeyboard:
3180         n = "UngrabKeyboard";
3181         break;
3182     case QEvent::ChildAdded: n = n ? n : "ChildAdded";
3183     case QEvent::ChildPolished: n = n ? n : "ChildPolished";
3184     case QEvent::ChildRemoved: n = n ? n : "ChildRemoved";
3185         dbg.nospace() << "QChildEvent(" << n << ", " << (static_cast<const QChildEvent*>(e))->child();
3186         return dbg.space();
3187 #ifndef QT_NO_GESTURES
3188     case QEvent::Gesture:
3189         n = "Gesture";
3190         break;
3191 #endif
3192     default:
3193         dbg.nospace() << "QEvent(" << (const void *)e << ", type = " << e->type() << ')';
3194         return dbg.space();
3195     }
3196
3197     dbg.nospace() << 'Q' << n << "Event(" << (const void *)e << ')';
3198     return dbg.space();
3199 }
3200 #endif
3201
3202 /*!
3203     \class QShortcutEvent
3204     \brief The QShortcutEvent class provides an event which is generated when
3205     the user presses a key combination.
3206
3207     \ingroup events
3208     \inmodule QtGui
3209
3210     Normally you don't need to use this class directly; QShortcut
3211     provides a higher-level interface to handle shortcut keys.
3212
3213     \sa QShortcut
3214 */
3215
3216 /*!
3217     \fn const QKeySequence &QShortcutEvent::key() const
3218
3219     Returns the key sequence that triggered the event.
3220 */
3221
3222 /*!
3223     \fn int QShortcutEvent::shortcutId() const
3224
3225     Returns the ID of the QShortcut object for which this event was
3226     generated.
3227
3228     \sa QShortcut::id()
3229 */
3230
3231 /*!
3232     \fn bool QShortcutEvent::isAmbiguous() const
3233
3234     Returns true if the key sequence that triggered the event is
3235     ambiguous.
3236
3237     \sa QShortcut::activatedAmbiguously()
3238 */
3239
3240 /*!
3241     \class QWindowStateChangeEvent
3242     \ingroup events
3243     \inmodule QtGui
3244
3245     \brief The QWindowStateChangeEvent class provides the window state before a
3246     window state change.
3247 */
3248
3249 /*! \fn Qt::WindowStates QWindowStateChangeEvent::oldState() const
3250
3251     Returns the state of the window before the change.
3252 */
3253
3254 /*! \internal
3255  */
3256 QWindowStateChangeEvent::QWindowStateChangeEvent(Qt::WindowStates s, bool isOverride)
3257     : QEvent(WindowStateChange), ostate(s), m_override(isOverride)
3258 {
3259 }
3260
3261 /*! \internal
3262  */
3263 bool QWindowStateChangeEvent::isOverride() const
3264 {
3265     return m_override;
3266 }
3267
3268 /*! \internal
3269 */
3270 QWindowStateChangeEvent::~QWindowStateChangeEvent()
3271 {
3272 }
3273
3274
3275 /*!
3276     \class QTouchEvent
3277     \brief The QTouchEvent class contains parameters that describe a touch event.
3278     \since 4.6
3279     \ingroup events
3280     \ingroup touch
3281     \inmodule QtGui
3282
3283     \section1 Enabling Touch Events
3284
3285     Touch events occur when pressing, releasing, or moving one or more touch points on a touch
3286     device (such as a touch-screen or track-pad). To receive touch events, widgets have to have the
3287     Qt::WA_AcceptTouchEvents attribute set and graphics items need to have the
3288     \l{QGraphicsItem::setAcceptTouchEvents()}{acceptTouchEvents} attribute set to true.
3289
3290     When using QAbstractScrollArea based widgets, you should enable the Qt::WA_AcceptTouchEvents
3291     attribute on the scroll area's \l{QAbstractScrollArea::viewport()}{viewport}.
3292
3293     Similarly to QMouseEvent, Qt automatically grabs each touch point on the first press inside a
3294     widget, and the widget will receive all updates for the touch point until it is released.
3295     Note that it is possible for a widget to receive events for numerous touch points, and that
3296     multiple widgets may be receiving touch events at the same time.
3297
3298     \section1 Event Handling
3299
3300     All touch events are of type QEvent::TouchBegin, QEvent::TouchUpdate, QEvent::TouchEnd or
3301     QEvent::TouchCancel. Reimplement QWidget::event() or QAbstractScrollArea::viewportEvent() for
3302     widgets and QGraphicsItem::sceneEvent() for items in a graphics view to receive touch events.
3303
3304     Unlike widgets, QWindows receive touch events always, there is no need to opt in. When working
3305     directly with a QWindow, it is enough to reimplement QWindow::touchEvent().
3306
3307     The QEvent::TouchUpdate and QEvent::TouchEnd events are sent to the widget or item that
3308     accepted the QEvent::TouchBegin event. If the QEvent::TouchBegin event is not accepted and not
3309     filtered by an event filter, then no further touch events are sent until the next
3310     QEvent::TouchBegin.
3311
3312     Some systems may send an event of type QEvent::TouchCancel. Upon receiving this event
3313     applications are requested to ignore the entire active touch sequence. For example in a
3314     composited system the compositor may decide to treat certain gestures as system-wide
3315     gestures. Whenever such a decision is made (the gesture is recognized), the clients will be
3316     notified with a QEvent::TouchCancel event so they can update their state accordingly.
3317
3318     The touchPoints() function returns a list of all touch points contained in the event. Note that
3319     this list may be empty, for example in case of a QEvent::TouchCancel event. Information about
3320     each touch point can be retrieved using the QTouchEvent::TouchPoint class. The
3321     Qt::TouchPointState enum describes the different states that a touch point may have.
3322
3323     \note The list of touchPoints() will never be partial: A touch event will always contain a touch
3324     point for each existing physical touch contacts targetting the window or widget to which the
3325     event is sent. For instance, assuming that all touches target the same window or widget, an
3326     event with a condition of touchPoints().count()==2 is guaranteed to imply that the number of
3327     fingers touching the touchscreen or touchpad is exactly two.
3328
3329     \section1 Event Delivery and Propagation
3330
3331     By default, QGuiApplication translates the first touch point in a QTouchEvent into
3332     a QMouseEvent. This makes it possible to enable touch events on existing widgets that do not
3333     normally handle QTouchEvent. See below for information on some special considerations needed
3334     when doing this.
3335
3336     QEvent::TouchBegin is the first touch event sent to a widget. The QEvent::TouchBegin event
3337     contains a special accept flag that indicates whether the receiver wants the event. By default,
3338     the event is accepted. You should call ignore() if the touch event is not handled by your
3339     widget. The QEvent::TouchBegin event is propagated up the parent widget chain until a widget
3340     accepts it with accept(), or an event filter consumes it. For QGraphicsItems, the
3341     QEvent::TouchBegin event is propagated to items under the mouse (similar to mouse event
3342     propagation for QGraphicsItems).
3343
3344     \section1 Touch Point Grouping
3345
3346     As mentioned above, it is possible that several widgets can be receiving QTouchEvents at the
3347     same time. However, Qt makes sure to never send duplicate QEvent::TouchBegin events to the same
3348     widget, which could theoretically happen during propagation if, for example, the user touched 2
3349     separate widgets in a QGroupBox and both widgets ignored the QEvent::TouchBegin event.
3350
3351     To avoid this, Qt will group new touch points together using the following rules:
3352
3353     \list
3354
3355     \li When the first touch point is detected, the destination widget is determined firstly by the
3356     location on screen and secondly by the propagation rules.
3357
3358     \li When additional touch points are detected, Qt first looks to see if there are any active
3359     touch points on any ancestor or descendent of the widget under the new touch point. If there
3360     are, the new touch point is grouped with the first, and the new touch point will be sent in a
3361     single QTouchEvent to the widget that handled the first touch point. (The widget under the new
3362     touch point will not receive an event).
3363
3364     \endlist
3365
3366     This makes it possible for sibling widgets to handle touch events independently while making
3367     sure that the sequence of QTouchEvents is always correct.
3368
3369     \section1 Mouse Events and Touch Event synthesizing
3370
3371     QTouchEvent delivery is independent from that of QMouseEvent. The application flags
3372     Qt::AA_SynthesizeTouchForUnhandledMouseEvents and Qt::AA_SynthesizeMouseForUnhandledTouchEvents
3373     can be used to enable or disable automatic synthesizing of touch events to mouse events and
3374     mouse events to touch events.
3375
3376     \section1 Caveats
3377
3378     \list
3379
3380     \li As mentioned above, enabling touch events means multiple widgets can be receiving touch
3381     events simultaneously. Combined with the default QWidget::event() handling for QTouchEvents,
3382     this gives you great flexibility in designing touch user interfaces. Be aware of the
3383     implications. For example, it is possible that the user is moving a QSlider with one finger and
3384     pressing a QPushButton with another. The signals emitted by these widgets will be
3385     interleaved.
3386
3387     \li Recursion into the event loop using one of the exec() methods (e.g., QDialog::exec() or
3388     QMenu::exec()) in a QTouchEvent event handler is not supported. Since there are multiple event
3389     recipients, recursion may cause problems, including but not limited to lost events
3390     and unexpected infinite recursion.
3391
3392     \li QTouchEvents are not affected by a \l{QWidget::grabMouse()}{mouse grab} or an
3393     \l{QApplication::activePopupWidget()}{active pop-up widget}. The behavior of QTouchEvents is
3394     undefined when opening a pop-up or grabbing the mouse while there are more than one active touch
3395     points.
3396
3397     \endlist
3398
3399     \sa QTouchEvent::TouchPoint, Qt::TouchPointState, Qt::WA_AcceptTouchEvents,
3400     QGraphicsItem::acceptTouchEvents()
3401 */
3402
3403 /*! \enum Qt::TouchPointState
3404     \since 4.6
3405
3406     This enum represents the state of a touch point at the time the
3407     QTouchEvent occurred.
3408
3409     \value TouchPointPressed The touch point is now pressed.
3410     \value TouchPointMoved The touch point moved.
3411     \value TouchPointStationary The touch point did not move.
3412     \value TouchPointReleased The touch point was released.
3413 */
3414
3415 /*! \enum QTouchEvent::DeviceType
3416
3417     This enum represents the type of device that generated a QTouchEvent.
3418
3419     This enum has been deprecated. Use QTouchDevice::DeviceType instead.
3420
3421     \sa QTouchDevice::DeviceType, QTouchDevice::type(), QTouchEvent::device()
3422 */
3423
3424 /*!
3425     Constructs a QTouchEvent with the given \a eventType, \a deviceType, \a
3426     touchPoints and \a device. The \a touchPointStates and \a modifiers
3427     are the current touch point states and keyboard modifiers at the time of
3428     the event.
3429 */
3430 QTouchEvent::QTouchEvent(QEvent::Type eventType,
3431                          QTouchDevice *device,
3432                          Qt::KeyboardModifiers modifiers,
3433                          Qt::TouchPointStates touchPointStates,
3434                          const QList<QTouchEvent::TouchPoint> &touchPoints)
3435     : QInputEvent(eventType, modifiers),
3436       _window(0),
3437       _target(0),
3438       _device(device),
3439       _touchPointStates(touchPointStates),
3440       _touchPoints(touchPoints)
3441 { }
3442
3443 /*!
3444     Destroys the QTouchEvent.
3445 */
3446 QTouchEvent::~QTouchEvent()
3447 { }
3448
3449 /*! \fn QWindow *QTouchEvent::window() const
3450
3451     Returns the window on which the event occurred. Useful for doing
3452     global-local mapping on data like rawScreenPositions() which,
3453     for performance reasons, only stores the global positions in the
3454     touch event.
3455 */
3456
3457 /*! \fn QObject *QTouchEvent::target() const
3458
3459     Returns the target object within the window on which the event occurred.
3460     This is typically a QWidget or a QQuickItem. May be 0 when no specific target is available.
3461 */
3462
3463 /*! \fn QTouchEvent::DeviceType QTouchEvent::deviceType() const
3464
3465     Returns the touch device Type, which is of type \l {QTouchEvent::DeviceType} {DeviceType}.
3466
3467     This function has been deprecated. Use QTouchDevice::type() instead.
3468
3469     \sa QTouchDevice::type(), QTouchEvent::device()
3470 */
3471
3472 /*! \fn Qt::TouchPointStates QTouchEvent::touchPointStates() const
3473
3474     Returns a bitwise OR of all the touch point states for this event.
3475 */
3476
3477 /*! \fn const QList<QTouchEvent::TouchPoint> &QTouchEvent::touchPoints() const
3478
3479     Returns the list of touch points contained in the touch event.
3480 */
3481
3482 /*! \fn QTouchEvent::DeviceType QTouchEvent::deviceType() const
3483
3484     Returns the touch device Type, which is of type \l {QTouchEvent::DeviceType} {DeviceType}.
3485 */
3486
3487 /*! \fn QTouchDevice* QTouchEvent::device() const
3488
3489     Returns the touch device from which this touch event originates.
3490 */
3491
3492 /*! \fn void QTouchEvent::setWindow(QWindow *window)
3493
3494     \internal
3495
3496     Sets the window for this event.
3497 */
3498
3499 /*! \fn void QTouchEvent::setTarget(QObject *target)
3500
3501     \internal
3502
3503     Sets the target within the window (typically a widget) for this event.
3504 */
3505
3506 /*! \fn void QTouchEvent::setTouchPointStates(Qt::TouchPointStates touchPointStates)
3507
3508     \internal
3509
3510     Sets a bitwise OR of all the touch point states for this event.
3511 */
3512
3513 /*! \fn void QTouchEvent::setTouchPoints(const QList<QTouchEvent::TouchPoint> &touchPoints)
3514
3515     \internal
3516
3517     Sets the list of touch points for this event.
3518 */
3519
3520 /*! \fn void QTouchEvent::setDeviceType(DeviceType deviceType)
3521
3522     \internal
3523
3524     Sets the device type to \a deviceType, which is of type \l {QTouchEvent::DeviceType}
3525     {DeviceType}.
3526 */
3527
3528 /*! \fn void QTouchEvent::setTouchDevice(QTouchDevice *device)
3529
3530     \internal
3531
3532     Sets the touch event's device to the given one.
3533 */
3534
3535 /*! \class QTouchEvent::TouchPoint
3536     \brief The TouchPoint class provides information about a touch point in a QTouchEvent.
3537     \since 4.6
3538     \inmodule QtGui
3539 */
3540
3541 /*! \enum QTouchEvent::TouchPoint::InfoFlags
3542
3543     The values of this enum describe additional information about a touch point.
3544
3545     \value Pen Indicates that the contact has been made by a designated pointing device (e.g. a pen) instead of a finger.
3546 */
3547
3548 /*! \internal
3549
3550     Constructs a QTouchEvent::TouchPoint for use in a QTouchEvent.
3551 */
3552 QTouchEvent::TouchPoint::TouchPoint(int id)
3553     : d(new QTouchEventTouchPointPrivate(id))
3554 { }
3555
3556 /*! \internal
3557
3558     Constructs a copy of \a other.
3559 */
3560 QTouchEvent::TouchPoint::TouchPoint(const QTouchEvent::TouchPoint &other)
3561     : d(other.d)
3562 {
3563     d->ref.ref();
3564 }
3565
3566 /*! \internal
3567
3568     Destroys the QTouchEvent::TouchPoint.
3569 */
3570 QTouchEvent::TouchPoint::~TouchPoint()
3571 {
3572     if (d && !d->ref.deref())
3573         delete d;
3574 }
3575
3576 /*!
3577     Returns the id number of this touch point.
3578
3579     Do not assume that id numbers start at zero or that they are sequential.
3580     Such an assumption is often false due to the way the underlying drivers work.
3581 */
3582 int QTouchEvent::TouchPoint::id() const
3583 {
3584     return d->id;
3585 }
3586
3587 /*!
3588     Returns the current state of this touch point.
3589 */
3590 Qt::TouchPointState QTouchEvent::TouchPoint::state() const
3591 {
3592     return Qt::TouchPointState(int(d->state));
3593 }
3594
3595 /*!
3596     Returns the position of this touch point, relative to the widget
3597     or QGraphicsItem that received the event.
3598
3599     \sa startPos(), lastPos(), screenPos(), scenePos(), normalizedPos()
3600 */
3601 QPointF QTouchEvent::TouchPoint::pos() const
3602 {
3603     return d->rect.center();
3604 }
3605
3606 /*!
3607     Returns the scene position of this touch point.
3608
3609     The scene position is the position in QGraphicsScene coordinates
3610     if the QTouchEvent is handled by a QGraphicsItem::touchEvent()
3611     reimplementation, and identical to the screen position for
3612     widgets.
3613
3614     \sa startScenePos(), lastScenePos(), pos()
3615 */
3616 QPointF QTouchEvent::TouchPoint::scenePos() const
3617 {
3618     return d->sceneRect.center();
3619 }
3620
3621 /*!
3622     Returns the screen position of this touch point.
3623
3624     \sa startScreenPos(), lastScreenPos(), pos()
3625 */
3626 QPointF QTouchEvent::TouchPoint::screenPos() const
3627 {
3628     return d->screenRect.center();
3629 }
3630
3631 /*!
3632     Returns the normalized position of this touch point.
3633
3634     The coordinates are normalized to the size of the touch device,
3635     i.e. (0,0) is the top-left corner and (1,1) is the bottom-right corner.
3636
3637     \sa startNormalizedPos(), lastNormalizedPos(), pos()
3638 */
3639 QPointF QTouchEvent::TouchPoint::normalizedPos() const
3640 {
3641     return d->normalizedPos;
3642 }
3643
3644 /*!
3645     Returns the starting position of this touch point, relative to the
3646     widget or QGraphicsItem that received the event.
3647
3648     \sa pos(), lastPos()
3649 */
3650 QPointF QTouchEvent::TouchPoint::startPos() const
3651 {
3652     return d->startPos;
3653 }
3654
3655 /*!
3656     Returns the starting scene position of this touch point.
3657
3658     The scene position is the position in QGraphicsScene coordinates
3659     if the QTouchEvent is handled by a QGraphicsItem::touchEvent()
3660     reimplementation, and identical to the screen position for
3661     widgets.
3662
3663     \sa scenePos(), lastScenePos()
3664 */
3665 QPointF QTouchEvent::TouchPoint::startScenePos() const
3666 {
3667     return d->startScenePos;
3668 }
3669
3670 /*!
3671     Returns the starting screen position of this touch point.
3672
3673     \sa screenPos(), lastScreenPos()
3674 */
3675 QPointF QTouchEvent::TouchPoint::startScreenPos() const
3676 {
3677     return d->startScreenPos;
3678 }
3679
3680 /*!
3681     Returns the normalized starting position of this touch point.
3682
3683     The coordinates are normalized to the size of the touch device,
3684     i.e. (0,0) is the top-left corner and (1,1) is the bottom-right corner.
3685
3686     \sa normalizedPos(), lastNormalizedPos()
3687 */
3688 QPointF QTouchEvent::TouchPoint::startNormalizedPos() const
3689 {
3690     return d->startNormalizedPos;
3691 }
3692
3693 /*!
3694     Returns the position of this touch point from the previous touch
3695     event, relative to the widget or QGraphicsItem that received the event.
3696
3697     \sa pos(), startPos()
3698 */
3699 QPointF QTouchEvent::TouchPoint::lastPos() const
3700 {
3701     return d->lastPos;
3702 }
3703
3704 /*!
3705     Returns the scene position of this touch point from the previous
3706     touch event.
3707
3708     The scene position is the position in QGraphicsScene coordinates
3709     if the QTouchEvent is handled by a QGraphicsItem::touchEvent()
3710     reimplementation, and identical to the screen position for
3711     widgets.
3712
3713     \sa scenePos(), startScenePos()
3714 */
3715 QPointF QTouchEvent::TouchPoint::lastScenePos() const
3716 {
3717     return d->lastScenePos;
3718 }
3719
3720 /*!
3721     Returns the screen position of this touch point from the previous
3722     touch event.
3723
3724     \sa screenPos(), startScreenPos()
3725 */
3726 QPointF QTouchEvent::TouchPoint::lastScreenPos() const
3727 {
3728     return d->lastScreenPos;
3729 }
3730
3731 /*!
3732     Returns the normalized position of this touch point from the
3733     previous touch event.
3734
3735     The coordinates are normalized to the size of the touch device,
3736     i.e. (0,0) is the top-left corner and (1,1) is the bottom-right corner.
3737
3738     \sa normalizedPos(), startNormalizedPos()
3739 */
3740 QPointF QTouchEvent::TouchPoint::lastNormalizedPos() const
3741 {
3742     return d->lastNormalizedPos;
3743 }
3744
3745 /*!
3746     Returns the rect for this touch point, relative to the widget
3747     or QGraphicsItem that received the event. The rect is centered
3748     around the point returned by pos().
3749
3750     \note This function returns an empty rect if the device does not report touch point sizes.
3751 */
3752 QRectF QTouchEvent::TouchPoint::rect() const
3753 {
3754     return d->rect;
3755 }
3756
3757 /*!
3758     Returns the rect for this touch point in scene coordinates.
3759
3760     \note This function returns an empty rect if the device does not report touch point sizes.
3761
3762     \sa scenePos(), rect()
3763 */
3764 QRectF QTouchEvent::TouchPoint::sceneRect() const
3765 {
3766     return d->sceneRect;
3767 }
3768
3769 /*!
3770     Returns the rect for this touch point in screen coordinates.
3771
3772     \note This function returns an empty rect if the device does not report touch point sizes.
3773
3774     \sa screenPos(), rect()
3775 */
3776 QRectF QTouchEvent::TouchPoint::screenRect() const
3777 {
3778     return d->screenRect;
3779 }
3780
3781 /*!
3782     Returns the pressure of this touch point. The return value is in
3783     the range 0.0 to 1.0.
3784 */
3785 qreal QTouchEvent::TouchPoint::pressure() const
3786 {
3787     return d->pressure;
3788 }
3789
3790 /*!
3791     Returns a velocity vector for this touch point.
3792     The vector is in the screen's coordinate system, using pixels per seconds for the magnitude.
3793
3794     \note The returned vector is only valid if the touch device's capabilities include QTouchDevice::Velocity.
3795
3796     \sa QTouchDevice::capabilities(), device()
3797 */
3798 QVector2D QTouchEvent::TouchPoint::velocity() const
3799 {
3800     return d->velocity;
3801 }
3802
3803 /*!
3804   Returns additional information about the touch point.
3805
3806   \sa QTouchEvent::TouchPoint::InfoFlags
3807   */
3808 QTouchEvent::TouchPoint::InfoFlags QTouchEvent::TouchPoint::flags() const
3809 {
3810     return d->flags;
3811 }
3812
3813 /*!
3814   \since 5.0
3815   Returns the raw, unfiltered positions for the touch point. The positions are in native screen coordinates.
3816   To get local coordinates you can use mapFromGlobal() of the QWindow returned by QTouchEvent::window().
3817
3818   \note Returns an empty vector if the touch device's capabilities do not include QTouchDevice::RawPositions.
3819
3820   \note Native screen coordinates refer to the native orientation of the screen which, in case of
3821   mobile devices, is typically portrait. This means that on systems capable of screen orientation
3822   changes the positions in this list will not reflect the current orientation (unlike pos(),
3823   screenPos(), etc.) and will always be reported in the native orientation.
3824
3825   \sa QTouchDevice::capabilities(), device(), window()
3826   */
3827 QVector<QPointF> QTouchEvent::TouchPoint::rawScreenPositions() const
3828 {
3829     return d->rawScreenPositions;
3830 }
3831
3832 /*! \internal */
3833 void QTouchEvent::TouchPoint::setId(int id)
3834 {
3835     if (d->ref.load() != 1)
3836         d = d->detach();
3837     d->id = id;
3838 }
3839
3840 /*! \internal */
3841 void QTouchEvent::TouchPoint::setState(Qt::TouchPointStates state)
3842 {
3843     if (d->ref.load() != 1)
3844         d = d->detach();
3845     d->state = state;
3846 }
3847
3848 /*! \internal */
3849 void QTouchEvent::TouchPoint::setPos(const QPointF &pos)
3850 {
3851     if (d->ref.load() != 1)
3852         d = d->detach();
3853     d->rect.moveCenter(pos);
3854 }
3855
3856 /*! \internal */
3857 void QTouchEvent::TouchPoint::setScenePos(const QPointF &scenePos)
3858 {
3859     if (d->ref.load() != 1)
3860         d = d->detach();
3861     d->sceneRect.moveCenter(scenePos);
3862 }
3863
3864 /*! \internal */
3865 void QTouchEvent::TouchPoint::setScreenPos(const QPointF &screenPos)
3866 {
3867     if (d->ref.load() != 1)
3868         d = d->detach();
3869     d->screenRect.moveCenter(screenPos);
3870 }
3871
3872 /*! \internal */
3873 void QTouchEvent::TouchPoint::setNormalizedPos(const QPointF &normalizedPos)
3874 {
3875     if (d->ref.load() != 1)
3876         d = d->detach();
3877     d->normalizedPos = normalizedPos;
3878 }
3879
3880 /*! \internal */
3881 void QTouchEvent::TouchPoint::setStartPos(const QPointF &startPos)
3882 {
3883     if (d->ref.load() != 1)
3884         d = d->detach();
3885     d->startPos = startPos;
3886 }
3887
3888 /*! \internal */
3889 void QTouchEvent::TouchPoint::setStartScenePos(const QPointF &startScenePos)
3890 {
3891     if (d->ref.load() != 1)
3892         d = d->detach();
3893     d->startScenePos = startScenePos;
3894 }
3895
3896 /*! \internal */
3897 void QTouchEvent::TouchPoint::setStartScreenPos(const QPointF &startScreenPos)
3898 {
3899     if (d->ref.load() != 1)
3900         d = d->detach();
3901     d->startScreenPos = startScreenPos;
3902 }
3903
3904 /*! \internal */
3905 void QTouchEvent::TouchPoint::setStartNormalizedPos(const QPointF &startNormalizedPos)
3906 {
3907     if (d->ref.load() != 1)
3908         d = d->detach();
3909     d->startNormalizedPos = startNormalizedPos;
3910 }
3911
3912 /*! \internal */
3913 void QTouchEvent::TouchPoint::setLastPos(const QPointF &lastPos)
3914 {
3915     if (d->ref.load() != 1)
3916         d = d->detach();
3917     d->lastPos = lastPos;
3918 }
3919
3920 /*! \internal */
3921 void QTouchEvent::TouchPoint::setLastScenePos(const QPointF &lastScenePos)
3922 {
3923     if (d->ref.load() != 1)
3924         d = d->detach();
3925     d->lastScenePos = lastScenePos;
3926 }
3927
3928 /*! \internal */
3929 void QTouchEvent::TouchPoint::setLastScreenPos(const QPointF &lastScreenPos)
3930 {
3931     if (d->ref.load() != 1)
3932         d = d->detach();
3933     d->lastScreenPos = lastScreenPos;
3934 }
3935
3936 /*! \internal */
3937 void QTouchEvent::TouchPoint::setLastNormalizedPos(const QPointF &lastNormalizedPos)
3938 {
3939     if (d->ref.load() != 1)
3940         d = d->detach();
3941     d->lastNormalizedPos = lastNormalizedPos;
3942 }
3943
3944 /*! \internal */
3945 void QTouchEvent::TouchPoint::setRect(const QRectF &rect)
3946 {
3947     if (d->ref.load() != 1)
3948         d = d->detach();
3949     d->rect = rect;
3950 }
3951
3952 /*! \internal */
3953 void QTouchEvent::TouchPoint::setSceneRect(const QRectF &sceneRect)
3954 {
3955     if (d->ref.load() != 1)
3956         d = d->detach();
3957     d->sceneRect = sceneRect;
3958 }
3959
3960 /*! \internal */
3961 void QTouchEvent::TouchPoint::setScreenRect(const QRectF &screenRect)
3962 {
3963     if (d->ref.load() != 1)
3964         d = d->detach();
3965     d->screenRect = screenRect;
3966 }
3967
3968 /*! \internal */
3969 void QTouchEvent::TouchPoint::setPressure(qreal pressure)
3970 {
3971     if (d->ref.load() != 1)
3972         d = d->detach();
3973     d->pressure = pressure;
3974 }
3975
3976 /*! \internal */
3977 void QTouchEvent::TouchPoint::setVelocity(const QVector2D &v)
3978 {
3979     if (d->ref.load() != 1)
3980         d = d->detach();
3981     d->velocity = v;
3982 }
3983
3984 /*! \internal */
3985 void QTouchEvent::TouchPoint::setRawScreenPositions(const QVector<QPointF> &positions)
3986 {
3987     if (d->ref.load() != 1)
3988         d = d->detach();
3989     d->rawScreenPositions = positions;
3990 }
3991
3992 /* \internal */
3993 void QTouchEvent::TouchPoint::setFlags(InfoFlags flags)
3994 {
3995     if (d->ref.load() != 1)
3996         d = d->detach();
3997     d->flags = flags;
3998 }
3999
4000 /*!
4001     \fn QTouchEvent::TouchPoint &QTouchEvent::TouchPoint::operator=(const QTouchEvent::TouchPoint &other)
4002     \internal
4003  */
4004
4005 /*!
4006     \fn void QTouchEvent::TouchPoint::swap(TouchPoint &other);
4007     \internal
4008 */
4009
4010 /*!
4011     \class QScrollPrepareEvent
4012     \since 4.8
4013     \ingroup events
4014     \inmodule QtGui
4015
4016     \brief The QScrollPrepareEvent class is send in preparation of a scrolling.
4017
4018     The scroll prepare event is send before scrolling (usually by QScroller) is started.
4019     The object receiving this event should set viewportSize, maxContentPos and contentPos.
4020     It also should accept this event to indicate that scrolling should be started.
4021
4022     It is not guaranteed that a QScrollEvent will be send after an acceepted
4023     QScrollPrepareEvent, e.g. in a case where the maximum content position is (0,0).
4024
4025     \sa QScrollEvent, QScroller
4026 */
4027
4028 /*!
4029     Creates new QScrollPrepareEvent
4030     The \a startPos is the position of a touch or mouse event that started the scrolling.
4031 */
4032 QScrollPrepareEvent::QScrollPrepareEvent(const QPointF &startPos)
4033     : QEvent(QEvent::ScrollPrepare), m_target(0), m_startPos(startPos)
4034 {
4035 }
4036
4037 /*!
4038     Destroys QScrollEvent.
4039 */
4040 QScrollPrepareEvent::~QScrollPrepareEvent()
4041 {
4042 }
4043
4044 /*!
4045     Returns the position of the touch or mouse event that started the scrolling.
4046 */
4047 QPointF QScrollPrepareEvent::startPos() const
4048 {
4049     return m_startPos;
4050 }
4051
4052 /*!
4053     Returns size of the area that is to be scrolled as set by setViewportSize
4054
4055     \sa setViewportSize()
4056 */
4057 QSizeF QScrollPrepareEvent::viewportSize() const
4058 {
4059     return m_viewportSize;
4060 }
4061
4062 /*!
4063     Returns the range of coordinates for the content as set by setContentPosRange().
4064 */
4065 QRectF QScrollPrepareEvent::contentPosRange() const
4066 {
4067     return m_contentPosRange;
4068 }
4069
4070 /*!
4071     Returns the current position of the content as set by setContentPos.
4072 */
4073 QPointF QScrollPrepareEvent::contentPos() const
4074 {
4075     return m_contentPos;
4076 }
4077
4078
4079 /*!
4080     Sets the size of the area that is to be scrolled to \a size.
4081
4082     \sa viewportSize()
4083 */
4084 void QScrollPrepareEvent::setViewportSize(const QSizeF &size)
4085 {
4086     m_viewportSize = size;
4087 }
4088
4089 /*!
4090     Sets the range of content coordinates to \a rect.
4091
4092     \sa contentPosRange()
4093 */
4094 void QScrollPrepareEvent::setContentPosRange(const QRectF &rect)
4095 {
4096     m_contentPosRange = rect;
4097 }
4098
4099 /*!
4100     Sets the current content position to \a pos.
4101
4102     \sa contentPos()
4103 */
4104 void QScrollPrepareEvent::setContentPos(const QPointF &pos)
4105 {
4106     m_contentPos = pos;
4107 }
4108
4109
4110 /*!
4111     \class QScrollEvent
4112     \since 4.8
4113     \ingroup events
4114     \inmodule QtGui
4115
4116     \brief The QScrollEvent class is send when scrolling.
4117
4118     The scroll event is send to indicate that the receiver should be scrolled.
4119     Usually the receiver should be something visual like QWidget or QGraphicsObject.
4120
4121     Some care should be taken that no conflicting QScrollEvents are sent from two
4122     sources. Using QScroller::scrollTo is save however.
4123
4124     \sa QScrollPrepareEvent, QScroller
4125 */
4126
4127 /*!
4128     \enum QScrollEvent::ScrollState
4129
4130     This enum describes the states a scroll event can have.
4131
4132     \value ScrollStarted Set for the first scroll event of a scroll activity.
4133
4134     \value ScrollUpdated Set for all but the first and the last scroll event of a scroll activity.
4135
4136     \value ScrollFinished Set for the last scroll event of a scroll activity.
4137
4138     \sa QScrollEvent::scrollState()
4139 */
4140
4141 /*!
4142     Creates a new QScrollEvent
4143     \a contentPos is the new content position, \a overshootDistance is the
4144     new overshoot distance while \a scrollState indicates if this scroll
4145     event is the first one, the last one or some event in between.
4146 */
4147 QScrollEvent::QScrollEvent(const QPointF &contentPos, const QPointF &overshootDistance, ScrollState scrollState)
4148     : QEvent(QEvent::Scroll), m_contentPos(contentPos), m_overshoot(overshootDistance), m_state(scrollState)
4149 {
4150 }
4151
4152 /*!
4153     Destroys QScrollEvent.
4154 */
4155 QScrollEvent::~QScrollEvent()
4156 {
4157 }
4158
4159 /*!
4160     Returns the new scroll position.
4161 */
4162 QPointF QScrollEvent::contentPos() const
4163 {
4164     return m_contentPos;
4165 }
4166
4167 /*!
4168     Returns the new overshoot distance.
4169     See QScroller for an explanation of the term overshoot.
4170
4171     \sa QScroller
4172 */
4173 QPointF QScrollEvent::overshootDistance() const
4174 {
4175     return m_overshoot;
4176 }
4177
4178 /*!
4179     Returns the current scroll state as a combination of ScrollStateFlag values.
4180     ScrollStarted (or ScrollFinished) will be set, if this scroll event is the first (or last) event in a scrolling activity.
4181     Please note that both values can be set at the same time, if the activity consists of a single QScrollEvent.
4182     All other scroll events in between will have their state set to ScrollUpdated.
4183
4184     A widget could for example revert selections when scrolling is started and stopped.
4185 */
4186 QScrollEvent::ScrollState QScrollEvent::scrollState() const
4187 {
4188     return m_state;
4189 }
4190
4191 /*!
4192     Creates a new QScreenOrientationChangeEvent
4193     \a orientation is the new orientation of the screen.
4194 */
4195 QScreenOrientationChangeEvent::QScreenOrientationChangeEvent(QScreen *screen, Qt::ScreenOrientation screenOrientation)
4196     : QEvent(QEvent::OrientationChange), m_screen(screen), m_orientation(screenOrientation)
4197 {
4198 }
4199
4200 /*!
4201     Destroys QScreenOrientationChangeEvent.
4202 */
4203 QScreenOrientationChangeEvent::~QScreenOrientationChangeEvent()
4204 {
4205 }
4206
4207 /*!
4208     Returns the screen whose orientation changed.
4209 */
4210 QScreen *QScreenOrientationChangeEvent::screen() const
4211 {
4212     return m_screen;
4213 }
4214
4215 /*!
4216     Returns the orientation of the screen.
4217 */
4218 Qt::ScreenOrientation QScreenOrientationChangeEvent::orientation() const
4219 {
4220     return m_orientation;
4221 }
4222
4223 QT_END_NAMESPACE