2018-06-22 15:33:16 +02:00
|
|
|
import QtQuick 2.9
|
|
|
|
import QtQuick.Controls 2.2
|
|
|
|
|
|
|
|
Page {
|
2018-06-24 21:56:40 +02:00
|
|
|
id:root
|
2018-06-22 15:33:16 +02:00
|
|
|
anchors.fill: parent
|
2018-06-24 21:56:40 +02:00
|
|
|
property bool cookplanChanged
|
2018-06-22 15:33:16 +02:00
|
|
|
title: qsTr("Speiseplanplan")
|
2018-06-24 21:56:40 +02:00
|
|
|
|
2018-06-22 15:33:16 +02:00
|
|
|
|
2018-06-24 09:23:10 +02:00
|
|
|
Timer {
|
|
|
|
id: firstLoadTimer
|
|
|
|
interval: 1;
|
|
|
|
running: true
|
|
|
|
repeat: false
|
2018-06-24 21:56:40 +02:00
|
|
|
|
2018-06-24 09:23:10 +02:00
|
|
|
onTriggered: {
|
|
|
|
_cppServerConn.getFoodPlan()
|
2018-06-24 21:56:40 +02:00
|
|
|
cookplanChanged = true
|
2018-06-24 09:23:10 +02:00
|
|
|
}
|
|
|
|
}
|
2018-06-22 15:33:16 +02:00
|
|
|
|
2018-06-24 09:23:10 +02:00
|
|
|
ScrollView {
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
ListView {
|
2018-06-24 21:56:40 +02:00
|
|
|
id: listView
|
2018-06-24 09:23:10 +02:00
|
|
|
width: parent.width
|
|
|
|
model: 8
|
2018-06-24 21:56:40 +02:00
|
|
|
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 {
|
2018-06-24 09:23:10 +02:00
|
|
|
//text: getText(index, "cookteam")
|
|
|
|
width: parent.width
|
2018-06-24 21:56:40 +02:00
|
|
|
id: delegate
|
|
|
|
height: listView.isDayVisible(index) ? childrenRect.height + 10:0
|
|
|
|
visible: listView.isDayVisible(index)
|
|
|
|
|
|
|
|
//height: 150
|
|
|
|
|
2018-06-24 09:23:10 +02:00
|
|
|
Label {
|
|
|
|
anchors.left: parent.left
|
2018-06-24 21:56:40 +02:00
|
|
|
anchors.leftMargin: 10
|
2018-06-24 09:23:10 +02:00
|
|
|
anchors.top: parent.top
|
2018-06-24 21:56:40 +02:00
|
|
|
anchors.topMargin: 10
|
|
|
|
font.bold: true
|
2018-06-24 09:23:10 +02:00
|
|
|
id: cookteam
|
|
|
|
text: _cppServerConn.getFoodPlanData(index).cookteam
|
|
|
|
}
|
|
|
|
Label {
|
|
|
|
anchors.left: parent.left
|
2018-06-24 21:56:40 +02:00
|
|
|
anchors.leftMargin: 10
|
|
|
|
anchors.top: cookteam.bottom
|
|
|
|
font.bold: true
|
2018-06-24 09:23:10 +02:00
|
|
|
id: date
|
2018-06-24 21:56:40 +02:00
|
|
|
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
|
2018-06-24 09:23:10 +02:00
|
|
|
}
|
2018-06-24 21:56:40 +02:00
|
|
|
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
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
2018-06-24 09:23:10 +02:00
|
|
|
}
|
|
|
|
|
2018-06-24 21:56:40 +02:00
|
|
|
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"))
|
|
|
|
}
|
2018-06-25 00:15:18 +02:00
|
|
|
|
2018-06-24 21:56:40 +02:00
|
|
|
}
|
|
|
|
function isDayVisible(index){
|
|
|
|
var date = _cppServerConn.getFoodPlanData(index).date
|
|
|
|
return( date.getDate() >= today.getDate() || date.getMonth() > today.getMonth())
|
|
|
|
}
|
2018-06-22 15:33:16 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|