214 lines
7.2 KiB
QML
214 lines
7.2 KiB
QML
|
import QtQuick 2.9
|
||
|
import QtQuick.Controls 2.4
|
||
|
|
||
|
Item {
|
||
|
id: control
|
||
|
|
||
|
ScrollView {
|
||
|
id:scroll
|
||
|
anchors.fill: parent
|
||
|
visible: _cppServerConn.getFoodPlanData(0).cookteam !== ""
|
||
|
|
||
|
ListView {
|
||
|
id: listView
|
||
|
//width: 514
|
||
|
model: 8
|
||
|
spacing: 0
|
||
|
property var today: new Date
|
||
|
anchors {
|
||
|
right: parent.right
|
||
|
left: parent.left
|
||
|
top: parent.top
|
||
|
bottom: parent.bottom
|
||
|
leftMargin: 5
|
||
|
rightMargin: 5
|
||
|
topMargin: 3
|
||
|
}
|
||
|
|
||
|
delegate: Button {
|
||
|
|
||
|
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
|
||
|
visible: listView.isDayVisible(index)
|
||
|
|
||
|
property int cust_spacing: 5
|
||
|
|
||
|
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
|
||
|
width: parent.width - 10
|
||
|
wrapMode: Label.Wrap
|
||
|
height: text!=""? undefined:0
|
||
|
}
|
||
|
Label {
|
||
|
anchors.left: parent.left
|
||
|
anchors.leftMargin: 10
|
||
|
anchors.top: cookteam.bottom
|
||
|
font.bold: true
|
||
|
id: date
|
||
|
text: listView.getDateString(index)
|
||
|
width: parent.width - 10
|
||
|
wrapMode: Label.Wrap
|
||
|
}
|
||
|
Rectangle {
|
||
|
anchors.top: date.bottom
|
||
|
anchors.topMargin: cust_spacing
|
||
|
anchors.left: parent.left
|
||
|
anchors.leftMargin: 10
|
||
|
anchors.right: parent.right
|
||
|
anchors.rightMargin: 10
|
||
|
height: 2
|
||
|
color: "grey"
|
||
|
|
||
|
}
|
||
|
|
||
|
Label {
|
||
|
anchors.left: parent.left
|
||
|
anchors.leftMargin: 10
|
||
|
anchors.top: date.bottom
|
||
|
anchors.topMargin: cust_spacing * 2
|
||
|
width: parent.width - 10
|
||
|
wrapMode: Label.Wrap
|
||
|
id: main_dish
|
||
|
text: _cppServerConn.getFoodPlanData(index).main_dish
|
||
|
height: text!=""? undefined:0
|
||
|
}
|
||
|
|
||
|
Rectangle {
|
||
|
anchors.top: main_dish.bottom
|
||
|
anchors.topMargin: cust_spacing
|
||
|
anchors.left: parent.left
|
||
|
anchors.leftMargin: 10
|
||
|
width: parent.width / 10
|
||
|
height: main_dish_veg.text!=""? 1:0
|
||
|
color: "grey"
|
||
|
|
||
|
}
|
||
|
|
||
|
Label {
|
||
|
anchors.left: parent.left
|
||
|
anchors.leftMargin: 10
|
||
|
anchors.top: main_dish.bottom
|
||
|
anchors.topMargin: cust_spacing * 2
|
||
|
id: main_dish_veg
|
||
|
text: _cppServerConn.getFoodPlanData(index).main_dish_veg
|
||
|
width: parent.width - 10
|
||
|
wrapMode: Label.Wrap
|
||
|
height: text!=""? undefined:0
|
||
|
}
|
||
|
|
||
|
Rectangle {
|
||
|
anchors.top: main_dish_veg.bottom
|
||
|
anchors.topMargin: cust_spacing
|
||
|
anchors.left: parent.left
|
||
|
anchors.leftMargin: 10
|
||
|
width: parent.width / 10
|
||
|
height: garnish.text!=""? 1:0
|
||
|
color: "grey"
|
||
|
}
|
||
|
|
||
|
Label {
|
||
|
anchors.left: parent.left
|
||
|
anchors.leftMargin: 10
|
||
|
anchors.top: main_dish_veg.bottom
|
||
|
anchors.topMargin: cust_spacing * 2
|
||
|
id: garnish
|
||
|
text: _cppServerConn.getFoodPlanData(index).garnish
|
||
|
width: parent.width - 10
|
||
|
wrapMode: Label.Wrap
|
||
|
height: text!=""? undefined:0
|
||
|
}
|
||
|
|
||
|
Rectangle {
|
||
|
anchors.top: garnish.bottom
|
||
|
anchors.topMargin: cust_spacing
|
||
|
anchors.left: parent.left
|
||
|
anchors.leftMargin: 10
|
||
|
width: parent.width / 10
|
||
|
height: dessert.text!=""? 1:0
|
||
|
color: "grey"
|
||
|
|
||
|
}
|
||
|
|
||
|
Label {
|
||
|
anchors.left: parent.left
|
||
|
anchors.leftMargin: 10
|
||
|
anchors.top: garnish.bottom
|
||
|
anchors.topMargin: cust_spacing * 2
|
||
|
id: dessert
|
||
|
text: _cppServerConn.getFoodPlanData(index).dessert
|
||
|
width: parent.width - 10
|
||
|
wrapMode: Label.Wrap
|
||
|
height: text!=""? undefined:0
|
||
|
}
|
||
|
|
||
|
Label {
|
||
|
anchors.left: parent.left
|
||
|
anchors.leftMargin: 10
|
||
|
anchors.top: dessert.bottom
|
||
|
anchors.topMargin: cust_spacing
|
||
|
id: spacer
|
||
|
text: ""
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function getDateString(index){
|
||
|
var date = _cppServerConn.getFoodPlanData(index).date
|
||
|
console.log(date.getTime())
|
||
|
console.log(today.getTime())
|
||
|
if(date.getDate() === today.getDate()){
|
||
|
return("Heute")
|
||
|
}
|
||
|
else if(date.getTime() < (today.getTime() + (24 * 60 * 60 * 1000) )/*date.getDate() === today.getDate() + 1 || (date.getDate() === 1 && date.getMonth() === today.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
|
||
|
// console.warn(date.getTime())
|
||
|
// console.warn(today.getTime())
|
||
|
// console.log("")
|
||
|
return( date.getTime() > today.getTime() || date.getDate() === today.getDate()/*(date.getDate() >= today.getDate() && date.getMonth() >= today.getMonth()) || (date.getDate() < today.getDate() && date.getMonth() >= today.getMonth())*/)
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
Rectangle {
|
||
|
id: errorRect
|
||
|
|
||
|
anchors {
|
||
|
left: parent.left
|
||
|
right: parent.right
|
||
|
verticalCenter: parent.verticalCenter
|
||
|
margins: parent.width * 0.15
|
||
|
}
|
||
|
|
||
|
radius: height * 0.5
|
||
|
height: width
|
||
|
|
||
|
color: "transparent"
|
||
|
border.width: 5
|
||
|
border.color: "red"
|
||
|
|
||
|
visible: _cppServerConn.getFoodPlanData(0).cookteam === ""
|
||
|
|
||
|
Label {
|
||
|
anchors.centerIn: parent
|
||
|
text: "keine Daten..."
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
|