summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qbasictimer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/kernel/qbasictimer.cpp')
-rw-r--r--src/corelib/kernel/qbasictimer.cpp86
1 files changed, 35 insertions, 51 deletions
diff --git a/src/corelib/kernel/qbasictimer.cpp b/src/corelib/kernel/qbasictimer.cpp
index 60de171e14..17711a355e 100644
--- a/src/corelib/kernel/qbasictimer.cpp
+++ b/src/corelib/kernel/qbasictimer.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qbasictimer.h"
#include "qabstracteventdispatcher.h"
@@ -69,10 +33,8 @@ QT_BEGIN_NAMESPACE
can maintain a list of basic timers by holding them in container
that supports move-only types, e.g. std::vector.
- The \l{widgets/wiggly}{Wiggly} example uses QBasicTimer to repaint
- a widget at regular intervals.
-
- \sa QTimer, QTimerEvent, QObject::timerEvent(), Timers, {Wiggly Example}
+ \sa QTimer, QChronoTimer, QTimerEvent, QObject::timerEvent(),
+ Timers, {Affine Transformations}
*/
@@ -122,10 +84,18 @@ QT_BEGIN_NAMESPACE
/*!
\fn QBasicTimer::swap(QBasicTimer &other)
+ \since 5.14
+
+ Swaps the timer \a other with this timer.
+ This operation is very fast and never fails.
+*/
+
+/*!
\fn swap(QBasicTimer &lhs, QBasicTimer &rhs)
+ \relates QBasicTimer
\since 5.14
- Swaps string \a other with this string, or \a lhs with \a rhs.
+ Swaps the timer \a lhs with \a rhs.
This operation is very fast and never fails.
*/
@@ -140,7 +110,13 @@ QT_BEGIN_NAMESPACE
/*!
\fn void QBasicTimer::start(int msec, QObject *object)
- Starts (or restarts) the timer with a \a msec milliseconds timeout. The
+ \obsolete Use chrono overload instead.
+*/
+
+/*!
+ \since 6.5
+
+ Starts (or restarts) the timer with a \a duration timeout. The
timer will be a Qt::CoarseTimer. See Qt::TimerType for information on the
different timer types.
@@ -148,15 +124,23 @@ QT_BEGIN_NAMESPACE
\sa stop(), isActive(), QObject::timerEvent(), Qt::CoarseTimer
*/
-void QBasicTimer::start(int msec, QObject *obj)
+void QBasicTimer::start(std::chrono::milliseconds duration, QObject *object)
{
- start(msec, Qt::CoarseTimer, obj);
+ start(duration, Qt::CoarseTimer, object);
}
/*!
+ \fn QBasicTimer::start(int msec, Qt::TimerType timerType, QObject *obj)
\overload
+ \obsolete
+
+ Use chrono overload instead.
+*/
+
+/*!
+ \since 6.5
- Starts (or restarts) the timer with a \a msec milliseconds timeout and the
+ Starts (or restarts) the timer with a \a duration timeout and the
given \a timerType. See Qt::TimerType for information on the different
timer types.
@@ -164,10 +148,10 @@ void QBasicTimer::start(int msec, QObject *obj)
\sa stop(), isActive(), QObject::timerEvent(), Qt::TimerType
*/
-void QBasicTimer::start(int msec, Qt::TimerType timerType, QObject *obj)
+void QBasicTimer::start(std::chrono::milliseconds duration, Qt::TimerType timerType, QObject *obj)
{
QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance();
- if (Q_UNLIKELY(msec < 0)) {
+ if (Q_UNLIKELY(duration.count() < 0)) {
qWarning("QBasicTimer::start: Timers cannot have negative timeouts");
return;
}
@@ -181,7 +165,7 @@ void QBasicTimer::start(int msec, Qt::TimerType timerType, QObject *obj)
}
stop();
if (obj)
- id = eventDispatcher->registerTimer(msec, timerType, obj);
+ id = int(eventDispatcher->registerTimer(duration, timerType, obj));
}
/*!
@@ -193,7 +177,7 @@ void QBasicTimer::stop()
{
if (id) {
QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance();
- if (eventDispatcher && !eventDispatcher->unregisterTimer(id)) {
+ if (eventDispatcher && !eventDispatcher->unregisterTimer(Qt::TimerId(id))) {
qWarning("QBasicTimer::stop: Failed. Possibly trying to stop from a different thread");
return;
}