Launcher: fix favourites loading
Also fix some warnings, closer to no output from the launcher.
This commit is contained in:
parent
36faef5ad9
commit
f24b886ce4
6 changed files with 30 additions and 22 deletions
|
@ -125,7 +125,7 @@ private:
|
|||
return QModelIndex();
|
||||
}
|
||||
|
||||
int offset = std::distance(m_model->m_packages.begin(), it);
|
||||
const int offset = static_cast<int>(std::distance(m_model->m_packages.begin(), it));
|
||||
return m_model->index(offset + m_model->m_cachedLocalAircraftCount);
|
||||
}
|
||||
|
||||
|
@ -138,6 +138,8 @@ void PackageDelegate::catalogRefreshed(CatalogRef aCatalog, StatusCode aReason)
|
|||
// nothing to do
|
||||
} else if ((aReason == STATUS_REFRESHED) || (aReason == STATUS_SUCCESS)) {
|
||||
m_model->refreshPackages();
|
||||
} else if (aReason == FAIL_VERSION) {
|
||||
// silent about this
|
||||
} else {
|
||||
qWarning() << "failed refresh of"
|
||||
<< QString::fromStdString(aCatalog->url()) << ":" << aReason << endl;
|
||||
|
@ -338,7 +340,7 @@ QVariant AircraftItemModel::dataFromItem(AircraftItemPtr item, const DelegateSta
|
|||
QVariant AircraftItemModel::dataFromPackage(const PackageRef& item, const DelegateState& state, int role) const
|
||||
{
|
||||
if (role >= AircraftVariantDescriptionRole) {
|
||||
int variantIndex = role - AircraftVariantDescriptionRole;
|
||||
const unsigned int variantIndex = static_cast<unsigned int>(role - AircraftVariantDescriptionRole);
|
||||
QString desc = QString::fromStdString(item->nameForVariant(variantIndex));
|
||||
if (desc.isEmpty()) {
|
||||
desc = tr("Missing description for: %1").arg(QString::fromStdString(item->id()));
|
||||
|
@ -493,9 +495,10 @@ QModelIndex AircraftItemModel::indexOfAircraftURI(QUrl uri) const
|
|||
|
||||
PackageRef pkg = m_packageRoot->getPackageById(ident.toStdString());
|
||||
if (pkg) {
|
||||
for (size_t i=0; i < m_packages.size(); ++i) {
|
||||
if (m_packages[i] == pkg) {
|
||||
return index(rowOffset + i);
|
||||
const auto numPackages = m_packages.size();
|
||||
for (unsigned int i=0; i < numPackages; ++i) {
|
||||
if (m_packages.at(i) == pkg) {
|
||||
return index(static_cast<int>(rowOffset + i));
|
||||
}
|
||||
} // of linear package scan
|
||||
}
|
||||
|
@ -542,7 +545,7 @@ void AircraftItemModel::selectVariantForAircraftURI(QUrl uri)
|
|||
if (pkg) {
|
||||
for (size_t i=0; i < m_packages.size(); ++i) {
|
||||
if (m_packages[i] == pkg) {
|
||||
modelIndex = index(rowOffset + static_cast<int>(i));
|
||||
modelIndex = index(rowOffset + static_cast<int>(i));
|
||||
variantIndex = pkg->indexOfVariant(ident.toStdString());
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ protected:
|
|||
private:
|
||||
bool filterAircraft(const QModelIndex& sourceIndex) const;
|
||||
|
||||
bool m_ratingsFilter = true;
|
||||
bool m_ratingsFilter = false;
|
||||
bool m_onlyShowInstalled = false;
|
||||
bool m_onlyShowWithUpdate = false;
|
||||
bool m_onlyShowFavourites = false;
|
||||
|
|
|
@ -111,7 +111,7 @@ QVariant CatalogListModel::data(const QModelIndex& index, int role) const
|
|||
desc = tr("The catalog data was not found on the server at the expected location (URL)");
|
||||
break;
|
||||
case Delegate::FAIL_VERSION:
|
||||
desc = tr("The catalog is not comaptible with the version of FlightGear");
|
||||
desc = tr("The catalog is not compatible with the version of FlightGear");
|
||||
break;
|
||||
case Delegate::FAIL_HTTP_FORBIDDEN:
|
||||
desc = tr("The catalog server is blocking access from some reason (forbidden)");
|
||||
|
|
|
@ -43,7 +43,10 @@ QVariant ModelDataExtractor::data() const
|
|||
return m_rawModel.property(uIndex).toVariant();
|
||||
}
|
||||
|
||||
qWarning() << "Unable to convert model data:" << m_rawModel.toString();
|
||||
if (!m_rawModel.isUndefined() && !m_rawModel.isNull()) {
|
||||
qWarning() << "Unable to convert model data:" << m_rawModel.toString();
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,8 @@ public:
|
|||
}
|
||||
|
||||
protected:
|
||||
void finishInstall(InstallRef aInstall, StatusCode aReason) override;
|
||||
|
||||
void catalogRefreshed(CatalogRef, StatusCode) override
|
||||
{
|
||||
}
|
||||
|
@ -55,19 +57,9 @@ protected:
|
|||
}
|
||||
}
|
||||
|
||||
void finishInstall(InstallRef aInstall, StatusCode aReason) override
|
||||
{
|
||||
Q_UNUSED(aReason);
|
||||
if (aInstall->package() == p->packageRef()) {
|
||||
p->_cachedProps.reset();
|
||||
p->checkForStates();
|
||||
p->infoChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void installStatusChanged(InstallRef aInstall, StatusCode aReason) override
|
||||
{
|
||||
Q_UNUSED(aReason);
|
||||
Q_UNUSED(aReason)
|
||||
if (aInstall->package() == p->packageRef()) {
|
||||
p->downloadChanged();
|
||||
}
|
||||
|
@ -85,6 +77,16 @@ private:
|
|||
QmlAircraftInfo* p;
|
||||
};
|
||||
|
||||
void QmlAircraftInfo::Delegate::finishInstall(InstallRef aInstall, StatusCode aReason)
|
||||
{
|
||||
Q_UNUSED(aReason)
|
||||
if (aInstall->package() == p->packageRef()) {
|
||||
p->_cachedProps.reset();
|
||||
p->checkForStates();
|
||||
p->infoChanged();
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
@ -441,7 +443,7 @@ QVariantList QmlAircraftInfo::previews() const
|
|||
for (auto p : previews) {
|
||||
SGPath localPreviewPath = ex->path() / p.path;
|
||||
if (!localPreviewPath.exists()) {
|
||||
qWarning() << "missing local preview" << QString::fromStdString(localPreviewPath.utf8Str());
|
||||
// this happens when the aircraft is being installed, for example
|
||||
continue;
|
||||
}
|
||||
result.append(QUrl::fromLocalFile(QString::fromStdString(localPreviewPath.utf8Str())));
|
||||
|
|
|
@ -628,7 +628,7 @@ int fgInitConfig ( int argc, char **argv, bool reinit )
|
|||
#endif
|
||||
|
||||
// Read global defaults from $FG_ROOT/defaults
|
||||
SG_LOG(SG_GENERAL, SG_INFO, "Reading global defaults");
|
||||
SG_LOG(SG_GENERAL, SG_DEBUG, "Reading global defaults");
|
||||
SGPath defaultsXML = globals->get_fg_root() / "defaults.xml";
|
||||
if (!defaultsXML.exists()) {
|
||||
flightgear::fatalMessageBoxThenExit(
|
||||
|
|
Loading…
Add table
Reference in a new issue