diff --git a/qml/Components/EventView.qml b/qml/Components/EventView.qml
index c3fb188..642cbb2 100644
--- a/qml/Components/EventView.qml
+++ b/qml/Components/EventView.qml
@@ -2,23 +2,15 @@ import Backend 1.0
import QtQuick 2.9
import QtQuick.Controls 2.4
-ListView {
+FannyDataListView {
id: eventList
- signal refresh()
-
anchors.fill: parent
- anchors.margins: 10
model: EventModel {
id: foodPlanModel
}
- onContentYChanged: {
- if(contentY < -125){
- eventList.refresh()
- }
- }
delegate: Button {
id: delegate
diff --git a/qml/Components/FannyDataListView.qml b/qml/Components/FannyDataListView.qml
new file mode 100644
index 0000000..0b1a054
--- /dev/null
+++ b/qml/Components/FannyDataListView.qml
@@ -0,0 +1,52 @@
+import Backend 1.0
+import QtQuick 2.9
+import QtQuick.Controls 2.4
+
+ListView {
+ id: control
+
+ property int status: -1
+
+ signal refresh()
+
+ anchors.fill: parent
+ anchors.margins: 10
+ anchors.rightMargin: 14
+
+ ScrollBar.vertical: ScrollBar {
+ parent: control.parent
+
+ anchors {
+ top: parent.top
+ right: parent.right
+ bottom: parent.bottom
+ margins: 10
+ rightMargin: 3
+ }
+
+ width: 8
+
+ active: true
+ }
+
+ onContentYChanged: {
+ if(contentY < -125){
+ control.refresh()
+ }
+ }
+
+ InfoArea {
+ id: infoArea
+
+ anchors {
+ left: parent.left
+ right: parent.right
+ top: parent.top
+ margins: app.landscape() ? parent.width * 0.4:parent.width * 0.3
+ topMargin: parent.height*( status === 901 ? 0.6:0.5) - height * 0.8
+ }
+
+ excludedCodes: [200, 902]
+ errorCode: control.status
+ }
+}
diff --git a/qml/Components/FoodPlanView.qml b/qml/Components/FoodPlanView.qml
index bc15e8b..90130df 100644
--- a/qml/Components/FoodPlanView.qml
+++ b/qml/Components/FoodPlanView.qml
@@ -2,19 +2,10 @@ import Backend 1.0
import QtQuick 2.9
import QtQuick.Controls 2.4
-ListView {
+FannyDataListView {
id: foodList
- signal refresh()
-
anchors.fill: parent
- anchors.margins: 10
-
- onContentYChanged: {
- if(contentY < -125){
- foodList.refresh()
- }
- }
model: FoodPlanModel {
id: foodPlanModel
diff --git a/qml/Forms/EventForm.qml b/qml/Forms/EventForm.qml
index 5f47628..d9f9d5a 100644
--- a/qml/Forms/EventForm.qml
+++ b/qml/Forms/EventForm.qml
@@ -47,7 +47,10 @@ Page {
anchors.fill: parent
source: "./LoadingForm.qml"
- onSourceChanged: newItemAnimation.start()
+ onSourceChanged: {
+ pageLoader.item.status = root.status
+ newItemAnimation.start()
+ }
NumberAnimation {
id: newItemAnimation
@@ -90,22 +93,8 @@ Page {
running: true
repeat: false
onTriggered: {
- status = serverConn.getEvents(day)
+ root.status = serverConn.getEvents(day)
pageLoader.newSource = "../Components/EventView.qml"
}
}
-
- InfoArea {
- id: infoArea
-
- anchors {
- left: parent.left
- right: parent.right
- top: parent.top
- margins: app.landscape() ? parent.width * 0.4:parent.width * 0.3
- topMargin: parent.height*( status === 901 ? 0.6:0.5) - height * 0.8
- }
-
- errorCode: status
- }
}
diff --git a/qml/Forms/FilterForm.qml b/qml/Forms/FilterForm.qml
index 09353bc..21ec335 100644
--- a/qml/Forms/FilterForm.qml
+++ b/qml/Forms/FilterForm.qml
@@ -19,20 +19,29 @@ Page {
Dialog {
id: filterDialog
- signal finished(string grade, string classletter)
+ signal finished(string grade, string classletter, string teacherShortcut)
+
+ property bool teacherMode: _cppAppSettings.loadSetting("teacherMode") === "true"
onFinished: {
- if(parseInt(grade) > 10 || classletter === "alle"){
- classletter = ""
+ if(_cppAppSettings.loadSetting("teacherMode") === "true"){
+ contactView.model.append(teacherShortcut, "")
}
+ else {
+ if(parseInt(grade) > 10 || classletter === "alle"){
+ classletter = ""
+ }
- contactView.model.append(grade, classletter)
+ contactView.model.append(grade, classletter)
+ }
}
function createContact() {
form.grade.value = 5
+ form.classLetter.currentIndex = 0
+ form.teacherShortcut.text = ""
- filterDialog.title = qsTr("Klasse hinzufügen");
+ filterDialog.title = qsTr("Filter hinzufügen");
filterDialog.open();
}
@@ -45,47 +54,69 @@ Page {
standardButtons: Dialog.Ok | Dialog.Cancel
contentItem: GridLayout {
- id: form
- property alias grade: gradeSb
- property alias classLetter: classLetterCb
- property int minimumInputSize: 120
+ id: form
+ property alias grade: gradeSb
+ property alias classLetter: classLetterCb
+ property alias teacherShortcut: shortcutTf
+ property int minimumInputSize: 120
- rows: 4
- columns: 2
+ rows: 4
+ columns: 2
- Label {
- text: qsTr("Stufe")
- Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline
+ Label {
+ text: qsTr("Stufe")
+ Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline
+ visible: !filterDialog.teacherMode
+ }
+
+ SpinBox {
+ id: gradeSb
+ focus: true
+ Layout.fillWidth: true
+ Layout.minimumWidth: form.minimumInputSize
+ Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline
+ from: 5
+ to: 12
+ stepSize: 1
+ value: 5
+ visible: !filterDialog.teacherMode
+ }
+
+ Label {
+ text: qsTr("Klasse")
+ Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline
+ visible: !filterDialog.teacherMode
+ }
+
+ ComboBox {
+ id: classLetterCb
+ Layout.fillWidth: true
+ Layout.minimumWidth: form.minimumInputSize
+ Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline
+ model: ["a", "b", "c", "d", "e", "alle"]
+ enabled: gradeSb.value < 11
+ visible: !filterDialog.teacherMode
+ }
+
+ Label {
+ text: qsTr("Kürzel")
+ Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline
+
+ visible: filterDialog.teacherMode
+ }
+
+ TextField {
+ id: shortcutTf
+ focus: true
+ Layout.fillWidth: true
+ Layout.minimumWidth: form.minimumInputSize
+ Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline
+
+ visible: filterDialog.teacherMode
+ }
}
- SpinBox {
- id: gradeSb
- focus: true
- Layout.fillWidth: true
- Layout.minimumWidth: form.minimumInputSize
- Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline
- from: 5
- to: 12
- stepSize: 1
- value: 5
- }
-
- Label {
- text: qsTr("Klasse")
- Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline
- }
-
- ComboBox {
- id: classLetterCb
- Layout.fillWidth: true
- Layout.minimumWidth: form.minimumInputSize
- Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline
- model: ["a", "b", "c", "d", "e", "alle"]
- enabled: gradeSb.value < 11
- }
- }
-
- onAccepted: finished(form.grade.value.toString(), form.classLetter.currentText)
+ onAccepted: finished(form.grade.value, form.classLetter.currentText, form.teacherShortcut.text)
}
ListView {
diff --git a/qml/Forms/FoodPlanForm.qml b/qml/Forms/FoodPlanForm.qml
index b688d67..a11f74c 100644
--- a/qml/Forms/FoodPlanForm.qml
+++ b/qml/Forms/FoodPlanForm.qml
@@ -48,7 +48,10 @@ Page {
anchors.fill: parent
source: "./LoadingForm.qml"
- onSourceChanged: newItemAnimation.start()
+ onSourceChanged: {
+ pageLoader.item.status = root.status
+ newItemAnimation.start()
+ }
NumberAnimation {
id: newItemAnimation
@@ -95,19 +98,4 @@ Page {
pageLoader.newSource = "../Components/FoodPlanView.qml"
}
}
-
- InfoArea {
- id: infoArea
-
- anchors {
- left: parent.left
- right: parent.right
- top: parent.top
- margins: app.landscape() ? parent.width * 0.4:parent.width * 0.3
- topMargin: parent.height/2 - height * 0.8
- }
-
- excludedCodes: [200, 902]
- errorCode: status
- }
}
diff --git a/qml/Forms/HomeForm.qml b/qml/Forms/HomeForm.qml
index 760fee7..a572e8f 100644
--- a/qml/Forms/HomeForm.qml
+++ b/qml/Forms/HomeForm.qml
@@ -38,7 +38,7 @@ Page {
height: mainMenu.buttonHeight
onClicked: {
- eventConfirmationDialog.openDay("sheute")
+ eventConfirmationDialog.openDay( _cppAppSettings.loadSetting("teacherMode") === "true" ? "lheute":"sheute")
}
}
@@ -51,7 +51,7 @@ Page {
height: mainMenu.buttonHeight
onClicked: {
- eventConfirmationDialog.openDay("smorgen")
+ eventConfirmationDialog.openDay( _cppAppSettings.loadSetting("teacherMode") === "true" ? "lmorgen":"smorgen")
}
}
diff --git a/qml/Forms/LoadingForm.qml b/qml/Forms/LoadingForm.qml
index 144bed7..416bd1a 100644
--- a/qml/Forms/LoadingForm.qml
+++ b/qml/Forms/LoadingForm.qml
@@ -6,6 +6,8 @@ Page {
signal refresh()
+ property int status: -1
+
BusyIndicator {
anchors.centerIn: parent
}
diff --git a/qml/Forms/SettingsForm.qml b/qml/Forms/SettingsForm.qml
index 4618a69..5978a86 100644
--- a/qml/Forms/SettingsForm.qml
+++ b/qml/Forms/SettingsForm.qml
@@ -28,8 +28,85 @@ Page {
formStack.push(filterForm)
}
- title: "Klassen"
- description: "Wähle die Klassen(stufen) aus, für die du den Vertretungsplan ansehen möchtest"
+ title: "Filter"
+ description: "Wähle die Klassen(stufen) bzw. Lehrerkürzel aus, für die du den Vertretungsplan ansehen möchtest"
+ }
+
+ SwitchDelegate {
+ width: parent.width
+ height: 10 + shortDescription.height + 2 + longDescription.height + 10
+
+ checked: _cppAppSettings.loadSetting("teacherMode") === "true"
+
+ onCheckedChanged: {
+ _cppAppSettings.writeSetting("teacherMode", checked)
+ }
+
+ Label {
+ id: shortDescription
+
+ anchors {
+ top: parent.top
+ left: parent.left
+ margins: 10
+ }
+
+ font.pixelSize: longDescription.font.pixelSize * 1.4
+
+ text: "Lehrermodus"
+
+ }
+
+ Label {
+ id: longDescription
+
+ anchors {
+ top: shortDescription.bottom
+ topMargin: 2
+ left: parent.left
+ leftMargin: 10
+ }
+
+ width: parent.width * 0.9
+
+ wrapMode: Label.Wrap
+
+ text: "Lehrermodus aktivieren"
+ }
+
+ indicator: Rectangle {
+ property bool checked: parent.checked
+ property bool down: parent.down
+ property int set_height: parent.font.pixelSize * 1.4
+ implicitWidth: set_height * 1.84
+ implicitHeight: set_height
+ x: parent.width - width - parent.rightPadding
+ y: parent.height / 2 - height / 2
+ radius: implicitHeight * 0.5
+ color: parent.checked ? "#17a81a" : "transparent"
+ border.color: parent.checked ? "#17a81a" : "#cccccc"
+ Behavior on color{
+ ColorAnimation{
+ duration: 200
+ }
+ }
+
+ Rectangle {
+ x: parent.checked ? parent.width - width : 0
+ width: parent.height
+ height: parent.height
+ radius: height * 0.5
+ color: parent.down ? "#cccccc" : "#ffffff"
+ border.color: parent.checked ? (parent.down ? "#17a81a" : "#21be2b") : "#999999"
+ Behavior on x{
+ NumberAnimation {
+ property: "x"
+ duration: 200
+ easing.type: Easing.InOutQuad
+ }
+ }
+ }
+ }
}
}
}
diff --git a/qml/qml.qrc b/qml/qml.qrc
index 17ba6fb..3c756d1 100644
--- a/qml/qml.qrc
+++ b/qml/qml.qrc
@@ -16,5 +16,6 @@
Forms/SettingsForm.qml
Forms/FilterForm.qml
Components/SettingsDelegate.qml
+ Components/FannyDataListView.qml
diff --git a/sources/serverconn.cpp b/sources/serverconn.cpp
index 03d8367..4c62bae 100644
--- a/sources/serverconn.cpp
+++ b/sources/serverconn.cpp
@@ -253,7 +253,8 @@ int ServerConn::getEvents(QString day){
QVariant status_code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
this->progress = 1;
if(status_code != 200){
- // if the request didn't result in a success, return the error code
+ // if the request didn't result in a success, clear the old events, as they are probaply incorrect and return the error code
+ this->m_events.clear();
return(status_code.toInt());
}