Added a searchPattern property to the model
[quandoparte] / application / stationlistproxymodel.h
1 #ifndef STATIONLISTPROXYMODEL_H
2 #define STATIONLISTPROXYMODEL_H
3
4 #include <QSortFilterProxyModel>
5 #include <QGeoCoordinate>
6 #include <QStringList>
7
8 QTM_USE_NAMESPACE
9
10 class StationListProxyModel : public QSortFilterProxyModel
11 {
12     Q_OBJECT
13     Q_PROPERTY(QString searchPattern READ searchPattern WRITE setSearchPattern)
14
15 public:
16     explicit StationListProxyModel(QObject *parent = 0);
17
18     QString searchPattern() const;
19     void setSearchPattern(const QString &pattern);
20
21     Q_INVOKABLE void setUserPosition(const QGeoCoordinate &pos);
22     Q_INVOKABLE void setRecentStations(const QStringList &stations);
23     Q_INVOKABLE void setRecentOnlyFilter(bool);
24
25 protected:
26     virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
27     virtual bool filterAcceptsRow(int sourceRow,
28             const QModelIndex &sourceParent) const;
29
30 private:
31     QString m_searchPattern;
32     QGeoCoordinate m_here;
33     QStringList m_stations;
34     bool m_filterRecentOnly;
35 };
36
37 #endif // STATIONLISTPROXYMODEL_H