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>
|
|
|
|
|
|
|
|
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)
|
2017-10-13 15:48:24 +00:00
|
|
|
Q_PROPERTY(int 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)
|
2017-10-09 20:53:26 +00:00
|
|
|
Q_PROPERTY(int numVariants READ numVariants NOTIFY infoChanged)
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
Q_PROPERTY(QString pathOnDisk READ pathOnDisk NOTIFY infoChanged)
|
|
|
|
|
|
|
|
Q_PROPERTY(QString packageId READ packageId NOTIFY infoChanged)
|
|
|
|
|
|
|
|
Q_PROPERTY(int packageSize READ packageSize NOTIFY infoChanged)
|
|
|
|
|
|
|
|
Q_PROPERTY(int downloadedBytes READ downloadedBytes NOTIFY downloadChanged)
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
Q_INVOKABLE void requestInstallUpdate();
|
|
|
|
|
|
|
|
Q_INVOKABLE void requestUninstall();
|
|
|
|
|
|
|
|
Q_INVOKABLE void requestInstallCancel();
|
|
|
|
|
|
|
|
Q_PROPERTY(QVariantList ratings READ ratings NOTIFY infoChanged)
|
|
|
|
|
2017-10-13 15:48:24 +00:00
|
|
|
Q_PROPERTY(QStringList variantNames READ variantNames NOTIFY infoChanged)
|
|
|
|
|
2017-12-08 22:03:09 +00:00
|
|
|
Q_PROPERTY(bool isPackaged READ isPackaged 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)
|
|
|
|
|
2018-03-11 11:49:38 +00:00
|
|
|
Q_PROPERTY(StatesModel* statesModel READ statesModel NOTIFY infoChanged)
|
2018-02-11 21:28:25 +00:00
|
|
|
|
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
|
|
|
|
|
|
|
int numVariants() const;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
QString packageId() const;
|
|
|
|
int packageSize() const;
|
|
|
|
int downloadedBytes() const;
|
|
|
|
|
|
|
|
QVariant status() const;
|
|
|
|
QString minimumFGVersion() const;
|
|
|
|
|
|
|
|
static QVariant packageAircraftStatus(simgear::pkg::PackageRef p);
|
2017-10-13 15:48:24 +00:00
|
|
|
|
|
|
|
int variant() const
|
|
|
|
{
|
|
|
|
return _variant;
|
|
|
|
}
|
|
|
|
|
|
|
|
QVariant installStatus() const;
|
|
|
|
|
|
|
|
simgear::pkg::PackageRef packageRef() const;
|
|
|
|
|
|
|
|
void setDownloadBytes(int bytes);
|
|
|
|
|
|
|
|
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-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();
|
2017-10-09 20:53:26 +00:00
|
|
|
signals:
|
|
|
|
void uriChanged();
|
|
|
|
void infoChanged();
|
|
|
|
void downloadChanged();
|
2017-10-13 15:48:24 +00:00
|
|
|
void variantChanged(int variant);
|
|
|
|
|
2017-10-09 20:53:26 +00:00
|
|
|
public slots:
|
|
|
|
|
|
|
|
void setUri(QUrl uri);
|
|
|
|
|
2017-10-13 15:48:24 +00:00
|
|
|
void setVariant(int variant);
|
|
|
|
|
2017-10-09 20:53:26 +00:00
|
|
|
private:
|
2018-02-11 21:28:25 +00:00
|
|
|
AircraftItemPtr resolveItem() const;
|
|
|
|
void checkForStates();
|
|
|
|
|
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;
|
|
|
|
int _variant = 0;
|
2017-10-13 15:48:24 +00:00
|
|
|
int _downloadBytes = 0;
|
2018-03-11 11:49:38 +00:00
|
|
|
QScopedPointer<StatesModel> _statesModel;
|
2017-10-09 20:53:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // QMLAIRCRAFTINFO_HXX
|