X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;ds=sidebyside;f=application%2Fview.cpp;h=bfa8e74ca3cbe24e90b901ac8758f6687af8098e;hb=5af6a7f561dedb784336d378c005addec0ae8ba2;hp=7dd261181d6583900f45235ef6a7da2fe6d9622d;hpb=d285ab4ed7fd205492e5c01530b3e5f9c86d0a83;p=quandoparte diff --git a/application/view.cpp b/application/view.cpp index 7dd2611..bfa8e74 100644 --- a/application/view.cpp +++ b/application/view.cpp @@ -1,8 +1,34 @@ +/* + +Copyright (C) 2011 Luciano Montanaro + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; see the file COPYING. If not, write to +the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +Boston, MA 02110-1301, USA. + +*/ + #include "view.h" -#include +#include "settings.h" +#include "dataprovider.h" +#include "stationlistmodel.h" +#include "stationlistproxymodel.h" + #include #include #include +#include // search Paths seem to be broken in Harmattan? @@ -28,13 +54,30 @@ static QString trueFilePath(QString path) } View::View(QWidget *parent) : - QWidget(parent), - m_view(new QDeclarativeView(this)) + QDeclarativeView(parent), + stationListModel(new StationListModel(this)), + stationListProxyModel(new StationListProxyModel(this)) { showFullScreen(); + stationListModel->load(trueFilePath("stations:stations.qpl")); + + stationListProxyModel->setSourceModel(stationListModel); + + /* Types to be made accessible to QML */ + qmlRegisterType("net.cirulla.quandoparte", 1, 0, "DataProvider"); + qmlRegisterType("net.cirulla.quandoparte", 1, 0, "Settings"); + qmlRegisterType( + "net.cirulla.quandoparte", 1, 0, "StationListProxyModel"); + + QDeclarativeContext *context = this->rootContext(); + /* objects to be made accessible to QML */ + context->setContextProperty("settings", Settings::instance()); + context->setContextProperty("stationList", stationListModel); + 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")); - m_view->setSource(QUrl::fromLocalFile(trueFilePath("qml:main.qml"))); + setSource(QUrl::fromLocalFile(trueFilePath("qml:main.qml"))); + }