> m_weekplan;
+
+};
+
+#endif // SERVERCONN_H
diff --git a/qml/AppToolBar.qml b/qml/AppToolBar.qml
new file mode 100644
index 0000000..980493a
--- /dev/null
+++ b/qml/AppToolBar.qml
@@ -0,0 +1,69 @@
+import QtQuick 2.6
+import QtQuick.Controls 2.1
+import QtQuick.Controls.Material 2.1
+
+ToolBar {
+ id: toolBar
+ property bool showErrorBar: true
+ Material.theme: Material.Light
+ Rectangle {
+ id: errorField
+ width: parent.width
+ height: 30
+ enabled: window.is_error & stackView.currentItem.objectName !== "LoginPage" & showErrorBar
+ anchors.top: parent.bottom
+
+ color: "red"
+ onEnabledChanged: {
+ if(enabled){
+ toolBar.state = 'moveIn'
+ }
+ else {
+ toolBar.state = 'moveOut'
+ }
+ }
+
+ MouseArea { anchors.fill: parent; onClicked: {
+ toolBar.state = 'moveOut'
+
+ console.log("clicked")
+ }
+ }
+
+ Text {
+ anchors {
+ horizontalCenter: parent.horizontalCenter
+ verticalCenter: parent.verticalCenter
+ }
+
+ id: errorText
+ font.family: "Helvetica"
+ color: "White"
+ font.pointSize: 8
+ visible: parent.height !== 0
+ text: window.error
+ }
+ }
+
+ states: [
+ State {
+ name: "moveOut"
+ PropertyChanges { target: errorField; height: 0 }
+ },
+ State {
+ name: "moveIn"
+ PropertyChanges { target: errorField; height: 30 }
+ }
+ ]
+
+ transitions: [
+ Transition {
+ to: "moveOut"
+ NumberAnimation { properties: "height"; easing.type: Easing.InOutQuad; duration: 200 }
+ },
+ Transition {
+ to: "moveIn"
+ NumberAnimation { properties: "height"; easing.type: Easing.InOutQuad; duration: 200 }
+ }
+ ]
+}
diff --git a/qml/FoodPlanForm.qml b/qml/FoodPlanForm.qml
new file mode 100644
index 0000000..b07c89e
--- /dev/null
+++ b/qml/FoodPlanForm.qml
@@ -0,0 +1,215 @@
+import QtQuick 2.9
+import QtQuick.Controls 2.2
+import QtGraphicalEffects 1.0
+
+Page {
+ id:root
+ //anchors.fill: parent
+ property bool cookplanChanged
+ title: qsTr("Speiseplan")
+ property string icon: "qrc:/graphics/TreffpunktFannyLogo.png"
+ property string link: "http://www.treffpunkt-fanny.de"
+
+// 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" }
+// }
+// }
+
+ Timer {
+ id: firstLoadTimer
+ interval: 1;
+ running: true
+ repeat: false
+
+ onTriggered: {
+ _cppServerConn.getFoodPlan()
+ cookplanChanged = true
+ }
+ }
+
+ ScrollView {
+ id:scroll
+ anchors.fill: parent
+ 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 {
+ //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
+ 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)
+ if(date.getDate() === today.getDate()){
+ return("Heute")
+ }
+ 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"))
+ }
+
+ }
+ function isDayVisible(index){
+ var date = _cppServerConn.getFoodPlanData(index).date
+ return( date.getDate() >= today.getDate() && date.getMonth() >= today.getMonth())
+ }
+ }
+ }
+}
diff --git a/qml/HomeForm.qml b/qml/HomeForm.qml
new file mode 100644
index 0000000..aa9aa29
--- /dev/null
+++ b/qml/HomeForm.qml
@@ -0,0 +1,206 @@
+import QtQuick 2.9
+import QtQuick.Controls 2.2
+import QtGraphicalEffects 1.0
+
+Page {
+ //anchors.fill: parent
+
+ title: qsTr("Vertretungsplan")
+ property string icon: "qrc:/graphics/FannyLogo_small.png"
+ property string link: "http://www.fanny-leicht.de/j34"
+
+// 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" }
+// }
+// }
+
+ Label {
+ id: laWelcome
+ text: "Hier kannst du dir den Vertretungsplan des Fannys anschauen"
+ font.pixelSize: 20
+ wrapMode: Label.Wrap
+ width: window.width / 1.2
+ color: window.text_color
+ anchors {
+ top: parent.top
+ topMargin: window.height / 8 - laWelcome.height / 2
+ horizontalCenter: parent.horizontalCenter
+ }
+ }
+
+ Button {
+ id:buttToday
+ enabled: window.is_error === false
+ anchors {
+ left: parent.left
+ leftMargin: (window.width / 4) - (buttToday.width / 2)
+ verticalCenter: parent.verticalCenter
+ }
+
+ onClicked: {
+ verificationDialog.day = "sheute"
+ verificationDialog.open()
+ }
+
+ onPressed: sheuteImage.scale = 0.9
+ onReleased: sheuteImage.scale = 1.0
+
+ background: Image {
+ id: sheuteImage
+ source: "qrc:/graphics/sheute.png"
+
+ Behavior on scale {
+ PropertyAnimation {
+ duration: 100
+ }
+ }
+ }
+ }
+
+ Button {
+ id: buttTomorrow
+ enabled: window.is_error === false
+ anchors {
+ right: parent.right
+ rightMargin: (window.width / 4) - (buttTomorrow.width / 2)
+ verticalCenter: parent.verticalCenter
+ }
+
+ onClicked: {
+ verificationDialog.day = "smorgen"
+ verificationDialog.open()
+ }
+
+ onPressed: smorgenImage.scale = 0.9
+ onReleased: smorgenImage.scale = 1.0
+
+ background: Image {
+ id: smorgenImage
+ source: "qrc:/graphics/smorgen.png"
+
+ Behavior on scale {
+ PropertyAnimation {
+ duration: 100
+ }
+ }
+ }
+
+ }
+
+ Rectangle {
+ id: buttonsDisabled
+ anchors.left: buttToday.left
+ anchors.right: buttTomorrow.right
+ anchors.top: buttToday.top
+ anchors.bottom: buttToday.bottom
+ color: "white"
+ opacity: 0.7
+ visible: window.is_error
+ }
+
+ Dialog {
+ property string day
+ id: verificationDialog
+ modal: true
+ focus: true
+ title: "Bedingung"
+ x: (window.width - width) / 2
+ y: window.height / 6
+ width: Math.min(window.width, window.height) / 3 * 2
+ contentHeight: aboutColumn.height
+ standardButtons: Dialog.Ok | Dialog.Cancel
+ onAccepted: {
+ _cppServerConn.updateProgress(0,100)
+ busyDialog.open()
+ text.visible = false
+ var ret = _cppServerConn.getDay(day)
+ progressCircle.arcEnd = 36000
+ progress.text = "100%"
+ busyDialog.close()
+ text.visible = true
+ if(ret === "OK"){
+ return
+ }
+ else if(ret === "Ungültige Benutzerdaten."){
+ root.StackView.view.pop()
+ }
+ else {
+ error.text = ret
+ window.is_error = true
+ window.error = ret
+ error.visible = true
+ }
+ }
+
+ Column {
+ id: aboutColumn
+ spacing: 20
+ Label {
+ id: text
+ visible: true
+ width: verificationDialog.availableWidth
+ wrapMode: Label.Wrap
+ text: "Vertretungsplan, vertraulich, nur zum persönlichen Gebrauch, keine Speicherung!"
+ }
+ }
+ }
+
+ Dialog {
+ id: busyDialog
+ modal: true
+ closePolicy: "NoAutoClose"
+ focus: true
+ //title: "Please wait..."
+ x: (window.width - width) / 2
+ y: window.height / 6
+ //width: Math.min(window.width, window.height) / 3 * 2
+ height: contentHeight * 1.5
+ width: contentWidth * 1.5
+ contentHeight: progressCircle.height
+ contentWidth: progressCircle.width
+
+ ProgressCircle {
+ id: progressCircle
+ size: 50
+ lineWidth: 5
+ anchors.centerIn: parent
+ colorCircle: "#FF3333"
+ colorBackground: "#E6E6E6"
+ showBackground: true
+ arcBegin: 0
+ arcEnd: 0
+ Label {
+ id: progress
+ anchors.centerIn: parent
+ text: "0%"
+ }
+ Timer {
+ id: refreshTimer
+ interval: 1;
+ running: busyDialog.visible
+ repeat: true
+ onTriggered: {
+ var ret = _cppServerConn.getProgress()
+
+ progressCircle.arcEnd = 360 * ret * 1.2
+ progress.text = Math.round( ret * 100 ) + "%"
+ }
+ }
+ }
+ }
+}
diff --git a/qml/LoginPage.qml b/qml/LoginPage.qml
new file mode 100644
index 0000000..06549da
--- /dev/null
+++ b/qml/LoginPage.qml
@@ -0,0 +1,165 @@
+import QtQuick 2.0
+import QtQuick.Layouts 1.3
+import QtQuick.Controls 2.2
+
+Page {
+ id: root
+ //anchors.fill: parent
+ objectName: "LoginPage";
+
+ header: AppToolBar {
+ Label {
+ text: "Anmeldung"
+ anchors.centerIn: parent
+ color: "white"
+ }
+ }
+
+ Image {
+ id: bigLogo
+ source: "favicon.png"
+ anchors.top: parent.top
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.margins: window.height * 0.01
+ height: window.height * 0.2
+ fillMode: Image.PreserveAspectFit
+ }
+
+ Label {
+ id: infoText
+ text: "Bitte melde dich mit den Anmeldedaten an, die du für den Vertretungsplan erhalten hast.
+ Weitere Informationen"
+ wrapMode: Text.Wrap
+ onLinkActivated: {
+ Qt.openUrlExternally(link)
+ }
+
+ anchors {
+ top: bigLogo.bottom
+ left: parent.left
+ right: parent.right
+ leftMargin: window.width * 0.05
+ rightMargin: window.width * 0.05
+ }
+ }
+
+ ColumnLayout {
+
+ spacing: 40
+ width: parent.width
+ anchors.fill: parent
+ anchors.topMargin: bigLogo.height + infoText.height + window.height * 0.02
+ anchors.bottomMargin: window.height * 0.2
+
+ TextField {
+ id: tiuname
+ placeholderText: "Benutzername"
+ anchors.horizontalCenter: parent.horizontalCenter
+ Keys.onReturnPressed: login(tiuname.text, tipasswd.text, cBperm.checked)
+ anchors.left: parent.left
+ anchors.margins: window.width * 0.05
+
+ }
+
+
+ TextField {
+ id: tipasswd
+ echoMode: TextInput.Password
+ placeholderText: "Passwort"
+ anchors.horizontalCenter: parent.horizontalCenter
+ Keys.onReturnPressed: login(tiuname.text, tipasswd.text, cBperm.checked)
+ anchors.left: parent.left
+ anchors.margins: window.width * 0.05
+ }
+
+ CheckDelegate {
+ id: cBperm
+ text: qsTr("Angemeldet bleiben")
+ checked: true
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+
+ Button {
+ id: loginButton
+ objectName: "loginButton"
+ text: qsTr("Anmelden")
+ enabled: tiuname.length > 0 & tipasswd.length > 0
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.left: parent.left
+ anchors.margins: window.width * 0.05
+ onClicked: login(tiuname.text, tipasswd.text, cBperm.checked)
+ }
+ Label {
+ id: laStatus
+ text: qsTr("")
+ font.pixelSize: 20
+ color: "red"
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ }
+
+ function login(username, password, permanent){
+ Qt.inputMethod.hide();
+ busyDialog.open()
+ loginButton.enabled = false
+ loginButton.text = "Loggin in.."
+ console.log(username, password, permanent)
+ var ret = _cppServerConn.login(username, password, permanent);
+ busyDialog.close()
+ loginButton.enabled = true
+ loginButton.text = "Login"
+ if(ret === "OK"){
+ _cppAppSettings.writeSetting("init", 1);
+ window.is_error = false;
+ root.StackView.view.push("MainPage.qml")
+ }
+ else{
+ if(_cppAppSettings.loadSetting("permanent") === "1"){
+ tiuname.text = _cppAppSettings.loadSetting("username")
+ tipasswd.text = _cppAppSettings.loadSetting("password")
+ _cppAppSettings.writeSetting("permanent", "0")
+ _cppAppSettings.writeSetting("username", "")
+ _cppAppSettings.writeSetting("password", "")
+ }
+ laStatus.text = ret
+ }
+ //root.qmlSignal(tiuname.text, tipasswd.text)
+ }
+
+ Dialog {
+ id: busyDialog
+ modal: true
+ closePolicy: "NoAutoClose"
+ focus: true
+ title: "Please wait..."
+ x: (window.width - width) / 2
+ y: window.height / 6
+ width: Math.min(window.width, window.height) / 3 * 2
+ height: 150
+ contentHeight: aboutColumn.height
+ Column {
+ id: aboutColumn
+ spacing: 20
+ RowLayout {
+ width: parent.width
+ BusyIndicator {
+ id: busyIndicator
+ visible: true
+ x: 22
+ y: 38
+ }
+
+ Label {
+ width: busyDialog.availableWidth
+ text: "logging in..."
+ wrapMode: Label.Wrap
+ font.pixelSize: 12
+ }
+ }
+ }
+ }
+
+
+
+}
diff --git a/qml/MainPage.qml b/qml/MainPage.qml
new file mode 100644
index 0000000..6e0806e
--- /dev/null
+++ b/qml/MainPage.qml
@@ -0,0 +1,244 @@
+import QtQuick 2.9
+import QtQuick.Controls 2.2
+
+import QtQuick.Layouts 1.1
+import QtQuick.Controls.Styles 1.2
+
+Page {
+ id: root
+ objectName: "MainPage"
+
+ Shortcut {
+ sequences: ["Esc", "Back"]
+ enabled: stackView.depth > 1
+ onActivated: {
+ stackView.pop()
+ }
+ }
+
+ header: AppToolBar {
+
+
+ Button {
+ id:toolButton
+ enabled: window.is_error === false
+ anchors {
+ left: parent.left
+ verticalCenter: parent.verticalCenter
+ leftMargin: parent.width *0.02
+ }
+ height: parent.height - parent.height * 0.5
+ width: height
+
+ onClicked: {
+ if (stackView.depth > 1) {
+ stackView.pop()
+ } else {
+ drawer.open()
+ }
+ }
+
+ onPressed: toolButton.scale = 0.9
+ onReleased: toolButton.scale = 1.0
+
+ background: Image {
+ source: stackView.depth > 1 ? "qrc:/graphics/icons/back.png" : "qrc:/graphics/icons/drawer.png"
+ height: parent.height
+ width: parent.width
+ Behavior on scale {
+ PropertyAnimation {
+ duration: 100
+ }
+ }
+ }
+ }
+
+ Label {
+ text: stackView.currentItem.title
+ anchors {
+ verticalCenter: parent.verticalCenter
+ left: toolButton.right
+ leftMargin: parent.width * 0.02
+ }
+ font.bold: true
+ color: "white"
+ }
+
+ Image {
+ id: logo
+ source: stackView.currentItem.icon
+ anchors.right: parent.right
+ anchors.rightMargin: parent.width * 0.02
+ anchors.top: parent.top
+ height: parent.height
+ fillMode: Image.PreserveAspectFit
+ mipmap: true
+ Behavior on scale {
+ PropertyAnimation {
+ duration: 100
+ }
+ }
+ MouseArea {
+ enabled: stackView.currentItem.link !== undefined && stackView.currentItem.objectName !== "WebsitePage"
+ anchors.fill: parent
+ onPressed: logo.scale = 0.9
+ onReleased: logo.scale = 1.0
+ onClicked: {
+ stackView.push("qrc:/WebsitePage.qml",{title: "Web", link: stackView.currentItem.link, icon: stackView.currentItem.icon})
+ }
+ }
+ }
+ }
+
+ Drawer {
+ id: drawer
+ width: window.width * 0.66
+ height: window.height
+ AppToolBar {
+ id: header
+ showErrorBar: false
+ anchors {
+ top: parent.top
+ left: parent.left
+ right: parent.right
+ }
+
+ Label {
+ text: "Menü"
+ anchors {
+ verticalCenter: parent.verticalCenter
+ left: parent.left
+ leftMargin: 17
+ }
+
+ font.bold: true
+ }
+ }
+ Column {
+ anchors {
+ top: header.bottom
+ bottom: parent.bottom
+ left: parent.left
+ right: parent.right
+ }
+
+
+ ItemDelegate {
+ text: qsTr("Fanny Webseite")
+ width: parent.width
+ onClicked: {
+ stackView.push("qrc:/WebsitePage.qml",{title: "Fanny Webseite", link: "http://www.fanny-leicht.de/j34", icon: stackView.currentItem.icon})
+ drawer.close()
+ }
+ }
+
+ ItemDelegate {
+ text: qsTr("Speiseplan")
+ width: parent.width
+ onClicked: {
+ busyDialog.open()
+ var ret = _cppServerConn.getFoodPlan();
+ drawer.close()
+ busyDialog.close()
+ if(ret === 200 || _cppServerConn.getFoodPlanData(1).cookteam !== ""){
+ stackView.push("qrc:/FoodPlanForm.qml")
+ }
+ }
+ }
+
+ ItemDelegate {
+ Label {
+ text: "abmelden"
+ color: "red"
+ anchors {
+ verticalCenter: parent.verticalCenter
+ left: parent.left
+ leftMargin: 17
+ }
+
+ font.bold: true
+ }
+ width: parent.width
+
+ onClicked: {
+ confirmationDialog.open()
+ }
+
+ Dialog {
+ id: confirmationDialog
+
+ x: (window.width - width) / 2
+ y: (window.height - height) / 2
+ parent: ApplicationWindow.overlay
+
+
+ modal: true
+ standardButtons: Dialog.Cancel | Dialog.Ok
+ Column {
+ spacing: 20
+ anchors.fill: parent
+ Label {
+ text: "Möchtest du dich wirklich abmelden?"
+ }
+ }
+ onAccepted: {
+ _cppServerConn.logout()
+ drawer.close()
+ root.StackView.view.push("qrc:/LoginPage.qml")
+ }
+ }
+ }
+ }
+ }
+
+ StackView {
+ id: stackView
+ initialItem: "qrc:/HomeForm.qml"
+ anchors.fill: parent
+ }
+
+ Dialog {
+ id: busyDialog
+ modal: true
+ focus: true
+ //title: "Please wait..."
+ x: (window.width - width) / 2
+ y: window.height / 6
+ //width: Math.min(window.width, window.height) / 3 * 2
+ height: contentHeight * 1.5
+ width: contentWidth * 1.5
+ contentHeight: progressCircle.height
+ contentWidth: progressCircle.width
+ ProgressCircle {
+ id: progressCircle
+ size: 50
+ lineWidth: 5
+ anchors.centerIn: parent
+ colorCircle: "#FF3333"
+ colorBackground: "#E6E6E6"
+ showBackground: true
+ arcBegin: 0
+ arcEnd: 0
+ Label {
+ id: progress
+ anchors.centerIn: parent
+ text: "0%"
+ }
+ Timer {
+ id: refreshTimer
+ interval: 1;
+ running: busyDialog.visible
+ repeat: true
+ onTriggered: {
+ var ret = _cppServerConn.getProgress()
+ if(ret > 100 || ret < 0){
+ ret = 0
+ }
+
+ progress.text = Math.round( ret * 100 ) + "%"
+ progressCircle.arcEnd = 360 * ret
+ }
+ }
+ }
+ }
+}
diff --git a/qml/ProgressCircle.qml b/qml/ProgressCircle.qml
new file mode 100644
index 0000000..26268d3
--- /dev/null
+++ b/qml/ProgressCircle.qml
@@ -0,0 +1,90 @@
+import QtQuick 2.0
+import QtQml 2.2
+
+Item {
+ id: root
+
+ width: size
+ height: size
+
+ property int size: 200 // The size of the circle in pixel
+ property real arcBegin: 0 // start arc angle in degree
+ property real arcEnd: 270 // end arc angle in degree
+ property real arcOffset: 0 // rotation
+ property bool isPie: false // paint a pie instead of an arc
+ property bool showBackground: false // a full circle as a background of the arc
+ property real lineWidth: 20 // width of the line
+ property string colorCircle: "#CC3333"
+ property string colorBackground: "#779933"
+
+ property alias beginAnimation: animationArcBegin.enabled
+ property alias endAnimation: animationArcEnd.enabled
+
+ property int animationDuration: 20
+
+ onArcBeginChanged: canvas.requestPaint()
+ onArcEndChanged: canvas.requestPaint()
+
+ Behavior on arcBegin {
+ id: animationArcBegin
+ enabled: true
+ NumberAnimation {
+ duration: root.animationDuration
+ easing.type: Easing.InOutCubic
+ }
+ }
+
+ Behavior on arcEnd {
+ id: animationArcEnd
+ enabled: true
+ NumberAnimation {
+ duration: root.animationDuration
+ easing.type: Easing.InOutCubic
+ }
+ }
+
+ Canvas {
+ id: canvas
+ anchors.fill: parent
+ rotation: -90 + parent.arcOffset
+
+ onPaint: {
+ var ctx = getContext("2d")
+ var x = width / 2
+ var y = height / 2
+ var start = Math.PI * (parent.arcBegin / 180)
+ var end = Math.PI * (parent.arcEnd / 180)
+ ctx.reset()
+
+ if (root.isPie) {
+ if (root.showBackground) {
+ ctx.beginPath()
+ ctx.fillStyle = root.colorBackground
+ ctx.moveTo(x, y)
+ ctx.arc(x, y, width / 2, 0, Math.PI * 2, false)
+ ctx.lineTo(x, y)
+ ctx.fill()
+ }
+ ctx.beginPath()
+ ctx.fillStyle = root.colorCircle
+ ctx.moveTo(x, y)
+ ctx.arc(x, y, width / 2, start, end, false)
+ ctx.lineTo(x, y)
+ ctx.fill()
+ } else {
+ if (root.showBackground) {
+ ctx.beginPath();
+ ctx.arc(x, y, (width / 2) - parent.lineWidth / 2, 0, Math.PI * 2, false)
+ ctx.lineWidth = root.lineWidth
+ ctx.strokeStyle = root.colorBackground
+ ctx.stroke()
+ }
+ ctx.beginPath();
+ ctx.arc(x, y, (width / 2) - parent.lineWidth / 2, start, end, false)
+ ctx.lineWidth = root.lineWidth
+ ctx.strokeStyle = root.colorCircle
+ ctx.stroke()
+ }
+ }
+ }
+}
diff --git a/qml/WebsitePage.qml b/qml/WebsitePage.qml
new file mode 100644
index 0000000..49b034e
--- /dev/null
+++ b/qml/WebsitePage.qml
@@ -0,0 +1,48 @@
+import QtQuick 2.9
+import QtWebView 1.1
+import QtQuick.Controls 2.2
+
+import QtWebView 1.1
+import QtQuick.Layouts 1.1
+import QtQuick.Controls.Styles 1.2
+
+Page {
+ id:root
+
+ objectName: "WebsitePage";
+
+ title: qsTr("Fanny Webseite")
+ property string icon: "qrc:/graphics/FannyLogo_small.png"
+
+ property string link: "http://www.fanny-leicht.de/j34"
+
+ ProgressBar {
+ id: progress
+ width: parent.width
+ anchors {
+ top: parent.top
+ }
+ //z: Qt.platform.os === "android" ? -1 : 1
+ visible: webView.loadProgress < 100
+ value: webView.loadProgress === 100 ? 0 : webView.loadProgress / 100
+ }
+
+ WebView {
+ id: webView
+ Keys.onBackPressed: webView.goBack()
+ z: 0
+ anchors {
+ top: webView.loadProgress < 100 ? progress.bottom:parent.top
+ bottom: parent.bottom
+ left: parent.left
+ right: parent.right
+ }
+
+ url: link
+ onLoadingChanged: {
+ console.log(url)
+ if (loadRequest.errorString)
+ console.error(loadRequest.errorString);
+ }
+ }
+}
diff --git a/qml/main.qml b/qml/main.qml
new file mode 100644
index 0000000..755a319
--- /dev/null
+++ b/qml/main.qml
@@ -0,0 +1,133 @@
+import QtQuick 2.9
+import QtQuick.Controls 2.2
+
+ApplicationWindow {
+ id: window
+ visible: true
+ width: 540
+ height: 960
+
+ property bool is_error
+ property string error
+ property bool initdone: false
+ property bool firstinitdone: false
+
+ property string text_color: "black" //"#424753"
+ property string background_color: "white"
+ property string toolbar_color: "#312f38"
+
+ onBeforeRendering: {
+ if(!firstinitdone){
+ var isinit = _cppAppSettings.loadSetting("permanent")
+ console.log("getinit");
+ console.log(isinit);
+ if(isinit === "0"){
+ stackView.push("qrc:/LoginPage.qml", {});
+ }
+ }
+ firstinitdone = true
+ }
+
+ Timer {
+ //runs only one time at applictaion lauch
+ property bool finished: true
+ id: initTimer
+ interval: 1;
+ running: initdone === false
+ repeat: finished
+ onTriggered: {
+ finished = false
+ var init = _cppAppSettings.loadSetting("init")
+
+ var perm = _cppAppSettings.loadSetting("permanent")
+ console.log("checkoldlogin:", perm);
+ if(perm === "1"){
+ console.log("Perm")
+ var ret = _cppServerConn.login(_cppAppSettings.loadSetting("username"), _cppAppSettings.loadSetting("password"), true);
+ if(ret === "OK"){
+ initdone = true
+ _cppAppSettings.writeSetting("init", 1);
+ if(stackView.currentItem.objectName !== "MainPage"){
+ stackView.push("qrc:/MainPage.qml", {});
+ }
+ window.is_error = false;
+ }
+ else if(ret === "Keine Verbindung zum Server."){
+ handleError(0)
+ //initTimer.interval = 1000
+ finished = true
+ return
+ }
+
+ else {
+ ret = _cppServerConn.checkConn()
+ handleError(ret)
+ }
+ }
+ else {
+ initdone = false
+ if(stackView.currentItem.objectName !== "LoginPage"){
+ stackView.push("qrc:/LoginPage.qml")
+ }
+ }
+ finished = true
+ initdone = true
+ }
+ }
+
+ Timer {
+ id: refreshTimer
+ interval: 1000;
+ running: initdone && stackView.currentItem.objectName !== "LoginPage"
+ repeat: true
+ onTriggered: {
+ var ret = _cppServerConn.checkConn()
+ handleError(ret)
+ }
+ }
+
+ StackView {
+ id: stackView
+ initialItem: "MainPage.qml"
+ anchors.fill: parent
+ }
+
+ function handleError(error_code){
+ if(error_code === 200){
+ window.is_error = false;
+ window.error = "";
+ }
+ else if(error_code === 401){
+ console.warn("401")
+ _cppAppSettings.writeSetting("permanent", 0)
+ _cppAppSettings.writeSetting("username", "")
+ _cppAppSettings.writeSetting("password", "")
+ if(["LoginPage"].indexOf(stackView.currentItem.objectName) < 0){
+ console.log("switching to login page")
+ stackView.push("qrc:/LoginPage.qml");
+ }
+ window.is_error = true;
+ window.error = "Nicht angemeldet!!";
+ }
+ else if(error_code === 500){
+ window.is_error = true;
+ window.error = "Interner Server Fehler!";
+ }
+ else if(error_code === 0){
+ window.is_error = true;
+ window.error = "Keine Verbindung zum Server!";
+ }
+ else if(error_code === 404){
+ //the testcon function calls a non existent file to be fast, so no error here
+ window.is_error = false;
+ }
+ else if(error_code === 111){
+ window.is_error = true;
+ window.error = "Unbekannter interner Fehler!";
+ }
+ else {
+ window.is_error = true;
+ window.error = "Unbekannter Fehler! ("+error_code+")";
+ }
+ }
+}
diff --git a/qml/qml.qrc b/qml/qml.qrc
new file mode 100644
index 0000000..f33724f
--- /dev/null
+++ b/qml/qml.qrc
@@ -0,0 +1,13 @@
+
+
+ main.qml
+ HomeForm.qml
+ qtquickcontrols2.conf
+ LoginPage.qml
+ MainPage.qml
+ AppToolBar.qml
+ WebsitePage.qml
+ FoodPlanForm.qml
+ ProgressCircle.qml
+
+
diff --git a/qml/qtquickcontrols2.conf b/qml/qtquickcontrols2.conf
new file mode 100644
index 0000000..571f1cb
--- /dev/null
+++ b/qml/qtquickcontrols2.conf
@@ -0,0 +1,9 @@
+; This file can be edited to change the style of the application
+; Read "Qt Quick Controls 2 Configuration File" for details:
+; http://doc.qt.io/qt-5/qtquickcontrols2-configuration.html
+
+[Controls]
+Style=Material
+
+[Material]
+; Primary="#312f38"
diff --git a/readme.md b/readme.md
new file mode 100644
index 0000000..c6c0277
--- /dev/null
+++ b/readme.md
@@ -0,0 +1,26 @@
+Dies ist die offizielle entwicklungs - repo der Fanny-App
+Die App bietet die Möglichkeit, komfortabel auf den Vertretungsplan des Fanny-Leicht-Gymnasiums in Stuttgart zuzugreifen.
+
+Funktionen
+- Zugriff auf den Vertretungsplan
+- Anzeige des Speiseplanes des Treffpunkt Fanny
+- Zugriff auf die Fanny-Webseite (www.fanny-leicht.de)
+
+
Geplante Funktionen
+- Sortierung der Ereignsse pro Klasse
+
+Weitere Informationen:
+Wenn du eine Idee für eine neue Funktion hast, erstelle einfach eine issue (dafür musst du dich hier registrieren),
+oder schreibe eine Mail an development@itsblue.de.
+Falls du dich gerne an diesem Projekt beteiligen würdest (als Programmier, Designer o.ä.),
+schreibe bitte eine Mail an contact@itsblue.de, oder frag mich in der Schule.
+Aktueller Status:
+Warte auf die Anpassung des Vertretungsplanes.
+
+Downloads:
+
+
- Mac OS
+- Windows
+
+
+Verantwortlicher Entwickler: Dorian Zedler
\ No newline at end of file
diff --git a/release/.DS_Store b/release/.DS_Store
new file mode 100644
index 0000000..d4242c6
Binary files /dev/null and b/release/.DS_Store differ
diff --git a/release/mac OS/.DS_Store b/release/mac OS/.DS_Store
new file mode 100644
index 0000000..5008ddf
Binary files /dev/null and b/release/mac OS/.DS_Store differ
diff --git a/release/mac OS/fannyapp.dmg b/release/mac OS/fannyapp.dmg
new file mode 100644
index 0000000..91488de
Binary files /dev/null and b/release/mac OS/fannyapp.dmg differ
diff --git a/release/windows/fannyapp-setup.exe b/release/windows/fannyapp-setup.exe
new file mode 100644
index 0000000..a5d8f92
Binary files /dev/null and b/release/windows/fannyapp-setup.exe differ
diff --git a/shared.qrc b/shared.qrc
new file mode 100644
index 0000000..509ba29
--- /dev/null
+++ b/shared.qrc
@@ -0,0 +1,14 @@
+
+
+ favicon.png
+ graphics/sheute.png
+ graphics/smorgen.png
+ graphics/chat_background.jpg
+ graphics/FannyLogo.png
+ graphics/TreffpunktFannyLogo.png
+ graphics/icons/back.png
+ graphics/icons/drawer.png
+ graphics/icons/menu.png
+ graphics/FannyLogo_small.png
+
+
diff --git a/source/appsettings.cpp b/source/appsettings.cpp
new file mode 100644
index 0000000..eefda45
--- /dev/null
+++ b/source/appsettings.cpp
@@ -0,0 +1,37 @@
+#include "headers/appsettings.h"
+
+AppSettings * pGlobalAppSettings = NULL;
+
+AppSettings::AppSettings(QObject* parent)
+ :QObject(parent)
+{
+ QString path = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
+ qDebug(path.toLatin1());
+ this->settingsManager = new QSettings(path+"/fannyapp/settings.ini", QSettings::IniFormat);
+
+ qDebug("AppSettings konstruktor");
+ if(loadSetting("init") == "false"){
+ this->writeSetting("init", 0);
+ }
+}
+
+QString AppSettings::loadSetting(const QString &key)
+{
+ this->settingsManager->beginGroup("AppSettings");
+ QString value = this->settingsManager->value(key , false).toString();
+ this->settingsManager->endGroup();
+ return(value);
+}
+
+void AppSettings::writeSetting(const QString &key, const QVariant &variant)
+{
+ this->settingsManager->beginGroup("AppSettings");
+ this->settingsManager->setValue(key , variant);
+ this->settingsManager->endGroup();
+}
+
+AppSettings::~AppSettings()
+{
+ delete settingsManager;
+}
+
diff --git a/source/main.cpp b/source/main.cpp
new file mode 100644
index 0000000..445d69e
--- /dev/null
+++ b/source/main.cpp
@@ -0,0 +1,56 @@
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "headers/serverconn.h"
+#include "headers/appsettings.h"
+
+int main(int argc, char *argv[])
+{
+ ServerConn * pServerConn = new ServerConn;
+ AppSettings * pAppSettings = new AppSettings();
+ pGlobalAppSettings = pAppSettings;
+
+
+ QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+
+
+ QGuiApplication app(argc, argv);
+ QtWebView::initialize();
+
+ QQuickStyle::setStyle("Material");
+ QQmlApplicationEngine engine;
+ engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
+ if (engine.rootObjects().isEmpty())
+ return -1;
+ engine.rootContext()->setContextProperty("_cppServerConn", pServerConn);
+ engine.rootContext()->setContextProperty("_cppAppSettings", pAppSettings);
+
+ int ret;
+ ret = app.exec();
+
+ delete pServerConn;
+ delete pAppSettings;
+ return(ret);
+}
diff --git a/source/serverconn.cpp b/source/serverconn.cpp
new file mode 100644
index 0000000..819495d
--- /dev/null
+++ b/source/serverconn.cpp
@@ -0,0 +1,353 @@
+#include "headers/serverconn.h"
+
+
+ServerConn::ServerConn(QObject *parent) : QObject(parent)
+{
+ qDebug("serverconn konstruktor");
+ this->networkManager = new QNetworkAccessManager();
+ this->refreshNetworkManager = new QNetworkAccessManager();
+}
+
+ServerConn::~ServerConn()
+{
+ qDebug("serverconn destruktor");
+ delete this->networkManager;
+ delete this->refreshNetworkManager;
+
+ QString path = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
+ QDir dir(path + "/.fannyapp-tmp");
+ dir.removeRecursively();
+}
+
+
+QString ServerConn::login(QString username, QString password, bool permanent)
+{
+// QUrlQuery pdata;
+// ReturnData_t ret = this->senddata(QUrl("http://www.fanny-leicht.de/static15/http.intern/sheute.pdf"), pdata);
+// qDebug() << ret.text;
+
+ // Create request
+ QNetworkRequest request;
+ request.setUrl( QUrl( "http://www.fanny-leicht.de/static15/http.intern/sheute.pdf" ) );
+
+ // Pack in credentials
+ QString concatenatedCredentials = username + ":" + password;
+ QByteArray data = concatenatedCredentials.toLocal8Bit().toBase64();
+ QString headerData = "Basic " + data;
+ request.setRawHeader( "Authorization", headerData.toLocal8Bit() );
+
+ QUrlQuery pdata;
+ // Send request and connect all possible signals
+ QNetworkReply*reply = this->networkManager->post(request, pdata.toString(QUrl::FullyEncoded).toUtf8());
+ //QNetworkReply*reply = networkManager->get( request );
+
+ QEventLoop loop;
+ loop.connect(this->networkManager, SIGNAL(finished(QNetworkReply*)), SLOT(quit()));
+ loop.exec();
+ int status_code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
+
+ if(status_code == 200){
+ this->username = username;
+ this->password = password;
+ if(permanent){
+ qDebug() << "permanent";
+ pGlobalAppSettings->writeSetting("permanent", "1");
+ pGlobalAppSettings->writeSetting("username", username);
+ pGlobalAppSettings->writeSetting("password", password);
+ }
+ return("OK");
+ }
+ else if(status_code == 401){
+ return("Ungültige Benutzerdaten.");
+ }
+ else if(status_code == 0){
+ return("Keine Verbindung zum Server.");
+ }
+ else {
+ QString ret = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toChar();
+ ret = ret + reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toChar();
+ return(ret);
+ }
+}
+
+int ServerConn::logout()
+{
+ this->username = "";
+ this->password = "";
+ pGlobalAppSettings->writeSetting("permanent", "0");
+ pGlobalAppSettings->writeSetting("username", "");
+ pGlobalAppSettings->writeSetting("password", "");
+ return(200);
+}
+
+QString ServerConn::getDay(QString day)
+{
+ this->progress = 0;
+ // Create request
+ QNetworkRequest request;
+ request.setUrl( QUrl( "http://www.fanny-leicht.de/static15/http.intern/" + day + ".pdf" ) );
+
+ // Pack in credentials
+ // Pack in credentials
+ QString concatenatedCredentials = this->username + ":" + this->password;
+ QByteArray data = concatenatedCredentials.toLocal8Bit().toBase64();
+ QString headerData = "Basic " + data;
+ request.setRawHeader( "Authorization", headerData.toLocal8Bit() );
+
+ QUrlQuery pdata;
+ // Send request and connect all possible signals
+ QNetworkReply*reply = this->networkManager->post(request, pdata.toString(QUrl::FullyEncoded).toUtf8());
+ //QNetworkReply*reply = networkManager->get( request );
+
+ connect(reply, SIGNAL(downloadProgress(qint64, qint64)),
+ this, SLOT(updateProgress(qint64, qint64)));
+ QEventLoop loop;
+ loop.connect(this->networkManager, SIGNAL(finished(QNetworkReply*)), SLOT(quit()));
+ loop.exec();
+
+ this->progress = 1;
+ int status_code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
+ if(status_code == 200){
+ QString path = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
+
+ QDir dir;
+ dir.mkdir(path + "/.fannyapp-tmp");
+ QFile file(path + "/.fannyapp-tmp/" + day + ".pdf");
+ file.remove();
+
+ file.open(QIODevice::ReadWrite);
+ file.write(reply->readAll());
+ file.close();
+ QDesktopServices::openUrl(QUrl::fromLocalFile(path + "/.fannyapp-tmp/" + day + ".pdf"));
+ return("OK");
+ }
+ else if(status_code == 401){
+ return("Ungültige Benutzerdaten.");
+ }
+ else if(status_code == 0){
+ return("Keine Verbindung zum Server.");
+ }
+ else {
+ QString ret = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toChar();
+ ret = ret + " (" + reply->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toChar() + ")";
+ return(ret);
+ }
+}
+
+int ServerConn::checkConn()
+{
+ // Create request
+ QNetworkRequest request;
+ request.setUrl( QUrl( "http://www.fanny-leicht.de/static15/http.intern/" ) );
+
+ // Pack in credentials
+ // Pack in credentials
+ //ZedlerDo:LxyJQB
+ QString concatenatedCredentials = this->username + ":" + this->password;
+ QByteArray data = concatenatedCredentials.toLocal8Bit().toBase64();
+ QString headerData = "Basic " + data;
+ request.setRawHeader( "Authorization", headerData.toLocal8Bit() );
+
+ QUrlQuery pdata;
+ // Send request and connect all possible signals
+ QNetworkReply*reply = this->refreshNetworkManager->post(request, pdata.toString(QUrl::FullyEncoded).toUtf8());
+ //QNetworkReply*reply = networkManager->get( request );
+
+ QEventLoop loop;
+ loop.connect(this->refreshNetworkManager, SIGNAL(finished(QNetworkReply*)), SLOT(quit()));
+ loop.exec();
+
+ int status_code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
+ return(status_code);
+
+}
+
+void ServerConn::updateProgress(qint64 read, qint64 total)
+{
+ int read_int = read;
+ int total_int = total;
+ float percent = ((float)read_int / (float)total_int);
+ this->progress = percent;
+ percent = (int)percent;
+
+// qDebug() << read << total << percent << "%";
+}
+
+float ServerConn::getProgress()
+{
+ return(this->progress);
+}
+
+int ServerConn::getFoodPlan()
+{
+ this->progress = 0;
+ ReturnData_t ret; //this is a custom type to store the returned data
+ // Call the webservice
+
+ QNetworkRequest request(QUrl("http://www.treffpunkt-fanny.de/fuer-schueler-und-lehrer/speiseplan.html"));
+ request.setHeader(QNetworkRequest::ContentTypeHeader,
+ "application/x-www-form-urlencoded");
+
+ //set ssl configuration
+ //send a POST request with the given url and data to the server
+ QNetworkReply* reply;
+
+ QUrlQuery pdata;
+ reply = this->networkManager->post(request, pdata.toString(QUrl::FullyEncoded).toUtf8());
+
+ connect(reply, SIGNAL(downloadProgress(qint64, qint64)),
+ this, SLOT(updateProgress(qint64, qint64)));
+ //wait until the request has finished
+ QEventLoop loop;
+ loop.connect(this->networkManager, SIGNAL(finished(QNetworkReply*)), SLOT(quit()));
+ loop.exec();
+
+ //get the status code
+ QVariant status_code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
+ this->progress = 1;
+ if(status_code != 200){
+ return(status_code.toInt());
+ }
+
+ //initialize the weekplan to store information to it
+ //m_weekplan.empty(); //empty the weekplan
+ QList> 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
+ ret.text.replace("\n",""); //remove unnecessary stuff
+ ret.text.replace("\r","");
+ ret.text.replace("\t","");
+
+ QStringList stringlist_0 = ret.text.split( "" ); //split the
+
+ //prepare the table of the first week
+ QString table1 = stringlist_0[1];
+
+ QStringList stringlist_1 = table1.split( "
" ); //remove everything after ""
+ table1 = stringlist_1[0];
+ 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
+ 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
+ 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
+ temp = weeklist[i];
+ //table list[i] looks now like:
+ //Red Hot Chili Peppers
+ //
+ //26.06.2018
+ //
Gulasch mit Kartoffeln
+ //
Pellkartoffeln mit Quark
+ //
Gemischter Salat
+ //
Eaton Mess ( Erdbeer-Nachtisch )
+
+ QStringList templist = temp.split(""); //split item at strong, to get the cookteam and the date
+ //qDebug() << templist << "\n";
+ temp = "";
+ for (int i = 0; i <=2; i ++){
+ temp += templist[i]; //convert the list to a big string
+ }
+
+ temp.replace("
","");
+ templist = temp.split("");
+ temp_weekplan.append({templist[0], templist[1]}); //store cookteam and date
+ temp = templist[2]; //store information in temp (looks like: "
Gulasch mit Kartoffeln
Pellkartoffeln mit Quark
Gemischter Salat
Eaton Mess ( Erdbeer-Nachtisch )")
+ templist = temp.split("
"); //seperate the information
+ templist.takeFirst(); //remove first item
+
+ temp_weekplan[i].append(templist);
+
+
+ }
+
+ //qDebug() << temp_weekplan;
+ this->m_weekplan = temp_weekplan; //write changes to global foodplan
+
+
+ return(200);
+}
+
+QVariantMap ServerConn::getFoodPlanData(int index)
+{
+ //cookteam, date, main dish, vagi main dish, garnish(Beilage) and Dessert.
+
+ QStringList ret; //list to return
+ //qDebug() << index;
+ for(int i=0;i<=5;i++){
+
+ if(m_weekplan.size() > index){
+ //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);
+ }
+ }
+ else {
+ ret.append(NULL);
+ }
+ }
+ 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]} };
+
+}
+
+ReturnData_t ServerConn::senddata(QUrl serviceUrl, QUrlQuery pdata)
+{
+
+ ReturnData_t ret; //this is a custom type to store the returned data
+ // Call the webservice
+
+ QNetworkRequest request(serviceUrl);
+ QAuthenticator authenticator;
+ authenticator.setUser("ZedlerDo");
+ authenticator.setPassword("LxyJQB");
+ request.setHeader(QNetworkRequest::ContentTypeHeader,
+ "application/x-www-form-urlencoded");
+
+ //set ssl configuration
+ //send a POST request with the given url and data to the server
+ QNetworkReply* reply;
+
+ reply = this->networkManager->post(request, pdata.toString(QUrl::FullyEncoded).toUtf8());
+
+ //wait until the request has finished
+ QEventLoop loop;
+ loop.connect(this->networkManager, SIGNAL(finished(QNetworkReply*)), SLOT(quit()));
+ loop.exec();
+
+ //get the status code
+ QVariant status_code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
+
+ ret.status_code = status_code.toInt();
+ if(ret.status_code == 0){ //if tehstatus code is zero, the connecion to the server was not possible
+ ret.status_code = 444;
+ }
+ //get the full text response
+ ret.text = QString::fromUtf8(reply->readAll());
+
+ //return the data
+ return(ret);
+}