Debian Codegraph @

src/GUI/AircraftProxyModel.hxx

raw symbols SCIP
1 #ifndef AIRCRAFTSEARCHFILTERMODEL_HXX
2 #define AIRCRAFTSEARCHFILTERMODEL_HXX
3
4 #include <QSortFilterProxyModel>
5 #include <QUrl>
6
7 #include <simgear/props/props.hxx>
8
9 class AircraftProxyModel : public QSortFilterProxyModel
10 {
11 Q_OBJECT
12 public:
13 AircraftProxyModel(QObject* pr, QAbstractItemModel * source);
14
15 Q_PROPERTY(QList<int> ratings READ ratings WRITE setRatings NOTIFY ratingsChanged)
16
17 Q_PROPERTY(bool ratingsFilterEnabled READ ratingsFilterEnabled WRITE setRatingFilterEnabled NOTIFY ratingsFilterEnabledChanged)
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
25 /**
26 * Compute the row (index in QML / ListView speak) based on an aircraft URI.
27 * Return -1 if the UIR is not present in the (filtered) model
28 **/
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
42 bool ratingsFilterEnabled() const
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;
53 signals:
54 void ratingsChanged();
55 void ratingsFilterEnabledChanged();
56 void summaryTextChanged();
57 void countChanged();
58
59 public slots:
60
61 void setInstalledFilterEnabled(bool e);
62
63 void setHaveUpdateFilterEnabled(bool e);
64
65 void setShowFavourites(bool e);
66 protected:
67 bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
68 bool lessThan(const QModelIndex& left, const QModelIndex& right) const override;
69
70 private:
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