| 1 | /**************************************************************************** |
|---|---|
| 2 | ** |
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. |
| 4 | ** Contact: https://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the QtWidgets module of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at https://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU Lesser General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
| 19 | ** General Public License version 3 as published by the Free Software |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
| 21 | ** packaging of this file. Please review the following information to |
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements |
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
| 24 | ** |
| 25 | ** GNU General Public License Usage |
| 26 | ** Alternatively, this file may be used under the terms of the GNU |
| 27 | ** General Public License version 2.0 or (at your option) the GNU General |
| 28 | ** Public license version 3 or any later version approved by the KDE Free |
| 29 | ** Qt Foundation. The licenses are as published by the Free Software |
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
| 31 | ** included in the packaging of this file. Please review the following |
| 32 | ** information to ensure the GNU General Public License requirements will |
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
| 35 | ** |
| 36 | ** $QT_END_LICENSE$ |
| 37 | ** |
| 38 | ****************************************************************************/ |
| 39 | |
| 40 | #include <QtGui/qevent.h> |
| 41 | #include <QtWidgets/qtwidgetsglobal.h> |
| 42 | #if QT_CONFIG(graphicsview) |
| 43 | #include <QtWidgets/qgraphicssceneevent.h> |
| 44 | #endif |
| 45 | |
| 46 | #include "private/qapplication_p.h" |
| 47 | |
| 48 | QT_BEGIN_NAMESPACE |
| 49 | |
| 50 | QEvent *QApplicationPrivate::cloneEvent(QEvent *e) |
| 51 | { |
| 52 | switch (e->type()) { |
| 53 | #if QT_CONFIG(statustip) |
| 54 | case QEvent::StatusTip: |
| 55 | return new QStatusTipEvent(*static_cast<QStatusTipEvent*>(e)); |
| 56 | #endif // QT_CONFIG(statustip) |
| 57 | |
| 58 | #if QT_CONFIG(toolbar) |
| 59 | case QEvent::ToolBarChange: |
| 60 | return new QToolBarChangeEvent(*static_cast<QToolBarChangeEvent*>(e)); |
| 61 | #endif // QT_CONFIG(toolbar) |
| 62 | |
| 63 | #if QT_CONFIG(graphicsview) |
| 64 | case QEvent::GraphicsSceneMouseMove: |
| 65 | case QEvent::GraphicsSceneMousePress: |
| 66 | case QEvent::GraphicsSceneMouseRelease: |
| 67 | case QEvent::GraphicsSceneMouseDoubleClick: { |
| 68 | QGraphicsSceneMouseEvent *me = static_cast<QGraphicsSceneMouseEvent*>(e); |
| 69 | QGraphicsSceneMouseEvent *me2 = new QGraphicsSceneMouseEvent(me->type()); |
| 70 | me2->setWidget(me->widget()); |
| 71 | me2->setPos(me->pos()); |
| 72 | me2->setScenePos(me->scenePos()); |
| 73 | me2->setScreenPos(me->screenPos()); |
| 74 | // ### for all buttons |
| 75 | me2->setButtonDownPos(Qt::LeftButton, me->buttonDownPos(Qt::LeftButton)); |
| 76 | me2->setButtonDownPos(Qt::RightButton, me->buttonDownPos(Qt::RightButton)); |
| 77 | me2->setButtonDownScreenPos(Qt::LeftButton, me->buttonDownScreenPos(Qt::LeftButton)); |
| 78 | me2->setButtonDownScreenPos(Qt::RightButton, me->buttonDownScreenPos(Qt::RightButton)); |
| 79 | me2->setLastPos(me->lastPos()); |
| 80 | me2->setLastScenePos(me->lastScenePos()); |
| 81 | me2->setLastScreenPos(me->lastScreenPos()); |
| 82 | me2->setButtons(me->buttons()); |
| 83 | me2->setButton(me->button()); |
| 84 | me2->setModifiers(me->modifiers()); |
| 85 | me2->setSource(me->source()); |
| 86 | me2->setFlags(me->flags()); |
| 87 | return me2; |
| 88 | } |
| 89 | |
| 90 | case QEvent::GraphicsSceneContextMenu: { |
| 91 | QGraphicsSceneContextMenuEvent *me = static_cast<QGraphicsSceneContextMenuEvent*>(e); |
| 92 | QGraphicsSceneContextMenuEvent *me2 = new QGraphicsSceneContextMenuEvent(me->type()); |
| 93 | me2->setWidget(me->widget()); |
| 94 | me2->setPos(me->pos()); |
| 95 | me2->setScenePos(me->scenePos()); |
| 96 | me2->setScreenPos(me->screenPos()); |
| 97 | me2->setModifiers(me->modifiers()); |
| 98 | me2->setReason(me->reason()); |
| 99 | return me2; |
| 100 | } |
| 101 | |
| 102 | case QEvent::GraphicsSceneHoverEnter: |
| 103 | case QEvent::GraphicsSceneHoverMove: |
| 104 | case QEvent::GraphicsSceneHoverLeave: { |
| 105 | QGraphicsSceneHoverEvent *he = static_cast<QGraphicsSceneHoverEvent*>(e); |
| 106 | QGraphicsSceneHoverEvent *he2 = new QGraphicsSceneHoverEvent(he->type()); |
| 107 | he2->setPos(he->pos()); |
| 108 | he2->setScenePos(he->scenePos()); |
| 109 | he2->setScreenPos(he->screenPos()); |
| 110 | he2->setLastPos(he->lastPos()); |
| 111 | he2->setLastScenePos(he->lastScenePos()); |
| 112 | he2->setLastScreenPos(he->lastScreenPos()); |
| 113 | he2->setModifiers(he->modifiers()); |
| 114 | return he2; |
| 115 | } |
| 116 | case QEvent::GraphicsSceneHelp: |
| 117 | return new QHelpEvent(*static_cast<QHelpEvent*>(e)); |
| 118 | case QEvent::GraphicsSceneDragEnter: |
| 119 | case QEvent::GraphicsSceneDragMove: |
| 120 | case QEvent::GraphicsSceneDragLeave: |
| 121 | case QEvent::GraphicsSceneDrop: { |
| 122 | QGraphicsSceneDragDropEvent *dde = static_cast<QGraphicsSceneDragDropEvent*>(e); |
| 123 | QGraphicsSceneDragDropEvent *dde2 = new QGraphicsSceneDragDropEvent(dde->type()); |
| 124 | dde2->setPos(dde->pos()); |
| 125 | dde2->setScenePos(dde->scenePos()); |
| 126 | dde2->setScreenPos(dde->screenPos()); |
| 127 | dde2->setButtons(dde->buttons()); |
| 128 | dde2->setModifiers(dde->modifiers()); |
| 129 | return dde2; |
| 130 | } |
| 131 | case QEvent::GraphicsSceneWheel: { |
| 132 | QGraphicsSceneWheelEvent *we = static_cast<QGraphicsSceneWheelEvent*>(e); |
| 133 | QGraphicsSceneWheelEvent *we2 = new QGraphicsSceneWheelEvent(we->type()); |
| 134 | we2->setPos(we->pos()); |
| 135 | we2->setScenePos(we->scenePos()); |
| 136 | we2->setScreenPos(we->screenPos()); |
| 137 | we2->setButtons(we->buttons()); |
| 138 | we2->setModifiers(we->modifiers()); |
| 139 | we2->setOrientation(we->orientation()); |
| 140 | we2->setDelta(we->delta()); |
| 141 | return we2; |
| 142 | } |
| 143 | |
| 144 | case QEvent::GraphicsSceneResize: { |
| 145 | QGraphicsSceneResizeEvent *re = static_cast<QGraphicsSceneResizeEvent*>(e); |
| 146 | QGraphicsSceneResizeEvent *re2 = new QGraphicsSceneResizeEvent(); |
| 147 | re2->setOldSize(re->oldSize()); |
| 148 | re2->setNewSize(re->newSize()); |
| 149 | return re2; |
| 150 | } |
| 151 | case QEvent::GraphicsSceneMove: { |
| 152 | QGraphicsSceneMoveEvent *me = static_cast<QGraphicsSceneMoveEvent*>(e); |
| 153 | QGraphicsSceneMoveEvent *me2 = new QGraphicsSceneMoveEvent(); |
| 154 | me2->setWidget(me->widget()); |
| 155 | me2->setNewPos(me->newPos()); |
| 156 | me2->setOldPos(me->oldPos()); |
| 157 | return me2; |
| 158 | } |
| 159 | #endif |
| 160 | default: |
| 161 | ; |
| 162 | } |
| 163 | return QApplicationPrivateBase::cloneEvent(e); |
| 164 | } |
| 165 | |
| 166 | QT_END_NAMESPACE |
| 167 |