Fix launcher ratings order and labelling
Had a dumb string naming glitch, and also we didn’t check for the ordering of ratings being different when dealing with packaged aircraft.
This commit is contained in:
parent
8e05816b43
commit
28f55889b0
6 changed files with 29 additions and 19 deletions
|
@ -418,12 +418,7 @@ QVariant AircraftItemModel::dataFromPackage(const PackageRef& item, const Delega
|
||||||
} else if (role == AircraftHasRatingsRole) {
|
} else if (role == AircraftHasRatingsRole) {
|
||||||
return item->properties()->hasChild("rating");
|
return item->properties()->hasChild("rating");
|
||||||
} else if ((role >= AircraftRatingRole) && (role < AircraftVariantDescriptionRole)) {
|
} else if ((role >= AircraftRatingRole) && (role < AircraftVariantDescriptionRole)) {
|
||||||
int ratingIndex = role - AircraftRatingRole;
|
return packageRating(item, role - AircraftRatingRole);
|
||||||
SGPropertyNode* ratings = item->properties()->getChild("rating");
|
|
||||||
if (!ratings) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return ratings->getChild(ratingIndex)->getIntValue();
|
|
||||||
} else if (role == AircraftStatusRole) {
|
} else if (role == AircraftStatusRole) {
|
||||||
return QmlAircraftInfo::packageAircraftStatus(item);
|
return QmlAircraftInfo::packageAircraftStatus(item);
|
||||||
} else if (role == AircraftMinVersionRole) {
|
} else if (role == AircraftMinVersionRole) {
|
||||||
|
@ -436,6 +431,11 @@ QVariant AircraftItemModel::dataFromPackage(const PackageRef& item, const Delega
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariant AircraftItemModel::packageRating(const PackageRef& p, int ratingIndex) const
|
||||||
|
{
|
||||||
|
return LocalAircraftCache::ratingFromProperties(p->properties()->getChild("rating"), ratingIndex);
|
||||||
|
}
|
||||||
|
|
||||||
QVariant AircraftItemModel::packageThumbnail(PackageRef p, const DelegateState& ds, bool download) const
|
QVariant AircraftItemModel::packageThumbnail(PackageRef p, const DelegateState& ds, bool download) const
|
||||||
{
|
{
|
||||||
const Package::Thumbnail& thumb(p->thumbnailForVariant(ds.variant));
|
const Package::Thumbnail& thumb(p->thumbnailForVariant(ds.variant));
|
||||||
|
|
|
@ -70,7 +70,7 @@ public:
|
||||||
|
|
||||||
AircraftItemModel(QObject* pr);
|
AircraftItemModel(QObject* pr);
|
||||||
|
|
||||||
~AircraftItemModel();
|
~AircraftItemModel() override;
|
||||||
|
|
||||||
void setPackageRoot(const simgear::pkg::RootRef& root);
|
void setPackageRoot(const simgear::pkg::RootRef& root);
|
||||||
|
|
||||||
|
@ -135,6 +135,7 @@ private:
|
||||||
QVariant dataFromPackage(const simgear::pkg::PackageRef& item,
|
QVariant dataFromPackage(const simgear::pkg::PackageRef& item,
|
||||||
const DelegateState& state, int role) const;
|
const DelegateState& state, int role) const;
|
||||||
|
|
||||||
|
QVariant packageRating(const simgear::pkg::PackageRef& p, int ratingIndex) const;
|
||||||
QVariant packageThumbnail(simgear::pkg::PackageRef p,
|
QVariant packageThumbnail(simgear::pkg::PackageRef p,
|
||||||
const DelegateState& state, bool download = true) const;
|
const DelegateState& state, bool download = true) const;
|
||||||
|
|
||||||
|
|
|
@ -70,11 +70,9 @@ AircraftItem::AircraftItem(QDir dir, QString filePath)
|
||||||
|
|
||||||
if (sim->hasChild("rating")) {
|
if (sim->hasChild("rating")) {
|
||||||
SGPropertyNode_ptr ratingsNode = sim->getNode("rating");
|
SGPropertyNode_ptr ratingsNode = sim->getNode("rating");
|
||||||
ratings[0] = ratingsNode->getIntValue("FDM");
|
for (int i=0; i< 4; ++i) {
|
||||||
ratings[1] = ratingsNode->getIntValue("systems");
|
ratings[i] = LocalAircraftCache::ratingFromProperties(ratingsNode, i);
|
||||||
ratings[2] = ratingsNode->getIntValue("cockpit");
|
}
|
||||||
ratings[3] = ratingsNode->getIntValue("model");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sim->hasChild("long-description")) {
|
if (sim->hasChild("long-description")) {
|
||||||
|
@ -572,4 +570,11 @@ bool LocalAircraftCache::isCandidateAircraftPath(QString path)
|
||||||
return (setXmlCount > 0);
|
return (setXmlCount > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int LocalAircraftCache::ratingFromProperties(SGPropertyNode* node, int ratingIndex)
|
||||||
|
{
|
||||||
|
const char* names[] = {"FDM", "systems", "cockpit", "model"};
|
||||||
|
assert((ratingIndex >= 0) && (ratingIndex < 4));
|
||||||
|
return node->getIntValue(names[ratingIndex]);
|
||||||
|
}
|
||||||
|
|
||||||
#include "LocalAircraftCache.moc"
|
#include "LocalAircraftCache.moc"
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
class QDataStream;
|
class QDataStream;
|
||||||
struct AircraftItem;
|
struct AircraftItem;
|
||||||
class AircraftScanThread;
|
class AircraftScanThread;
|
||||||
|
class SGPropertyNode;
|
||||||
|
|
||||||
typedef QSharedPointer<AircraftItem> AircraftItemPtr;
|
typedef QSharedPointer<AircraftItem> AircraftItemPtr;
|
||||||
|
|
||||||
|
@ -129,6 +130,9 @@ public:
|
||||||
|
|
||||||
Q_ENUMS(PackageStatus)
|
Q_ENUMS(PackageStatus)
|
||||||
Q_ENUMS(AircraftStatus)
|
Q_ENUMS(AircraftStatus)
|
||||||
|
|
||||||
|
// rating order is FDM, Systems, Cockpit, External model
|
||||||
|
static int ratingFromProperties(SGPropertyNode* node, int ratingIndex);
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
void scanStarted();
|
void scanStarted();
|
||||||
|
|
|
@ -175,7 +175,7 @@ Rectangle {
|
||||||
AircraftRating {
|
AircraftRating {
|
||||||
title: qsTr("Flight model")
|
title: qsTr("Flight model")
|
||||||
Binding on value {
|
Binding on value {
|
||||||
when: aircraft.ratings != undefined
|
when: aircraft.ratings !== undefined
|
||||||
value: aircraft.ratings[0]
|
value: aircraft.ratings[0]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -183,7 +183,7 @@ Rectangle {
|
||||||
AircraftRating {
|
AircraftRating {
|
||||||
title: qsTr("Systems")
|
title: qsTr("Systems")
|
||||||
Binding on value {
|
Binding on value {
|
||||||
when: aircraft.ratings != undefined
|
when: aircraft.ratings !== undefined
|
||||||
value: aircraft.ratings[1]
|
value: aircraft.ratings[1]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -196,7 +196,7 @@ Rectangle {
|
||||||
AircraftRating {
|
AircraftRating {
|
||||||
title: qsTr("Cockpit")
|
title: qsTr("Cockpit")
|
||||||
Binding on value {
|
Binding on value {
|
||||||
when: aircraft.ratings != undefined
|
when: aircraft.ratings !== undefined
|
||||||
value: aircraft.ratings[2]
|
value: aircraft.ratings[2]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,7 @@ Rectangle {
|
||||||
AircraftRating {
|
AircraftRating {
|
||||||
title: qsTr("Exterior")
|
title: qsTr("Exterior")
|
||||||
Binding on value {
|
Binding on value {
|
||||||
when: aircraft.ratings != undefined
|
when: aircraft.ratings !== undefined
|
||||||
value: aircraft.ratings[3]
|
value: aircraft.ratings[3]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,19 +88,19 @@ ListHeaderBox
|
||||||
}
|
}
|
||||||
|
|
||||||
RatingSlider {
|
RatingSlider {
|
||||||
label: qsTr("Minimum visual model rating")
|
label: qsTr("Minimum systems rating")
|
||||||
ratings: _launcher.browseAircraftModel.ratings
|
ratings: _launcher.browseAircraftModel.ratings
|
||||||
ratingIndex: 1
|
ratingIndex: 1
|
||||||
}
|
}
|
||||||
|
|
||||||
RatingSlider {
|
RatingSlider {
|
||||||
label: qsTr("Minimum systems rating")
|
label: qsTr("Minimum cockpit visual rating")
|
||||||
ratings: _launcher.browseAircraftModel.ratings
|
ratings: _launcher.browseAircraftModel.ratings
|
||||||
ratingIndex: 2
|
ratingIndex: 2
|
||||||
}
|
}
|
||||||
|
|
||||||
RatingSlider {
|
RatingSlider {
|
||||||
label: qsTr("Minimum FDM rating")
|
label: qsTr("Minimum exterial visual model rating")
|
||||||
ratings: _launcher.browseAircraftModel.ratings
|
ratings: _launcher.browseAircraftModel.ratings
|
||||||
ratingIndex: 3
|
ratingIndex: 3
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue