1
0
Fork 0

Search packages using the matches API

This commit is contained in:
James Turner 2016-11-30 21:33:16 +00:00
parent 1c4e3263f8
commit 54aec82c38
3 changed files with 20 additions and 0 deletions

View file

@ -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<quint64>(ex.valid() ? ex->downloadedBytes() : 0);
} else if (role == AircraftPackageRefRole ) {
return QVariant::fromValue(pkg);
}
return dataFromPackage(pkg, m_delegateStates.at(row), role);

View file

@ -31,6 +31,8 @@
#include <simgear/package/Delegate.hxx>
#include <simgear/package/Root.hxx>
#include <simgear/package/Catalog.hxx>
#include <simgear/package/Package.hxx>
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<AircraftItem> AircraftItemPtr;
Q_DECLARE_METATYPE(simgear::pkg::PackageRef)
struct AircraftItem
{
AircraftItem();

View file

@ -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<simgear::pkg::PackageRef>();
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