diff --git a/qml/FoodPlanForm.qml b/qml/FoodPlanForm.qml index b07c89e..bf75fa3 100644 --- a/qml/FoodPlanForm.qml +++ b/qml/FoodPlanForm.qml @@ -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())*/) } } } diff --git a/source/serverconn.cpp b/source/serverconn.cpp index 819495d..81caa2c 100644 --- a/source/serverconn.cpp +++ b/source/serverconn.cpp @@ -230,21 +230,22 @@ int ServerConn::getFoodPlan() table1.remove(0,71); //remove "" at the beginning table1 = table1.left(table1.length() - 13); //remove "" at the end - QStringList table1list = table1.split(""); //split at the days to get a list of all days + QStringList table1list = table1.split(""); //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( "" ); //remove everything after "" table2 = stringlist_2[0]; table2.remove(0,39); //remove "" at the beginning table2.remove(table2.length() - 13, table2.length()); //remove "" at the end - QStringList table2list = table2.split(""); //split at the days to get a list of all days + + QStringList table2list = table2.split(""); //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 "" 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]} }; }