Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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// Qt-Security score:significant reason:default
4#ifndef QTIMER_P_H
5#define QTIMER_P_H
6//
7// W A R N I N G
8// -------------
9//
10// This file is not part of the Qt API. It exists for the convenience
11// of the Qt translation tools. This header file may change from version
12// to version without notice, or even be removed.
13//
14// We mean it.
15//
16#include "qtimer.h"
17#include "qchronotimer.h"
18
19#include "qobject_p.h"
20#include "qproperty_p.h"
21#include "qttypetraits.h"
22
24
26{
27public:
28 QTimerPrivate(QTimer *qq)
29 : q(qq),
30 isQTimer(true)
31 {}
32
33 QTimerPrivate(std::chrono::nanoseconds nsec, QChronoTimer *qq)
35 q(qq)
36 {
37 intervalDuration.notify();
38 }
40
41 static constexpr int INV_TIMER = -1; // invalid timer id
42
43 void setIntervalDuration(std::chrono::nanoseconds nsec)
44 {
45 if (isQTimer) {
46 const auto msec = std::chrono::ceil<std::chrono::milliseconds>(nsec);
47 static_cast<QTimer *>(q)->setInterval(msec);
48 } else {
49 static_cast<QChronoTimer *>(q)->setInterval(nsec);
50 }
51 }
52
53 void setInterval(int msec)
54 {
55 Q_ASSERT(isQTimer);
56 static_cast<QTimer *>(q)->setInterval(msec);
57 }
58
59 bool isActive() const { return id > Qt::TimerId::Invalid; }
60
69
70 QObject *q;
71 const bool isQTimer = false; // true if q is a QTimer*
72};
73
74QT_END_NAMESPACE
75#endif // QTIMER_P_H
\inmodule QtCore
~QTimerPrivate() override
QTimerPrivate(QTimer *qq)
Definition qtimer_p.h:28
void setIntervalDuration(std::chrono::nanoseconds nsec)
Definition qtimer_p.h:43
static constexpr int INV_TIMER
Definition qtimer_p.h:41
void setInterval(int msec)
Definition qtimer_p.h:53
bool isActive() const
Definition qtimer_p.h:59
const bool isQTimer
Definition qtimer_p.h:71
QTimerPrivate(std::chrono::nanoseconds nsec, QChronoTimer *qq)
Definition qtimer_p.h:33
Qt::TimerId id
Definition qtimer_p.h:61
Combined button and popup list for selecting options.
#define Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(...)
Definition qproperty.h:1336
#define Q_OBJECT_COMPUTED_PROPERTY(Class, Type, name, ...)
Definition qproperty.h:1425
#define Q_OBJECT_COMPAT_PROPERTY_WITH_ARGS(...)