30 using Duration = QAbstractEventDispatcher::Duration;
31 using TimePoint = std::chrono::time_point<std::chrono::steady_clock, Duration>;
32 QTimerInfo(Qt::TimerId timerId, Duration interval, Qt::TimerType type, QObject *obj)
33 : interval(interval), id(timerId), timerType(type), obj(obj)
37 TimePoint timeout = {};
38 Duration interval = Duration{-1};
39 Qt::TimerId id = Qt::TimerId::Invalid;
40 Qt::TimerType timerType;
41 QObject *obj =
nullptr;
42 QTimerInfo **activateRef =
nullptr;
48 using Duration = QAbstractEventDispatcher::Duration;
49 using TimerInfo = QAbstractEventDispatcher::TimerInfoV2;
52 mutable std::chrono::steady_clock::time_point currentTime;
54 std::optional<Duration> timerWait();
55 void timerInsert(QTimerInfo *);
57 Duration remainingDuration(Qt::TimerId timerId)
const;
59 void registerTimer(Qt::TimerId timerId, Duration interval,
60 Qt::TimerType timerType, QObject *object);
61 bool unregisterTimer(Qt::TimerId timerId);
62 bool unregisterTimers(QObject *object);
63 QList<TimerInfo> registeredTimers(QObject *object)
const;
66 bool hasPendingTimers();
74 bool isEmpty()
const {
return timers.empty(); }
76 qsizetype size()
const {
return timers.size(); }
78 auto findTimerById(Qt::TimerId timerId)
const
80 auto matchesId = [timerId](
const auto &t) {
return t->id == timerId; };
81 return std::find_if(timers.cbegin(), timers.cend(), matchesId);
85 std::chrono::steady_clock::time_point updateCurrentTime()
const;
88 QTimerInfo *firstTimerInfo =
nullptr;
89 QList<QTimerInfo *> timers;