Moved SortingMode enum to StationListProxyModel
[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     Q_ENUMS(SortingMode)
15 public:
16
17     enum SortingMode {
18         NoSorting,
19         AlphaSorting,
20         DistanceSorting,
21         RecentUsageSorting
22     };
23
24     explicit StationListProxyModel(QObject *parent = 0);
25
26     QString searchPattern() const;
27     void setSearchPattern(const QString &pattern);
28
29     Q_INVOKABLE void setUserPosition(const QGeoCoordinate &pos);
30     Q_INVOKABLE void setRecentStations(const QStringList &stations);
31     Q_INVOKABLE void setRecentOnlyFilter(bool);
32
33 protected:
34     virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
35     virtual bool filterAcceptsRow(int sourceRow,
36             const QModelIndex &sourceParent) const;
37
38 private:
39     QString m_searchPattern;
40     QGeoCoordinate m_here;
41     QStringList m_stations;
42     bool m_filterRecentOnly;
43 };
44
45 #endif // STATIONLISTPROXYMODEL_H