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
qtimer_p.h
Go to the documentation of this file.
1// Copyright (C) 2022 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#ifndef QTIMER_P_H
4#define QTIMER_P_H
5//
6// W A R N I N G
7// -------------
8//
9// This file is not part of the Qt API. It exists for the convenience
10// of the Qt translation tools. This header file may change from version
11// to version without notice, or even be removed.
12//
13// We mean it.
14//
15#include "qtimer.h"
16#include "qchronotimer.h"
17
18#include "qobject_p.h"
19#include "qproperty_p.h"
20#include "qttypetraits.h"
21
23
25{
26public:
28 : q(qq),
29 isQTimer(true)
30 {}
31
32 QTimerPrivate(std::chrono::nanoseconds nsec, QChronoTimer *qq)
33 : intervalDuration(nsec),
34 q(qq)
35 {
36 intervalDuration.notify();
37 }
38
39 static constexpr int INV_TIMER = -1; // invalid timer id
40
41 void setIntervalDuration(std::chrono::nanoseconds nsec)
42 {
43 if (isQTimer) {
44 const auto msec = std::chrono::ceil<std::chrono::milliseconds>(nsec);
45 static_cast<QTimer *>(q)->setInterval(msec);
46 } else {
47 static_cast<QChronoTimer *>(q)->setInterval(nsec);
48 }
49 }
50
51 void setInterval(int msec)
52 {
54 static_cast<QTimer *>(q)->setInterval(msec);
55 }
56
57 bool isActive() const { return id > Qt::TimerId::Invalid; }
58
61 Q_OBJECT_COMPAT_PROPERTY_WITH_ARGS(QTimerPrivate, std::chrono::nanoseconds, intervalDuration,
63 std::chrono::nanoseconds{0})
67
68 QObject *q;
69 const bool isQTimer = false; // true if q is a QTimer*
70};
71
73#endif // QTIMER_P_H
\inmodule QtCore
\inmodule QtCore
Definition qobject.h:103
QTimerPrivate(QTimer *qq)
Definition qtimer_p.h:27
void setIntervalDuration(std::chrono::nanoseconds nsec)
Definition qtimer_p.h:41
static constexpr int INV_TIMER
Definition qtimer_p.h:39
void setInterval(int msec)
Definition qtimer_p.h:51
bool isActive() const
Definition qtimer_p.h:57
const bool isQTimer
Definition qtimer_p.h:69
QTimerPrivate(std::chrono::nanoseconds nsec, QChronoTimer *qq)
Definition qtimer_p.h:32
\inmodule QtCore
Definition qtimer.h:20
Combined button and popup list for selecting options.
TimerType
@ CoarseTimer
GLenum type
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
#define Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(...)
Definition qproperty.h:1266
#define Q_OBJECT_COMPUTED_PROPERTY(Class, Type, name, ...)
Definition qproperty.h:1355
#define Q_OBJECT_COMPAT_PROPERTY_WITH_ARGS(...)
#define Q_ASSERT(cond)
Definition qrandom.cpp:47