2023-12-15 15:48:40 +00:00
|
|
|
// Copyright (C) 2023 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
|
|
|
|
|
|
|
#ifndef CONTROLLER_H
|
|
|
|
#define CONTROLLER_H
|
|
|
|
|
2024-01-22 13:02:02 +00:00
|
|
|
#include "laststrikeinfo.h"
|
|
|
|
#include "lightningitemmodel.h"
|
|
|
|
#include "lightningprovider.h"
|
2023-12-15 15:48:40 +00:00
|
|
|
|
2024-01-26 18:31:08 +00:00
|
|
|
#include <QGeoPositionInfo>
|
2023-12-15 15:48:40 +00:00
|
|
|
#include <QObject>
|
2024-01-22 13:02:02 +00:00
|
|
|
#include <QtQmlIntegration>
|
2023-12-15 15:48:40 +00:00
|
|
|
#include <QTime>
|
|
|
|
|
|
|
|
class Controller : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2024-01-16 14:14:12 +00:00
|
|
|
Q_DISABLE_COPY_MOVE(Controller)
|
2023-12-15 15:48:40 +00:00
|
|
|
|
|
|
|
Q_PROPERTY(QAbstractItemModel* model READ getModel NOTIFY modelUpdated FINAL)
|
2024-01-18 11:45:31 +00:00
|
|
|
Q_PROPERTY(double lastStrikeDistance READ getLastStrikeDistance NOTIFY lastStrikeInfoUpdated FINAL)
|
|
|
|
Q_PROPERTY(int lastStrikeTime READ getLastStrikeTime NOTIFY lastStrikeInfoUpdated FINAL)
|
|
|
|
Q_PROPERTY(double lastStrikeDirection READ getLastStrikeDirection NOTIFY lastStrikeInfoUpdated FINAL)
|
|
|
|
Q_PROPERTY(bool distanceTimeLayerEnabled READ isDistanceTimeLayerEnabled WRITE setDistanceTimeLayerEnabled NOTIFY distanceTimeLayerEnabledChanged FINAL)
|
2023-12-15 15:48:40 +00:00
|
|
|
|
2024-01-22 13:02:02 +00:00
|
|
|
QML_NAMED_ELEMENT(LightningController)
|
|
|
|
QML_SINGLETON
|
|
|
|
|
2023-12-15 15:48:40 +00:00
|
|
|
public:
|
|
|
|
explicit Controller(QObject *parent = nullptr);
|
|
|
|
~Controller() override;
|
|
|
|
|
|
|
|
QAbstractItemModel *getModel();
|
|
|
|
|
2024-01-26 18:31:08 +00:00
|
|
|
Q_INVOKABLE void setUserLocation(const QGeoCoordinate &coordinate);
|
|
|
|
|
2023-12-15 15:48:40 +00:00
|
|
|
private:
|
2024-01-15 13:47:32 +00:00
|
|
|
int getLastStrikeTime();
|
2023-12-15 15:48:40 +00:00
|
|
|
double getLastStrikeDistance();
|
|
|
|
double getLastStrikeDirection();
|
2024-01-18 11:45:31 +00:00
|
|
|
void setDistanceTimeLayerEnabled(bool enabled);
|
|
|
|
bool isDistanceTimeLayerEnabled() const;
|
|
|
|
void updateDistanceTime();
|
2024-01-09 09:55:48 +00:00
|
|
|
void updateDistanceTime(const LightningItemData &data);
|
2023-12-15 15:48:40 +00:00
|
|
|
|
|
|
|
private slots:
|
2024-01-09 09:55:48 +00:00
|
|
|
void onDataReceived(const LightningItemData &data);
|
2023-12-15 15:48:40 +00:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void lastStrikeInfoUpdated();
|
|
|
|
void modelUpdated();
|
2024-01-18 11:45:31 +00:00
|
|
|
void distanceTimeLayerEnabledChanged();
|
2023-12-15 15:48:40 +00:00
|
|
|
|
|
|
|
private:
|
2024-01-16 14:14:12 +00:00
|
|
|
LastStrikeInfo m_lastStrikeInfo;
|
|
|
|
LightningItemModel m_model;
|
|
|
|
LightningProvider m_provider;
|
|
|
|
QGeoCoordinate m_userLocation;
|
2024-01-18 11:45:31 +00:00
|
|
|
bool m_distanceTimeLayerEnabled {false};
|
2023-12-15 15:48:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CONTROLLER_H
|