On-disk support for multiple primary aircraft.
Also add support for customised / per-variant thumbnails in on-disk aircraft; equivalent support for catalog aircraft still to be done.
This commit is contained in:
parent
41f875a729
commit
8d68741ee9
2 changed files with 22 additions and 6 deletions
|
@ -42,7 +42,7 @@
|
||||||
|
|
||||||
const int STANDARD_THUMBNAIL_HEIGHT = 128;
|
const int STANDARD_THUMBNAIL_HEIGHT = 128;
|
||||||
const int STANDARD_THUMBNAIL_WIDTH = 172;
|
const int STANDARD_THUMBNAIL_WIDTH = 172;
|
||||||
static quint32 CACHE_VERSION = 6;
|
static quint32 CACHE_VERSION = 7;
|
||||||
|
|
||||||
using namespace simgear::pkg;
|
using namespace simgear::pkg;
|
||||||
|
|
||||||
|
@ -87,6 +87,12 @@ AircraftItem::AircraftItem(QDir dir, QString filePath)
|
||||||
|
|
||||||
if (sim->hasChild("variant-of")) {
|
if (sim->hasChild("variant-of")) {
|
||||||
variantOf = sim->getStringValue("variant-of");
|
variantOf = sim->getStringValue("variant-of");
|
||||||
|
} else {
|
||||||
|
isPrimary = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sim->hasChild("primary-set")) {
|
||||||
|
isPrimary = sim->getBoolValue("primary-set");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sim->hasChild("tags")) {
|
if (sim->hasChild("tags")) {
|
||||||
|
@ -113,6 +119,12 @@ AircraftItem::AircraftItem(QDir dir, QString filePath)
|
||||||
previews.append(QUrl::fromLocalFile(previewPath));
|
previews.append(QUrl::fromLocalFile(previewPath));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sim->hasChild("thumbnail")) {
|
||||||
|
thumbnailPath = sim->getStringValue("thumbnail");
|
||||||
|
} else {
|
||||||
|
thumbnailPath = "thumbnail.jpg";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AircraftItem::baseName() const
|
QString AircraftItem::baseName() const
|
||||||
|
@ -129,9 +141,10 @@ void AircraftItem::fromDataStream(QDataStream& ds)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ds >> description >> longDescription >> authors >> variantOf;
|
ds >> description >> longDescription >> authors >> variantOf >> isPrimary;
|
||||||
for (int i=0; i<4; ++i) ds >> ratings[i];
|
for (int i=0; i<4; ++i) ds >> ratings[i];
|
||||||
ds >> previews;
|
ds >> previews;
|
||||||
|
ds >> thumbnailPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AircraftItem::toDataStream(QDataStream& ds) const
|
void AircraftItem::toDataStream(QDataStream& ds) const
|
||||||
|
@ -141,9 +154,10 @@ void AircraftItem::toDataStream(QDataStream& ds) const
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ds << description << longDescription << authors << variantOf;
|
ds << description << longDescription << authors << variantOf << isPrimary;
|
||||||
for (int i=0; i<4; ++i) ds << ratings[i];
|
for (int i=0; i<4; ++i) ds << ratings[i];
|
||||||
ds << previews;
|
ds << previews;
|
||||||
|
ds << thumbnailPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap AircraftItem::thumbnail(bool loadIfRequired) const
|
QPixmap AircraftItem::thumbnail(bool loadIfRequired) const
|
||||||
|
@ -151,8 +165,8 @@ QPixmap AircraftItem::thumbnail(bool loadIfRequired) const
|
||||||
if (m_thumbnail.isNull() && loadIfRequired) {
|
if (m_thumbnail.isNull() && loadIfRequired) {
|
||||||
QFileInfo info(path);
|
QFileInfo info(path);
|
||||||
QDir dir = info.dir();
|
QDir dir = info.dir();
|
||||||
if (dir.exists("thumbnail.jpg")) {
|
if (dir.exists(thumbnailPath)) {
|
||||||
m_thumbnail.load(dir.filePath("thumbnail.jpg"));
|
m_thumbnail.load(dir.filePath(thumbnailPath));
|
||||||
// resize to the standard size
|
// resize to the standard size
|
||||||
if (m_thumbnail.height() > STANDARD_THUMBNAIL_HEIGHT) {
|
if (m_thumbnail.height() > STANDARD_THUMBNAIL_HEIGHT) {
|
||||||
m_thumbnail = m_thumbnail.scaledToHeight(STANDARD_THUMBNAIL_HEIGHT, Qt::SmoothTransformation);
|
m_thumbnail = m_thumbnail.scaledToHeight(STANDARD_THUMBNAIL_HEIGHT, Qt::SmoothTransformation);
|
||||||
|
@ -283,7 +297,7 @@ private:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item->variantOf.isNull()) {
|
if (item->isPrimary) {
|
||||||
baseAircraft.insert(item->baseName(), item);
|
baseAircraft.insert(item->baseName(), item);
|
||||||
} else {
|
} else {
|
||||||
variants.append(item);
|
variants.append(item);
|
||||||
|
|
|
@ -92,6 +92,8 @@ struct AircraftItem
|
||||||
bool usesHeliports = false;
|
bool usesHeliports = false;
|
||||||
bool usesSeaports = false;
|
bool usesSeaports = false;
|
||||||
QList<QUrl> previews;
|
QList<QUrl> previews;
|
||||||
|
bool isPrimary = false;
|
||||||
|
QString thumbnailPath;
|
||||||
private:
|
private:
|
||||||
mutable QPixmap m_thumbnail;
|
mutable QPixmap m_thumbnail;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue