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