X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=application%2Fview.cpp;h=03ef9f01bc0f2edf240303fe1b8de097584dbc45;hb=10b758aa403704b12f1f9deafcfd03095eb73b52;hp=bfa8e74ca3cbe24e90b901ac8758f6687af8098e;hpb=45f5427503f5a326271aa03952b478d0cd64aa14;p=quandoparte diff --git a/application/view.cpp b/application/view.cpp index bfa8e74..03ef9f0 100644 --- a/application/view.cpp +++ b/application/view.cpp @@ -22,19 +22,30 @@ Boston, MA 02110-1301, USA. #include "view.h" #include "settings.h" #include "dataprovider.h" -#include "stationlistmodel.h" +#include "stationschedulemodel.h" #include "stationlistproxymodel.h" +#include "stationlistmodel.h" +#include +#include #include #include #include +#include +#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#include +#else #include +#endif // search Paths seem to be broken in Harmattan? -static QString trueFilePath(QString path) +static QString trueFilePath(const QString &path) { qDebug() << "searching for" << path; +#if USE_RESOURCES + return path; +#else QString searchPathName = path.section(':', 0, 0); qDebug() << "path is" << searchPathName; QString fileName = path.section(':', 1, 1); @@ -51,33 +62,58 @@ static QString trueFilePath(QString path) } qDebug() << "file not found"; return QString(); +#endif } +Q_DECLARE_METATYPE(QList< QPersistentModelIndex >) +#if (QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)) +Q_DECLARE_METATYPE(QAbstractItemModel::LayoutChangeHint) +#endif + +#if (QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)) +View::View(QWindow *parent) : + QQuickView(parent), +#else View::View(QWidget *parent) : QDeclarativeView(parent), +#endif stationListModel(new StationListModel(this)), stationListProxyModel(new StationListProxyModel(this)) { showFullScreen(); - stationListModel->load(trueFilePath("stations:stations.qpl")); - + future = QtConcurrent::run( + stationListModel, &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( +#if (QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)) + qRegisterMetaType< QModelIndex >(); + qRegisterMetaType< QList< QPersistentModelIndex > >(); + qRegisterMetaType< QAbstractItemModel::LayoutChangeHint>(); +#endif + qmlRegisterType< StationListProxyModel >( "net.cirulla.quandoparte", 1, 0, "StationListProxyModel"); + qmlRegisterType< StationScheduleModel >( + "net.cirulla.quandoparte", 1, 0, "StationScheduleModel"); +#if (QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)) + QQmlContext *context = this->rootContext(); +#else QDeclarativeContext *context = this->rootContext(); +#endif /* 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 + // This does not seem to work in harmattan. As a workaround, change dir to // the qml dir, then load the file. // m_view->setSource(QUrl::fromLocalFile("qml:main.qml")); - setSource(QUrl::fromLocalFile(trueFilePath("qml:main.qml"))); + setSource(trueFilePath("qml:main.qml")); +} +View::~View() +{ + future.waitForFinished(); }