2017-10-09 20:53:26 +00:00
|
|
|
#ifndef QMLAIRCRAFTINFO_HXX
|
|
|
|
#define QMLAIRCRAFTINFO_HXX
|
|
|
|
|
2017-10-13 15:48:24 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2017-10-09 20:53:26 +00:00
|
|
|
#include <QObject>
|
|
|
|
#include <QUrl>
|
|
|
|
#include <QSharedPointer>
|
2018-02-11 21:28:25 +00:00
|
|
|
#include <QAbstractListModel>
|
2017-10-09 20:53:26 +00:00
|
|
|
|
|
|
|
#include <simgear/package/Catalog.hxx>
|
|
|
|
#include <simgear/package/Package.hxx>
|
|
|
|
|
2018-07-26 14:36:09 +00:00
|
|
|
#include "UnitsModel.hxx"
|
|
|
|
|
2017-10-09 20:53:26 +00:00
|
|
|
struct AircraftItem;
|
|
|
|
typedef QSharedPointer<AircraftItem> AircraftItemPtr;
|
|
|
|
|
2018-03-11 11:49:38 +00:00
|
|
|
class StatesModel;
|
|
|
|
|
2017-10-09 20:53:26 +00:00
|
|
|
class QmlAircraftInfo : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
Q_PROPERTY(QUrl uri READ uri WRITE setUri NOTIFY uriChanged)
|
2018-09-06 15:12:12 +00:00
|
|
|
Q_PROPERTY(quint32 variant READ variant WRITE setVariant NOTIFY variantChanged)
|
2017-10-09 20:53:26 +00:00
|
|
|
|
2017-10-13 15:48:24 +00:00
|
|
|
Q_PROPERTY(QVariantList previews READ previews NOTIFY infoChanged)
|
2018-09-06 15:12:12 +00:00
|
|
|
Q_PROPERTY(quint32 numVariants READ numVariants NOTIFY infoChanged)
|
2018-07-26 14:36:09 +00:00
|
|
|
Q_PROPERTY(QStringList variantNames READ variantNames NOTIFY infoChanged)
|
2017-10-09 20:53:26 +00:00
|
|
|
|
|
|
|
Q_PROPERTY(QString name READ name NOTIFY infoChanged)
|
|
|
|
Q_PROPERTY(QString description READ description NOTIFY infoChanged)
|
|
|
|
Q_PROPERTY(QString authors READ authors NOTIFY infoChanged)
|
|
|
|
Q_PROPERTY(QUrl thumbnail READ thumbnail NOTIFY infoChanged)
|
2018-07-26 14:36:09 +00:00
|
|
|
Q_PROPERTY(QVariantList ratings READ ratings NOTIFY infoChanged)
|
2017-10-09 20:53:26 +00:00
|
|
|
|
|
|
|
Q_PROPERTY(QString pathOnDisk READ pathOnDisk NOTIFY infoChanged)
|
|
|
|
Q_PROPERTY(QString packageId READ packageId NOTIFY infoChanged)
|
2018-09-06 15:12:12 +00:00
|
|
|
Q_PROPERTY(quint64 packageSize READ packageSize NOTIFY infoChanged)
|
|
|
|
Q_PROPERTY(quint64 downloadedBytes READ downloadedBytes NOTIFY downloadChanged)
|
2018-07-26 14:36:09 +00:00
|
|
|
Q_PROPERTY(bool isPackaged READ isPackaged NOTIFY infoChanged)
|
2017-10-09 20:53:26 +00:00
|
|
|
|
|
|
|
Q_PROPERTY(QVariant status READ status NOTIFY infoChanged)
|
2017-10-13 15:48:24 +00:00
|
|
|
Q_PROPERTY(QVariant installStatus READ installStatus NOTIFY downloadChanged)
|
2017-10-09 20:53:26 +00:00
|
|
|
|
|
|
|
Q_PROPERTY(QString minimumFGVersion READ minimumFGVersion NOTIFY infoChanged)
|
|
|
|
|
2018-07-26 11:03:21 +00:00
|
|
|
Q_PROPERTY(QUrl homePage READ homePage NOTIFY infoChanged)
|
|
|
|
Q_PROPERTY(QUrl supportUrl READ supportUrl NOTIFY infoChanged)
|
|
|
|
Q_PROPERTY(QUrl wikipediaUrl READ wikipediaUrl NOTIFY infoChanged)
|
|
|
|
|
2018-07-26 14:36:09 +00:00
|
|
|
Q_PROPERTY(QuantityValue cruiseSpeed READ cruiseSpeed NOTIFY infoChanged)
|
|
|
|
Q_PROPERTY(QuantityValue cruiseAltitude READ cruiseAltitude NOTIFY infoChanged)
|
|
|
|
Q_PROPERTY(QuantityValue approachSpeed READ approachSpeed NOTIFY infoChanged)
|
2018-07-26 11:03:21 +00:00
|
|
|
|
2018-07-26 14:36:09 +00:00
|
|
|
Q_PROPERTY(QString icaoType READ icaoType NOTIFY infoChanged)
|
2017-10-13 15:48:24 +00:00
|
|
|
|
2018-02-11 21:28:25 +00:00
|
|
|
Q_PROPERTY(bool hasStates READ hasStates NOTIFY infoChanged)
|
2020-10-06 10:39:21 +00:00
|
|
|
Q_PROPERTY(StatesModel* statesModel READ statesModel CONSTANT)
|
2018-02-11 21:28:25 +00:00
|
|
|
|
2020-04-04 08:20:23 +00:00
|
|
|
Q_PROPERTY(bool favourite READ favourite WRITE setFavourite NOTIFY favouriteChanged)
|
2017-10-09 20:53:26 +00:00
|
|
|
public:
|
|
|
|
explicit QmlAircraftInfo(QObject *parent = nullptr);
|
|
|
|
virtual ~QmlAircraftInfo();
|
|
|
|
|
2017-10-13 15:48:24 +00:00
|
|
|
QUrl uri() const;
|
2017-10-09 20:53:26 +00:00
|
|
|
|
2018-09-06 15:12:12 +00:00
|
|
|
quint32 numVariants() const;
|
2017-10-09 20:53:26 +00:00
|
|
|
|
|
|
|
QString name() const;
|
|
|
|
QString description() const;
|
|
|
|
QString authors() const;
|
|
|
|
QVariantList ratings() const;
|
|
|
|
|
2017-10-13 15:48:24 +00:00
|
|
|
QVariantList previews() const;
|
|
|
|
|
2017-10-09 20:53:26 +00:00
|
|
|
QUrl thumbnail() const;
|
|
|
|
QString pathOnDisk() const;
|
|
|
|
|
2018-07-26 11:03:21 +00:00
|
|
|
QUrl homePage() const;
|
|
|
|
QUrl supportUrl() const;
|
|
|
|
QUrl wikipediaUrl() const;
|
|
|
|
|
2017-10-09 20:53:26 +00:00
|
|
|
QString packageId() const;
|
2018-09-06 15:12:12 +00:00
|
|
|
quint64 packageSize() const;
|
|
|
|
quint64 downloadedBytes() const;
|
2017-10-09 20:53:26 +00:00
|
|
|
|
|
|
|
QVariant status() const;
|
|
|
|
QString minimumFGVersion() const;
|
|
|
|
|
|
|
|
static QVariant packageAircraftStatus(simgear::pkg::PackageRef p);
|
2017-10-13 15:48:24 +00:00
|
|
|
|
2018-09-06 15:12:12 +00:00
|
|
|
quint32 variant() const
|
2017-10-13 15:48:24 +00:00
|
|
|
{
|
|
|
|
return _variant;
|
|
|
|
}
|
|
|
|
|
|
|
|
QVariant installStatus() const;
|
|
|
|
|
|
|
|
simgear::pkg::PackageRef packageRef() const;
|
|
|
|
|
2018-09-06 15:12:12 +00:00
|
|
|
void setDownloadBytes(quint64 bytes);
|
2017-10-13 15:48:24 +00:00
|
|
|
|
|
|
|
QStringList variantNames() const;
|
2017-12-08 22:03:09 +00:00
|
|
|
|
|
|
|
bool isPackaged() const;
|
2018-02-11 21:28:25 +00:00
|
|
|
|
2018-04-09 16:13:15 +00:00
|
|
|
bool hasStates() const;
|
2018-02-11 21:28:25 +00:00
|
|
|
|
2018-05-31 23:44:12 +00:00
|
|
|
bool hasState(QString name) const;
|
|
|
|
|
2018-06-27 22:06:39 +00:00
|
|
|
bool haveExplicitAutoState() const;
|
|
|
|
|
2018-02-11 21:28:25 +00:00
|
|
|
static const int StateTagRole;
|
|
|
|
static const int StateDescriptionRole;
|
|
|
|
static const int StateExplicitRole;
|
|
|
|
|
2018-03-11 11:49:38 +00:00
|
|
|
StatesModel* statesModel();
|
2018-07-26 14:36:09 +00:00
|
|
|
|
|
|
|
QuantityValue cruiseSpeed() const;
|
|
|
|
QuantityValue approachSpeed() const;
|
|
|
|
QuantityValue cruiseAltitude() const;
|
|
|
|
|
|
|
|
QString icaoType() const;
|
|
|
|
|
|
|
|
Q_INVOKABLE bool isSpeedBelowLimits(QuantityValue speed) const;
|
|
|
|
Q_INVOKABLE bool isAltitudeBelowLimits(QuantityValue speed) const;
|
|
|
|
|
2018-10-09 09:25:50 +00:00
|
|
|
Q_INVOKABLE bool hasTag(QString tag) const;
|
2020-04-04 08:20:23 +00:00
|
|
|
bool favourite() const;
|
|
|
|
|
2017-10-09 20:53:26 +00:00
|
|
|
signals:
|
|
|
|
void uriChanged();
|
|
|
|
void infoChanged();
|
|
|
|
void downloadChanged();
|
2018-09-06 15:12:12 +00:00
|
|
|
void variantChanged(quint32 variant);
|
2020-04-04 08:20:23 +00:00
|
|
|
void favouriteChanged();
|
2017-10-13 15:48:24 +00:00
|
|
|
|
2017-10-09 20:53:26 +00:00
|
|
|
public slots:
|
|
|
|
|
|
|
|
void setUri(QUrl uri);
|
|
|
|
|
2018-09-06 15:12:12 +00:00
|
|
|
void setVariant(quint32 variant);
|
2017-10-13 15:48:24 +00:00
|
|
|
|
2020-04-04 08:20:23 +00:00
|
|
|
void setFavourite(bool favourite);
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void onFavouriteChanged(QUrl u);
|
2020-10-06 10:39:21 +00:00
|
|
|
void retryValidateLocalProps();
|
|
|
|
|
2017-10-09 20:53:26 +00:00
|
|
|
private:
|
2018-02-11 21:28:25 +00:00
|
|
|
AircraftItemPtr resolveItem() const;
|
|
|
|
|
2020-10-06 10:39:21 +00:00
|
|
|
void validateStates() const;
|
2018-07-26 14:36:09 +00:00
|
|
|
void validateLocalProps() const;
|
|
|
|
|
2017-10-13 15:48:24 +00:00
|
|
|
class Delegate;
|
|
|
|
std::unique_ptr<Delegate> _delegate;
|
|
|
|
|
2017-10-09 20:53:26 +00:00
|
|
|
simgear::pkg::PackageRef _package;
|
|
|
|
AircraftItemPtr _item;
|
2018-07-26 14:36:09 +00:00
|
|
|
quint32 _variant = 0;
|
2018-09-06 15:12:12 +00:00
|
|
|
quint64 _downloadBytes = 0;
|
2020-10-06 10:39:21 +00:00
|
|
|
|
|
|
|
/// either null or owned by us
|
|
|
|
mutable StatesModel* _statesModel = nullptr;
|
|
|
|
|
|
|
|
mutable bool _statesChecked = false;
|
2018-07-26 14:36:09 +00:00
|
|
|
|
|
|
|
/// if the aircraft is locally installed, this is the cached
|
|
|
|
/// parsed contents of the -set.xml.
|
|
|
|
mutable SGPropertyNode_ptr _cachedProps;
|
2017-10-09 20:53:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // QMLAIRCRAFTINFO_HXX
|