Vollständiger Vertretungsplan support wurde hinzugefügt
This commit is contained in:
parent
73973f145a
commit
2964ac126f
4 changed files with 133 additions and 41 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0"?>
|
||||
<manifest package="com.itsblue.flgvertretung" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="0.01" android:versionCode="2" android:installLocation="auto">
|
||||
<manifest package="com.itsblue.flgvertretungtest" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="0.01" android:versionCode="2" android:installLocation="auto">
|
||||
<paths xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<external-path name="external_files" path="."/>
|
||||
</paths>
|
||||
|
|
|
@ -2,19 +2,21 @@ import QtQuick 2.9
|
|||
import QtQuick.Controls 2.2
|
||||
|
||||
Page {
|
||||
id:root
|
||||
anchors.fill: parent
|
||||
|
||||
property bool cookplanChanged
|
||||
title: qsTr("Speiseplanplan")
|
||||
property bool loaded: false
|
||||
|
||||
|
||||
Timer {
|
||||
id: firstLoadTimer
|
||||
interval: 1;
|
||||
running: true
|
||||
repeat: false
|
||||
|
||||
onTriggered: {
|
||||
_cppServerConn.getFoodPlan()
|
||||
loaded = true
|
||||
cookplanChanged = true
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,33 +24,124 @@ Page {
|
|||
anchors.fill: parent
|
||||
|
||||
ListView {
|
||||
enabled: loaded
|
||||
id: listView
|
||||
width: parent.width
|
||||
model: 8
|
||||
delegate: ItemDelegate {
|
||||
spacing: 5
|
||||
property var today: new Date
|
||||
anchors {
|
||||
right: parent.right
|
||||
left: parent.left
|
||||
top: parent.top
|
||||
bottom: parent.bottom
|
||||
leftMargin: 5
|
||||
rightMargin: 5
|
||||
}
|
||||
|
||||
delegate: Button {
|
||||
//text: getText(index, "cookteam")
|
||||
width: parent.width
|
||||
id: delegate
|
||||
height: listView.isDayVisible(index) ? childrenRect.height + 10:0
|
||||
visible: listView.isDayVisible(index)
|
||||
|
||||
//height: 150
|
||||
|
||||
Label {
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 10
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: 10
|
||||
font.bold: true
|
||||
id: cookteam
|
||||
text: _cppServerConn.getFoodPlanData(index).cookteam
|
||||
}
|
||||
Label {
|
||||
anchors.left: parent.left
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.leftMargin: 10
|
||||
anchors.top: cookteam.bottom
|
||||
font.bold: true
|
||||
id: date
|
||||
text: _cppServerConn.getFoodPlanData(index).date
|
||||
}
|
||||
text: listView.getDateString(index)
|
||||
}
|
||||
Rectangle {
|
||||
anchors.top: date.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 10
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 10
|
||||
height: 1
|
||||
color: "grey"
|
||||
}
|
||||
|
||||
Label {
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 10
|
||||
anchors.top: date.bottom
|
||||
id: main_dish
|
||||
text: _cppServerConn.getFoodPlanData(index).main_dish
|
||||
}
|
||||
Label {
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 10
|
||||
anchors.top: main_dish.bottom
|
||||
id: main_dish_veg
|
||||
text: _cppServerConn.getFoodPlanData(index).main_dish_veg
|
||||
}
|
||||
Label {
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 10
|
||||
anchors.top: main_dish_veg.bottom
|
||||
id: garnish
|
||||
text: _cppServerConn.getFoodPlanData(index).garnish
|
||||
}
|
||||
Label {
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 10
|
||||
anchors.top: garnish.bottom
|
||||
id: dessert
|
||||
text: _cppServerConn.getFoodPlanData(index).dessert
|
||||
}
|
||||
|
||||
// Timer {
|
||||
// id: reloadTimer
|
||||
// interval: 10;
|
||||
// running: cookplanChanged
|
||||
// repeat: true
|
||||
// onTriggered: {
|
||||
// //var today = new Date
|
||||
|
||||
// cookteam.text = _cppServerConn.getFoodPlanData(index).cookteam
|
||||
// date.text = listView.getDateString(index)
|
||||
// //_cppServerConn.getFoodPlanData(index).date
|
||||
// main_dish.text = _cppServerConn.getFoodPlanData(index).main_dish
|
||||
// main_dish_veg.text = _cppServerConn.getFoodPlanData(index).main_dish_veg
|
||||
// garnish.text = _cppServerConn.getFoodPlanData(index).garnish
|
||||
// dessert.text = _cppServerConn.getFoodPlanData(index).dessert
|
||||
// if(index === 7) {
|
||||
// cookplanChanged = false
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
function getDateString(index){
|
||||
var date = _cppServerConn.getFoodPlanData(index).date
|
||||
//console.log(date)
|
||||
if(date.getDate() === today.getDate()){
|
||||
return("Heute")
|
||||
}
|
||||
else if(date.getDate() === today.getDate() + 1 || (date.getDay() === 1 && today.getMonth() === date.getMonth() + 1)){
|
||||
return("Morgen")
|
||||
}
|
||||
else {
|
||||
return(Qt.formatDateTime(_cppServerConn.getFoodPlanData(index).date, "dddd, d.M.yy"))
|
||||
}
|
||||
}
|
||||
function isDayVisible(index){
|
||||
var date = _cppServerConn.getFoodPlanData(index).date
|
||||
return( date.getDate() >= today.getDate() || date.getMonth() > today.getMonth())
|
||||
}
|
||||
function getText(indexvar, type){
|
||||
if(!loaded){
|
||||
_cppServerConn.getFoodPlan()
|
||||
loaded = true
|
||||
}
|
||||
//console.log(_cppServerConn.getFoodPlanData(indexvar))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,15 +26,6 @@ Page {
|
|||
text: stackView.currentItem.title
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
Button {
|
||||
id: butt
|
||||
text: "load"
|
||||
anchors.right: parent.right
|
||||
visible: stackView.currentItem.title === "Speiseplanplan"
|
||||
onClicked: {
|
||||
var ret = _cppServerConn.getFoodPlan();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Drawer {
|
||||
|
@ -57,6 +48,7 @@ Page {
|
|||
text: qsTr("Speiseplan")
|
||||
width: parent.width
|
||||
onClicked: {
|
||||
_cppServerConn.getFoodPlan();
|
||||
stackView.push("FoodPlanForm.qml")
|
||||
drawer.close()
|
||||
}
|
||||
|
|
|
@ -212,7 +212,9 @@ QString ServerConn::getFoodPlan()
|
|||
}
|
||||
|
||||
//initialize the weekplan to store information to it
|
||||
m_weekplan.empty(); //empty the weekplan
|
||||
//m_weekplan.empty(); //empty the weekplan
|
||||
QList<QList<QString>> temp_weekplan;
|
||||
|
||||
//m_weekplan is a list, that contains a list for each day, which contains: cookteam, date, main dish, vagi main dish, garnish(Beilage) and Dessert.
|
||||
|
||||
ret.text = QString::fromUtf8(reply->readAll()); //read the whole website
|
||||
|
@ -224,11 +226,13 @@ QString ServerConn::getFoodPlan()
|
|||
|
||||
//prepare the table of the first week
|
||||
QString table1 = stringlist_0[1];
|
||||
|
||||
QStringList stringlist_1 = table1.split( "</table>" ); //remove everything after "</table>"
|
||||
table1 = stringlist_1[0];
|
||||
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 width=\"25%\">"); //split at the days to get a list of all days
|
||||
|
||||
QStringList table1list = table1.split("<td style=\"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
|
||||
|
@ -237,7 +241,7 @@ QString ServerConn::getFoodPlan()
|
|||
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 width=\"25%\">"); //split at the days to get a list of all days
|
||||
QStringList table2list = table2.split("<td style=\"width: 25%;\">"); //split at the days to get a list of all days
|
||||
table2list.takeFirst(); //remove the first item, as it is empty
|
||||
|
||||
|
||||
|
@ -267,37 +271,36 @@ QString ServerConn::getFoodPlan()
|
|||
|
||||
temp.replace("<br />","");
|
||||
templist = temp.split("</strong>");
|
||||
m_weekplan.append({templist[0], templist[1]}); //store cookteam and date
|
||||
temp_weekplan.append({templist[0], templist[1]}); //store cookteam and date
|
||||
temp = templist[2]; //store information in temp (looks like: "<hr />Gulasch mit Kartoffeln<hr />Pellkartoffeln mit Quark<hr />Gemischter Salat<hr />Eaton Mess ( Erdbeer-Nachtisch )")
|
||||
templist = temp.split("<hr />"); //seperate the information
|
||||
templist.takeFirst(); //remove first item
|
||||
|
||||
m_weekplan[i].append(templist);
|
||||
temp_weekplan[i].append(templist);
|
||||
|
||||
|
||||
}
|
||||
|
||||
qDebug() << m_weekplan;
|
||||
qDebug() << temp_weekplan;
|
||||
this->m_weekplan = temp_weekplan;
|
||||
|
||||
|
||||
return("");
|
||||
}
|
||||
|
||||
QVariantMap ServerConn::getFoodPlanData(int index)
|
||||
{
|
||||
//cookteam, date, main dish, vagi main dish, garnish(Beilage) and Dessert.
|
||||
QString cookteam;
|
||||
QString date;
|
||||
QString main_dish;
|
||||
QString main_dish_veg;
|
||||
QString garnish;
|
||||
QString Dessert;
|
||||
|
||||
QStringList ret; //list to return
|
||||
qDebug() << index;
|
||||
//qDebug() << index;
|
||||
for(int i=0;i<=5;i++){
|
||||
qDebug() << i << m_weekplan.size();
|
||||
|
||||
if(m_weekplan.size() > index){
|
||||
if(m_weekplan.at(index).size() > i){
|
||||
//qDebug() << i << m_weekplan[index].size();
|
||||
if(m_weekplan[index].size() > i){
|
||||
ret.append(m_weekplan[index][i]);
|
||||
//qDebug() << i << m_weekplan[index][i];
|
||||
}
|
||||
else {
|
||||
ret.append(NULL);
|
||||
|
@ -307,7 +310,11 @@ QVariantMap ServerConn::getFoodPlanData(int index)
|
|||
ret.append(NULL);
|
||||
}
|
||||
}
|
||||
return { {"cookteam", ret[0]}, {"date", ret[1]}, {"main", ret[2]}, {"main_veg", ret[3]}, {"garnish", ret[4]}, {"dessert", ret[5]} };
|
||||
QString date_string_on_db = ret[1];
|
||||
QDate Date = QDate::fromString(date_string_on_db," dd.MM.yyyy");
|
||||
//date_string_on_db
|
||||
//qDebug() << Date;
|
||||
return { {"cookteam", ret[0]}, {"date", Date}, {"main_dish", ret[2]}, {"main_dish_veg", ret[3]}, {"garnish", ret[4]}, {"dessert", ret[5]} };
|
||||
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue