#include "headers/serverconn.h"
#include "headers/appsettings.h"
@@ -35,16 +27,21 @@ int main(int argc, char *argv[])
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
- QGuiApplication app(argc, argv);
- //QtWebView::initialize();
+ //! [0]
+ QGuiApplication app(argc, argv);
+ QtWebView::initialize();
+ //! [0]
QQuickStyle::setStyle("Material");
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
+ QQmlContext *context = engine.rootContext();
+
+ context->setContextProperty("_cppServerConn", pServerConn);
+ context->setContextProperty("_cppAppSettings", pAppSettings);
+
if (engine.rootObjects().isEmpty())
return -1;
- engine.rootContext()->setContextProperty("_cppServerConn", pServerConn);
- engine.rootContext()->setContextProperty("_cppAppSettings", pAppSettings);
int ret;
ret = app.exec();
diff --git a/sources/serverconn.cpp b/sources/serverconn.cpp
index 72071d8..3485168 100644
--- a/sources/serverconn.cpp
+++ b/sources/serverconn.cpp
@@ -181,17 +181,16 @@ float ServerConn::getProgress()
return(this->progress);
}
-int ServerConn::getEvents(){
- /*
+int ServerConn::getEvents(QString day){
+
this->progress = 0;
ReturnData_t ret; //this is a custom type to store the returned data
// Call the webservice
- QNetworkRequest request(QUrl("http://api.itsblue.de/fanny/vertretung.php?uname=ZedlerDo&passwd=LxyJQB&day=smorgen&agree=true"));
+ QNetworkRequest request(QUrl("http://api.itsblue.de/fanny/vertretung.php?uname=" + this->username + "&passwd=" + this->password + "&day=" + day + "&agree=true"));
request.setHeader(QNetworkRequest::ContentTypeHeader,
"application/x-www-form-urlencoded");
- //set ssl configuration
//send a POST request with the given url and data to the server
QNetworkReply* reply;
@@ -213,39 +212,16 @@ int ServerConn::getEvents(){
}
QString eventString = reply->readAll();
- eventString.replace(" - ", "-");
- eventString.replace(" / ", "/");
- eventString.replace("", "");
- eventString.replace("
", "");
- eventString.replace("Entfall für Lehrer", "Entfall_für_Lehrer");
- QStringList tmp = eventString.split("\f");
- QStringList rawEvents;
- QList tmpEvents;
- for(int i=0; iopen(QIODevice::ReadOnly | QIODevice::Text)) {
- qDebug() << "Load XML File Problem Couldn't open xmlfile.xml to load settings for download";
- return 900;
- }
+// QFile * xmlFile = new QFile(":/samplehtml/Download File.xml");
+// if (!xmlFile->open(QIODevice::ReadOnly | QIODevice::Text)) {
+// qDebug() << "Load XML File Problem Couldn't open xmlfile.xml to load settings for download";
+// return 900;
+// }
- QXmlStreamReader * xmlReader = new QXmlStreamReader(xmlFile);
+ QXmlStreamReader * xmlReader = new QXmlStreamReader(eventString);
//qDebug() << xmlFile->readAll();
QList tmpEvents;
QStringList dayList;
@@ -300,7 +276,7 @@ int ServerConn::getEvents(){
//close reader and flush file
xmlReader->clear();
- xmlFile->close();
+ //xmlFile->close();
return(200);
}
@@ -430,15 +406,15 @@ QVariantMap ServerConn::getFoodPlanData(int index)
//qDebug() << i << m_weekplan[index][i];
}
else {
- ret.append(NULL);
+ ret.append(nullptr);
}
}
else {
- ret.append(NULL);
+ ret.append(nullptr);
}
}
QString date_string_on_db = ret[1];
- QDate Date = QDate::fromString(date_string_on_db," dd.MM.yyyy");
+ QDate Date = QDate::fromString(date_string_on_db,"dd.MM.yyyy");
//date_string_on_db
qDebug() << Date;
qDebug() << ret;