1// Copyright (C) 2021 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 QQUICKVELOCITYCALCULATOR_P_P_H
5#define QQUICKVELOCITYCALCULATOR_P_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/qpoint.h>
19#include <QtCore/qelapsedtimer.h>
20#include <QtCore/private/qglobal_p.h>
21
22QT_BEGIN_NAMESPACE
23
24class QQuickVelocityCalculator
25{
26public:
27 void startMeasuring(const QPointF &point1, qint64 timestamp = 0);
28 void stopMeasuring(const QPointF &m_point2, qint64 timestamp = 0);
29 void reset();
30 QPointF velocity() const;
31
32private:
33 QPointF m_point1;
34 QPointF m_point2;
35 qint64 m_point1Timestamp = 0;
36 qint64 m_point2Timestamp = 0;
37 // When a timestamp isn't available, we must use a timer.
38 // When stopMeasuring() has been called, we store the elapsed time in point2timestamp.
39 QElapsedTimer m_timer;
40};
41
42QT_END_NAMESPACE
43
44#endif // QQUICKVELOCITYCALCULATOR_P_P_H
45

source code of qtdeclarative/src/quicktemplates/qquickvelocitycalculator_p_p.h