Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qabstracteventdispatcher.h
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QABSTRACTEVENTDISPATCHER_H
5#define QABSTRACTEVENTDISPATCHER_H
6
7#include <QtCore/qobject.h>
8#include <QtCore/qeventloop.h>
9
11
14class QSocketNotifier;
15
16class Q_CORE_EXPORT QAbstractEventDispatcher : public QObject
17{
19 Q_DECLARE_PRIVATE(QAbstractEventDispatcher)
20
21public:
22 using Duration = std::chrono::nanoseconds;
23 struct TimerInfo
24 {
28
29 inline TimerInfo(int id, int i, Qt::TimerType t)
30 : timerId(id), interval(i), timerType(t) { }
31 };
38
39 explicit QAbstractEventDispatcher(QObject *parent = nullptr);
41
42 static QAbstractEventDispatcher *instance(QThread *thread = nullptr);
43
44 virtual bool processEvents(QEventLoop::ProcessEventsFlags flags) = 0;
45
48
49 Qt::TimerId registerTimer(Duration interval, Qt::TimerType timerType, QObject *object);
50
51#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
52 int registerTimer(qint64 interval, Qt::TimerType timerType, QObject *object);
53
54 // old, integer-based API
55 virtual void registerTimer(int timerId, qint64 interval, Qt::TimerType timerType, QObject *object) = 0;
56 virtual bool unregisterTimer(int timerId) = 0;
57 virtual QList<TimerInfo> registeredTimers(QObject *object) const = 0;
58 virtual int remainingTime(int timerId) = 0;
59
60 void registerTimer(Qt::TimerId timerId, Duration interval, Qt::TimerType timerType, QObject *object);
61 bool unregisterTimer(Qt::TimerId timerId);
62 QList<TimerInfoV2> timersForObject(QObject *object) const;
63 Duration remainingTime(Qt::TimerId timerId) const;
64#else
65 virtual void registerTimer(Qt::TimerId timerId, Duration interval, Qt::TimerType timerType, QObject *object) = 0;
66 virtual bool unregisterTimer(Qt::TimerId timerId) = 0;
67 virtual QList<TimerInfoV2> timersForObject(QObject *object) const = 0;
68 virtual Duration remainingTime(Qt::TimerId timerId) const = 0;
69#endif
70 virtual bool unregisterTimers(QObject *object) = 0;
71
72 virtual void wakeUp() = 0;
73 virtual void interrupt() = 0;
74
75 virtual void startingUp();
76 virtual void closingDown();
77
78 void installNativeEventFilter(QAbstractNativeEventFilter *filterObj);
79 void removeNativeEventFilter(QAbstractNativeEventFilter *filterObj);
80 bool filterNativeEvent(const QByteArray &eventType, void *message, qintptr *result);
81
84 void awake();
85
86protected:
88 QObject *parent);
89};
90
93
94#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
96{
98 Q_DECLARE_PRIVATE(QAbstractEventDispatcher) // not V2
99
100public:
101 explicit QAbstractEventDispatcherV2(QObject *parent = nullptr);
103
104 // new virtuals
105 virtual void registerTimer(Qt::TimerId timerId, Duration interval, Qt::TimerType timerType,
106 QObject *object) = 0;
107 virtual bool unregisterTimer(Qt::TimerId timerId) = 0;
108 virtual QList<TimerInfoV2> timersForObject(QObject *object) const = 0;
109 virtual Duration remainingTime(Qt::TimerId timerId) const = 0;
110
111protected:
113
114private:
115 // final overrides from V1
116 virtual void registerTimer(int timerId, qint64 interval, Qt::TimerType timerType,
117 QObject *object) override final;
118 virtual bool unregisterTimer(int timerId) override final;
119 virtual QList<TimerInfo> registeredTimers(QObject *object) const override final;
120
121 virtual int remainingTime(int timerId) override final;
122};
123#else
125#endif // Qt 7
126
128
129#endif // QABSTRACTEVENTDISPATCHER_H
DarwinBluetooth::LECBManagerNotifier * notifier
virtual void registerSocketNotifier(QSocketNotifier *notifier)=0
Registers notifier with the event loop.
virtual Duration remainingTime(Qt::TimerId timerId) const =0
Returns the remaining time of the timer with the given timerId.
void aboutToBlock()
This signal is emitted before the event loop calls a function that could block.
std::chrono::nanoseconds Duration
A {std::chrono::duration} type that is used in various API in this class.
virtual void unregisterSocketNotifier(QSocketNotifier *notifier)=0
Unregisters notifier from the event dispatcher.
virtual void wakeUp()=0
\threadsafe
virtual QList< TimerInfoV2 > timersForObject(QObject *object) const =0
void awake()
This signal is emitted after the event loop returns from a function that could block.
virtual void registerTimer(Qt::TimerId timerId, Duration interval, Qt::TimerType timerType, QObject *object)=0
virtual bool processEvents(QEventLoop::ProcessEventsFlags flags)=0
Processes pending events that match flags until there are no more events to process.
virtual bool unregisterTimer(Qt::TimerId timerId)=0
virtual bool unregisterTimers(QObject *object)=0
Unregisters all the timers associated with the given object.
virtual void interrupt()=0
Interrupts event dispatching.
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore
Definition qobject.h:103
\inmodule QtCore
Combined button and popup list for selecting options.
TimerType
QAbstractEventDispatcher QAbstractEventDispatcherV2
GLenum GLuint id
[7]
GLbitfield flags
GLuint GLsizei const GLchar * message
GLdouble GLdouble t
Definition qopenglext.h:243
GLuint64EXT * result
[6]
#define Q_OBJECT
#define Q_SIGNALS
@ Q_PRIMITIVE_TYPE
Definition qtypeinfo.h:157
#define Q_DECLARE_TYPEINFO(TYPE, FLAGS)
Definition qtypeinfo.h:180
long long qint64
Definition qtypes.h:60
ptrdiff_t qintptr
Definition qtypes.h:166
\variable QAbstractEventDispatcher::TimerInfo::timerId
TimerInfo(int id, int i, Qt::TimerType t)
Constructs a TimerInfo struct with the given timerId, interval, and timerType.