Line | Source Code | Coverage |
---|
1 | /**************************************************************************** | - |
2 | ** | - |
3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
4 | ** Contact: http://www.qt-project.org/legal | - |
5 | ** | - |
6 | ** This file is part of the QtCore 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 Digia. For licensing terms and | - |
14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
15 | ** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software | - |
20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
21 | ** packaging of this file. Please review the following information to | - |
22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
24 | ** | - |
25 | ** In addition, as a special exception, Digia gives you certain additional | - |
26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
28 | ** | - |
29 | ** GNU General Public License Usage | - |
30 | ** Alternatively, this file may be used under the terms of the GNU | - |
31 | ** General Public License version 3.0 as published by the Free Software | - |
32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
33 | ** packaging of this file. Please review the following information to | - |
34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
36 | ** | - |
37 | ** | - |
38 | ** $QT_END_LICENSE$ | - |
39 | ** | - |
40 | ****************************************************************************/ | - |
41 | | - |
42 | #include "qcoreevent.h" | - |
43 | #include "qcoreapplication.h" | - |
44 | #include "qcoreapplication_p.h" | - |
45 | | - |
46 | #include "qmutex.h" | - |
47 | #include "qset.h" | - |
48 | | - |
49 | QT_BEGIN_NAMESPACE | - |
50 | | - |
51 | /*! | - |
52 | \class QEvent | - |
53 | \inmodule QtCore | - |
54 | \brief The QEvent class is the base class of all | - |
55 | event classes. Event objects contain event parameters. | - |
56 | | - |
57 | \ingroup events | - |
58 | | - |
59 | Qt's main event loop (QCoreApplication::exec()) fetches native | - |
60 | window system events from the event queue, translates them into | - |
61 | QEvents, and sends the translated events to \l{QObject}s. | - |
62 | | - |
63 | In general, events come from the underlying window system | - |
64 | (spontaneous() returns true), but it is also possible to manually | - |
65 | send events using QCoreApplication::sendEvent() and | - |
66 | QCoreApplication::postEvent() (spontaneous() returns false). | - |
67 | | - |
68 | QObjects receive events by having their QObject::event() function | - |
69 | called. The function can be reimplemented in subclasses to | - |
70 | customize event handling and add additional event types; | - |
71 | QWidget::event() is a notable example. By default, events are | - |
72 | dispatched to event handlers like QObject::timerEvent() and | - |
73 | QWidget::mouseMoveEvent(). QObject::installEventFilter() allows an | - |
74 | object to intercept events destined for another object. | - |
75 | | - |
76 | The basic QEvent contains only an event type parameter and an | - |
77 | "accept" flag. The accept flag set with accept(), and cleared | - |
78 | with ignore(). It is set by default, but don't rely on this as | - |
79 | subclasses may choose to clear it in their constructor. | - |
80 | | - |
81 | Subclasses of QEvent contain additional parameters that describe | - |
82 | the particular event. | - |
83 | | - |
84 | \sa QObject::event(), QObject::installEventFilter(), | - |
85 | QCoreApplication::sendEvent(), | - |
86 | QCoreApplication::postEvent(), QCoreApplication::processEvents() | - |
87 | */ | - |
88 | | - |
89 | | - |
90 | /*! | - |
91 | \enum QEvent::Type | - |
92 | | - |
93 | This enum type defines the valid event types in Qt. The event | - |
94 | types and the specialized classes for each type are as follows: | - |
95 | | - |
96 | \value None Not an event. | - |
97 | \value ActionAdded A new action has been added (QActionEvent). | - |
98 | \value ActionChanged An action has been changed (QActionEvent). | - |
99 | \value ActionRemoved An action has been removed (QActionEvent). | - |
100 | \value ActivationChange A widget's top-level window activation state has changed. | - |
101 | \value ApplicationActivate The application has been made available to the user. | - |
102 | \value ApplicationActivated This enum has been deprecated. Use ApplicationActivate instead. | - |
103 | \value ApplicationDeactivate The application has been suspended, and is unavailable to the user. | - |
104 | \value ApplicationFontChange The default application font has changed. | - |
105 | \value ApplicationLayoutDirectionChange The default application layout direction has changed. | - |
106 | \value ApplicationPaletteChange The default application palette has changed. | - |
107 | \value ApplicationWindowIconChange The application's icon has changed. | - |
108 | \value ChildAdded An object gets a child (QChildEvent). | - |
109 | \value ChildPolished A widget child gets polished (QChildEvent). | - |
110 | \value ChildRemoved An object loses a child (QChildEvent). | - |
111 | \value Clipboard The clipboard contents have changed (QClipboardEvent). | - |
112 | \value Close Widget was closed (QCloseEvent). | - |
113 | \value CloseSoftwareInputPanel A widget wants to close the software input panel (SIP). | - |
114 | \value ContentsRectChange The margins of the widget's content rect changed. | - |
115 | \value ContextMenu Context popup menu (QContextMenuEvent). | - |
116 | \value CursorChange The widget's cursor has changed. | - |
117 | \value DeferredDelete The object will be deleted after it has cleaned up (QDeferredDeleteEvent). | - |
118 | \value DragEnter The cursor enters a widget during a drag and drop operation (QDragEnterEvent). | - |
119 | \value DragLeave The cursor leaves a widget during a drag and drop operation (QDragLeaveEvent). | - |
120 | \value DragMove A drag and drop operation is in progress (QDragMoveEvent). | - |
121 | \value Drop A drag and drop operation is completed (QDropEvent). | - |
122 | \value DynamicPropertyChange A dynamic property was added, changed, or removed from the object. | - |
123 | \value EnabledChange Widget's enabled state has changed. | - |
124 | \value Enter Mouse enters widget's boundaries (QEnterEvent). | - |
125 | \value EnterEditFocus An editor widget gains focus for editing. QT_KEYPAD_NAVIGATION must be defined. | - |
126 | \value EnterWhatsThisMode Send to toplevel widgets when the application enters "What's This?" mode. | - |
127 | \value Expose Sent to a window when its on-screen contents are invalidated and need to be flushed from the backing store. | - |
128 | \value FileOpen File open request (QFileOpenEvent). | - |
129 | \value FocusIn Widget or Window gains keyboard focus (QFocusEvent). | - |
130 | \value FocusOut Widget or Window loses keyboard focus (QFocusEvent). | - |
131 | \value FocusAboutToChange Widget or Window focus is about to change (QFocusEvent) | - |
132 | \value FontChange Widget's font has changed. | - |
133 | \value Gesture A gesture was triggered (QGestureEvent). | - |
134 | \value GestureOverride A gesture override was triggered (QGestureEvent). | - |
135 | \value GrabKeyboard Item gains keyboard grab (QGraphicsItem only). | - |
136 | \value GrabMouse Item gains mouse grab (QGraphicsItem only). | - |
137 | \value GraphicsSceneContextMenu Context popup menu over a graphics scene (QGraphicsSceneContextMenuEvent). | - |
138 | \value GraphicsSceneDragEnter The cursor enters a graphics scene during a drag and drop operation (QGraphicsSceneDragDropEvent). | - |
139 | \value GraphicsSceneDragLeave The cursor leaves a graphics scene during a drag and drop operation (QGraphicsSceneDragDropEvent). | - |
140 | \value GraphicsSceneDragMove A drag and drop operation is in progress over a scene (QGraphicsSceneDragDropEvent). | - |
141 | \value GraphicsSceneDrop A drag and drop operation is completed over a scene (QGraphicsSceneDragDropEvent). | - |
142 | \value GraphicsSceneHelp The user requests help for a graphics scene (QHelpEvent). | - |
143 | \value GraphicsSceneHoverEnter The mouse cursor enters a hover item in a graphics scene (QGraphicsSceneHoverEvent). | - |
144 | \value GraphicsSceneHoverLeave The mouse cursor leaves a hover item in a graphics scene (QGraphicsSceneHoverEvent). | - |
145 | \value GraphicsSceneHoverMove The mouse cursor moves inside a hover item in a graphics scene (QGraphicsSceneHoverEvent). | - |
146 | \value GraphicsSceneMouseDoubleClick Mouse press again (double click) in a graphics scene (QGraphicsSceneMouseEvent). | - |
147 | \value GraphicsSceneMouseMove Move mouse in a graphics scene (QGraphicsSceneMouseEvent). | - |
148 | \value GraphicsSceneMousePress Mouse press in a graphics scene (QGraphicsSceneMouseEvent). | - |
149 | \value GraphicsSceneMouseRelease Mouse release in a graphics scene (QGraphicsSceneMouseEvent). | - |
150 | \value GraphicsSceneMove Widget was moved (QGraphicsSceneMoveEvent). | - |
151 | \value GraphicsSceneResize Widget was resized (QGraphicsSceneResizeEvent). | - |
152 | \value GraphicsSceneWheel Mouse wheel rolled in a graphics scene (QGraphicsSceneWheelEvent). | - |
153 | \value Hide Widget was hidden (QHideEvent). | - |
154 | \value HideToParent A child widget has been hidden. | - |
155 | \value HoverEnter The mouse cursor enters a hover widget (QHoverEvent). | - |
156 | \value HoverLeave The mouse cursor leaves a hover widget (QHoverEvent). | - |
157 | \value HoverMove The mouse cursor moves inside a hover widget (QHoverEvent). | - |
158 | \value IconDrag The main icon of a window has been dragged away (QIconDragEvent). | - |
159 | \value IconTextChange Widget's icon text has been changed. | - |
160 | \value InputMethod An input method is being used (QInputMethodEvent). | - |
161 | \value InputMethodQuery A input method query event (QInputMethodQueryEvent) | - |
162 | \value KeyboardLayoutChange The keyboard layout has changed. | - |
163 | \value KeyPress Key press (QKeyEvent). | - |
164 | \value KeyRelease Key release (QKeyEvent). | - |
165 | \value LanguageChange The application translation changed. | - |
166 | \value LayoutDirectionChange The direction of layouts changed. | - |
167 | \value LayoutRequest Widget layout needs to be redone. | - |
168 | \value Leave Mouse leaves widget's boundaries. | - |
169 | \value LeaveEditFocus An editor widget loses focus for editing. QT_KEYPAD_NAVIGATION must be defined. | - |
170 | \value LeaveWhatsThisMode Send to toplevel widgets when the application leaves "What's This?" mode. | - |
171 | \value LocaleChange The system locale has changed. | - |
172 | \value NonClientAreaMouseButtonDblClick A mouse double click occurred outside the client area. | - |
173 | \value NonClientAreaMouseButtonPress A mouse button press occurred outside the client area. | - |
174 | \value NonClientAreaMouseButtonRelease A mouse button release occurred outside the client area. | - |
175 | \value NonClientAreaMouseMove A mouse move occurred outside the client area. | - |
176 | \value MacSizeChange The user changed his widget sizes (Mac OS X only). | - |
177 | \value MetaCall An asynchronous method invocation via QMetaObject::invokeMethod(). | - |
178 | \value ModifiedChange Widgets modification state has been changed. | - |
179 | \value MouseButtonDblClick Mouse press again (QMouseEvent). | - |
180 | \value MouseButtonPress Mouse press (QMouseEvent). | - |
181 | \value MouseButtonRelease Mouse release (QMouseEvent). | - |
182 | \value MouseMove Mouse move (QMouseEvent). | - |
183 | \value MouseTrackingChange The mouse tracking state has changed. | - |
184 | \value Move Widget's position changed (QMoveEvent). | - |
185 | \value OrientationChange The screens orientation has changes (QScreenOrientationChangeEvent) | - |
186 | \value Paint Screen update necessary (QPaintEvent). | - |
187 | \value PaletteChange Palette of the widget changed. | - |
188 | \value ParentAboutToChange The widget parent is about to change. | - |
189 | \value ParentChange The widget parent has changed. | - |
190 | \value PlatformPanel A platform specific panel has been requested. | - |
191 | \value Polish The widget is polished. | - |
192 | \value PolishRequest The widget should be polished. | - |
193 | \value QueryWhatsThis The widget should accept the event if it has "What's This?" help. | - |
194 | \value RequestSoftwareInputPanel A widget wants to open a software input panel (SIP). | - |
195 | \value Resize Widget's size changed (QResizeEvent). | - |
196 | \value ScrollPrepare The object needs to fill in its geometry information (QScrollPrepareEvent). | - |
197 | \value Scroll The object needs to scroll to the supplied position (QScrollEvent). | - |
198 | \value Shortcut Key press in child for shortcut key handling (QShortcutEvent). | - |
199 | \value ShortcutOverride Key press in child, for overriding shortcut key handling (QKeyEvent). | - |
200 | \value Show Widget was shown on screen (QShowEvent). | - |
201 | \value ShowToParent A child widget has been shown. | - |
202 | \value SockAct Socket activated, used to implement QSocketNotifier. | - |
203 | \omitvalue SockClose | - |
204 | \value StateMachineSignal A signal delivered to a state machine (QStateMachine::SignalEvent). | - |
205 | \value StateMachineWrapped The event is a wrapper for, i.e., contains, another event (QStateMachine::WrappedEvent). | - |
206 | \value StatusTip A status tip is requested (QStatusTipEvent). | - |
207 | \value StyleChange Widget's style has been changed. | - |
208 | \value TabletMove Wacom tablet move (QTabletEvent). | - |
209 | \value TabletPress Wacom tablet press (QTabletEvent). | - |
210 | \value TabletRelease Wacom tablet release (QTabletEvent). | - |
211 | \value OkRequest Ok button in decoration pressed. Supported only for Windows CE. | - |
212 | \value TabletEnterProximity Wacom tablet enter proximity event (QTabletEvent), sent to QApplication. | - |
213 | \value TabletLeaveProximity Wacom tablet leave proximity event (QTabletEvent), sent to QApplication. | - |
214 | \omitvalue ThemeChange | - |
215 | \value ThreadChange The object is moved to another thread. This is the last event sent to this object in the previous thread. See QObject::moveToThread(). | - |
216 | \value Timer Regular timer events (QTimerEvent). | - |
217 | \value ToolBarChange The toolbar button is toggled on Mac OS X. | - |
218 | \value ToolTip A tooltip was requested (QHelpEvent). | - |
219 | \value ToolTipChange The widget's tooltip has changed. | - |
220 | \value TouchBegin Beginning of a sequence of touch-screen or track-pad events (QTouchEvent). | - |
221 | \value TouchCancel Cancellation of touch-event sequence (QTouchEvent). | - |
222 | \value TouchEnd End of touch-event sequence (QTouchEvent). | - |
223 | \value TouchUpdate Touch-screen event (QTouchEvent). | - |
224 | \value UngrabKeyboard Item loses keyboard grab (QGraphicsItem only). | - |
225 | \value UngrabMouse Item loses mouse grab (QGraphicsItem only). | - |
226 | \value UpdateLater The widget should be queued to be repainted at a later time. | - |
227 | \value UpdateRequest The widget should be repainted. | - |
228 | \value WhatsThis The widget should reveal "What's This?" help (QHelpEvent). | - |
229 | \value WhatsThisClicked A link in a widget's "What's This?" help was clicked. | - |
230 | \value Wheel Mouse wheel rolled (QWheelEvent). | - |
231 | \value WinEventAct A Windows-specific activation event has occurred. | - |
232 | \value WindowActivate Window was activated. | - |
233 | \value WindowBlocked The window is blocked by a modal dialog. | - |
234 | \value WindowDeactivate Window was deactivated. | - |
235 | \value WindowIconChange The window's icon has changed. | - |
236 | \value WindowStateChange The \l{QWindow::windowState()}{window's state} (minimized, maximized or full-screen) has changed (QWindowStateChangeEvent). | - |
237 | \value WindowTitleChange The window title has changed. | - |
238 | \value WindowUnblocked The window is unblocked after a modal dialog exited. | - |
239 | \value WinIdChange The window system identifer for this native widget has changed. | - |
240 | \value ZOrderChange The widget's z-order has changed. This event is never sent to top level windows. | - |
241 | | - |
242 | User events should have values between \c User and \c{MaxUser}: | - |
243 | | - |
244 | \value User User-defined event. | - |
245 | \value MaxUser Last user event ID. | - |
246 | | - |
247 | For convenience, you can use the registerEventType() function to | - |
248 | register and reserve a custom event type for your | - |
249 | application. Doing so will allow you to avoid accidentally | - |
250 | re-using a custom event type already in use elsewhere in your | - |
251 | application. | - |
252 | | - |
253 | \omitvalue AcceptDropsChange | - |
254 | \omitvalue ActivateControl | - |
255 | \omitvalue Create | - |
256 | \omitvalue DeactivateControl | - |
257 | \omitvalue Destroy | - |
258 | \omitvalue DragResponse | - |
259 | \omitvalue EmbeddingControl | - |
260 | \omitvalue HelpRequest | - |
261 | \omitvalue Quit | - |
262 | \omitvalue ShowWindowRequest | - |
263 | \omitvalue Speech | - |
264 | \omitvalue Style | - |
265 | \omitvalue StyleAnimationUpdate | - |
266 | \omitvalue ZeroTimerEvent | - |
267 | \omitvalue ApplicationActivated | - |
268 | \omitvalue ApplicationDeactivated | - |
269 | \omitvalue MacGLWindowChange | - |
270 | \omitvalue MacGLClearDrawable | - |
271 | \omitvalue NetworkReplyUpdated | - |
272 | \omitvalue FutureCallOut | - |
273 | \omitvalue NativeGesture | - |
274 | */ | - |
275 | | - |
276 | /*! | - |
277 | Contructs an event object of type \a type. | - |
278 | */ | - |
279 | QEvent::QEvent(Type type) | - |
280 | : d(0), t(type), posted(false), spont(false), m_accept(true) | - |
281 | {} executed: } Execution Count:2951276 | 2951276 |
282 | | - |
283 | /*! | - |
284 | \internal | - |
285 | Attempts to copy the \a other event. | - |
286 | | - |
287 | Copying events is a bad idea, yet some Qt 4 code does it (notably, | - |
288 | QApplication and the state machine). | - |
289 | */ | - |
290 | QEvent::QEvent(const QEvent &other) | - |
291 | : d(other.d), t(other.t), posted(other.posted), spont(other.spont), | - |
292 | m_accept(other.m_accept) | - |
293 | { | - |
294 | // if QEventPrivate becomes available, make sure to implement a | - |
295 | // virtual QEventPrivate *clone() const; function so we can copy here | - |
296 | Q_ASSERT_X(!d, "QEvent", "Impossible, this can't happen: QEventPrivate isn't defined anywhere"); executed (the execution status of this line is deduced): qt_noop(); | - |
297 | } executed: } Execution Count:27 | 27 |
298 | | - |
299 | /*! | - |
300 | \internal | - |
301 | Attempts to copy the \a other event. | - |
302 | | - |
303 | Copying events is a bad idea, yet some Qt 4 code does it (notably, | - |
304 | QApplication and the state machine). | - |
305 | */ | - |
306 | QEvent &QEvent::operator=(const QEvent &other) | - |
307 | { | - |
308 | // if QEventPrivate becomes available, make sure to implement a | - |
309 | // virtual QEventPrivate *clone() const; function so we can copy here | - |
310 | Q_ASSERT_X(!other.d, "QEvent", "Impossible, this can't happen: QEventPrivate isn't defined anywhere"); executed (the execution status of this line is deduced): qt_noop(); | - |
311 | | - |
312 | t = other.t; executed (the execution status of this line is deduced): t = other.t; | - |
313 | posted = other.posted; executed (the execution status of this line is deduced): posted = other.posted; | - |
314 | spont = other.spont; executed (the execution status of this line is deduced): spont = other.spont; | - |
315 | m_accept = other.m_accept; executed (the execution status of this line is deduced): m_accept = other.m_accept; | - |
316 | return *this; executed: return *this; Execution Count:11445 | 11445 |
317 | } | - |
318 | | - |
319 | /*! | - |
320 | Destroys the event. If it was \l{QCoreApplication::postEvent()}{posted}, | - |
321 | it will be removed from the list of events to be posted. | - |
322 | */ | - |
323 | | - |
324 | QEvent::~QEvent() | - |
325 | { | - |
326 | if (posted && QCoreApplication::instance()) partially evaluated: posted no Evaluation Count:0 | yes Evaluation Count:2939505 |
never evaluated: QCoreApplication::instance() | 0-2939505 |
327 | QCoreApplicationPrivate::removePostedEvent(this); never executed: QCoreApplicationPrivate::removePostedEvent(this); | 0 |
328 | Q_ASSERT_X(!d, "QEvent", "Impossible, this can't happen: QEventPrivate isn't defined anywhere"); executed (the execution status of this line is deduced): qt_noop(); | - |
329 | } executed: } Execution Count:2939329 | 2939329 |
330 | | - |
331 | | - |
332 | /*! | - |
333 | \property QEvent::accepted | - |
334 | the accept flag of the event object | - |
335 | | - |
336 | Setting the accept parameter indicates that the event receiver | - |
337 | wants the event. Unwanted events might be propagated to the parent | - |
338 | widget. By default, isAccepted() is set to true, but don't rely on | - |
339 | this as subclasses may choose to clear it in their constructor. | - |
340 | | - |
341 | For convenience, the accept flag can also be set with accept(), | - |
342 | and cleared with ignore(). | - |
343 | */ | - |
344 | | - |
345 | /*! | - |
346 | \fn void QEvent::accept() | - |
347 | | - |
348 | Sets the accept flag of the event object, the equivalent of | - |
349 | calling setAccepted(true). | - |
350 | | - |
351 | Setting the accept parameter indicates that the event receiver | - |
352 | wants the event. Unwanted events might be propagated to the parent | - |
353 | widget. | - |
354 | | - |
355 | \sa ignore() | - |
356 | */ | - |
357 | | - |
358 | | - |
359 | /*! | - |
360 | \fn void QEvent::ignore() | - |
361 | | - |
362 | Clears the accept flag parameter of the event object, the | - |
363 | equivalent of calling setAccepted(false). | - |
364 | | - |
365 | Clearing the accept parameter indicates that the event receiver | - |
366 | does not want the event. Unwanted events might be propagated to the | - |
367 | parent widget. | - |
368 | | - |
369 | \sa accept() | - |
370 | */ | - |
371 | | - |
372 | | - |
373 | /*! | - |
374 | \fn QEvent::Type QEvent::type() const | - |
375 | | - |
376 | Returns the event type. | - |
377 | */ | - |
378 | | - |
379 | /*! | - |
380 | \fn bool QEvent::spontaneous() const | - |
381 | | - |
382 | Returns true if the event originated outside the application (a | - |
383 | system event); otherwise returns false. | - |
384 | | - |
385 | The return value of this function is not defined for paint events. | - |
386 | */ | - |
387 | | - |
388 | class QEventUserEventRegistration | - |
389 | { | - |
390 | public: | - |
391 | QMutex mutex; | - |
392 | QSet<int> set; | - |
393 | }; | - |
394 | Q_GLOBAL_STATIC(QEventUserEventRegistration, userEventRegistrationHelper) never executed: delete x; executed: return thisGlobalStatic.pointer.load(); Execution Count:5 partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x) no Evaluation Count:0 | yes Evaluation Count:2 |
evaluated: !thisGlobalStatic.pointer.load() yes Evaluation Count:2 | yes Evaluation Count:3 |
partially evaluated: !thisGlobalStatic.destroyed yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-5 |
395 | | - |
396 | /*! | - |
397 | \since 4.4 | - |
398 | \threadsafe | - |
399 | | - |
400 | Registers and returns a custom event type. The \a hint provided | - |
401 | will be used if it is available, otherwise it will return a value | - |
402 | between QEvent::User and QEvent::MaxUser that has not yet been | - |
403 | registered. The \a hint is ignored if its value is not between | - |
404 | QEvent::User and QEvent::MaxUser. | - |
405 | */ | - |
406 | int QEvent::registerEventType(int hint) | - |
407 | { | - |
408 | QEventUserEventRegistration *userEventRegistration executed (the execution status of this line is deduced): QEventUserEventRegistration *userEventRegistration | - |
409 | = userEventRegistrationHelper(); executed (the execution status of this line is deduced): = userEventRegistrationHelper(); | - |
410 | if (!userEventRegistration) partially evaluated: !userEventRegistration no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
411 | return -1; never executed: return -1; | 0 |
412 | | - |
413 | QMutexLocker locker(&userEventRegistration->mutex); executed (the execution status of this line is deduced): QMutexLocker locker(&userEventRegistration->mutex); | - |
414 | | - |
415 | // if the type hint hasn't been registered yet, take it | - |
416 | if (hint >= QEvent::User && hint <= QEvent::MaxUser && !userEventRegistration->set.contains(hint)) { evaluated: hint >= QEvent::User yes Evaluation Count:2 | yes Evaluation Count:3 |
partially evaluated: hint <= QEvent::MaxUser yes Evaluation Count:2 | no Evaluation Count:0 |
evaluated: !userEventRegistration->set.contains(hint) yes Evaluation Count:1 | yes Evaluation Count:1 |
| 0-3 |
417 | userEventRegistration->set.insert(hint); executed (the execution status of this line is deduced): userEventRegistration->set.insert(hint); | - |
418 | return hint; executed: return hint; Execution Count:1 | 1 |
419 | } | - |
420 | | - |
421 | // find a free event type, starting at MaxUser and decreasing | - |
422 | int id = QEvent::MaxUser; executed (the execution status of this line is deduced): int id = QEvent::MaxUser; | - |
423 | while (userEventRegistration->set.contains(id) && id >= QEvent::User) evaluated: userEventRegistration->set.contains(id) yes Evaluation Count:3 | yes Evaluation Count:4 |
partially evaluated: id >= QEvent::User yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-4 |
424 | --id; executed: --id; Execution Count:3 | 3 |
425 | if (id >= QEvent::User) { partially evaluated: id >= QEvent::User yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
426 | userEventRegistration->set.insert(id); executed (the execution status of this line is deduced): userEventRegistration->set.insert(id); | - |
427 | return id; executed: return id; Execution Count:4 | 4 |
428 | } | - |
429 | return -1; never executed: return -1; | 0 |
430 | } | - |
431 | | - |
432 | /*! | - |
433 | \class QTimerEvent | - |
434 | \inmodule QtCore | - |
435 | \brief The QTimerEvent class contains parameters that describe a | - |
436 | timer event. | - |
437 | | - |
438 | \ingroup events | - |
439 | | - |
440 | Timer events are sent at regular intervals to objects that have | - |
441 | started one or more timers. Each timer has a unique identifier. A | - |
442 | timer is started with QObject::startTimer(). | - |
443 | | - |
444 | The QTimer class provides a high-level programming interface that | - |
445 | uses signals instead of events. It also provides single-shot timers. | - |
446 | | - |
447 | The event handler QObject::timerEvent() receives timer events. | - |
448 | | - |
449 | \sa QTimer, QObject::timerEvent(), QObject::startTimer(), | - |
450 | QObject::killTimer() | - |
451 | */ | - |
452 | | - |
453 | /*! | - |
454 | Constructs a timer event object with the timer identifier set to | - |
455 | \a timerId. | - |
456 | */ | - |
457 | QTimerEvent::QTimerEvent(int timerId) | - |
458 | : QEvent(Timer), id(timerId) | - |
459 | {} executed: } Execution Count:42121 | 42121 |
460 | | - |
461 | /*! | - |
462 | \internal | - |
463 | */ | - |
464 | QTimerEvent::~QTimerEvent() | - |
465 | { | - |
466 | } | - |
467 | | - |
468 | /*! | - |
469 | \fn int QTimerEvent::timerId() const | - |
470 | | - |
471 | Returns the unique timer identifier, which is the same identifier | - |
472 | as returned from QObject::startTimer(). | - |
473 | */ | - |
474 | | - |
475 | /*! | - |
476 | \class QChildEvent | - |
477 | \inmodule QtCore | - |
478 | \brief The QChildEvent class contains event parameters for child object | - |
479 | events. | - |
480 | | - |
481 | \ingroup events | - |
482 | | - |
483 | Child events are sent immediately to objects when children are | - |
484 | added or removed. | - |
485 | | - |
486 | In both cases you can only rely on the child being a QObject (or, | - |
487 | if QObject::isWidgetType() returns true, a QWidget). This is | - |
488 | because in the QEvent::ChildAdded case the child is not yet fully | - |
489 | constructed; in the QEvent::ChildRemoved case it might have | - |
490 | already been destructed. | - |
491 | | - |
492 | The handler for these events is QObject::childEvent(). | - |
493 | */ | - |
494 | | - |
495 | /*! | - |
496 | Constructs a child event object of a particular \a type for the | - |
497 | \a child. | - |
498 | | - |
499 | \a type can be QEvent::ChildAdded, QEvent::ChildRemoved, | - |
500 | QEvent::ChildPolished, or QEvent::ChildRemoved. | - |
501 | | - |
502 | \sa child() | - |
503 | */ | - |
504 | QChildEvent::QChildEvent(Type type, QObject *child) | - |
505 | : QEvent(type), c(child) | - |
506 | {} executed: } Execution Count:202343 | 202343 |
507 | | - |
508 | /*! | - |
509 | \internal | - |
510 | */ | - |
511 | QChildEvent::~QChildEvent() | - |
512 | { | - |
513 | } | - |
514 | | - |
515 | /*! | - |
516 | \fn QObject *QChildEvent::child() const | - |
517 | | - |
518 | Returns the child object that was added or removed. | - |
519 | */ | - |
520 | | - |
521 | /*! | - |
522 | \fn bool QChildEvent::added() const | - |
523 | | - |
524 | Returns true if type() is QEvent::ChildAdded; otherwise returns | - |
525 | false. | - |
526 | */ | - |
527 | | - |
528 | /*! | - |
529 | \fn bool QChildEvent::removed() const | - |
530 | | - |
531 | Returns true if type() is QEvent::ChildRemoved; otherwise returns | - |
532 | false. | - |
533 | */ | - |
534 | | - |
535 | /*! | - |
536 | \fn bool QChildEvent::polished() const | - |
537 | | - |
538 | Returns true if type() is QEvent::ChildPolished; otherwise returns | - |
539 | false. | - |
540 | */ | - |
541 | | - |
542 | | - |
543 | /*! | - |
544 | \class QDynamicPropertyChangeEvent | - |
545 | \inmodule QtCore | - |
546 | \since 4.2 | - |
547 | \brief The QDynamicPropertyChangeEvent class contains event parameters for dynamic | - |
548 | property change events. | - |
549 | | - |
550 | \ingroup events | - |
551 | | - |
552 | Dynamic property change events are sent to objects when properties are | - |
553 | dynamically added, changed or removed using QObject::setProperty(). | - |
554 | */ | - |
555 | | - |
556 | /*! | - |
557 | Constructs a dynamic property change event object with the property name set to | - |
558 | \a name. | - |
559 | */ | - |
560 | QDynamicPropertyChangeEvent::QDynamicPropertyChangeEvent(const QByteArray &name) | - |
561 | : QEvent(QEvent::DynamicPropertyChange), n(name) | - |
562 | { | - |
563 | } executed: } Execution Count:3427 | 3427 |
564 | | - |
565 | /*! | - |
566 | \internal | - |
567 | */ | - |
568 | QDynamicPropertyChangeEvent::~QDynamicPropertyChangeEvent() | - |
569 | { | - |
570 | } | - |
571 | | - |
572 | /*! | - |
573 | \fn QByteArray QDynamicPropertyChangeEvent::propertyName() const | - |
574 | | - |
575 | Returns the name of the dynamic property that was added, changed or | - |
576 | removed. | - |
577 | | - |
578 | \sa QObject::setProperty(), QObject::dynamicPropertyNames() | - |
579 | */ | - |
580 | | - |
581 | /*! | - |
582 | Constructs a deferred delete event with an initial loopLevel() of zero. | - |
583 | */ | - |
584 | QDeferredDeleteEvent::QDeferredDeleteEvent() | - |
585 | : QEvent(QEvent::DeferredDelete) | - |
586 | , level(0) | - |
587 | { } executed: } Execution Count:8431 | 8431 |
588 | | - |
589 | /*! | - |
590 | \internal | - |
591 | */ | - |
592 | QDeferredDeleteEvent::~QDeferredDeleteEvent() | - |
593 | { } | - |
594 | | - |
595 | /*! \fn int QDeferredDeleteEvent::loopLevel() const | - |
596 | | - |
597 | Returns the loop-level in which the event was posted. The | - |
598 | loop-level is set by QCoreApplication::postEvent(). | - |
599 | | - |
600 | \sa QObject::deleteLater() | - |
601 | */ | - |
602 | | - |
603 | QT_END_NAMESPACE | - |
604 | | - |
| | |