+ QScopedPointer<QGuiApplication> app(SailfishApp::application(argc, argv));
+ // These values are used by QSettings to access the config file in
+ // /home/nemo/.local/share/flypig/harbour-pedalo.conf
+ //QCoreApplication::setOrganizationName("flypig");
+ QCoreApplication::setOrganizationDomain("www.flypig.co.uk");
+ QCoreApplication::setApplicationName(APP_NAME);
+
+ Settings::instantiate();
+ qmlRegisterSingletonType<Settings>("harbour.pedalo.settings", 1, 0, "Settings", Settings::provider);
+
+ JourneyModel journeys;
+ Status currentStatus(journeys);
+ Settings::getInstance().setMainStatus(currentStatus);
+ Settings::getInstance().loadSettings();
+
+ QFile file;
+ file.setFileName(Settings::getConfigDir() + "/journeys.csv");
+ journeys.importFromFile(file);
+ journeys.sort(JourneyModel::StartRole, Qt::DescendingOrder);
+
+ QScopedPointer<QQuickView> view(SailfishApp::createView());
+ view->engine()->addImageProvider(QLatin1String("pedalo"), new ImageProvider(Settings::getInstance()));
+ view->setSource(SailfishApp::pathTo("qml/harbour-pedalo.qml"));
+
+ QQmlContext *ctxt = view->rootContext();
+ ctxt->setContextProperty("version", VERSION);
+ qDebug() << "harbour-pedalo VERSION string: " << VERSION;
+ qDebug() << "VERSION_MAJOR: " << VERSION_MAJOR;
+ qDebug() << "VERSION_MINOR: " << VERSION_MINOR;
+ qDebug() << "VERSION_BUILD: " << VERSION_BUILD;
+
+ ctxt->setContextProperty("journeymodel", &journeys);
+ ctxt->setContextProperty("currentStatus", ¤tStatus);
+
+ view->show();
+ int result = app->exec();
+
+ // Write out the journey data
+ QDir dir;
+ dir.mkpath(Settings::getConfigDir());
+ file.setFileName(Settings::getConfigDir() + "/journeys.csv");
+ qDebug() << "File saved as: " << file.fileName();
+ journeys.exportToFile(file);
+
+ Settings::getInstance().saveSettings();
+
+ return result;