diff --git a/qml/Forms/EventForm.qml b/qml/Forms/EventForm.qml index 623be06..a04a43a 100644 --- a/qml/Forms/EventForm.qml +++ b/qml/Forms/EventForm.qml @@ -71,7 +71,7 @@ Page { right: parent.right top: parent.top margins: app.landscape() ? parent.width * 0.4:parent.width * 0.3 - topMargin: parent.height/2 - height * 0.8 + topMargin: parent.height*( status === 901 ? 0.6:0.5) - height * 0.8 } errorCode: status diff --git a/sources/serverconn.cpp b/sources/serverconn.cpp index beb2661..d6e6165 100644 --- a/sources/serverconn.cpp +++ b/sources/serverconn.cpp @@ -254,13 +254,6 @@ int ServerConn::getEvents(QString day){ this->progress = 1; if(status_code != 200){ // if the request didn't result in a success, return the error code - - // if the request failed but there is still old data available - if(!this->m_events.isEmpty()){ - // set the status code to 902 (old data) - status_code = 902; - } - return(status_code.toInt()); } @@ -411,6 +404,20 @@ int ServerConn::getEvents(QString day){ tmpEventHeader.append(""); } + // check if the header is valid + // variable to count filled blocks + int blocksOK = 0; + foreach(QString block, tmpEventHeader){ + if(block != ""){ + blocksOK ++; + } + } + + if(blocksOK != 3) { + // if there are more or less than 3 filled blocks, the data is invalid + return(900); + } + // swap creation and target date tmpEventHeader.swap(0,1); @@ -448,8 +455,10 @@ int ServerConn::getEvents(QString day){ qDebug() << tmpEvents; // check if there is any valid data - if(this->m_events.isEmpty()){ - // no data + if(this->m_events.length() < 3){ + // remove the last (in this case the second) element, as it is unnecessary + m_events.takeLast(); + // return no data return(901); }