abbe2bef00d177350dac6ad105a1f149c7e62217
6 #include <sailfishapp.h>
9 #include "journeymodel.h"
10 #include "statsmodel.h"
13 #include "imageprovider.h"
16 #include "harbour-pedalo.h"
18 int main(int argc
, char *argv
[])
20 // SailfishApp::main() will display "qml/harbour-pedalo.qml", if you need more
21 // control over initialization, you can use:
23 // - SailfishApp::application(int, char *[]) to get the QGuiApplication *
24 // - SailfishApp::createView() to get a new QQuickView * instance
25 // - SailfishApp::pathTo(QString) to get a QUrl to a resource file
26 // - SailfishApp::pathToMainQml() to get a QUrl to the main QML file
28 // To display the view, call "show()" (will show fullscreen on device).
30 QScopedPointer
<QGuiApplication
> app(SailfishApp::application(argc
, argv
));
31 // These values are used by QSettings to access the config file in
32 // /home/nemo/.local/share/flypig/harbour-pedalo.conf
33 //QCoreApplication::setOrganizationName("flypig");
34 QCoreApplication::setOrganizationDomain("www.flypig.co.uk");
35 QCoreApplication::setApplicationName(APP_NAME
);
37 Settings::instantiate();
38 qmlRegisterSingletonType
<Settings
>("harbour.pedalo.settings", 1, 0, "Settings", Settings::provider
);
39 qmlRegisterType
<JourneyModel
>("harbour.pedalo.journeymodel", 1, 0, "JourneyModel");
40 qmlRegisterType
<Graph
>("harbour.pedalo.graph", 1, 0, "Graph");
42 JourneyModel journeys
;
43 Status
currentStatus(journeys
);
44 Settings::getInstance().setMainStatus(currentStatus
);
45 Settings::getInstance().loadSettings();
47 StatsModel statsmodel
;
49 QList
<float> data
{0.1, 0.1, 0.2};
50 QStringList labels
{"A", "B", "C"};
51 stats
.setValues(data
);
52 stats
.setLabels(labels
);
53 statsmodel
.addStats(stats
);
55 data
= QList
<float>{0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.5};
56 labels
= QStringList
{"M", "T", "W", "Th", "F", "S", "Su"};
57 stats
.setValues(data
);
58 stats
.setLabels(labels
);
59 statsmodel
.addStats(stats
);
63 file
.setFileName(Settings::getConfigDir() + "/journeys.csv");
64 journeys
.importFromFile(file
);
65 journeys
.sort(JourneyModel::StartRole
, Qt::DescendingOrder
);
67 QScopedPointer
<QQuickView
> view(SailfishApp::createView());
68 view
->engine()->addImageProvider(QLatin1String("pedalo"), new ImageProvider(Settings::getInstance()));
69 view
->setSource(SailfishApp::pathTo("qml/harbour-pedalo.qml"));
71 QQmlContext
*ctxt
= view
->rootContext();
72 ctxt
->setContextProperty("version", VERSION
);
73 qDebug() << "harbour-pedalo VERSION string: " << VERSION
;
74 qDebug() << "VERSION_MAJOR: " << VERSION_MAJOR
;
75 qDebug() << "VERSION_MINOR: " << VERSION_MINOR
;
76 qDebug() << "VERSION_BUILD: " << VERSION_BUILD
;
78 ctxt
->setContextProperty("journeymodel", &journeys
);
79 ctxt
->setContextProperty("currentStatus", ¤tStatus
);
80 ctxt
->setContextProperty("statsmodel", &statsmodel
);
83 int result
= app
->exec();
85 // Write out the journey data
87 dir
.mkpath(Settings::getConfigDir());
88 file
.setFileName(Settings::getConfigDir() + "/journeys.csv");
89 qDebug() << "File saved as: " << file
.fileName();
90 journeys
.exportToFile(file
);
92 Settings::getInstance().saveSettings();