fixed bug that made the app crash when viewing the foodplan

This commit is contained in:
Dorian Zedler 2018-09-23 17:55:05 +02:00
parent c3aefb31a0
commit 1007a0ec36
2 changed files with 16 additions and 11 deletions

View file

@ -60,7 +60,7 @@ Page {
}
delegate: Button {
//text: getText(index, "cookteam")
width: listView.width
id: delegate
height: visible ? cookteam.height + date.height + main_dish.height + main_dish_veg.height + garnish.height + dessert.height + spacer.height + cust_spacing*9 + 5:0
@ -194,11 +194,11 @@ Page {
function getDateString(index){
var date = _cppServerConn.getFoodPlanData(index).date
//console.log(date)
console.log(date)
if(date.getDate() === today.getDate()){
return("Heute")
}
else if(date.getDate() === today.getDate() + 1 || (date.getDate() === 1 && date.getMonth() === today.getMonth() + 1)){
else if(date.getTime() < (today.getTime() + 60 * 60 * 24 )/*date.getDate() === today.getDate() + 1 || (date.getDate() === 1 && date.getMonth() === today.getMonth() + 1)*/){
return("Morgen")
}
else {
@ -208,7 +208,10 @@ Page {
}
function isDayVisible(index){
var date = _cppServerConn.getFoodPlanData(index).date
return( date.getDate() >= today.getDate() && date.getMonth() >= today.getMonth())
console.log(date.getTime())
console.log(today.getTime())
console.log("")
return( date.getTime() > today.getTime()/*(date.getDate() >= today.getDate() && date.getMonth() >= today.getMonth()) || (date.getDate() < today.getDate() && date.getMonth() >= today.getMonth())*/)
}
}
}

View file

@ -230,21 +230,22 @@ int ServerConn::getFoodPlan()
table1.remove(0,71); //remove "<tbody><tr style=\"border: 1px solid #999;\" align=\"center\" valign=\"top\">" at the beginning
table1 = table1.left(table1.length() - 13); //remove "</tr></tbody>" at the end
QStringList table1list = table1.split("<td style=\"width: 25%;\">"); //split at the days to get a list of all days
QStringList table1list = table1.split("<td width=\"25%\">"); //split at the days to get a list of all days
table1list.takeFirst(); //remove the first item, as it is empty
//prepare the table of the second week
QString table2 = stringlist_0[2];
QStringList stringlist_2 = table2.split( "</table>" ); //remove everything after "</table>"
table2 = stringlist_2[0];
table2.remove(0,39); //remove "<tbody><tr align=\"center\" valign=\"top\">" at the beginning
table2.remove(table2.length() - 13, table2.length()); //remove "</tr></tbody>" at the end
QStringList table2list = table2.split("<td style=\"width: 25%;\">"); //split at the days to get a list of all days
QStringList table2list = table2.split("<td width=\"25%\">"); //split at the days to get a list of all days
table2list.takeFirst(); //remove the first item, as it is empty
QStringList weeklist = table1list + table2list; //put both weeks into one big list
for (int i = 0; i <=7; i ++){
QString temp = weeklist[i]; //store item temporarly to edit it
weeklist[i] = temp.left(temp.length()-5); //remove "</td>" at the and of the Item
@ -274,12 +275,12 @@ int ServerConn::getFoodPlan()
temp_weekplan[i].append(templist);
}
//qDebug() << temp_weekplan;
this->m_weekplan = temp_weekplan; //write changes to global foodplan
this->m_weekplan = temp_weekplan; //write changes to global foodplan
qDebug() << temp_weekplan;
return(200);
}
@ -307,9 +308,10 @@ QVariantMap ServerConn::getFoodPlanData(int index)
}
}
QString date_string_on_db = ret[1];
QDate Date = QDate::fromString(date_string_on_db," dd.MM.yyyy");
//date_string_on_db
QDate Date = QDate::fromString(date_string_on_db,"dd.MM.yyyy");
//date_string_on_db
//qDebug() << Date;
//qDebug() << ret;
return { {"cookteam", ret[0]}, {"date", Date}, {"main_dish", ret[2]}, {"main_dish_veg", ret[3]}, {"garnish", ret[4]}, {"dessert", ret[5]} };
}