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) {
|
||||
return item->properties()->hasChild("rating");
|
||||
} else if ((role >= AircraftRatingRole) && (role < AircraftVariantDescriptionRole)) {
|
||||
int ratingIndex = role - AircraftRatingRole;
|
||||
SGPropertyNode* ratings = item->properties()->getChild("rating");
|
||||
if (!ratings) {
|
||||
return 0;
|
||||
}
|
||||
return ratings->getChild(ratingIndex)->getIntValue();
|
||||
return packageRating(item, role - AircraftRatingRole);
|
||||
} else if (role == AircraftStatusRole) {
|
||||
return QmlAircraftInfo::packageAircraftStatus(item);
|
||||
} else if (role == AircraftMinVersionRole) {
|
||||
|
@ -436,6 +431,11 @@ QVariant AircraftItemModel::dataFromPackage(const PackageRef& item, const Delega
|
|||
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
|
||||
{
|
||||
const Package::Thumbnail& thumb(p->thumbnailForVariant(ds.variant));
|
||||
|
|
|
@ -70,7 +70,7 @@ public:
|
|||
|
||||
AircraftItemModel(QObject* pr);
|
||||
|
||||
~AircraftItemModel();
|
||||
~AircraftItemModel() override;
|
||||
|
||||
void setPackageRoot(const simgear::pkg::RootRef& root);
|
||||
|
||||
|
@ -135,6 +135,7 @@ private:
|
|||
QVariant dataFromPackage(const simgear::pkg::PackageRef& item,
|
||||
const DelegateState& state, int role) const;
|
||||
|
||||
QVariant packageRating(const simgear::pkg::PackageRef& p, int ratingIndex) const;
|
||||
QVariant packageThumbnail(simgear::pkg::PackageRef p,
|
||||
const DelegateState& state, bool download = true) const;
|
||||
|
||||
|
|
|
@ -70,11 +70,9 @@ AircraftItem::AircraftItem(QDir dir, QString filePath)
|
|||
|
||||
if (sim->hasChild("rating")) {
|
||||
SGPropertyNode_ptr ratingsNode = sim->getNode("rating");
|
||||
ratings[0] = ratingsNode->getIntValue("FDM");
|
||||
ratings[1] = ratingsNode->getIntValue("systems");
|
||||
ratings[2] = ratingsNode->getIntValue("cockpit");
|
||||
ratings[3] = ratingsNode->getIntValue("model");
|
||||
|
||||
for (int i=0; i< 4; ++i) {
|
||||
ratings[i] = LocalAircraftCache::ratingFromProperties(ratingsNode, i);
|
||||
}
|
||||
}
|
||||
|
||||
if (sim->hasChild("long-description")) {
|
||||
|
@ -572,4 +570,11 @@ bool LocalAircraftCache::isCandidateAircraftPath(QString path)
|
|||
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"
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
class QDataStream;
|
||||
struct AircraftItem;
|
||||
class AircraftScanThread;
|
||||
class SGPropertyNode;
|
||||
|
||||
typedef QSharedPointer<AircraftItem> AircraftItemPtr;
|
||||
|
||||
|
@ -129,6 +130,9 @@ public:
|
|||
|
||||
Q_ENUMS(PackageStatus)
|
||||
Q_ENUMS(AircraftStatus)
|
||||
|
||||
// rating order is FDM, Systems, Cockpit, External model
|
||||
static int ratingFromProperties(SGPropertyNode* node, int ratingIndex);
|
||||
signals:
|
||||
|
||||
void scanStarted();
|
||||
|
|
|
@ -175,7 +175,7 @@ Rectangle {
|
|||
AircraftRating {
|
||||
title: qsTr("Flight model")
|
||||
Binding on value {
|
||||
when: aircraft.ratings != undefined
|
||||
when: aircraft.ratings !== undefined
|
||||
value: aircraft.ratings[0]
|
||||
}
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ Rectangle {
|
|||
AircraftRating {
|
||||
title: qsTr("Systems")
|
||||
Binding on value {
|
||||
when: aircraft.ratings != undefined
|
||||
when: aircraft.ratings !== undefined
|
||||
value: aircraft.ratings[1]
|
||||
}
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ Rectangle {
|
|||
AircraftRating {
|
||||
title: qsTr("Cockpit")
|
||||
Binding on value {
|
||||
when: aircraft.ratings != undefined
|
||||
when: aircraft.ratings !== undefined
|
||||
value: aircraft.ratings[2]
|
||||
}
|
||||
}
|
||||
|
@ -204,7 +204,7 @@ Rectangle {
|
|||
AircraftRating {
|
||||
title: qsTr("Exterior")
|
||||
Binding on value {
|
||||
when: aircraft.ratings != undefined
|
||||
when: aircraft.ratings !== undefined
|
||||
value: aircraft.ratings[3]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,19 +88,19 @@ ListHeaderBox
|
|||
}
|
||||
|
||||
RatingSlider {
|
||||
label: qsTr("Minimum visual model rating")
|
||||
label: qsTr("Minimum systems rating")
|
||||
ratings: _launcher.browseAircraftModel.ratings
|
||||
ratingIndex: 1
|
||||
}
|
||||
|
||||
RatingSlider {
|
||||
label: qsTr("Minimum systems rating")
|
||||
label: qsTr("Minimum cockpit visual rating")
|
||||
ratings: _launcher.browseAircraftModel.ratings
|
||||
ratingIndex: 2
|
||||
}
|
||||
|
||||
RatingSlider {
|
||||
label: qsTr("Minimum FDM rating")
|
||||
label: qsTr("Minimum exterial visual model rating")
|
||||
ratings: _launcher.browseAircraftModel.ratings
|
||||
ratingIndex: 3
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue