source: trunk/src/gui/statemachine/qguistatemachine.cpp@ 1147

Last change on this file since 1147 was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

  • Property svn:eol-style set to native
File size: 17.8 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 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** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
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** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at qt-info@nokia.com.
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#include <QtCore/qstatemachine.h>
43
44#ifndef QT_NO_STATEMACHINE
45
46#include <private/qstatemachine_p.h>
47#include <QtGui/qevent.h>
48#include <QtGui/qgraphicssceneevent.h>
49
50QT_BEGIN_NAMESPACE
51
52Q_CORE_EXPORT const QStateMachinePrivate::Handler *qcoreStateMachineHandler();
53
54static QEvent *cloneEvent(QEvent *e)
55{
56 switch (e->type()) {
57 case QEvent::MouseButtonPress:
58 case QEvent::MouseButtonRelease:
59 case QEvent::MouseButtonDblClick:
60 case QEvent::MouseMove:
61 return new QMouseEvent(*static_cast<QMouseEvent*>(e));
62 case QEvent::KeyPress:
63 case QEvent::KeyRelease:
64 return new QKeyEvent(*static_cast<QKeyEvent*>(e));
65 case QEvent::FocusIn:
66 case QEvent::FocusOut:
67 return new QFocusEvent(*static_cast<QFocusEvent*>(e));
68 case QEvent::Enter:
69 return new QEvent(*e);
70 case QEvent::Leave:
71 return new QEvent(*e);
72 break;
73 case QEvent::Paint:
74 Q_ASSERT_X(false, "cloneEvent()", "not implemented");
75 break;
76 case QEvent::Move:
77 return new QMoveEvent(*static_cast<QMoveEvent*>(e));
78 case QEvent::Resize:
79 return new QResizeEvent(*static_cast<QResizeEvent*>(e));
80 case QEvent::Create:
81 Q_ASSERT_X(false, "cloneEvent()", "not implemented");
82 break;
83 case QEvent::Destroy:
84 Q_ASSERT_X(false, "cloneEvent()", "not implemented");
85 break;
86 case QEvent::Show:
87 return new QShowEvent(*static_cast<QShowEvent*>(e));
88 case QEvent::Hide:
89 return new QHideEvent(*static_cast<QHideEvent*>(e));
90 case QEvent::Close:
91 return new QCloseEvent(*static_cast<QCloseEvent*>(e));
92 case QEvent::Quit:
93 return new QEvent(*e);
94 case QEvent::ParentChange:
95 return new QEvent(*e);
96 case QEvent::ParentAboutToChange:
97 return new QEvent(*e);
98 case QEvent::ThreadChange:
99 return new QEvent(*e);
100
101 case QEvent::WindowActivate:
102 case QEvent::WindowDeactivate:
103 return new QEvent(*e);
104
105 case QEvent::ShowToParent:
106 return new QEvent(*e);
107 case QEvent::HideToParent:
108 return new QEvent(*e);
109#ifndef QT_NO_WHEELEVENT
110 case QEvent::Wheel:
111 return new QWheelEvent(*static_cast<QWheelEvent*>(e));
112#endif //QT_NO_WHEELEVENT
113 case QEvent::WindowTitleChange:
114 return new QEvent(*e);
115 case QEvent::WindowIconChange:
116 return new QEvent(*e);
117 case QEvent::ApplicationWindowIconChange:
118 return new QEvent(*e);
119 case QEvent::ApplicationFontChange:
120 return new QEvent(*e);
121 case QEvent::ApplicationLayoutDirectionChange:
122 return new QEvent(*e);
123 case QEvent::ApplicationPaletteChange:
124 return new QEvent(*e);
125 case QEvent::PaletteChange:
126 return new QEvent(*e);
127 case QEvent::Clipboard:
128 Q_ASSERT_X(false, "cloneEvent()", "not implemented");
129 break;
130 case QEvent::Speech:
131 Q_ASSERT_X(false, "cloneEvent()", "not implemented");
132 break;
133 case QEvent::MetaCall:
134 Q_ASSERT_X(false, "cloneEvent()", "not implemented");
135 break;
136 case QEvent::SockAct:
137 return new QEvent(*e);
138 case QEvent::WinEventAct:
139 return new QEvent(*e);
140 case QEvent::DeferredDelete:
141 return new QEvent(*e);
142#ifndef QT_NO_DRAGANDDROP
143 case QEvent::DragEnter:
144 return new QDragEnterEvent(*static_cast<QDragEnterEvent*>(e));
145 case QEvent::DragMove:
146 return new QDragMoveEvent(*static_cast<QDragMoveEvent*>(e));
147 case QEvent::DragLeave:
148 return new QDragLeaveEvent(*static_cast<QDragLeaveEvent*>(e));
149 case QEvent::Drop:
150 return new QDropEvent(*static_cast<QDragMoveEvent*>(e));
151 case QEvent::DragResponse:
152 return new QDragResponseEvent(*static_cast<QDragResponseEvent*>(e));
153#endif
154 case QEvent::ChildAdded:
155 return new QChildEvent(*static_cast<QChildEvent*>(e));
156 case QEvent::ChildPolished:
157 return new QChildEvent(*static_cast<QChildEvent*>(e));
158#ifdef QT3_SUPPORT
159 case QEvent::ChildInsertedRequest:
160 return new QEvent(*e);
161 case QEvent::ChildInserted:
162 return new QChildEvent(*static_cast<QChildEvent*>(e));
163 case QEvent::LayoutHint:
164 Q_ASSERT_X(false, "cloneEvent()", "not implemented");
165 break;
166#endif
167 case QEvent::ChildRemoved:
168 return new QChildEvent(*static_cast<QChildEvent*>(e));
169 case QEvent::ShowWindowRequest:
170 return new QEvent(*e);
171 case QEvent::PolishRequest:
172 return new QEvent(*e);
173 case QEvent::Polish:
174 return new QEvent(*e);
175 case QEvent::LayoutRequest:
176 return new QEvent(*e);
177 case QEvent::UpdateRequest:
178 return new QEvent(*e);
179 case QEvent::UpdateLater:
180 return new QEvent(*e);
181
182 case QEvent::EmbeddingControl:
183 return new QEvent(*e);
184 case QEvent::ActivateControl:
185 return new QEvent(*e);
186 case QEvent::DeactivateControl:
187 return new QEvent(*e);
188
189#ifndef QT_NO_CONTEXTMENU
190 case QEvent::ContextMenu:
191 return new QContextMenuEvent(*static_cast<QContextMenuEvent*>(e));
192#endif
193 case QEvent::InputMethod:
194 return new QInputMethodEvent(*static_cast<QInputMethodEvent*>(e));
195 case QEvent::AccessibilityPrepare:
196 return new QEvent(*e);
197#ifndef QT_NO_TABLETEVENT
198 case QEvent::TabletMove:
199 return new QTabletEvent(*static_cast<QTabletEvent*>(e));
200#endif //QT_NO_TABLETEVENT
201 case QEvent::LocaleChange:
202 return new QEvent(*e);
203 case QEvent::LanguageChange:
204 return new QEvent(*e);
205 case QEvent::LayoutDirectionChange:
206 return new QEvent(*e);
207 case QEvent::Style:
208 return new QEvent(*e);
209#ifndef QT_NO_TABLETEVENT
210 case QEvent::TabletPress:
211 return new QTabletEvent(*static_cast<QTabletEvent*>(e));
212 case QEvent::TabletRelease:
213 return new QTabletEvent(*static_cast<QTabletEvent*>(e));
214#endif //QT_NO_TABLETEVENT
215 case QEvent::OkRequest:
216 return new QEvent(*e);
217 case QEvent::HelpRequest:
218 return new QEvent(*e);
219
220 case QEvent::IconDrag:
221 return new QIconDragEvent(*static_cast<QIconDragEvent*>(e));
222
223 case QEvent::FontChange:
224 return new QEvent(*e);
225 case QEvent::EnabledChange:
226 return new QEvent(*e);
227 case QEvent::ActivationChange:
228 return new QEvent(*e);
229 case QEvent::StyleChange:
230 return new QEvent(*e);
231 case QEvent::IconTextChange:
232 return new QEvent(*e);
233 case QEvent::ModifiedChange:
234 return new QEvent(*e);
235 case QEvent::MouseTrackingChange:
236 return new QEvent(*e);
237
238 case QEvent::WindowBlocked:
239 return new QEvent(*e);
240 case QEvent::WindowUnblocked:
241 return new QEvent(*e);
242 case QEvent::WindowStateChange:
243 return new QWindowStateChangeEvent(*static_cast<QWindowStateChangeEvent*>(e));
244
245 case QEvent::ToolTip:
246 return new QHelpEvent(*static_cast<QHelpEvent*>(e));
247 case QEvent::WhatsThis:
248 return new QHelpEvent(*static_cast<QHelpEvent*>(e));
249#ifndef QT_NO_STATUSTIP
250 case QEvent::StatusTip:
251 return new QStatusTipEvent(*static_cast<QStatusTipEvent*>(e));
252#endif //QT_NO_STATUSTIP
253#ifndef QT_NO_ACTION
254 case QEvent::ActionChanged:
255 case QEvent::ActionAdded:
256 case QEvent::ActionRemoved:
257 return new QActionEvent(*static_cast<QActionEvent*>(e));
258#endif
259 case QEvent::FileOpen:
260 return new QFileOpenEvent(*static_cast<QFileOpenEvent*>(e));
261
262#ifndef QT_NO_SHORTCUT
263 case QEvent::Shortcut:
264 return new QShortcutEvent(*static_cast<QShortcutEvent*>(e));
265#endif //QT_NO_SHORTCUT
266 case QEvent::ShortcutOverride:
267 return new QKeyEvent(*static_cast<QKeyEvent*>(e));
268
269#ifdef QT3_SUPPORT
270 case QEvent::Accel:
271 Q_ASSERT_X(false, "cloneEvent()", "not implemented");
272 break;
273 case QEvent::AccelAvailable:
274 Q_ASSERT_X(false, "cloneEvent()", "not implemented");
275 break;
276#endif
277
278#ifndef QT_NO_WHATSTHIS
279 case QEvent::WhatsThisClicked:
280 return new QWhatsThisClickedEvent(*static_cast<QWhatsThisClickedEvent*>(e));
281#endif //QT_NO_WHATSTHIS
282
283#ifndef QT_NO_TOOLBAR
284 case QEvent::ToolBarChange:
285 return new QToolBarChangeEvent(*static_cast<QToolBarChangeEvent*>(e));
286#endif //QT_NO_TOOLBAR
287
288 case QEvent::ApplicationActivate:
289 return new QEvent(*e);
290 case QEvent::ApplicationDeactivate:
291 return new QEvent(*e);
292
293 case QEvent::QueryWhatsThis:
294 return new QHelpEvent(*static_cast<QHelpEvent*>(e));
295 case QEvent::EnterWhatsThisMode:
296 return new QEvent(*e);
297 case QEvent::LeaveWhatsThisMode:
298 return new QEvent(*e);
299
300 case QEvent::ZOrderChange:
301 return new QEvent(*e);
302
303 case QEvent::HoverEnter:
304 case QEvent::HoverLeave:
305 case QEvent::HoverMove:
306 return new QHoverEvent(*static_cast<QHoverEvent*>(e));
307
308 case QEvent::AccessibilityHelp:
309 Q_ASSERT_X(false, "cloneEvent()", "not implemented");
310 break;
311 case QEvent::AccessibilityDescription:
312 Q_ASSERT_X(false, "cloneEvent()", "not implemented");
313 break;
314
315#ifdef QT_KEYPAD_NAVIGATION
316 case QEvent::EnterEditFocus:
317 return new QEvent(*e);
318 case QEvent::LeaveEditFocus:
319 return new QEvent(*e);
320#endif
321 case QEvent::AcceptDropsChange:
322 return new QEvent(*e);
323
324#ifdef QT3_SUPPORT
325 case QEvent::MenubarUpdated:
326 return new QMenubarUpdatedEvent(*static_cast<QMenubarUpdatedEvent*>(e));
327#endif
328
329 case QEvent::ZeroTimerEvent:
330 Q_ASSERT_X(false, "cloneEvent()", "not implemented");
331 break;
332#ifndef QT_NO_GRAPHICSVIEW
333 case QEvent::GraphicsSceneMouseMove:
334 case QEvent::GraphicsSceneMousePress:
335 case QEvent::GraphicsSceneMouseRelease:
336 case QEvent::GraphicsSceneMouseDoubleClick: {
337 QGraphicsSceneMouseEvent *me = static_cast<QGraphicsSceneMouseEvent*>(e);
338 QGraphicsSceneMouseEvent *me2 = new QGraphicsSceneMouseEvent(me->type());
339 me2->setWidget(me->widget());
340 me2->setPos(me->pos());
341 me2->setScenePos(me->scenePos());
342 me2->setScreenPos(me->screenPos());
343// ### for all buttons
344 me2->setButtonDownPos(Qt::LeftButton, me->buttonDownPos(Qt::LeftButton));
345 me2->setButtonDownPos(Qt::RightButton, me->buttonDownPos(Qt::RightButton));
346 me2->setButtonDownScreenPos(Qt::LeftButton, me->buttonDownScreenPos(Qt::LeftButton));
347 me2->setButtonDownScreenPos(Qt::RightButton, me->buttonDownScreenPos(Qt::RightButton));
348 me2->setLastPos(me->lastPos());
349 me2->setLastScenePos(me->lastScenePos());
350 me2->setLastScreenPos(me->lastScreenPos());
351 me2->setButtons(me->buttons());
352 me2->setButton(me->button());
353 me2->setModifiers(me->modifiers());
354 return me2;
355 }
356
357 case QEvent::GraphicsSceneContextMenu: {
358 QGraphicsSceneContextMenuEvent *me = static_cast<QGraphicsSceneContextMenuEvent*>(e);
359 QGraphicsSceneContextMenuEvent *me2 = new QGraphicsSceneContextMenuEvent(me->type());
360 me2->setWidget(me->widget());
361 me2->setPos(me->pos());
362 me2->setScenePos(me->scenePos());
363 me2->setScreenPos(me->screenPos());
364 me2->setModifiers(me->modifiers());
365 me2->setReason(me->reason());
366 return me2;
367 }
368
369 case QEvent::GraphicsSceneHoverEnter:
370 case QEvent::GraphicsSceneHoverMove:
371 case QEvent::GraphicsSceneHoverLeave: {
372 QGraphicsSceneHoverEvent *he = static_cast<QGraphicsSceneHoverEvent*>(e);
373 QGraphicsSceneHoverEvent *he2 = new QGraphicsSceneHoverEvent(he->type());
374 he2->setPos(he->pos());
375 he2->setScenePos(he->scenePos());
376 he2->setScreenPos(he->screenPos());
377 he2->setLastPos(he->lastPos());
378 he2->setLastScenePos(he->lastScenePos());
379 he2->setLastScreenPos(he->lastScreenPos());
380 he2->setModifiers(he->modifiers());
381 return he2;
382 }
383 case QEvent::GraphicsSceneHelp:
384 return new QHelpEvent(*static_cast<QHelpEvent*>(e));
385 case QEvent::GraphicsSceneDragEnter:
386 case QEvent::GraphicsSceneDragMove:
387 case QEvent::GraphicsSceneDragLeave:
388 case QEvent::GraphicsSceneDrop: {
389 QGraphicsSceneDragDropEvent *dde = static_cast<QGraphicsSceneDragDropEvent*>(e);
390 QGraphicsSceneDragDropEvent *dde2 = new QGraphicsSceneDragDropEvent(dde->type());
391 dde2->setPos(dde->pos());
392 dde2->setScenePos(dde->scenePos());
393 dde2->setScreenPos(dde->screenPos());
394 dde2->setButtons(dde->buttons());
395 dde2->setModifiers(dde->modifiers());
396 return dde2;
397 }
398 case QEvent::GraphicsSceneWheel: {
399 QGraphicsSceneWheelEvent *we = static_cast<QGraphicsSceneWheelEvent*>(e);
400 QGraphicsSceneWheelEvent *we2 = new QGraphicsSceneWheelEvent(we->type());
401 we2->setPos(we->pos());
402 we2->setScenePos(we->scenePos());
403 we2->setScreenPos(we->screenPos());
404 we2->setButtons(we->buttons());
405 we2->setModifiers(we->modifiers());
406 we2->setOrientation(we->orientation());
407 return we2;
408 }
409#endif
410 case QEvent::KeyboardLayoutChange:
411 return new QEvent(*e);
412
413 case QEvent::DynamicPropertyChange:
414 return new QDynamicPropertyChangeEvent(*static_cast<QDynamicPropertyChangeEvent*>(e));
415
416#ifndef QT_NO_TABLETEVENT
417 case QEvent::TabletEnterProximity:
418 case QEvent::TabletLeaveProximity:
419 return new QTabletEvent(*static_cast<QTabletEvent*>(e));
420#endif //QT_NO_TABLETEVENT
421
422 case QEvent::NonClientAreaMouseMove:
423 case QEvent::NonClientAreaMouseButtonPress:
424 case QEvent::NonClientAreaMouseButtonRelease:
425 case QEvent::NonClientAreaMouseButtonDblClick:
426 return new QMouseEvent(*static_cast<QMouseEvent*>(e));
427
428 case QEvent::MacSizeChange:
429 return new QEvent(*e);
430
431 case QEvent::ContentsRectChange:
432 return new QEvent(*e);
433
434 case QEvent::MacGLWindowChange:
435 return new QEvent(*e);
436
437 case QEvent::FutureCallOut:
438 Q_ASSERT_X(false, "cloneEvent()", "not implemented");
439 break;
440#ifndef QT_NO_GRAPHICSVIEW
441 case QEvent::GraphicsSceneResize: {
442 QGraphicsSceneResizeEvent *re = static_cast<QGraphicsSceneResizeEvent*>(e);
443 QGraphicsSceneResizeEvent *re2 = new QGraphicsSceneResizeEvent();
444 re2->setOldSize(re->oldSize());
445 re2->setNewSize(re->newSize());
446 return re2;
447 }
448 case QEvent::GraphicsSceneMove: {
449 QGraphicsSceneMoveEvent *me = static_cast<QGraphicsSceneMoveEvent*>(e);
450 QGraphicsSceneMoveEvent *me2 = new QGraphicsSceneMoveEvent();
451 me2->setWidget(me->widget());
452 me2->setNewPos(me->newPos());
453 me2->setOldPos(me->oldPos());
454 return me2;
455 }
456#endif
457 case QEvent::CursorChange:
458 return new QEvent(*e);
459 case QEvent::ToolTipChange:
460 return new QEvent(*e);
461
462 case QEvent::NetworkReplyUpdated:
463 Q_ASSERT_X(false, "cloneEvent()", "not implemented");
464 break;
465
466 case QEvent::GrabMouse:
467 case QEvent::UngrabMouse:
468 case QEvent::GrabKeyboard:
469 case QEvent::UngrabKeyboard:
470 return new QEvent(*e);
471
472 case QEvent::TouchBegin:
473 case QEvent::TouchUpdate:
474 case QEvent::TouchEnd:
475 return new QTouchEvent(*static_cast<QTouchEvent*>(e));
476
477#ifndef QT_NO_GESTURES
478 case QEvent::NativeGesture:
479 Q_ASSERT_X(false, "cloneEvent()", "not implemented");
480 break;
481#endif
482
483 case QEvent::RequestSoftwareInputPanel:
484 case QEvent::CloseSoftwareInputPanel:
485 return new QEvent(*e);
486
487 case QEvent::UpdateSoftKeys:
488 return new QEvent(*e);
489
490 case QEvent::User:
491 case QEvent::MaxUser:
492 Q_ASSERT_X(false, "cloneEvent()", "not implemented");
493 break;
494 default:
495 ;
496 }
497 return qcoreStateMachineHandler()->cloneEvent(e);
498}
499
500const QStateMachinePrivate::Handler qt_gui_statemachine_handler = {
501 cloneEvent
502};
503
504static const QStateMachinePrivate::Handler *qt_guistatemachine_last_handler = 0;
505int qRegisterGuiStateMachine()
506{
507 qt_guistatemachine_last_handler = QStateMachinePrivate::handler;
508 QStateMachinePrivate::handler = &qt_gui_statemachine_handler;
509 return 1;
510}
511Q_CONSTRUCTOR_FUNCTION(qRegisterGuiStateMachine)
512
513int qUnregisterGuiStateMachine()
514{
515 QStateMachinePrivate::handler = qt_guistatemachine_last_handler;
516 return 1;
517}
518Q_DESTRUCTOR_FUNCTION(qUnregisterGuiStateMachine)
519
520QT_END_NAMESPACE
521
522#endif //QT_NO_STATEMACHINE
Note: See TracBrowser for help on using the repository browser.