X-Git-Url: https://www.flypig.org.uk/git/?p=harbour-pedalo.git;a=blobdiff_plain;f=src%2Fharbour-pedalo.cpp;h=f19a8fcc0dd56df91b931f93cf487a1af889fa72;hp=a4218cd2e1e68d08a340c11e4c836360e6ee4218;hb=54ab3ebfadf8cb258561a4641249da8c6469dc0f;hpb=e5b6de629d0585d29f0591deec4afec33f44f20c diff --git a/src/harbour-pedalo.cpp b/src/harbour-pedalo.cpp index a4218cd..f19a8fc 100644 --- a/src/harbour-pedalo.cpp +++ b/src/harbour-pedalo.cpp @@ -7,8 +7,15 @@ #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 "statshourjourneys.h" +#include "statsweekdaycongestion.h" +#include "statshourcongestion.h" #include "harbour-pedalo.h" @@ -33,17 +40,35 @@ 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); + + StatsHourJourneys statshourjourneys(&journeys); + statsmodel.addStats(statshourjourneys); + + StatsWeekdayCongestion statsweekdaycongestion(&journeys); + statsmodel.addStats(statsweekdaycongestion); + + StatsHourCongestion statshourcongestion(&journeys); + statsmodel.addStats(statshourcongestion); + 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 +77,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();