This repository has been archived on 2022-08-16. You can view files and clone it, but cannot push or open issues or pull requests.
fanny-app/qml/FoodPlanForm.qml

215 lines
7.3 KiB
QML
Raw Normal View History

2018-06-22 15:33:16 +02:00
import QtQuick 2.9
import QtQuick.Controls 2.2
2018-06-25 10:04:11 +02:00
import QtGraphicalEffects 1.0
2018-06-22 15:33:16 +02:00
Page {
id:root
2018-07-06 13:29:16 +02:00
//anchors.fill: parent
property bool cookplanChanged
2018-06-22 15:33:16 +02:00
title: qsTr("Speiseplanplan")
2018-07-19 17:19:09 +02:00
property string icon: "qrc:/graphics/TreffpunktFannyLogo.png"
2018-06-25 10:04:11 +02:00
// Image{
// source: "qrc:/graphics/chat_background.jpg";
// height: parent.height
// width: parent.width
// fillMode: Image.Tile
// horizontalAlignment: Image.AlignLeft
// verticalAlignment: Image.AlignTop
// }
// LinearGradient {
// anchors.fill: parent
// start: Qt.point(0, 0)
// end: Qt.point(0, parent.height)
// gradient: Gradient {
// GradientStop { position: 0.0; color: "#4db2b3" }
// GradientStop { position: 1.0; color: "#8f4dae" }
// }
// }
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 09:23:10 +02:00
onTriggered: {
_cppServerConn.getFoodPlan()
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 {
2018-07-05 15:14:17 +02:00
id:scroll
2018-06-24 09:23:10 +02:00
anchors.fill: parent
ListView {
id: listView
2018-07-05 15:14:17 +02:00
//width: 514
2018-06-24 09:23:10 +02:00
model: 8
2018-06-25 10:04:11 +02:00
spacing: 0
property var today: new Date
anchors {
right: parent.right
left: parent.left
top: parent.top
bottom: parent.bottom
leftMargin: 5
rightMargin: 5
2018-06-25 10:04:11 +02:00
topMargin: 3
}
delegate: Button {
2018-06-24 09:23:10 +02:00
//text: getText(index, "cookteam")
2018-07-05 15:14:17 +02:00
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
2018-07-06 13:29:16 +02:00
visible: listView.isDayVisible(index)
property int cust_spacing: 5
2018-06-24 09:23:10 +02:00
Label {
anchors.left: parent.left
anchors.leftMargin: 10
2018-06-24 09:23:10 +02:00
anchors.top: parent.top
anchors.topMargin: 10
font.bold: true
2018-06-24 09:23:10 +02:00
id: cookteam
text: _cppServerConn.getFoodPlanData(index).cookteam
width: parent.width - 10
wrapMode: Label.Wrap
2018-06-30 20:59:42 +02:00
height: text!=""? undefined:0
2018-06-24 09:23:10 +02:00
}
Label {
anchors.left: parent.left
anchors.leftMargin: 10
anchors.top: cookteam.bottom
font.bold: true
2018-06-24 09:23:10 +02:00
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
2018-06-30 20:59:42 +02:00
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
2018-06-30 20:59:42 +02:00
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"
2018-06-24 09:23:10 +02:00
}
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
2018-06-30 20:59:42 +02:00
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
2018-06-30 20:59:42 +02:00
height: text!=""? undefined:0
}
2018-06-25 10:04:11 +02:00
Label {
anchors.left: parent.left
anchors.leftMargin: 10
anchors.top: dessert.bottom
anchors.topMargin: cust_spacing
2018-06-25 10:04:11 +02:00
id: spacer
text: ""
}
2018-06-24 09:23:10 +02:00
}
function getDateString(index){
var date = _cppServerConn.getFoodPlanData(index).date
//console.log(date)
if(date.getDate() === today.getDate()){
return("Heute")
}
2018-07-01 10:25:06 +02:00
else if(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"))
}
2018-06-25 00:15:18 +02:00
}
function isDayVisible(index){
var date = _cppServerConn.getFoodPlanData(index).date
2018-07-01 10:25:06 +02:00
return( date.getDate() >= today.getDate() && date.getMonth() >= today.getMonth())
}
2018-06-22 15:33:16 +02:00
}
}
}