Search packages using the matches API
This commit is contained in:
parent
1c4e3263f8
commit
54aec82c38
3 changed files with 20 additions and 0 deletions
|
@ -606,6 +606,8 @@ QVariant AircraftItemModel::data(const QModelIndex& index, int role) const
|
||||||
return ex.valid() ? ex->downloadedPercent() : 0;
|
return ex.valid() ? ex->downloadedPercent() : 0;
|
||||||
} else if (role == AircraftInstallDownloadedSizeRole) {
|
} else if (role == AircraftInstallDownloadedSizeRole) {
|
||||||
return static_cast<quint64>(ex.valid() ? ex->downloadedBytes() : 0);
|
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);
|
return dataFromPackage(pkg, m_delegateStates.at(row), role);
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
|
|
||||||
#include <simgear/package/Delegate.hxx>
|
#include <simgear/package/Delegate.hxx>
|
||||||
#include <simgear/package/Root.hxx>
|
#include <simgear/package/Root.hxx>
|
||||||
|
#include <simgear/package/Catalog.hxx>
|
||||||
|
#include <simgear/package/Package.hxx>
|
||||||
|
|
||||||
const int AircraftPathRole = Qt::UserRole + 1;
|
const int AircraftPathRole = Qt::UserRole + 1;
|
||||||
const int AircraftAuthorsRole = Qt::UserRole + 2;
|
const int AircraftAuthorsRole = Qt::UserRole + 2;
|
||||||
|
@ -50,6 +52,7 @@ const int AircraftThumbnailSizeRole = Qt::UserRole + 15;
|
||||||
const int AircraftIsHelicopterRole = Qt::UserRole + 16;
|
const int AircraftIsHelicopterRole = Qt::UserRole + 16;
|
||||||
const int AircraftIsSeaplaneRole = Qt::UserRole + 17;
|
const int AircraftIsSeaplaneRole = Qt::UserRole + 17;
|
||||||
const int AircraftCurrentThumbnailRole = Qt::UserRole + 18;
|
const int AircraftCurrentThumbnailRole = Qt::UserRole + 18;
|
||||||
|
const int AircraftPackageRefRole = Qt::UserRole + 19;
|
||||||
|
|
||||||
const int AircraftRatingRole = Qt::UserRole + 100;
|
const int AircraftRatingRole = Qt::UserRole + 100;
|
||||||
const int AircraftVariantDescriptionRole = Qt::UserRole + 200;
|
const int AircraftVariantDescriptionRole = Qt::UserRole + 200;
|
||||||
|
@ -61,6 +64,8 @@ class PackageDelegate;
|
||||||
struct AircraftItem;
|
struct AircraftItem;
|
||||||
typedef QSharedPointer<AircraftItem> AircraftItemPtr;
|
typedef QSharedPointer<AircraftItem> AircraftItemPtr;
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(simgear::pkg::PackageRef)
|
||||||
|
|
||||||
struct AircraftItem
|
struct AircraftItem
|
||||||
{
|
{
|
||||||
AircraftItem();
|
AircraftItem();
|
||||||
|
|
|
@ -352,6 +352,13 @@ public:
|
||||||
void setAircraftFilterString(QString s)
|
void setAircraftFilterString(QString s)
|
||||||
{
|
{
|
||||||
m_filterString = 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();
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -416,6 +423,11 @@ private:
|
||||||
return true;
|
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();
|
QString baseName = sourceIndex.data(Qt::DisplayRole).toString();
|
||||||
if (baseName.contains(m_filterString, Qt::CaseInsensitive)) {
|
if (baseName.contains(m_filterString, Qt::CaseInsensitive)) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -441,6 +453,7 @@ private:
|
||||||
bool m_onlyShowInstalled;
|
bool m_onlyShowInstalled;
|
||||||
int m_ratings[4];
|
int m_ratings[4];
|
||||||
QString m_filterString;
|
QString m_filterString;
|
||||||
|
SGPropertyNode_ptr m_filterProps;
|
||||||
};
|
};
|
||||||
|
|
||||||
class NoOfficialHangarMessage : public QWidget
|
class NoOfficialHangarMessage : public QWidget
|
||||||
|
|
Loading…
Add table
Reference in a new issue