FlightGear next
AircraftProxyModel.hxx
Go to the documentation of this file.
1#ifndef AIRCRAFTSEARCHFILTERMODEL_HXX
2#define AIRCRAFTSEARCHFILTERMODEL_HXX
3
4#include <QSortFilterProxyModel>
5#include <QUrl>
6
7#include <simgear/props/props.hxx>
8
9class AircraftProxyModel : public QSortFilterProxyModel
10{
11 Q_OBJECT
12public:
13 AircraftProxyModel(QObject* pr, QAbstractItemModel * source);
14
15 Q_PROPERTY(QList<int> ratings READ ratings WRITE setRatings NOTIFY ratingsChanged)
16
18
19 Q_PROPERTY(QString summaryText READ summaryText NOTIFY summaryTextChanged)
20
21 Q_INVOKABLE void setAircraftFilterString(QString s);
22
23 Q_PROPERTY(int count READ count NOTIFY countChanged)
24
29 Q_INVOKABLE int indexForURI(QUrl uri) const;
30
31 Q_INVOKABLE void selectVariantForAircraftURI(QUrl uri);
32
33 Q_INVOKABLE void loadRatingsSettings();
34
35 Q_INVOKABLE void saveRatingsSettings();
36
37 QList<int> ratings() const
38 {
39 return m_ratings;
40 }
41
43 {
44 return m_ratingsFilter;
45 }
46
47 void setRatings(QList<int> ratings);
48 void setRatingFilterEnabled(bool e);
49
50 QString summaryText() const;
51
52 int count() const;
53signals:
58
59public slots:
60
61 void setInstalledFilterEnabled(bool e);
62
63 void setHaveUpdateFilterEnabled(bool e);
64
65 void setShowFavourites(bool e);
66protected:
67 bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
68 bool lessThan(const QModelIndex& left, const QModelIndex& right) const override;
69
70private:
71 bool filterAircraft(const QModelIndex& sourceIndex) const;
72
73 bool m_ratingsFilter = false;
74 bool m_onlyShowInstalled = false;
75 bool m_onlyShowWithUpdate = false;
76 bool m_onlyShowFavourites = false;
77
78 QList<int> m_ratings;
79 QString m_filterString;
80 SGPropertyNode_ptr m_filterProps;
81};
82
83#endif // AIRCRAFTSEARCHFILTERMODEL_HXX
void setRatingFilterEnabled(bool e)
Q_INVOKABLE void saveRatingsSettings()
void ratingsFilterEnabledChanged()
void setRatings(QList< int > ratings)
void setHaveUpdateFilterEnabled(bool e)
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override
void setInstalledFilterEnabled(bool e)
Q_INVOKABLE void loadRatingsSettings()
bool ratingsFilterEnabled() const
AircraftProxyModel(QObject *pr, QAbstractItemModel *source)
Q_INVOKABLE void setAircraftFilterString(QString s)
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override
Custom sorting based on aircraft variants and URI.
Q_INVOKABLE int indexForURI(QUrl uri) const
Compute the row (index in QML / ListView speak) based on an aircraft URI.
Q_INVOKABLE void selectVariantForAircraftURI(QUrl uri)