diff --git a/src/GUI/AircraftModel.cxx b/src/GUI/AircraftModel.cxx index 3ab11bb17..67ab0a791 100644 --- a/src/GUI/AircraftModel.cxx +++ b/src/GUI/AircraftModel.cxx @@ -606,6 +606,8 @@ QVariant AircraftItemModel::data(const QModelIndex& index, int role) const return ex.valid() ? ex->downloadedPercent() : 0; } else if (role == AircraftInstallDownloadedSizeRole) { return static_cast(ex.valid() ? ex->downloadedBytes() : 0); + } else if (role == AircraftPackageRefRole ) { + return QVariant::fromValue(pkg); } return dataFromPackage(pkg, m_delegateStates.at(row), role); diff --git a/src/GUI/AircraftModel.hxx b/src/GUI/AircraftModel.hxx index 3731c167f..534114155 100644 --- a/src/GUI/AircraftModel.hxx +++ b/src/GUI/AircraftModel.hxx @@ -31,6 +31,8 @@ #include #include +#include +#include const int AircraftPathRole = Qt::UserRole + 1; const int AircraftAuthorsRole = Qt::UserRole + 2; @@ -50,6 +52,7 @@ const int AircraftThumbnailSizeRole = Qt::UserRole + 15; const int AircraftIsHelicopterRole = Qt::UserRole + 16; const int AircraftIsSeaplaneRole = Qt::UserRole + 17; const int AircraftCurrentThumbnailRole = Qt::UserRole + 18; +const int AircraftPackageRefRole = Qt::UserRole + 19; const int AircraftRatingRole = Qt::UserRole + 100; const int AircraftVariantDescriptionRole = Qt::UserRole + 200; @@ -61,6 +64,8 @@ class PackageDelegate; struct AircraftItem; typedef QSharedPointer AircraftItemPtr; +Q_DECLARE_METATYPE(simgear::pkg::PackageRef) + struct AircraftItem { AircraftItem(); diff --git a/src/GUI/QtLauncher.cxx b/src/GUI/QtLauncher.cxx index f6e85245e..752870afc 100644 --- a/src/GUI/QtLauncher.cxx +++ b/src/GUI/QtLauncher.cxx @@ -352,6 +352,13 @@ public: void setAircraftFilterString(QString s) { m_filterString = s; + + m_filterProps = new SGPropertyNode; + int index = 0; + Q_FOREACH(QString term, s.split(' ')) { + m_filterProps->getNode("all-of/text", index++, true)->setStringValue(term.toStdString()); + } + invalidate(); } @@ -416,6 +423,11 @@ private: return true; } + simgear::pkg::PackageRef pkg = sourceIndex.data(AircraftPackageRefRole).value(); + if (pkg) { + return pkg->matches(m_filterProps.ptr()); + } + QString baseName = sourceIndex.data(Qt::DisplayRole).toString(); if (baseName.contains(m_filterString, Qt::CaseInsensitive)) { return true; @@ -441,6 +453,7 @@ private: bool m_onlyShowInstalled; int m_ratings[4]; QString m_filterString; + SGPropertyNode_ptr m_filterProps; }; class NoOfficialHangarMessage : public QWidget