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