Move QTimerPrivate to separate header
Change-Id: Icf3f8701f3cced822f2241cb2c0d27cd8739efe1 Reviewed-by: Marc Mutz <marc.mutz@qt.io> (cherry picked from commit 84c085273f21fc6365a7fbe99d98d726a161d000) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
dbffd02feb
commit
bcbce8c8d6
@ -149,7 +149,7 @@ qt_internal_add_module(Core
|
||||
kernel/qsystemerror.cpp kernel/qsystemerror_p.h
|
||||
kernel/qsystemsemaphore.cpp kernel/qsystemsemaphore.h kernel/qsystemsemaphore_p.h
|
||||
kernel/qtestsupport_core.cpp kernel/qtestsupport_core.h
|
||||
kernel/qtimer.cpp kernel/qtimer.h
|
||||
kernel/qtimer.cpp kernel/qtimer.h kernel/qtimer_p.h
|
||||
kernel/qtranslator.cpp kernel/qtranslator.h kernel/qtranslator_p.h
|
||||
kernel/qvariant.cpp kernel/qvariant.h kernel/qvariant_p.h
|
||||
kernel/qvariantmap.h kernel/qvarianthash.h kernel/qvariantlist.h
|
||||
|
@ -3,6 +3,8 @@
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
#include "qtimer.h"
|
||||
#include "qtimer_p.h"
|
||||
|
||||
#include "qabstracteventdispatcher.h"
|
||||
#include "qcoreapplication.h"
|
||||
#include "qobject_p.h"
|
||||
@ -12,23 +14,6 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
static constexpr int INV_TIMER = -1; // invalid timer id
|
||||
|
||||
class QTimerPrivate : public QObjectPrivate
|
||||
{
|
||||
Q_DECLARE_PUBLIC(QTimer)
|
||||
public:
|
||||
void setInterval(int msec) { q_func()->setInterval(msec); }
|
||||
bool isActiveActualCalculation() const { return id >= 0; }
|
||||
|
||||
int id = INV_TIMER;
|
||||
Q_OBJECT_COMPAT_PROPERTY_WITH_ARGS(QTimerPrivate, int, inter, &QTimerPrivate::setInterval, 0)
|
||||
Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(QTimerPrivate, bool, single, false)
|
||||
Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(QTimerPrivate, Qt::TimerType, type, Qt::CoarseTimer)
|
||||
Q_OBJECT_COMPUTED_PROPERTY(QTimerPrivate, bool, isActiveData,
|
||||
&QTimerPrivate::isActiveActualCalculation)
|
||||
};
|
||||
|
||||
/*!
|
||||
\class QTimer
|
||||
\inmodule QtCore
|
||||
@ -139,7 +124,7 @@ QTimer::QTimer(QObject *parent)
|
||||
|
||||
QTimer::~QTimer()
|
||||
{
|
||||
if (d_func()->id != INV_TIMER) // stop running timer
|
||||
if (d_func()->id != QTimerPrivate::INV_TIMER) // stop running timer
|
||||
stop();
|
||||
}
|
||||
|
||||
@ -200,7 +185,7 @@ int QTimer::timerId() const
|
||||
void QTimer::start()
|
||||
{
|
||||
Q_D(QTimer);
|
||||
if (d->id != INV_TIMER) // stop running timer
|
||||
if (d->id != QTimerPrivate::INV_TIMER) // stop running timer
|
||||
stop();
|
||||
d->id = QObject::startTimer(d->inter, d->type);
|
||||
d->isActiveData.notify();
|
||||
@ -239,9 +224,9 @@ void QTimer::start(int msec)
|
||||
void QTimer::stop()
|
||||
{
|
||||
Q_D(QTimer);
|
||||
if (d->id != INV_TIMER) {
|
||||
if (d->id != QTimerPrivate::INV_TIMER) {
|
||||
QObject::killTimer(d->id);
|
||||
d->id = INV_TIMER;
|
||||
d->id = QTimerPrivate::INV_TIMER;
|
||||
d->isActiveData.notify();
|
||||
}
|
||||
}
|
||||
@ -721,7 +706,7 @@ void QTimer::setInterval(int msec)
|
||||
Q_D(QTimer);
|
||||
const bool intervalChanged = msec != d->inter;
|
||||
d->inter.setValue(msec);
|
||||
if (d->id != INV_TIMER) { // create new timer
|
||||
if (d->id != QTimerPrivate::INV_TIMER) { // create new timer
|
||||
QObject::killTimer(d->id); // restart timer
|
||||
d->id = QObject::startTimer(msec, d->type);
|
||||
// No need to call markDirty() for d->isActiveData here,
|
||||
@ -755,7 +740,7 @@ QBindable<int> QTimer::bindableInterval()
|
||||
int QTimer::remainingTime() const
|
||||
{
|
||||
Q_D(const QTimer);
|
||||
if (d->id != INV_TIMER) {
|
||||
if (d->id != QTimerPrivate::INV_TIMER) {
|
||||
return QAbstractEventDispatcher::instance()->remainingTime(d->id);
|
||||
}
|
||||
|
||||
|
39
src/corelib/kernel/qtimer_p.h
Normal file
39
src/corelib/kernel/qtimer_p.h
Normal file
@ -0,0 +1,39 @@
|
||||
// Copyright (C) 2022 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
|
||||
#ifndef QTIMER_P_H
|
||||
#define QTIMER_P_H
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists for the convenience
|
||||
// of the Qt translation tools. This header file may change from version
|
||||
// to version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
#include "qobject_p.h"
|
||||
#include "qproperty_p.h"
|
||||
#include "qtimer.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QTimerPrivate : public QObjectPrivate
|
||||
{
|
||||
Q_DECLARE_PUBLIC(QTimer)
|
||||
public:
|
||||
static constexpr int INV_TIMER = -1; // invalid timer id
|
||||
|
||||
void setInterval(int msec) { q_func()->setInterval(msec); }
|
||||
bool isActiveActualCalculation() const { return id >= 0; }
|
||||
|
||||
int id = INV_TIMER;
|
||||
Q_OBJECT_COMPAT_PROPERTY_WITH_ARGS(QTimerPrivate, int, inter, &QTimerPrivate::setInterval, 0)
|
||||
Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(QTimerPrivate, bool, single, false)
|
||||
Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(QTimerPrivate, Qt::TimerType, type, Qt::CoarseTimer)
|
||||
Q_OBJECT_COMPUTED_PROPERTY(QTimerPrivate, bool, isActiveData,
|
||||
&QTimerPrivate::isActiveActualCalculation)
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
#endif // QTIMER_P_H
|
Loading…
x
Reference in New Issue
Block a user