X-Git-Url: https://www.flypig.org.uk/git/?p=harbour-pedalo.git;a=blobdiff_plain;f=src%2Fharbour-pedalo.cpp;h=35fc77f6fda0c0c5199853f3b1b4f603fcada5b2;hp=a4218cd2e1e68d08a340c11e4c836360e6ee4218;hb=dc14479d561196e19417c4ecf78e847ec4b43b7c;hpb=e5b6de629d0585d29f0591deec4afec33f44f20c diff --git a/src/harbour-pedalo.cpp b/src/harbour-pedalo.cpp index a4218cd..35fc77f 100644 --- a/src/harbour-pedalo.cpp +++ b/src/harbour-pedalo.cpp @@ -7,8 +7,13 @@ #include "journey.h" #include "journeymodel.h" +#include "statsmodel.h" #include "status.h" #include "settings.h" +#include "imageprovider.h" +#include "graph.h" +#include "statsweekdayave.h" +#include "statsweekdaycongestion.h" #include "harbour-pedalo.h" @@ -33,17 +38,29 @@ int main(int argc, char *argv[]) Settings::instantiate(); qmlRegisterSingletonType("harbour.pedalo.settings", 1, 0, "Settings", Settings::provider); + qmlRegisterType("harbour.pedalo.journeymodel", 1, 0, "JourneyModel"); + qmlRegisterType("harbour.pedalo.graph", 1, 0, "Graph"); JourneyModel journeys; - Status currentStatus; + Status currentStatus(journeys); Settings::getInstance().setMainStatus(currentStatus); Settings::getInstance().loadSettings(); + StatsModel statsmodel; + + StatsWeekdayAve statsweekdayave(&journeys); + statsmodel.addStats(statsweekdayave); + + StatsWeekdayCongestion statsweekdaycongestion(&journeys); + statsmodel.addStats(statsweekdaycongestion); + QFile file; file.setFileName(Settings::getConfigDir() + "/journeys.csv"); journeys.importFromFile(file); + journeys.sort(JourneyModel::StartRole, Qt::DescendingOrder); QScopedPointer view(SailfishApp::createView()); + view->engine()->addImageProvider(QLatin1String("pedalo"), new ImageProvider(Settings::getInstance())); view->setSource(SailfishApp::pathTo("qml/harbour-pedalo.qml")); QQmlContext *ctxt = view->rootContext(); @@ -52,8 +69,10 @@ int main(int argc, char *argv[]) qDebug() << "VERSION_MAJOR: " << VERSION_MAJOR; qDebug() << "VERSION_MINOR: " << VERSION_MINOR; qDebug() << "VERSION_BUILD: " << VERSION_BUILD; + ctxt->setContextProperty("journeymodel", &journeys); ctxt->setContextProperty("currentStatus", ¤tStatus); + ctxt->setContextProperty("statsmodel", &statsmodel); view->show(); int result = app->exec();