#ifndef AIRCRAFTSEARCHFILTERMODEL_HXX #define AIRCRAFTSEARCHFILTERMODEL_HXX #include #include class AircraftProxyModel : public QSortFilterProxyModel { Q_OBJECT public: AircraftProxyModel(QObject* pr, QAbstractItemModel * source); Q_PROPERTY(QList ratings READ ratings WRITE setRatings NOTIFY ratingsChanged) Q_PROPERTY(bool ratingsFilterEnabled READ ratingsFilterEnabled WRITE setRatingFilterEnabled NOTIFY ratingsFilterEnabledChanged) Q_INVOKABLE void setAircraftFilterString(QString s); /** * Compute the row (index in QML / ListView speak) based on an aircraft URI. * Return -1 if the UIR is not present in the (filtered) model **/ Q_INVOKABLE int indexForURI(QUrl uri) const; Q_INVOKABLE void selectVariantForAircraftURI(QUrl uri); QList ratings() const { return m_ratings; } bool ratingsFilterEnabled() const { return m_ratingsFilter; } void setRatings(QList ratings); void setRatingFilterEnabled(bool e); signals: void ratingsChanged(); void ratingsFilterEnabledChanged(); public slots: void setInstalledFilterEnabled(bool e); protected: bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override; private: bool filterAircraft(const QModelIndex& sourceIndex) const; bool m_ratingsFilter = true; bool m_onlyShowInstalled = false; QList m_ratings; QString m_filterString; SGPropertyNode_ptr m_filterProps; }; #endif // AIRCRAFTSEARCHFILTERMODEL_HXX