Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qtimerinfo_unix_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 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 QTIMERINFO_UNIX_P_H
5#define QTIMERINFO_UNIX_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/private/qglobal_p.h>
19
21
22#include <sys/time.h> // struct timespec
23#include <chrono>
24
26
27// internal timer info
28struct QTimerInfo {
29 int id; // - timer identifier
30 Qt::TimerType timerType; // - timer type
31 std::chrono::milliseconds interval; // - timer interval
32 std::chrono::steady_clock::time_point timeout; // - when to actually fire
33 QObject *obj; // - object to receive event
34 QTimerInfo **activateRef; // - ref from activateTimers
35};
36
37class Q_CORE_EXPORT QTimerInfoList : public QList<QTimerInfo*>
38{
39 // state variables used by activateTimers()
40 QTimerInfo *firstTimerInfo = nullptr;
41
42public:
44
45 std::chrono::steady_clock::time_point currentTime;
46
47 bool timerWait(timespec &);
48 void timerInsert(QTimerInfo *);
49
50 qint64 timerRemainingTime(int timerId);
51 std::chrono::milliseconds remainingDuration(int timerId);
52
53 void registerTimer(int timerId, qint64 interval, Qt::TimerType timerType, QObject *object);
54 void registerTimer(int timerId, std::chrono::milliseconds interval, Qt::TimerType timerType,
55 QObject *object);
56 bool unregisterTimer(int timerId);
57 bool unregisterTimers(QObject *object);
58 QList<QAbstractEventDispatcher::TimerInfo> registeredTimers(QObject *object) const;
59
60 int activateTimers();
61 bool hasPendingTimers();
62
64 {
65 auto matchesId = [timerId](const QTimerInfo *t) { return t->id == timerId; };
66 return std::find_if(cbegin(), cend(), matchesId);
67 }
68
69private:
70 std::chrono::steady_clock::time_point updateCurrentTime();
71};
72
74
75#endif // QTIMERINFO_UNIX_P_H
Definition qlist.h:74
const_iterator cend() const noexcept
Definition qlist.h:614
const_iterator cbegin() const noexcept
Definition qlist.h:613
\inmodule QtCore
Definition qobject.h:90
void registerTimer(int timerId, std::chrono::milliseconds interval, Qt::TimerType timerType, QObject *object)
std::chrono::steady_clock::time_point currentTime
QList::const_iterator findTimerById(int timerId) const
Combined button and popup list for selecting options.
TimerType
GLdouble GLdouble t
Definition qopenglext.h:243
long long qint64
Definition qtypes.h:55
std::chrono::steady_clock::time_point timeout
QTimerInfo ** activateRef
std::chrono::milliseconds interval
Qt::TimerType timerType