X-Git-Url: https://www.flypig.org.uk/git/?p=harbour-pedalo.git;a=blobdiff_plain;f=src%2Fharbour-pedalo.cpp;h=acdcc2eea90a0bc817267d3c9847b3668491a655;hp=4cec5304aedf9df8c1f87257f1a40439a03a3fcd;hb=e917baa52e7157c7c41424527c3881c22ff65588;hpb=0108947ead4cc9e0ff23fee82db2fb1fd7cb2dad diff --git a/src/harbour-pedalo.cpp b/src/harbour-pedalo.cpp index 4cec530..acdcc2e 100644 --- a/src/harbour-pedalo.cpp +++ b/src/harbour-pedalo.cpp @@ -1,9 +1,13 @@ #ifdef QT_QML_DEBUG #include +#include #endif #include +#include "journey.h" +#include "journeymodel.h" + int main(int argc, char *argv[]) { // SailfishApp::main() will display "qml/harbour-pedalo.qml", if you need more @@ -16,5 +20,29 @@ int main(int argc, char *argv[]) // // To display the view, call "show()" (will show fullscreen on device). - return SailfishApp::main(argc, argv); + QScopedPointer app(SailfishApp::application(argc, argv)); + + JourneyModel journeys; + + QFile file; + file.setFileName(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/journeys.csv"); + journeys.importFromFile(file); + + QScopedPointer view(SailfishApp::createView()); + view->setSource(SailfishApp::pathTo("qml/harbour-pedalo.qml")); + + QQmlContext *ctxt = view->rootContext(); + ctxt->setContextProperty("journeymodel", &journeys); + + view->show(); + int result = app->exec(); + + // Write out the journey data + QDir dir; + dir.mkpath(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation)); + file.setFileName(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/journeys.csv"); + qDebug() << "File saved as: " << file.fileName(); + journeys.exportToFile(file); + + return result; }