File indexing completed on 2025-01-05 03:59:21
0001 /* 0002 This file is part of the Ofi Labs X2 project. 0003 0004 SPDX-FileCopyrightText: 2010 Ariya Hidayat <ariya.hidayat@gmail.com> 0005 SPDX-License-Identifier: BSD-3-Clause 0006 */ 0007 0008 #ifndef OFILABS_KINETICMODEL 0009 #define OFILABS_KINETICMODEL 0010 0011 #include <QObject> 0012 #include <QScopedPointer> 0013 #include <QPointF> 0014 0015 class KineticModelPrivate; 0016 0017 class KineticModel: public QObject 0018 { 0019 Q_OBJECT 0020 Q_PROPERTY(int duration READ duration WRITE setDuration) 0021 Q_PROPERTY(QPointF position READ position NOTIFY positionChanged) 0022 Q_PROPERTY(int updateInterval READ updateInterval WRITE setUpdateInterval) 0023 0024 public: 0025 explicit KineticModel(QObject *parent = nullptr); 0026 ~KineticModel() override; 0027 0028 int duration() const; 0029 QPointF position() const; 0030 int updateInterval() const; 0031 bool hasVelocity() const; 0032 0033 public Q_SLOTS: 0034 void setDuration(int ms); 0035 void setPosition(const QPointF& position); 0036 void setPosition(qreal posX, qreal posY); 0037 void setHeading(qreal heading); 0038 void jumpToPosition(const QPointF& position); 0039 void jumpToPosition(qreal posX, qreal posY); 0040 void setUpdateInterval(int ms); 0041 void stop(); 0042 void start(); 0043 0044 Q_SIGNALS: 0045 void positionChanged( qreal lon, qreal lat ); 0046 void headingChanged( qreal heading ); 0047 void finished(); 0048 0049 private Q_SLOTS: 0050 void update(); 0051 0052 private: 0053 QScopedPointer<KineticModelPrivate> d_ptr; 0054 Q_DECLARE_PRIVATE(KineticModel); 0055 Q_DISABLE_COPY(KineticModel); 0056 }; 0057 0058 #endif