OpenCoverage

qcoreevent.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/corelib/kernel/qcoreevent.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Copyright (C) 2016 Intel Corporation.-
5** Contact: https://www.qt.io/licensing/-
6**-
7** This file is part of the QtCore module of the Qt Toolkit.-
8**-
9** $QT_BEGIN_LICENSE:LGPL$-
10** Commercial License Usage-
11** Licensees holding valid commercial Qt licenses may use this file in-
12** accordance with the commercial license agreement provided with the-
13** Software or, alternatively, in accordance with the terms contained in-
14** a written agreement between you and The Qt Company. For licensing terms-
15** and conditions see https://www.qt.io/terms-conditions. For further-
16** information use the contact form at https://www.qt.io/contact-us.-
17**-
18** GNU Lesser General Public License Usage-
19** Alternatively, this file may be used under the terms of the GNU Lesser-
20** General Public License version 3 as published by the Free Software-
21** Foundation and appearing in the file LICENSE.LGPL3 included in the-
22** packaging of this file. Please review the following information to-
23** ensure the GNU Lesser General Public License version 3 requirements-
24** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
25**-
26** GNU General Public License Usage-
27** Alternatively, this file may be used under the terms of the GNU-
28** General Public License version 2.0 or (at your option) the GNU General-
29** Public license version 3 or any later version approved by the KDE Free-
30** Qt Foundation. The licenses are as published by the Free Software-
31** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
32** included in the packaging of this file. Please review the following-
33** information to ensure the GNU General Public License requirements will-
34** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
35** https://www.gnu.org/licenses/gpl-3.0.html.-
36**-
37** $QT_END_LICENSE$-
38**-
39****************************************************************************/-
40-
41#include "qcoreevent.h"-
42#include "qcoreapplication.h"-
43#include "qcoreapplication_p.h"-
44-
45#include "qbasicatomic.h"-
46-
47#include <limits>-
48-
49QT_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 \c true), but it is also possible to manually-
65 send events using QCoreApplication::sendEvent() and-
66 QCoreApplication::postEvent() (spontaneous() returns \c false).-
67-
68 \l {QObject}{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 This enum has been deprecated. Use ApplicationStateChange instead.-
102 \value ApplicationActivated This enum has been deprecated. Use ApplicationStateChange instead.-
103 \value ApplicationDeactivate This enum has been deprecated. Use ApplicationStateChange instead.-
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 ApplicationStateChange The state of the application has changed.-
108 \value ApplicationWindowIconChange The application's icon has changed.-
109 \value ChildAdded An object gets a child (QChildEvent).-
110 \value ChildPolished A widget child gets polished (QChildEvent).-
111 \value ChildRemoved An object loses a child (QChildEvent).-
112 \value Clipboard The clipboard contents have changed.-
113 \value Close Widget was closed (QCloseEvent).-
114 \value CloseSoftwareInputPanel A widget wants to close the software input panel (SIP).-
115 \value ContentsRectChange The margins of the widget's content rect changed.-
116 \value ContextMenu Context popup menu (QContextMenuEvent).-
117 \value CursorChange The widget's cursor has changed.-
118 \value DeferredDelete The object will be deleted after it has cleaned up (QDeferredDeleteEvent)-
119 \value DragEnter The cursor enters a widget during a drag and drop operation (QDragEnterEvent).-
120 \value DragLeave The cursor leaves a widget during a drag and drop operation (QDragLeaveEvent).-
121 \value DragMove A drag and drop operation is in progress (QDragMoveEvent).-
122 \value Drop A drag and drop operation is completed (QDropEvent).-
123 \value DynamicPropertyChange A dynamic property was added, changed, or removed from the object.-
124 \value EnabledChange Widget's enabled state has changed.-
125 \value Enter Mouse enters widget's boundaries (QEnterEvent).-
126 \value EnterEditFocus An editor widget gains focus for editing. \c QT_KEYPAD_NAVIGATION must be defined.-
127 \value EnterWhatsThisMode Send to toplevel widgets when the application enters "What's This?" mode.-
128 \value Expose Sent to a window when its on-screen contents are invalidated and need to be flushed from the backing store.-
129 \value FileOpen File open request (QFileOpenEvent).-
130 \value FocusIn Widget or Window gains keyboard focus (QFocusEvent).-
131 \value FocusOut Widget or Window loses keyboard focus (QFocusEvent).-
132 \value FocusAboutToChange Widget or Window focus is about to change (QFocusEvent)-
133 \value FontChange Widget's font has changed.-
134 \value Gesture A gesture was triggered (QGestureEvent).-
135 \value GestureOverride A gesture override was triggered (QGestureEvent).-
136 \value GrabKeyboard Item gains keyboard grab (QGraphicsItem only).-
137 \value GrabMouse Item gains mouse grab (QGraphicsItem only).-
138 \value GraphicsSceneContextMenu Context popup menu over a graphics scene (QGraphicsSceneContextMenuEvent).-
139 \value GraphicsSceneDragEnter The cursor enters a graphics scene during a drag and drop operation (QGraphicsSceneDragDropEvent).-
140 \value GraphicsSceneDragLeave The cursor leaves a graphics scene during a drag and drop operation (QGraphicsSceneDragDropEvent).-
141 \value GraphicsSceneDragMove A drag and drop operation is in progress over a scene (QGraphicsSceneDragDropEvent).-
142 \value GraphicsSceneDrop A drag and drop operation is completed over a scene (QGraphicsSceneDragDropEvent).-
143 \value GraphicsSceneHelp The user requests help for a graphics scene (QHelpEvent).-
144 \value GraphicsSceneHoverEnter The mouse cursor enters a hover item in a graphics scene (QGraphicsSceneHoverEvent).-
145 \value GraphicsSceneHoverLeave The mouse cursor leaves a hover item in a graphics scene (QGraphicsSceneHoverEvent).-
146 \value GraphicsSceneHoverMove The mouse cursor moves inside a hover item in a graphics scene (QGraphicsSceneHoverEvent).-
147 \value GraphicsSceneMouseDoubleClick Mouse press again (double click) in a graphics scene (QGraphicsSceneMouseEvent).-
148 \value GraphicsSceneMouseMove Move mouse in a graphics scene (QGraphicsSceneMouseEvent).-
149 \value GraphicsSceneMousePress Mouse press in a graphics scene (QGraphicsSceneMouseEvent).-
150 \value GraphicsSceneMouseRelease Mouse release in a graphics scene (QGraphicsSceneMouseEvent).-
151 \value GraphicsSceneMove Widget was moved (QGraphicsSceneMoveEvent).-
152 \value GraphicsSceneResize Widget was resized (QGraphicsSceneResizeEvent).-
153 \value GraphicsSceneWheel Mouse wheel rolled in a graphics scene (QGraphicsSceneWheelEvent).-
154 \value Hide Widget was hidden (QHideEvent).-
155 \value HideToParent A child widget has been hidden.-
156 \value HoverEnter The mouse cursor enters a hover widget (QHoverEvent).-
157 \value HoverLeave The mouse cursor leaves a hover widget (QHoverEvent).-
158 \value HoverMove The mouse cursor moves inside a hover widget (QHoverEvent).-
159 \value IconDrag The main icon of a window has been dragged away (QIconDragEvent).-
160 \value IconTextChange Widget's icon text has been changed. (Deprecated)-
161 \value InputMethod An input method is being used (QInputMethodEvent).-
162 \value InputMethodQuery A input method query event (QInputMethodQueryEvent)-
163 \value KeyboardLayoutChange The keyboard layout has changed.-
164 \value KeyPress Key press (QKeyEvent).-
165 \value KeyRelease Key release (QKeyEvent).-
166 \value LanguageChange The application translation changed.-
167 \value LayoutDirectionChange The direction of layouts changed.-
168 \value LayoutRequest Widget layout needs to be redone.-
169 \value Leave Mouse leaves widget's boundaries.-
170 \value LeaveEditFocus An editor widget loses focus for editing. QT_KEYPAD_NAVIGATION must be defined.-
171 \value LeaveWhatsThisMode Send to toplevel widgets when the application leaves "What's This?" mode.-
172 \value LocaleChange The system locale has changed.-
173 \value NonClientAreaMouseButtonDblClick A mouse double click occurred outside the client area.-
174 \value NonClientAreaMouseButtonPress A mouse button press occurred outside the client area.-
175 \value NonClientAreaMouseButtonRelease A mouse button release occurred outside the client area.-
176 \value NonClientAreaMouseMove A mouse move occurred outside the client area.-
177 \value MacSizeChange The user changed his widget sizes (\macos only).-
178 \value MetaCall An asynchronous method invocation via QMetaObject::invokeMethod().-
179 \value ModifiedChange Widgets modification state has been changed.-
180 \value MouseButtonDblClick Mouse press again (QMouseEvent).-
181 \value MouseButtonPress Mouse press (QMouseEvent).-
182 \value MouseButtonRelease Mouse release (QMouseEvent).-
183 \value MouseMove Mouse move (QMouseEvent).-
184 \value MouseTrackingChange The mouse tracking state has changed.-
185 \value Move Widget's position changed (QMoveEvent).-
186 \value NativeGesture The system has detected a gesture (QNativeGestureEvent).-
187 \value OrientationChange The screens orientation has changes (QScreenOrientationChangeEvent).-
188 \value Paint Screen update necessary (QPaintEvent).-
189 \value PaletteChange Palette of the widget changed.-
190 \value ParentAboutToChange The widget parent is about to change.-
191 \value ParentChange The widget parent has changed.-
192 \value PlatformPanel A platform specific panel has been requested.-
193 \value PlatformSurface A native platform surface has been created or is about to be destroyed (QPlatformSurfaceEvent).-
194 \omitvalue Pointer-
195 \value Polish The widget is polished.-
196 \value PolishRequest The widget should be polished.-
197 \value QueryWhatsThis The widget should accept the event if it has "What's This?" help.-
198 \value ReadOnlyChange Widget's read-only state has changed (since Qt 5.4).-
199 \value RequestSoftwareInputPanel A widget wants to open a software input panel (SIP).-
200 \value Resize Widget's size changed (QResizeEvent).-
201 \value ScrollPrepare The object needs to fill in its geometry information (QScrollPrepareEvent).-
202 \value Scroll The object needs to scroll to the supplied position (QScrollEvent).-
203 \value Shortcut Key press in child for shortcut key handling (QShortcutEvent).-
204 \value ShortcutOverride Key press in child, for overriding shortcut key handling (QKeyEvent).-
205 \value Show Widget was shown on screen (QShowEvent).-
206 \value ShowToParent A child widget has been shown.-
207 \value SockAct Socket activated, used to implement QSocketNotifier.-
208 \omitvalue SockClose-
209 \value StateMachineSignal A signal delivered to a state machine (QStateMachine::SignalEvent).-
210 \value StateMachineWrapped The event is a wrapper for, i.e., contains, another event (QStateMachine::WrappedEvent).-
211 \value StatusTip A status tip is requested (QStatusTipEvent).-
212 \value StyleChange Widget's style has been changed.-
213 \value TabletMove Wacom tablet move (QTabletEvent).-
214 \value TabletPress Wacom tablet press (QTabletEvent).-
215 \value TabletRelease Wacom tablet release (QTabletEvent).-
216 \omitvalue OkRequest-
217 \value TabletEnterProximity Wacom tablet enter proximity event (QTabletEvent), sent to QApplication.-
218 \value TabletLeaveProximity Wacom tablet leave proximity event (QTabletEvent), sent to QApplication.-
219 \omitvalue ThemeChange-
220 \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().-
221 \value Timer Regular timer events (QTimerEvent).-
222 \value ToolBarChange The toolbar button is toggled on \macos.-
223 \value ToolTip A tooltip was requested (QHelpEvent).-
224 \value ToolTipChange The widget's tooltip has changed.-
225 \value TouchBegin Beginning of a sequence of touch-screen or track-pad events (QTouchEvent).-
226 \value TouchCancel Cancellation of touch-event sequence (QTouchEvent).-
227 \value TouchEnd End of touch-event sequence (QTouchEvent).-
228 \value TouchUpdate Touch-screen event (QTouchEvent).-
229 \value UngrabKeyboard Item loses keyboard grab (QGraphicsItem only).-
230 \value UngrabMouse Item loses mouse grab (QGraphicsItem, QQuickItem).-
231 \value UpdateLater The widget should be queued to be repainted at a later time.-
232 \value UpdateRequest The widget should be repainted.-
233 \value WhatsThis The widget should reveal "What's This?" help (QHelpEvent).-
234 \value WhatsThisClicked A link in a widget's "What's This?" help was clicked.-
235 \value Wheel Mouse wheel rolled (QWheelEvent).-
236 \value WinEventAct A Windows-specific activation event has occurred.-
237 \value WindowActivate Window was activated.-
238 \value WindowBlocked The window is blocked by a modal dialog.-
239 \value WindowDeactivate Window was deactivated.-
240 \value WindowIconChange The window's icon has changed.-
241 \value WindowStateChange The \l{QWindow::windowState()}{window's state} (minimized, maximized or full-screen) has changed (QWindowStateChangeEvent).-
242 \value WindowTitleChange The window title has changed.-
243 \value WindowUnblocked The window is unblocked after a modal dialog exited.-
244 \value WinIdChange The window system identifer for this native widget has changed.-
245 \value ZOrderChange The widget's z-order has changed. This event is never sent to top level windows.-
246-
247 User events should have values between \c User and \c{MaxUser}:-
248-
249 \value User User-defined event.-
250 \value MaxUser Last user event ID.-
251-
252 For convenience, you can use the registerEventType() function to-
253 register and reserve a custom event type for your-
254 application. Doing so will allow you to avoid accidentally-
255 re-using a custom event type already in use elsewhere in your-
256 application.-
257-
258 \omitvalue AcceptDropsChange-
259 \omitvalue ActivateControl-
260 \omitvalue Create-
261 \omitvalue DeactivateControl-
262 \omitvalue Destroy-
263 \omitvalue DragResponse-
264 \omitvalue EmbeddingControl-
265 \omitvalue HelpRequest-
266 \omitvalue Quit-
267 \omitvalue ShowWindowRequest-
268 \omitvalue Speech-
269 \omitvalue Style-
270 \omitvalue StyleAnimationUpdate-
271 \omitvalue ZeroTimerEvent-
272 \omitvalue ApplicationActivate-
273 \omitvalue ApplicationActivated-
274 \omitvalue ApplicationDeactivate-
275 \omitvalue ApplicationDeactivated-
276 \omitvalue MacGLWindowChange-
277 \omitvalue MacGLClearDrawable-
278 \omitvalue NetworkReplyUpdated-
279 \omitvalue FutureCallOut-
280 \omitvalue NativeGesture-
281 \omitvalue WindowChangeInternal-
282 \omitvalue ScreenChangeInternal-
283*/-
284-
285/*!-
286 Contructs an event object of type \a type.-
287*/-
288QEvent::QEvent(Type type)-
289 : d(0), t(type), posted(false), spont(false), m_accept(true)-
290{}
executed 2174144 times by 536 tests: end of block
Executed by:
  • tst_Gestures
  • tst_Lancelot
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractAnimation
  • tst_QAbstractButton
  • tst_QAbstractItemModel
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractProxyModel
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAnimationGroup
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QBuffer
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • ...
2174144
291-
292/*!-
293 \internal-
294 Attempts to copy the \a other event.-
295-
296 Copying events is a bad idea, yet some Qt 4 code does it (notably,-
297 QApplication and the state machine).-
298 */-
299QEvent::QEvent(const QEvent &other)-
300 : d(other.d), t(other.t), posted(other.posted), spont(other.spont),-
301 m_accept(other.m_accept)-
302{-
303 // if QEventPrivate becomes available, make sure to implement a-
304 // virtual QEventPrivate *clone() const; function so we can copy here-
305 Q_ASSERT_X(!d, "QEvent", "Impossible, this can't happen: QEventPrivate isn't defined anywhere");-
306}
executed 24 times by 1 test: end of block
Executed by:
  • tst_QStateMachine
24
307-
308/*!-
309 \internal-
310 Attempts to copy the \a other event.-
311-
312 Copying events is a bad idea, yet some Qt 4 code does it (notably,-
313 QApplication and the state machine).-
314 */-
315QEvent &QEvent::operator=(const QEvent &other)-
316{-
317 // if QEventPrivate becomes available, make sure to implement a-
318 // virtual QEventPrivate *clone() const; function so we can copy here-
319 Q_ASSERT_X(!other.d, "QEvent", "Impossible, this can't happen: QEventPrivate isn't defined anywhere");-
320-
321 t = other.t;-
322 posted = other.posted;-
323 spont = other.spont;-
324 m_accept = other.m_accept;-
325 return *this;
executed 6692 times by 47 tests: return *this;
Executed by:
  • tst_Gestures
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QApplication
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDateTimeEdit
  • tst_QDoubleSpinBox
  • tst_QFileDialog2
  • tst_QGraphicsItem
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsScene
  • tst_QGraphicsView
  • tst_QGraphicsWidget
  • tst_QGroupBox
  • tst_QHeaderView
  • tst_QItemDelegate
  • tst_QItemView
  • tst_QLabel
  • ...
6692
326}-
327-
328/*!-
329 Destroys the event. If it was \l{QCoreApplication::postEvent()}{posted},-
330 it will be removed from the list of events to be posted.-
331*/-
332-
333QEvent::~QEvent()-
334{-
335 if (posted && QCoreApplication::instance())
postedDescription
TRUEnever evaluated
FALSEevaluated 2174105 times by 540 tests
Evaluated by:
  • tst_Gestures
  • tst_Lancelot
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractAnimation
  • tst_QAbstractButton
  • tst_QAbstractItemModel
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractProxyModel
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAnimationGroup
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QBuffer
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • ...
QCoreApplication::instance()Description
TRUEnever evaluated
FALSEnever evaluated
0-2174105
336 QCoreApplicationPrivate::removePostedEvent(this);
never executed: QCoreApplicationPrivate::removePostedEvent(this);
0
337 Q_ASSERT_X(!d, "QEvent", "Impossible, this can't happen: QEventPrivate isn't defined anywhere");-
338}
executed 2176394 times by 540 tests: end of block
Executed by:
  • tst_Gestures
  • tst_Lancelot
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractAnimation
  • tst_QAbstractButton
  • tst_QAbstractItemModel
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractProxyModel
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAnimationGroup
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QBuffer
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • ...
2176394
339-
340-
341/*!-
342 \property QEvent::accepted-
343 the accept flag of the event object-
344-
345 Setting the accept parameter indicates that the event receiver-
346 wants the event. Unwanted events might be propagated to the parent-
347 widget. By default, isAccepted() is set to true, but don't rely on-
348 this as subclasses may choose to clear it in their constructor.-
349-
350 For convenience, the accept flag can also be set with accept(),-
351 and cleared with ignore().-
352*/-
353-
354/*!-
355 \fn void QEvent::accept()-
356-
357 Sets the accept flag of the event object, the equivalent of-
358 calling setAccepted(true).-
359-
360 Setting the accept parameter indicates that the event receiver-
361 wants the event. Unwanted events might be propagated to the parent-
362 widget.-
363-
364 \sa ignore()-
365*/-
366-
367-
368/*!-
369 \fn void QEvent::ignore()-
370-
371 Clears the accept flag parameter of the event object, the-
372 equivalent of calling setAccepted(false).-
373-
374 Clearing the accept parameter indicates that the event receiver-
375 does not want the event. Unwanted events might be propagated to the-
376 parent widget.-
377-
378 \sa accept()-
379*/-
380-
381-
382/*!-
383 \fn QEvent::Type QEvent::type() const-
384-
385 Returns the event type.-
386*/-
387-
388/*!-
389 \fn bool QEvent::spontaneous() const-
390-
391 Returns \c true if the event originated outside the application (a-
392 system event); otherwise returns \c false.-
393-
394 The return value of this function is not defined for paint events.-
395*/-
396-
397namespace {-
398template <size_t N>-
399struct QBasicAtomicBitField {-
400 enum {-
401 BitsPerInt = std::numeric_limits<uint>::digits,-
402 NumInts = (N + BitsPerInt - 1) / BitsPerInt,-
403 NumBits = N-
404 };-
405-
406 // This atomic int points to the next (possibly) free ID saving-
407 // the otherwise necessary scan through 'data':-
408 QBasicAtomicInteger<uint> next;-
409 QBasicAtomicInteger<uint> data[NumInts];-
410-
411 bool allocateSpecific(int which) Q_DECL_NOTHROW-
412 {-
413 QBasicAtomicInteger<uint> &entry = data[which / BitsPerInt];-
414 const uint old = entry.load();-
415 const uint bit = 1U << (which % BitsPerInt);-
416 return !(old & bit) // wasn't taken
executed 129072 times by 3 tests: return !(old & bit) && entry.testAndSetRelaxed(old, old | bit);
Executed by:
  • tst_Gestures
  • tst_QEvent
  • tst_QWidget_window
129072
417 && entry.testAndSetRelaxed(old, old | bit); // still wasn't taken
executed 129072 times by 3 tests: return !(old & bit) && entry.testAndSetRelaxed(old, old | bit);
Executed by:
  • tst_Gestures
  • tst_QEvent
  • tst_QWidget_window
129072
418-
419 // don't update 'next' here - it's unlikely that it will need-
420 // to be updated, in the general case, and having 'next'-
421 // trailing a bit is not a problem, as it is just a starting-
422 // hint for allocateNext(), which, when wrong, will just-
423 // result in a few more rounds through the allocateNext()-
424 // loop.-
425 }-
426-
427 int allocateNext() Q_DECL_NOTHROW-
428 {-
429 // Unroll loop to iterate over ints, then bits? Would save-
430 // potentially a lot of cmpxchgs, because we can scan the-
431 // whole int before having to load it again.-
432-
433 // Then again, this should never execute many iterations, so-
434 // leave like this for now:-
435 for (uint i = next.load(); i < NumBits; ++i) {
i < NumBitsDescription
TRUEevaluated 64538 times by 3 tests
Evaluated by:
  • tst_Gestures
  • tst_QEvent
  • tst_QWidget_window
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QEvent
1-64538
436 if (allocateSpecific(i)) {
allocateSpecific(i)Description
TRUEevaluated 7 times by 3 tests
Evaluated by:
  • tst_Gestures
  • tst_QEvent
  • tst_QWidget_window
FALSEevaluated 64531 times by 1 test
Evaluated by:
  • tst_QEvent
7-64531
437 // remember next (possibly) free id:-
438 const uint oldNext = next.load();-
439 next.testAndSetRelaxed(oldNext, qMax(i + 1, oldNext));-
440 return i;
executed 7 times by 3 tests: return i;
Executed by:
  • tst_Gestures
  • tst_QEvent
  • tst_QWidget_window
7
441 }-
442 }
executed 64531 times by 1 test: end of block
Executed by:
  • tst_QEvent
64531
443 return -1;
executed 1 time by 1 test: return -1;
Executed by:
  • tst_QEvent
1
444 }-
445};-
446-
447} // unnamed namespace-
448-
449typedef QBasicAtomicBitField<QEvent::MaxUser - QEvent::User + 1> UserEventTypeRegistry;-
450-
451static UserEventTypeRegistry userEventTypeRegistry;-
452-
453static inline int registerEventTypeZeroBased(int id) Q_DECL_NOTHROW-
454{-
455 // if the type hint hasn't been registered yet, take it:-
456 if (id < UserEventTypeRegistry::NumBits && id >= 0 && userEventTypeRegistry.allocateSpecific(id))
id < UserEvent...istry::NumBitsDescription
TRUEevaluated 64535 times by 1 test
Evaluated by:
  • tst_QEvent
FALSEevaluated 4 times by 3 tests
Evaluated by:
  • tst_Gestures
  • tst_QEvent
  • tst_QWidget_window
id >= 0Description
TRUEevaluated 64534 times by 1 test
Evaluated by:
  • tst_QEvent
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QEvent
userEventTypeR...teSpecific(id)Description
TRUEevaluated 64531 times by 1 test
Evaluated by:
  • tst_QEvent
FALSEevaluated 3 times by 1 test
Evaluated by:
  • tst_QEvent
1-64535
457 return id;
executed 64531 times by 1 test: return id;
Executed by:
  • tst_QEvent
64531
458-
459 // otherwise, ignore hint:-
460 return userEventTypeRegistry.allocateNext();
executed 8 times by 3 tests: return userEventTypeRegistry.allocateNext();
Executed by:
  • tst_Gestures
  • tst_QEvent
  • tst_QWidget_window
8
461}-
462-
463/*!-
464 \since 4.4-
465 \threadsafe-
466-
467 Registers and returns a custom event type. The \a hint provided-
468 will be used if it is available, otherwise it will return a value-
469 between QEvent::User and QEvent::MaxUser that has not yet been-
470 registered. The \a hint is ignored if its value is not between-
471 QEvent::User and QEvent::MaxUser.-
472-
473 Returns -1 if all available values are already taken or the-
474 program is shutting down.-
475*/-
476int QEvent::registerEventType(int hint) Q_DECL_NOTHROW-
477{-
478 const int result = registerEventTypeZeroBased(QEvent::MaxUser - hint);-
479 return result < 0 ? -1 : QEvent::MaxUser - result ;
executed 64539 times by 3 tests: return result < 0 ? -1 : QEvent::MaxUser - result ;
Executed by:
  • tst_Gestures
  • tst_QEvent
  • tst_QWidget_window
64539
480}-
481-
482/*!-
483 \class QTimerEvent-
484 \inmodule QtCore-
485 \brief The QTimerEvent class contains parameters that describe a-
486 timer event.-
487-
488 \ingroup events-
489-
490 Timer events are sent at regular intervals to objects that have-
491 started one or more timers. Each timer has a unique identifier. A-
492 timer is started with QObject::startTimer().-
493-
494 The QTimer class provides a high-level programming interface that-
495 uses signals instead of events. It also provides single-shot timers.-
496-
497 The event handler QObject::timerEvent() receives timer events.-
498-
499 \sa QTimer, QObject::timerEvent(), QObject::startTimer(),-
500 QObject::killTimer()-
501*/-
502-
503/*!-
504 Constructs a timer event object with the timer identifier set to-
505 \a timerId.-
506*/-
507QTimerEvent::QTimerEvent(int timerId)-
508 : QEvent(Timer), id(timerId)-
509{}
executed 49574 times by 115 tests: end of block
Executed by:
  • tst_Gestures
  • tst_QAbstractAnimation
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAccessibility
  • tst_QApplication
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractInterface
  • tst_QDBusMarshall
  • tst_QDialog
  • tst_QDialogButtonBox
  • tst_QEventDispatcher
  • tst_QEventLoop
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • ...
49574
510-
511/*!-
512 \internal-
513*/-
514QTimerEvent::~QTimerEvent()-
515{-
516}-
517-
518/*!-
519 \fn int QTimerEvent::timerId() const-
520-
521 Returns the unique timer identifier, which is the same identifier-
522 as returned from QObject::startTimer().-
523*/-
524-
525/*!-
526 \class QChildEvent-
527 \inmodule QtCore-
528 \brief The QChildEvent class contains event parameters for child object-
529 events.-
530-
531 \ingroup events-
532-
533 Child events are sent immediately to objects when children are-
534 added or removed.-
535-
536 In both cases you can only rely on the child being a QObject (or,-
537 if QObject::isWidgetType() returns \c true, a QWidget). This is-
538 because in the QEvent::ChildAdded case the child is not yet fully-
539 constructed; in the QEvent::ChildRemoved case it might have-
540 already been destructed.-
541-
542 The handler for these events is QObject::childEvent().-
543*/-
544-
545/*!-
546 Constructs a child event object of a particular \a type for the-
547 \a child.-
548-
549 \a type can be QEvent::ChildAdded, QEvent::ChildRemoved,-
550 or QEvent::ChildPolished.-
551-
552 \sa child()-
553*/-
554QChildEvent::QChildEvent(Type type, QObject *child)-
555 : QEvent(type), c(child)-
556{}
executed 325287 times by 510 tests: end of block
Executed by:
  • tst_Gestures
  • tst_Lancelot
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractAnimation
  • tst_QAbstractButton
  • tst_QAbstractItemModel
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractProxyModel
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAnimationGroup
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QBuffer
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • ...
325287
557-
558/*!-
559 \internal-
560*/-
561QChildEvent::~QChildEvent()-
562{-
563}-
564-
565/*!-
566 \fn QObject *QChildEvent::child() const-
567-
568 Returns the child object that was added or removed.-
569*/-
570-
571/*!-
572 \fn bool QChildEvent::added() const-
573-
574 Returns \c true if type() is QEvent::ChildAdded; otherwise returns-
575 false.-
576*/-
577-
578/*!-
579 \fn bool QChildEvent::removed() const-
580-
581 Returns \c true if type() is QEvent::ChildRemoved; otherwise returns-
582 false.-
583*/-
584-
585/*!-
586 \fn bool QChildEvent::polished() const-
587-
588 Returns \c true if type() is QEvent::ChildPolished; otherwise returns-
589 false.-
590*/-
591-
592-
593/*!-
594 \class QDynamicPropertyChangeEvent-
595 \inmodule QtCore-
596 \since 4.2-
597 \brief The QDynamicPropertyChangeEvent class contains event parameters for dynamic-
598 property change events.-
599-
600 \ingroup events-
601-
602 Dynamic property change events are sent to objects when properties are-
603 dynamically added, changed or removed using QObject::setProperty().-
604*/-
605-
606/*!-
607 Constructs a dynamic property change event object with the property name set to-
608 \a name.-
609*/-
610QDynamicPropertyChangeEvent::QDynamicPropertyChangeEvent(const QByteArray &name)-
611 : QEvent(QEvent::DynamicPropertyChange), n(name)-
612{-
613}
executed 10046 times by 68 tests: end of block
Executed by:
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAccessibility
  • tst_QAnimationGroup
  • tst_QApplication
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QDBusAbstractAdaptor
  • tst_QDBusAbstractInterface
  • tst_QDBusConnection
  • tst_QDBusConnection_Delayed
  • tst_QDBusConnection_NoApplication
  • tst_QDBusConnection_SpyHook
  • tst_QDBusContext
  • tst_QDBusInterface
  • tst_QDBusLocalCalls
  • tst_QDBusMarshall
  • tst_QDBusPendingCall
  • tst_QDBusPendingReply
  • tst_QDBusReply
  • tst_QDBusThreading
  • tst_QFileDialog2
  • tst_QFiledialog
  • tst_QFocusEvent
  • tst_QFontDialog
  • ...
10046
614-
615/*!-
616 \internal-
617*/-
618QDynamicPropertyChangeEvent::~QDynamicPropertyChangeEvent()-
619{-
620}-
621-
622/*!-
623 \fn QByteArray QDynamicPropertyChangeEvent::propertyName() const-
624-
625 Returns the name of the dynamic property that was added, changed or-
626 removed.-
627-
628 \sa QObject::setProperty(), QObject::dynamicPropertyNames()-
629*/-
630-
631/*!-
632 Constructs a deferred delete event with an initial loopLevel() of zero.-
633*/-
634QDeferredDeleteEvent::QDeferredDeleteEvent()-
635 : QEvent(QEvent::DeferredDelete)-
636 , level(0)-
637{
executed 11751 times by 213 tests: end of block
Executed by:
  • tst_Gestures
  • tst_Lancelot
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QApplication
  • tst_QBoxLayout
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLineParser
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • ...
}
executed 11751 times by 213 tests: end of block
Executed by:
  • tst_Gestures
  • tst_Lancelot
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QApplication
  • tst_QBoxLayout
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLineParser
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QCoreApplication
  • tst_QDBusAbstractAdaptor
  • ...
11751
638-
639/*!-
640 \internal-
641*/-
642QDeferredDeleteEvent::~QDeferredDeleteEvent()-
643{ }-
644-
645/*! \fn int QDeferredDeleteEvent::loopLevel() const-
646-
647 Returns the loop-level in which the event was posted. The-
648 loop-level is set by QCoreApplication::postEvent().-
649-
650 \sa QObject::deleteLater()-
651*/-
652-
653QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9