painter->setBrush(Qt::NoBrush);
painter->drawRect(contentRect.left(), yPos, thumbnail.width(), thumbnail.height());
+ // draw bottom dividing line
+ painter->drawLine(contentRect.left(), contentRect.bottom() + MARGIN,
+ contentRect.right(), contentRect.bottom() + MARGIN);
+
int variantCount = index.data(AircraftVariantCountRole).toInt();
int currentVariant =index.data(AircraftVariantRole).toInt();
QString description = index.data(Qt::DisplayRole).toString();
r.moveLeft(r.right());
r.setHeight(24);
- drawRating(painter, "Flight model:", r, index.data(AircraftRatingRole).toInt());
- r.moveTop(r.bottom());
- drawRating(painter, "Systems:", r, index.data(AircraftRatingRole + 1).toInt());
+ if (index.data(AircraftHasRatingsRole).toBool()) {
+ drawRating(painter, "Flight model:", r, index.data(AircraftRatingRole).toInt());
+ r.moveTop(r.bottom());
+ drawRating(painter, "Systems:", r, index.data(AircraftRatingRole + 1).toInt());
- r.moveTop(actualBounds.bottom() + MARGIN);
- r.moveLeft(r.right());
- drawRating(painter, "Cockpit:", r, index.data(AircraftRatingRole + 2).toInt());
- r.moveTop(r.bottom());
- drawRating(painter, "Exterior model:", r, index.data(AircraftRatingRole + 3).toInt());
+ r.moveTop(actualBounds.bottom() + MARGIN);
+ r.moveLeft(r.right());
+ drawRating(painter, "Cockpit:", r, index.data(AircraftRatingRole + 2).toInt());
+ r.moveTop(r.bottom());
+ drawRating(painter, "Exterior model:", r, index.data(AircraftRatingRole + 3).toInt());
+ }
QVariant v = index.data(AircraftPackageStatusRole);
AircraftItemStatus status = static_cast<AircraftItemStatus>(v.toInt());
textHeight += smallMetrics.boundingRect(contentRect, Qt::TextWordWrap, desc).height();
}
- // ratings
- textHeight += 48; // (24px per rating box)
+ if (index.data(AircraftHasRatingsRole).toBool()) {
+ // ratings
+ textHeight += 48; // (24px per rating box)
+ } else {
+ // just the button height
+ textHeight += BUTTON_HEIGHT;
+ }
textHeight = qMax(textHeight, 128);
QPixmap thumbnail = index.data(Qt::DecorationRole).value<QPixmap>();
contentRect.setLeft(contentRect.left() + MARGIN + thumbnail.width());
- return QRect(contentRect.left() + ARROW_SIZE, contentRect.bottom() - 24, 60, 24);
+ return QRect(contentRect.left() + ARROW_SIZE, contentRect.bottom() - 24, 60, BUTTON_HEIGHT);
}
void AircraftItemDelegate::drawRating(QPainter* painter, QString label, const QRect& box, int value) const
{
const int DOT_SIZE = 10;
- const int DOT_MARGIN = 4;
+ const int DOT_MARGIN = 2;
QRect dotBox = box;
dotBox.setLeft(box.right() - (DOT_MARGIN * 6 + DOT_SIZE * 5));
using namespace simgear::pkg;
-AircraftItem::AircraftItem()
+AircraftItem::AircraftItem() :
+ excluded(false)
{
// oh for C++11 initialisers
for (int i=0; i<4; ++i) ratings[i] = 0;
}
-AircraftItem::AircraftItem(QDir dir, QString filePath)
+AircraftItem::AircraftItem(QDir dir, QString filePath) :
+ excluded(false)
{
for (int i=0; i<4; ++i) ratings[i] = 0;
path = filePath;
pathModTime = QFileInfo(path).lastModified();
+ if (sim->getBoolValue("exclude-from-gui", false)) {
+ excluded = true;
+ return;
+ }
description = sim->getStringValue("description");
authors = sim->getStringValue("author");
void AircraftItem::fromDataStream(QDataStream& ds)
{
- ds >> path >> description >> authors >> variantOf;
+ ds >> path >> pathModTime >> excluded;
+ if (excluded) {
+ return;
+ }
+
+ ds >> description >> authors >> variantOf;
for (int i=0; i<4; ++i) ds >> ratings[i];
- ds >> pathModTime;
}
void AircraftItem::toDataStream(QDataStream& ds) const
{
- ds << path << description << authors << variantOf;
+ ds << path << pathModTime << excluded;
+ if (excluded) {
+ return;
+ }
+
+ ds << description << authors << variantOf;
for (int i=0; i<4; ++i) ds << ratings[i];
- ds << pathModTime;
}
QPixmap AircraftItem::thumbnail() const
}
-static int CACHE_VERSION = 2;
+static int CACHE_VERSION = 3;
class AircraftScanThread : public QThread
{
m_nextCache[absolutePath] = item;
+ if (item->excluded) {
+ continue;
+ }
+
if (item->variantOf.isNull()) {
baseAircraft.insert(item->baseName(), item);
} else {
return PackageInstalled; // always the case
} else if (role == Qt::ToolTipRole) {
return item->path;
+ } else if (role == AircraftHasRatingsRole) {
+ bool have = false;
+ for (int i=0; i<4; ++i) {
+ have |= (item->ratings[i] > 0);
+ }
+ return have;
} else if (role == AircraftLongDescriptionRole) {
return "Lorum Ipsum, etc. Is this the real life? Is this just fantasy? Caught in a land-slide, "
"no escape from reality. Open your eyes, like up to the skies and see. "