Added new graphs
[harbour-pedalo.git] / src / harbour-pedalo.cpp
index a4218cd..f19a8fc 100644 (file)
@@ -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<Settings>("harbour.pedalo.settings", 1, 0, "Settings", Settings::provider);
+    qmlRegisterType<JourneyModel>("harbour.pedalo.journeymodel", 1, 0, "JourneyModel");
+    qmlRegisterType<Graph>("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<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();
@@ -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", &currentStatus);
+    ctxt->setContextProperty("statsmodel", &statsmodel);
 
     view->show();
     int result = app->exec();