diff --git a/headers/serverconn.h b/headers/serverconn.h index 4ed5e59..52b7bc2 100644 --- a/headers/serverconn.h +++ b/headers/serverconn.h @@ -59,7 +59,7 @@ private: ReturnData_t senddata(QUrl serviceUrl, QUrlQuery postData); - QList apiVersion = {0,1,15}; + QList apiVersion = {0,2,1}; private slots: diff --git a/qml/Forms/HomeForm.qml b/qml/Forms/HomeForm.qml index 43bc97e..4aababa 100644 --- a/qml/Forms/HomeForm.qml +++ b/qml/Forms/HomeForm.qml @@ -54,7 +54,7 @@ Page { height: mainMenu.buttonHeight onClicked: { - eventConfirmationDialog.openDay( _cppAppSettings.loadSetting("teacherMode") === "true" ? "lheute":"sheute") + eventConfirmationDialog.openDay( 0 ) } } @@ -67,7 +67,7 @@ Page { height: mainMenu.buttonHeight onClicked: { - eventConfirmationDialog.openDay( _cppAppSettings.loadSetting("teacherMode") === "true" ? "lmorgen":"smorgen") + eventConfirmationDialog.openDay( 1 ) } } diff --git a/sources/eventmodel.cpp b/sources/eventmodel.cpp index c82c068..f45eb4e 100644 --- a/sources/eventmodel.cpp +++ b/sources/eventmodel.cpp @@ -29,6 +29,10 @@ EventModel::EventModel(QObject *parent) : QAbstractListModel(parent) // convert the stringlist from the serverconn to a Day-list foreach(QListday, pGlobalServConn->m_events){ m_events.append({day[0], day[1], day[2], day[3], day[4], day[5], day[6]}); + if(day.length() > 7){ + // in teachermode it can happen that an event has eight value in that case the 8th value is appended to the 7th one + m_events[m_events.length()-1].text = m_events[m_events.length()-1].text + " | " + day[7]; + } } } diff --git a/sources/serverconn.cpp b/sources/serverconn.cpp index 0135bdb..fcf1e5b 100644 --- a/sources/serverconn.cpp +++ b/sources/serverconn.cpp @@ -141,6 +141,7 @@ int ServerConn::checkConn() int ServerConn::getEvents(QString day) { + // day: 0-today; 1-tomorrow if(this->state != "loggedIn"){ return(401); } @@ -149,6 +150,7 @@ int ServerConn::getEvents(QString day) QUrlQuery pdata; pdata.addQueryItem("username", this->username); pdata.addQueryItem("password", this->password); + pdata.addQueryItem("mode", pGlobalAppSettings->loadSetting("teacherMode") == "true" ? "1":"0"); pdata.addQueryItem("day", day); // send the request @@ -179,11 +181,12 @@ int ServerConn::getEvents(QString day) //qDebug() << jsonString; QJsonDocument jsonFilters = QJsonDocument::fromJson(ret.text.toUtf8()); - // array with all filters in it - QJsonObject dataArray = jsonFilters.object(); + + // array with tghe whole response in it + QJsonObject JsonArray = jsonFilters.object(); // get the version of the json format - QString version = dataArray.value("version").toString(); + QString version = JsonArray.value("version").toString(); QStringList versionList = version.split("."); if(versionList.length() < 3){ return(900); @@ -197,6 +200,8 @@ int ServerConn::getEvents(QString day) return(904); } + // get parse the document out of the return + QJsonObject dataArray = JsonArray.value("data").toObject(); // get the header data tmpEventHeader.append(dataArray.value("targetDate").toString()); @@ -515,7 +520,7 @@ QString ServerConn::getState() { void ServerConn::setState(QString state) { if(state != this->state){ - qDebug() << "+----- serverconn has new state: " + state + " -----+"; + qDebug() << "+----- serverconn has new state: " << state << " -----+"; this->state = state; this->stateChanged(this->state); }