Added a searchPattern property to the model
authorLuciano Montanaro <mikelima@cirulla.net>
Sun, 17 Jul 2011 11:16:03 +0000 (13:16 +0200)
committerLuciano Montanaro <mikelima@cirulla.net>
Tue, 27 Dec 2011 22:16:45 +0000 (23:16 +0100)
It is not strictly necessary, but in this way I should be able to bind
this property to the TetEdit string

application/stationlistproxymodel.cpp
application/stationlistproxymodel.h

index 0c0a97a..2e9b0b2 100644 (file)
@@ -62,3 +62,14 @@ void StationListProxyModel::setRecentOnlyFilter(bool activation)
 {
     m_filterRecentOnly = activation;
 }
+
+QString StationListProxyModel::searchPattern() const
+{
+    return m_searchPattern;
+}
+
+void StationListProxyModel::setSearchPattern(const QString &pattern)
+{
+    m_searchPattern = pattern;
+    setFilterFixedString(m_searchPattern);
+}
index 20ad365..f228752 100644 (file)
@@ -10,9 +10,14 @@ QTM_USE_NAMESPACE
 class StationListProxyModel : public QSortFilterProxyModel
 {
     Q_OBJECT
+    Q_PROPERTY(QString searchPattern READ searchPattern WRITE setSearchPattern)
 
 public:
     explicit StationListProxyModel(QObject *parent = 0);
+
+    QString searchPattern() const;
+    void setSearchPattern(const QString &pattern);
+
     Q_INVOKABLE void setUserPosition(const QGeoCoordinate &pos);
     Q_INVOKABLE void setRecentStations(const QStringList &stations);
     Q_INVOKABLE void setRecentOnlyFilter(bool);
@@ -23,6 +28,7 @@ protected:
             const QModelIndex &sourceParent) const;
 
 private:
+    QString m_searchPattern;
     QGeoCoordinate m_here;
     QStringList m_stations;
     bool m_filterRecentOnly;