Add the stationListProxyModel instance to the QML context
authorLuciano Montanaro <mikelima@cirulla.net>
Fri, 15 Jul 2011 23:13:46 +0000 (01:13 +0200)
committerLuciano Montanaro <mikelima@cirulla.net>
Fri, 15 Jul 2011 23:13:46 +0000 (01:13 +0200)
application/view.cpp
application/view.h

index e1a9e06..8162412 100644 (file)
@@ -1,6 +1,9 @@
 #include "view.h"
+#include "stationlistmodel.h"
+#include "stationlistproxymodel.h"
+
+#include <QDeclarativeContext>
 #include <QDeclarativeView>
-#include <QDeclarativeEngine>
 #include <QDebug>
 #include <QDir>
 #include <QFile>
@@ -29,13 +32,22 @@ static QString trueFilePath(QString path)
 }
 
 View::View(QWidget *parent) :
-    QDeclarativeView(parent)
+    QDeclarativeView(parent),
+    stationListModel(new StationListModel(this)),
+    stationListProxyModel(new StationListProxyModel(this))
 {
     showFullScreen();
+    stationListModel->load(trueFilePath("stations:stations.qpl"));
+
+    stationListProxyModel->setSourceModel(stationListModel);
+    stationListProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
+
+    QDeclarativeContext *context = this->rootContext();
+    context->setContextProperty("stationListProxyModel", stationListProxyModel);
 
     // This does not seem ot work in harmattan. As a workaround, change dir to
     // the qml dir, then load the file.
     // m_view->setSource(QUrl::fromLocalFile("qml:main.qml"));
-    qDebug() << "import path list:" << engine()->importPathList();
     setSource(QUrl::fromLocalFile(trueFilePath("qml:main.qml")));
+
 }
index 5266e27..2ded834 100644 (file)
@@ -3,6 +3,9 @@
 
 #include <QDeclarativeView>
 
+class StationListModel;
+class StationListProxyModel;
+
 class View : public QDeclarativeView
 {
     Q_OBJECT
@@ -14,6 +17,8 @@ signals:
 public slots:
 
 private:
+   StationListModel *stationListModel;
+   StationListProxyModel *stationListProxyModel;
 };
 
 #endif // QP_VIEW_H