diff --git a/headers/appsettings.h b/headers/appsettings.h index d597a30..5c37d3d 100644 --- a/headers/appsettings.h +++ b/headers/appsettings.h @@ -22,9 +22,6 @@ public: QList readFilters(); void writeFilters(QList list); - Q_INVOKABLE QStringList readFiltersQml(); - Q_INVOKABLE void writeFiltersQml(QStringList); - QSettings *settingsManager; QFile * filtersFile; diff --git a/headers/eventmodel.h b/headers/eventmodel.h index d58a799..a12c7a6 100644 --- a/headers/eventmodel.h +++ b/headers/eventmodel.h @@ -27,8 +27,6 @@ public: QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; QHash roleNames() const; - Q_INVOKABLE QStringList getHeader(); - Q_INVOKABLE QVariantMap get(int row) const; private: diff --git a/headers/serverconn.h b/headers/serverconn.h index 1d8558d..0ea743f 100644 --- a/headers/serverconn.h +++ b/headers/serverconn.h @@ -37,13 +37,11 @@ private: QNetworkAccessManager *networkManager; QNetworkAccessManager *refreshNetworkManager; QTimer *checkConnTimer; - float progress; int authErrorCount; ReturnData_t senddata(QUrl serviceUrl, QUrlQuery postData); private slots: - void updateProgress(qint64 read, qint64 total); void setState(QString state); @@ -55,7 +53,6 @@ public slots: Q_INVOKABLE int login(QString username, QString password, bool permanent); Q_INVOKABLE int logout(); Q_INVOKABLE int checkConn(); - Q_INVOKABLE float getProgress(); Q_INVOKABLE int getFoodPlan(); Q_INVOKABLE int getEvents(QString day); @@ -67,8 +64,6 @@ signals: public: QList> m_weekplan; QList m_events; - QStringList m_eventHeader; - }; extern ServerConn * pGlobalServConn; diff --git a/qml/Forms/EventForm.qml b/qml/Forms/EventForm.qml index d9f9d5a..0f35d6a 100644 --- a/qml/Forms/EventForm.qml +++ b/qml/Forms/EventForm.qml @@ -5,35 +5,16 @@ import "../Components" Page { id: root - //anchors.fill: parent + property string day + title: qsTr("Vertretungsplan") - property string icon: "qrc:/graphics/FannyLogo_small.png" - property string link: "http://www.fanny-leicht.de/j34" + property int status: -1 signal opened() - onOpened: { - } - - // 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" } - // } - // } + onOpened: {} Loader { id: pageLoader diff --git a/qml/Forms/FilterForm.qml b/qml/Forms/FilterForm.qml index 97742e4..ca05aae 100644 --- a/qml/Forms/FilterForm.qml +++ b/qml/Forms/FilterForm.qml @@ -14,9 +14,7 @@ Page { signal opened() - onOpened: { - console.log("Filter Form opened") - } + onOpened: {} Dialog { id: filterDialog diff --git a/qml/Forms/FoodPlanForm.qml b/qml/Forms/FoodPlanForm.qml index a11f74c..9cd5855 100644 --- a/qml/Forms/FoodPlanForm.qml +++ b/qml/Forms/FoodPlanForm.qml @@ -5,36 +5,14 @@ import "../Components" Page { id:root - //anchors.fill: parent - property bool cookplanChanged + title: qsTr("Speiseplan") - property string icon: "qrc:/graphics/images/TreffpunktFannyLogo.png" - property string link: "http://www.treffpunkt-fanny.de" + property int status: -1 signal opened() - onOpened: { - console.warn("foodplan opened") - } - -// 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" } -// } -// } + onOpened: {} Loader { id: pageLoader diff --git a/qml/Forms/HomeForm.qml b/qml/Forms/HomeForm.qml index a572e8f..8bee192 100644 --- a/qml/Forms/HomeForm.qml +++ b/qml/Forms/HomeForm.qml @@ -8,9 +8,7 @@ Page { signal opened() - onOpened: { - console.log("Home Form opened") - } + onOpened: {} Column { id: mainMenu @@ -32,7 +30,7 @@ Page { FancyButton { id: todayButton - image: "qrc:/graphics/sheute.png" + image: "qrc:/graphics/icons/sheute.png" width: mainMenu.buttonWidth height: mainMenu.buttonHeight @@ -45,7 +43,7 @@ Page { FancyButton { id: tomorrowButton - image: "qrc:/graphics/smorgen.png" + image: "qrc:/graphics/icons/smorgen.png" width: mainMenu.buttonWidth height: mainMenu.buttonHeight @@ -178,7 +176,6 @@ Page { } onAccepted: { serverConn.logout() - app.state = "notLoggedIn" } } } diff --git a/qml/Forms/SettingsForm.qml b/qml/Forms/SettingsForm.qml index 5978a86..6b87f43 100644 --- a/qml/Forms/SettingsForm.qml +++ b/qml/Forms/SettingsForm.qml @@ -10,11 +10,7 @@ Page { signal opened() - onOpened: { - console.log("Settings Form opened") - - var filters = _cppAppSettings.readFiltersQml() - } + onOpened: {} Column { id: settingsCol diff --git a/qml/main.qml b/qml/main.qml index fdbaeb3..37677d3 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -25,7 +25,7 @@ ApplicationWindow { property string backgroundColor: "white" property string toolbarColor: "#312f38" - state: "loggedIn" + state: serverConn.state states: [ State { @@ -118,6 +118,11 @@ ApplicationWindow { errorString = "Alte Daten" errorDescription = "Es konnte keine Verbindung zum Server hergestellt werden, aber es sind noch alte Daten gespeichert." break + case 903: + infoLevel = 1 + errorString = "Ungültiger Aufruf" + errorDescription = "Die aufgerufene Funktion ist momentan nicht verfügbar, bitte versuche es später erneut." + break default: infoLevel = 2 errorString = "Unerwarteter Fehler ("+errorCode+")" diff --git a/shared/circle.png b/shared/circle.png deleted file mode 100644 index d423779..0000000 Binary files a/shared/circle.png and /dev/null differ diff --git a/shared/favicon.png b/shared/favicon.png deleted file mode 100644 index ac69062..0000000 Binary files a/shared/favicon.png and /dev/null differ diff --git a/shared/favicon.xcf b/shared/favicon.xcf deleted file mode 100644 index 42a7c48..0000000 Binary files a/shared/favicon.xcf and /dev/null differ diff --git a/shared/graphics/chat_background.jpg b/shared/graphics/chat_background.jpg deleted file mode 100644 index fe815e1..0000000 Binary files a/shared/graphics/chat_background.jpg and /dev/null differ diff --git a/shared/favicon.icns b/shared/graphics/favicon.icns similarity index 100% rename from shared/favicon.icns rename to shared/graphics/favicon.icns diff --git a/shared/favicon.ico b/shared/graphics/favicon.ico similarity index 100% rename from shared/favicon.ico rename to shared/graphics/favicon.ico diff --git a/shared/graphics/favicon.png b/shared/graphics/favicon.png index 4ee3fc5..ac69062 100644 Binary files a/shared/graphics/favicon.png and b/shared/graphics/favicon.png differ diff --git a/shared/graphics/favicon.xcf b/shared/graphics/favicon.xcf index 2f48792..42a7c48 100644 Binary files a/shared/graphics/favicon.xcf and b/shared/graphics/favicon.xcf differ diff --git a/shared/graphics/icon.jpg b/shared/graphics/icon.jpg deleted file mode 100644 index aaf4da4..0000000 Binary files a/shared/graphics/icon.jpg and /dev/null differ diff --git a/shared/graphics/icons/logoutBlack.jpg b/shared/graphics/icons/logoutBlack.jpg deleted file mode 100644 index 9dea551..0000000 Binary files a/shared/graphics/icons/logoutBlack.jpg and /dev/null differ diff --git a/shared/graphics/icons/sheute.png b/shared/graphics/icons/sheute.png new file mode 100644 index 0000000..e06620a Binary files /dev/null and b/shared/graphics/icons/sheute.png differ diff --git a/shared/graphics/icons/smorgen.png b/shared/graphics/icons/smorgen.png new file mode 100644 index 0000000..deeec16 Binary files /dev/null and b/shared/graphics/icons/smorgen.png differ diff --git a/shared/graphics/sheute.png b/shared/graphics/sheute.png deleted file mode 100644 index 0b8f2aa..0000000 Binary files a/shared/graphics/sheute.png and /dev/null differ diff --git a/shared/graphics/sheute_new.png b/shared/graphics/sheute_new.png deleted file mode 100644 index 7b7eec8..0000000 Binary files a/shared/graphics/sheute_new.png and /dev/null differ diff --git a/shared/graphics/smorgen.png b/shared/graphics/smorgen.png deleted file mode 100644 index 1212cc7..0000000 Binary files a/shared/graphics/smorgen.png and /dev/null differ diff --git a/shared/samplehtml/convert.sh b/shared/sampleEventData/convert.sh similarity index 100% rename from shared/samplehtml/convert.sh rename to shared/sampleEventData/convert.sh diff --git a/shared/sampleEventData/sample.json b/shared/sampleEventData/sample.json new file mode 100644 index 0000000..ebca016 --- /dev/null +++ b/shared/sampleEventData/sample.json @@ -0,0 +1 @@ +{"result":200,"version":"0.01.14","targetDate":"Klasse 21.1. / Montag Woche-A","stewardingClass":"Ordnungsdienst: Klasse 5a","additionalHeaderData":[],"events":[["Kl.","Std.","Vertr.","Fach","Rau","nach","Vertretungs-Text"],["5a","1","Hl","E","---","Mi-23.1. / 2",""],["5a","5","Ni","BK","126","",""],["5b","3-4","Sg","E","114","",""],["6c","5","Gg","G","121","He / Aufgaben",""],["6d","1","Gw","D","---","Entfall",""],["6d","2","Ki","D","210","Mc / Aufgaben",""],["7b","1-2","Tri","E","414","",""],["7bd","8-9","Rs","inf","---","Entfall",""],["7c","8-9","Klr","Bio","415","Raum!",""],["8b","10","Tri","G","312","",""],["8b","11","He","Gk","323","",""],["9c","3-4","An","E","220","Entfall fu00fcr Lehrer",""],["11","3-4","Tb","D4","313","Entfall fu00fcr Lehrer",""],["11","6","Bz","410","Schule trifft Beruf","",""]],"rawHeader":["D-70563 FANNY-LEICHT-GYMN. Schuljahr 2018/19 - 2. Halbjahr Untis 2017","STUTTGART, F.-LEICHT-STR. 13 gu00fcltig ab 04. Februar 2019 18.1.2019 17:50","Klasse 21.1. / Montag Woche-A","Ordnungsdienst: Klasse 5a"],"rawData":["Kl. Std. Vertr. Fach Rau nach Vertretungs-Text","5a 1 Hl E --- Mi-23.1. / 2","5a 5 Ni BK 126","5b 3-4 Sg E 114","6c 5 Gg G 121 He / Aufgaben","6d 1 Gw D --- Entfall","6d 2 Ki D 210 Mc / Aufgaben","7b 1-2 Tri E 414","7bd 8-9 Rs inf --- Entfall","7c 8-9 Klr Bio 415 Raum!","8b 10 Tri G 312","8b 11 He Gk 323","9c 3-4 An E 220 Entfall fu00fcr Lehrer","11 3-4 Tb D4 313 Entfall fu00fcr Lehrer","11 6 Bz 410 Schule trifft Beruf"]} diff --git a/shared/samplehtml/Download File.pdf b/shared/sampleEventData/sample.pdf similarity index 100% rename from shared/samplehtml/Download File.pdf rename to shared/sampleEventData/sample.pdf diff --git a/shared/samplehtml/Download File.txt b/shared/sampleEventData/sample.txt similarity index 100% rename from shared/samplehtml/Download File.txt rename to shared/sampleEventData/sample.txt diff --git a/shared/samplehtml/Download File-html.html b/shared/samplehtml/Download File-html.html deleted file mode 100644 index 890dd46..0000000 --- a/shared/samplehtml/Download File-html.html +++ /dev/null @@ -1,485 +0,0 @@ - - - -Download File-html.html - - -
- - - -
-

D-70563 FANNY-LEICHT-GYMN.

-

STUTTGART, F.-LEICHT-STR. 13

-

Schuljahr 2018/19 - 1. Halbjahr
gültig ab 10. September 2018

-

Untis 2017

-

13.12.2018  9:04

-

Klasse  13.12. / Donnerstag Woche-A

-

Ordnungsdienst: Klasse 10a

-

Kl.

-

Std.

-

Vertr. Fach Rau nach

-

Vertretungs-Text

-

5b

-

1

-

Hei

-

D

-

---

-

Entfall

-

5b

-

2

-

Fu

-

D

-

114

-

Hei / Aufgaben, Arbeitsheft!

-

5b

-

3

-

Oe

-

M

-

114

-

Ei / Aufgaben

-

5b

-

4

-

Rm

-

M

-

114

-

Ei / Aufgaben

-

6bc

-

5

-

Sf

-

EvR

-

321

-

Bü / Aufgaben

-

6bc

-

5

-

Dk

-

KR

-

121

-

We / Aufgaben

-

6bc

-

6

-

-

EvR

-

---

-

Entfall

-

6bc

-

6

-

We

-

KR

-

---

-

Entfall

-

6d

-

6

-

Ku

-

Ek

-

---

-

Entfall

-

7b

-

2

-

Ga

-

G

-

414

-

KA Fkr

-

7b

-

8

-

Gg

-

BK

-

---

-

Mi-12.12. / 1

-

7b

-

9

-

Gg

-

BK

-

---

-

Mi-12.12. / 2

-

7c

-

8 - 9

-

Gw

-

G

-

---

-

Entfall

-

7d

-

1

-

Ku

-

D

-

---

-

Entfall

-

7d

-

2

-

Oz

-

D

-

416

-

Ku / Aufgaben

-

8a

-

1 - 2

-

Ei

-

Ch

-

---

-

Entfall

-

KEINE KA

-

9ac

-

8 - 9

-

Lk

-

SpJ

-

---

-

Entfall

-

9c

-

1 - 2

-

Jw

-

Gk

-

322

-

Raum!

-

9c

-

3

-

Hf

-

D

-

220

-

Hei / Aufgaben

-

9c

-

4

-

Bkn

-

D

-

220

-

Hei / Aufgaben

-

9d

-

1

-

Rt

-

Gk

-

---

-

Do-13.12. / 3

-

9d

-

2

-

Rt

-

Gk

-

---

-

Do-13.12. / 4

-

9d

-

3

-

Rt

-

Gk

-

218

-

9d

-

4

-

Rt

-

Gk

-

218

-

9d

-

5

-

Ni

-

BK

-

126

-

9d

-

6

-

Ni

-

BK

-

126

-

9d

-

8

-

Ni

-

BK

-

---

-

Do-13.12. / 5

-

9d

-

9

-

Ni

-

BK

-

---

-

Do-13.12. / 6

-

10b

-

10 - 11

-

Fe

-

Ph

-

---

-

Entfall

-

11

-

3 - 4

-

Ft

-

g4

-

---

-

Entfall

-

11

-

5

-

Ei

-

M1

-

---

-

Entfall

-

11

-

7

-

Gt

-

sem1 324

-

geteilte Gruppen Schwimmen / 

-

11

-

8 - 9

-

Ro

-

sem1 ???

-

11

-

10 - 11

-

Lk

-

sp3

-

---

-

Entfall

-

12

-

1 - 2

-

Ni

-

bk1

-

412

-

Raum!

-

12

-

5

-

Ku

-

D2

-

---

-

Entfall

-

1112 8 - 9

-

Fe

-

vma

-

---

-

Entfall

-
- - - - - -Download File-html.html - - -
- - - -
-

D-70563 FANNY-LEICHT-GYMN.

-

STUTTGART, F.-LEICHT-STR. 13

-

Schuljahr 2018/19 - 1. Halbjahr
gültig ab 10. September 2018

-

Untis 2017

-

13.12.2018  8:11

-

Klasse  14.12. / Freitag Woche-A

-

Ordnungsdienst: Klasse 10a

-

Kl.

-

Std. Vertr. Fach Rau nach

-

Vertretungs-Text

-

5abc 1

-

We

-

KR

-

---

-

Entfall

-

5a

-

1

-

-

EvR

-

---

-

Entfall

-

5abc 2

-

Jw

-

KR

-

123

-

We / Aufgaben

-

5a

-

2

-

Ng

-

EvR

-

321

-

Bü / Aufgaben

-

5d

-

3

-

Lo

-

D

-

122

-

anstatt 17.12., 1. Std.

-

5d

-

4

-

Lo

-

D

-

122

-

anstatt 19.12., 1 Std.

-

6a

-

6

-

He

-

E

-

---

-

Entfall

-

6acd 7

-

Ft

-

MF

-

---

-

Entfall

-

6c

-

1

-

Ku

-

D

-

---

-

Entfall

-

6c

-

2

-

Sl

-

D

-

121

-

Ku / Aufgaben

-

7a

-

3

-

Di

-

D

-

323

-

Raum

-

7a

-

4

-

Hhn

-

M

-

323

-

7a

-

5

-

Hhn

-

M

-

323

-

7a

-

6

-

Hhn

-

M

-

323

-

findet statt!

-

7b

-

6

-

Rt

-

D

-

---

-

Entfall

-

8a

-

1

-

Ft

-

M

-

---

-

Entfall

-

8a

-

2

-

Li

-

E

-

323

-

statt 18.12.

-

9c

-

5 - 6

-

Hei

-

D

-

---

-

Entfall

-

9d

-

1 - 2 Rm

-

NWT 412

-

Raum

-

9d

-

5 - 6

-

Ft

-

M

-

---

-

Entfall

-

10a

-

3 - 4 Smr

-

E

-

413

-

Hörverstehensklausur

-

10ad 3

-

Ro

-

EvR

-

SH

-

Sport!

-

10ad 3 - 4

-

We

-

KR

-

---

-

Entfall

-

10ad 4

-

Lk

-

EvR

-

SH

-

Sport!

-

10b

-

3 - 4 Ki

-

E

-

414

-

Hörverstehensklausur

-

10b

-

3 - 4

-

He

-

Gk

-

---

-

Entfall für Lehrer

-

10bc 5 - 6

-

We

-

KR

-

---

-

Entfall

-

10c

-

3 - 4

-

Ran

-

M

-

---

-

Entfall

-

alle bei Oe

-

10c

-

3 - 4 Oe

-

E

-

422

-

Hörverstehensklausur

-

10d

-

3 - 4 Wd

-

E

-

416

-

Hörverstehensklausur

-

11

-

3 - 4 At

-

D3

-

121

-

Raum

-

11

-

3 - 4 Sl

-

D2

-

415

-

Raum

-

12

-

1 - 2 Lo

-

Sp1

-

222

-

Theorie

-

12

-

3 - 4 Mf

-

E2

-

218

-

Raum

-

12

-

3 - 4 Sf

-

M3

-

322

-

Raum

-

12

-

3 - 4

-

Ft

-

M2

-

---

-

Entfall

-

12

-

5 - 6

-

Ku

-

ek1

-

---

-

Entfall

-
- - diff --git a/shared/samplehtml/Download File.html b/shared/samplehtml/Download File.html deleted file mode 100644 index 1a3278b..0000000 --- a/shared/samplehtml/Download File.html +++ /dev/null @@ -1,871 +0,0 @@ - - -MergedFile - - - - - - - - - - D-70563 - FANNY-LEICHT-GYMN. - - - - - STUTTGART, - F.-LEICHT-STR. - 13 - - - - - - - Schuljahr - 2018/19 - - - 1. - Halbjahr - - - gültig - ab - 10. - September - 2018 - - - - - - - Klasse - 13.12. - / - Donnerstag - Woche-A - - - - - Ordnungsdienst: - Klasse - 10a - - - - - - - Kl. - - - 5b - - - 5b - - - 5b - - - 5b - - - 6bc - - - 6bc - - - 6bc - - - 6bc - - - 6d - - - 7b - - - 7b - - - 7b - - - 7c - - - 7d - - - 7d - - - 8a - - - 9ac - - - 9c - - - 9c - - - 9c - - - 9d - - - 9d - - - 9d - - - 9d - - - 9d - - - 9d - - - 9d - - - 9d - - - 10b - - - 11 - - - 11 - - - 11 - - - 11 - - - 11 - - - 12 - - - 12 - - - 1112 - - - - - - - Std. - - - 1 - - - 2 - - - 3 - - - 4 - - - 5 - - - 5 - - - 6 - - - 6 - - - 6 - - - 2 - - - 8 - - - 9 - - - 8 - - - 9 - - - 1 - - - 2 - - - 1 - - - 2 - - - 8 - - - 9 - - - 1 - - - 2 - - - 3 - - - 4 - - - 1 - - - 2 - - - 3 - - - 4 - - - 5 - - - 6 - - - 8 - - - 9 - - - 10 - - - 11 - - - 3 - - - 4 - - - 5 - - - 7 - - - 8 - - - 9 - - - 10 - - - 11 - - - 1 - - - 2 - - - 5 - - - 8 - - - 9 - - - - - - - Vertr. - - - Hei - - - Fu - - - Oe - - - Rm - - - Sf - - - Dk - - - - - - We - - - Ku - - - Ga - - - Gg - - - Gg - - - Gw - - - Ku - - - Oz - - - Ei - - - Lk - - - Jw - - - Hf - - - Bkn - - - Rt - - - Rt - - - Rt - - - Rt - - - Ni - - - Ni - - - Ni - - - Ni - - - Fe - - - Ft - - - Ei - - - Gt - - - Ro - - - Lk - - - Ni - - - Ku - - - Fe - - - - - - - Fach - - - D - - - D - - - M - - - M - - - EvR - - - KR - - - EvR - - - KR - - - Ek - - - G - - - BK - - - BK - - - G - - - D - - - D - - - Ch - - - SpJ - - - Gk - - - D - - - D - - - Gk - - - Gk - - - Gk - - - Gk - - - BK - - - BK - - - BK - - - BK - - - Ph - - - g4 - - - M1 - - - sem1 - - - sem1 - - - sp3 - - - bk1 - - - D2 - - - vma - - - - - - - Rau - - - --- - - - 114 - - - 114 - - - 114 - - - 321 - - - 121 - - - --- - - - --- - - - --- - - - 414 - - - --- - - - --- - - - --- - - - --- - - - 416 - - - --- - - - --- - - - 322 - - - 220 - - - 220 - - - --- - - - --- - - - 218 - - - 218 - - - 126 - - - 126 - - - --- - - - --- - - - --- - - - --- - - - --- - - - 324 - - - ??? - - - --- - - - 412 - - - --- - - - --- - - - - - - - nach - - - Entfall - - - - - - - Vertretungs-Text - - - - - Hei - / - Aufgaben, - Arbeitsheft! - - - Ei - / - Aufgaben - - - Ei - / - Aufgaben - - - - / - Aufgaben - - - We - / - Aufgaben - - - - - - - Entfall - - - Entfall - - - Entfall - - - - - KA - Fkr - - - - - Mi-12.12. - / - 1 - - - Mi-12.12. - / - 2 - - - Entfall - - - Entfall - - - - - Entfall - - - Entfall - - - - - - - Ku - / - Aufgaben - - - KEINE - KA - - - - - Raum! - - - Hei - / - Aufgaben - - - Hei - / - Aufgaben - - - - - - - Do-13.12. - / - 3 - - - Do-13.12. - / - 4 - - - - - - - Do-13.12. - / - 5 - - - Do-13.12. - / - 6 - - - Entfall - - - Entfall - - - Entfall - - - - - geteilte - Gruppen - Schwimmen - / - - - - - Entfall - - - - - Raum! - - - - - Entfall - - - Entfall - - - - - - - Untis - 2017 - - - - - 13.12.2018 - 9:04 - - - - - - - - - diff --git a/shared/samplehtml/Download File.xml b/shared/samplehtml/Download File.xml deleted file mode 100644 index 3f8ea63..0000000 --- a/shared/samplehtml/Download File.xml +++ /dev/null @@ -1,455 +0,0 @@ - - - - - - - - - - -D-70563 FANNY-LEICHT-GYMN. -STUTTGART, F.-LEICHT-STR. 13 -Schuljahr 2018/19 - 1. Halbjahr -gültig ab 10. September 2018 -Untis 2017 -13.12.2018 9:04 -Klasse 13.12. / Donnerstag Woche-A -Ordnungsdienst: Klasse 10a -Kl. -Std. -Vertr. Fach Rau nach -Vertretungs-Text -5b -1 -Hei -D ---- -Entfall -5b -2 -Fu -D -114 -Hei / Aufgaben, Arbeitsheft! -5b -3 -Oe -M -114 -Ei / Aufgaben -5b -4 -Rm -M -114 -Ei / Aufgaben -6bc -5 -Sf -EvR -321 -Bü / Aufgaben -6bc -5 -Dk -KR -121 -We / Aufgaben -6bc -6 - -EvR ---- -Entfall -6bc -6 -We -KR ---- -Entfall -6d -6 -Ku -Ek ---- -Entfall -7b -2 -Ga -G -414 -KA Fkr -7b -8 -Gg -BK ---- -Mi-12.12. / 1 -7b -9 -Gg -BK ---- -Mi-12.12. / 2 -7c -8 - 9 -Gw -G ---- -Entfall -7d -1 -Ku -D ---- -Entfall -7d -2 -Oz -D -416 -Ku / Aufgaben -8a -1 - 2 -Ei -Ch ---- -Entfall -KEINE KA -9ac -8 - 9 -Lk -SpJ ---- -Entfall -9c -1 - 2 -Jw -Gk -322 -Raum! -9c -3 -Hf -D -220 -Hei / Aufgaben -9c -4 -Bkn -D -220 -Hei / Aufgaben -9d -1 -Rt -Gk ---- -Do-13.12. / 3 -9d -2 -Rt -Gk ---- -Do-13.12. / 4 -9d -3 -Rt -Gk -218 -9d -4 -Rt -Gk -218 -9d -5 -Ni -BK -126 -9d -6 -Ni -BK -126 -9d -8 -Ni -BK ---- -Do-13.12. / 5 -9d -9 -Ni -BK ---- -Do-13.12. / 6 -10b -10 - 11 -Fe -Ph ---- -Entfall -11 -3 - 4 -Ft -g4 ---- -Entfall -11 -5 -Ei -M1 ---- -Entfall -11 -7 -Gt -sem1 324 -geteilte Gruppen Schwimmen / -11 -8 - 9 -Ro -sem1 ??? -11 -10 - 11 -Lk -sp3 ---- -Entfall -12 -1 - 2 -Ni -bk1 -412 -Raum! -12 -5 -Ku -D2 ---- -Entfall -1112 8 - 9 -Fe -vma ---- -Entfall - - -D-70563 FANNY-LEICHT-GYMN. -STUTTGART, F.-LEICHT-STR. 13 -Schuljahr 2018/19 - 1. Halbjahr -gültig ab 10. September 2018 -Untis 2017 -13.12.2018 8:11 -Klasse 14.12. / Freitag Woche-A -Ordnungsdienst: Klasse 10a -Kl. -Std. Vertr. Fach Rau nach -Vertretungs-Text -5abc 1 -We -KR ---- -Entfall -5a -1 - -EvR ---- -Entfall -5abc 2 -Jw -KR -123 -We / Aufgaben -5a -2 -Ng -EvR -321 -Bü / Aufgaben -5d -3 -Lo -D -122 -anstatt 17.12., 1. Std. -5d -4 -Lo -D -122 -anstatt 19.12., 1 Std. -6a -6 -He -E ---- -Entfall -6acd 7 -Ft -MF ---- -Entfall -6c -1 -Ku -D ---- -Entfall -6c -2 -Sl -D -121 -Ku / Aufgaben -7a -3 -Di -D -323 -Raum -7a -4 -Hhn -M -323 -7a -5 -Hhn -M -323 -7a -6 -Hhn -M -323 -findet statt! -7b -6 -Rt -D ---- -Entfall -8a -1 -Ft -M ---- -Entfall -8a -2 -Li -E -323 -statt 18.12. -9c -5 - 6 -Hei -D ---- -Entfall -9d -1 - 2 Rm -NWT 412 -Raum -9d -5 - 6 -Ft -M ---- -Entfall -10a -3 - 4 Smr -E -413 -Hörverstehensklausur -10ad 3 -Ro -EvR -SH -Sport! -10ad 3 - 4 -We -KR ---- -Entfall -10ad 4 -Lk -EvR -SH -Sport! -10b -3 - 4 Ki -E -414 -Hörverstehensklausur -10b -3 - 4 -He -Gk ---- -Entfall für Lehrer -10bc 5 - 6 -We -KR ---- -Entfall -10c -3 - 4 -Ran -M ---- -Entfall -alle bei Oe -10c -3 - 4 Oe -E -422 -Hörverstehensklausur -10d -3 - 4 Wd -E -416 -Hörverstehensklausur -11 -3 - 4 At -D3 -121 -Raum -11 -3 - 4 Sl -D2 -415 -Raum -12 -1 - 2 Lo -Sp1 -222 -Theorie -12 -3 - 4 Mf -E2 -218 -Raum -12 -3 - 4 Sf -M3 -322 -Raum -12 -3 - 4 -Ft -M2 ---- -Entfall -12 -5 - 6 -Ku -ek1 ---- -Entfall - - diff --git a/shared/samplehtml/prefix.xml b/shared/samplehtml/prefix.xml deleted file mode 100644 index 3f8ea63..0000000 --- a/shared/samplehtml/prefix.xml +++ /dev/null @@ -1,455 +0,0 @@ - - - - - - - - - - -D-70563 FANNY-LEICHT-GYMN. -STUTTGART, F.-LEICHT-STR. 13 -Schuljahr 2018/19 - 1. Halbjahr -gültig ab 10. September 2018 -Untis 2017 -13.12.2018 9:04 -Klasse 13.12. / Donnerstag Woche-A -Ordnungsdienst: Klasse 10a -Kl. -Std. -Vertr. Fach Rau nach -Vertretungs-Text -5b -1 -Hei -D ---- -Entfall -5b -2 -Fu -D -114 -Hei / Aufgaben, Arbeitsheft! -5b -3 -Oe -M -114 -Ei / Aufgaben -5b -4 -Rm -M -114 -Ei / Aufgaben -6bc -5 -Sf -EvR -321 -Bü / Aufgaben -6bc -5 -Dk -KR -121 -We / Aufgaben -6bc -6 - -EvR ---- -Entfall -6bc -6 -We -KR ---- -Entfall -6d -6 -Ku -Ek ---- -Entfall -7b -2 -Ga -G -414 -KA Fkr -7b -8 -Gg -BK ---- -Mi-12.12. / 1 -7b -9 -Gg -BK ---- -Mi-12.12. / 2 -7c -8 - 9 -Gw -G ---- -Entfall -7d -1 -Ku -D ---- -Entfall -7d -2 -Oz -D -416 -Ku / Aufgaben -8a -1 - 2 -Ei -Ch ---- -Entfall -KEINE KA -9ac -8 - 9 -Lk -SpJ ---- -Entfall -9c -1 - 2 -Jw -Gk -322 -Raum! -9c -3 -Hf -D -220 -Hei / Aufgaben -9c -4 -Bkn -D -220 -Hei / Aufgaben -9d -1 -Rt -Gk ---- -Do-13.12. / 3 -9d -2 -Rt -Gk ---- -Do-13.12. / 4 -9d -3 -Rt -Gk -218 -9d -4 -Rt -Gk -218 -9d -5 -Ni -BK -126 -9d -6 -Ni -BK -126 -9d -8 -Ni -BK ---- -Do-13.12. / 5 -9d -9 -Ni -BK ---- -Do-13.12. / 6 -10b -10 - 11 -Fe -Ph ---- -Entfall -11 -3 - 4 -Ft -g4 ---- -Entfall -11 -5 -Ei -M1 ---- -Entfall -11 -7 -Gt -sem1 324 -geteilte Gruppen Schwimmen / -11 -8 - 9 -Ro -sem1 ??? -11 -10 - 11 -Lk -sp3 ---- -Entfall -12 -1 - 2 -Ni -bk1 -412 -Raum! -12 -5 -Ku -D2 ---- -Entfall -1112 8 - 9 -Fe -vma ---- -Entfall - - -D-70563 FANNY-LEICHT-GYMN. -STUTTGART, F.-LEICHT-STR. 13 -Schuljahr 2018/19 - 1. Halbjahr -gültig ab 10. September 2018 -Untis 2017 -13.12.2018 8:11 -Klasse 14.12. / Freitag Woche-A -Ordnungsdienst: Klasse 10a -Kl. -Std. Vertr. Fach Rau nach -Vertretungs-Text -5abc 1 -We -KR ---- -Entfall -5a -1 - -EvR ---- -Entfall -5abc 2 -Jw -KR -123 -We / Aufgaben -5a -2 -Ng -EvR -321 -Bü / Aufgaben -5d -3 -Lo -D -122 -anstatt 17.12., 1. Std. -5d -4 -Lo -D -122 -anstatt 19.12., 1 Std. -6a -6 -He -E ---- -Entfall -6acd 7 -Ft -MF ---- -Entfall -6c -1 -Ku -D ---- -Entfall -6c -2 -Sl -D -121 -Ku / Aufgaben -7a -3 -Di -D -323 -Raum -7a -4 -Hhn -M -323 -7a -5 -Hhn -M -323 -7a -6 -Hhn -M -323 -findet statt! -7b -6 -Rt -D ---- -Entfall -8a -1 -Ft -M ---- -Entfall -8a -2 -Li -E -323 -statt 18.12. -9c -5 - 6 -Hei -D ---- -Entfall -9d -1 - 2 Rm -NWT 412 -Raum -9d -5 - 6 -Ft -M ---- -Entfall -10a -3 - 4 Smr -E -413 -Hörverstehensklausur -10ad 3 -Ro -EvR -SH -Sport! -10ad 3 - 4 -We -KR ---- -Entfall -10ad 4 -Lk -EvR -SH -Sport! -10b -3 - 4 Ki -E -414 -Hörverstehensklausur -10b -3 - 4 -He -Gk ---- -Entfall für Lehrer -10bc 5 - 6 -We -KR ---- -Entfall -10c -3 - 4 -Ran -M ---- -Entfall -alle bei Oe -10c -3 - 4 Oe -E -422 -Hörverstehensklausur -10d -3 - 4 Wd -E -416 -Hörverstehensklausur -11 -3 - 4 At -D3 -121 -Raum -11 -3 - 4 Sl -D2 -415 -Raum -12 -1 - 2 Lo -Sp1 -222 -Theorie -12 -3 - 4 Mf -E2 -218 -Raum -12 -3 - 4 Sf -M3 -322 -Raum -12 -3 - 4 -Ft -M2 ---- -Entfall -12 -5 - 6 -Ku -ek1 ---- -Entfall - - diff --git a/shared/shared.qrc b/shared/shared.qrc index e2c08c6..a0d4deb 100644 --- a/shared/shared.qrc +++ b/shared/shared.qrc @@ -1,19 +1,12 @@ - favicon.png - graphics/sheute.png - graphics/smorgen.png - graphics/chat_background.jpg + graphics/icons/sheute.png + graphics/icons/smorgen.png graphics/icons/back.png graphics/icons/drawer.png graphics/icons/menu.png graphics/icons/hide.png graphics/icons/view.png - samplehtml/Download File-html.html - samplehtml/Download File.html - samplehtml/Download File.pdf - samplehtml/Download File.xml - circle.png graphics/images/FannyLogoDark.jpg graphics/images/FannyLogoLight.png graphics/images/FannyLogoLightSmall.png @@ -23,7 +16,9 @@ graphics/icons/logoutRed.png graphics/icons/settingsBlack.png graphics/icons/backDark.png - samplehtml/Download File.txt graphics/icons/delete.png + sampleEventData/sample.pdf + sampleEventData/sample.txt + sampleEventData/sample.json diff --git a/sources/appsettings.cpp b/sources/appsettings.cpp index 42911d1..b022aad 100644 --- a/sources/appsettings.cpp +++ b/sources/appsettings.cpp @@ -5,12 +5,12 @@ AppSettings * pGlobalAppSettings = nullptr; AppSettings::AppSettings(QObject* parent) :QObject(parent) { - qDebug("+----- AppSettings konstruktor -----"); + qDebug() << "+----- AppSettings konstruktor -----+"; pGlobalAppSettings = this; QString path = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); - qDebug() << "+----- Settings Path:" << path; + qDebug() << "+----- Settings Path:" << path << " -----+"; this->settingsManager = new QSettings(path+"/fannyapp/settings.ini", QSettings::IniFormat); @@ -22,11 +22,6 @@ AppSettings::AppSettings(QObject* parent) } this->filtersFile = new QFile(path + "/fannyapp/filters.json"); - - //QList filters = {{"5", "d"}, {"6", "c"}, {"11", ""}}; - - //writeFilters(filters); - //qDebug() << readFilters(); } QString AppSettings::loadSetting(const QString &key) @@ -128,23 +123,9 @@ void AppSettings::writeFilters(QList list) { this->filtersFile->close(); } -QStringList AppSettings::readFiltersQml() { - - QStringList filtersList; - - foreach(QStringList filterList, this->readFilters()){ - filtersList.append(filterList[0]+"|"+filterList[1]); - } - - return(filtersList); -} - -void AppSettings::writeFiltersQml(QStringList) { - -} - AppSettings::~AppSettings() { + qDebug("+----- AppSettings destruktor -----+"); delete settingsManager; } diff --git a/sources/eventmodel.cpp b/sources/eventmodel.cpp index eac2b6f..600f188 100644 --- a/sources/eventmodel.cpp +++ b/sources/eventmodel.cpp @@ -55,11 +55,6 @@ QVariantMap EventModel::get(int row) const return { {"grade", foodPlan.grade}, {"hour", foodPlan.hour}, {"replace", foodPlan.replace}, {"subject", foodPlan.subject}, {"room", foodPlan.room}, {"to", foodPlan.to}, {"text", foodPlan.text} }; } -QStringList EventModel::getHeader() -{ - return(pGlobalServConn->m_eventHeader); -} - EventModel::~EventModel() { diff --git a/sources/serverconn.cpp b/sources/serverconn.cpp index e25cadd..2d3df0a 100644 --- a/sources/serverconn.cpp +++ b/sources/serverconn.cpp @@ -4,18 +4,17 @@ ServerConn * pGlobalServConn = nullptr; ServerConn::ServerConn(QObject *parent) : QObject(parent) { - qDebug("+----- serverconn konstruktor -----+"); + qDebug("+----- ServerConn konstruktor -----+"); pGlobalServConn = this; this->networkManager = new QNetworkAccessManager(); this->refreshNetworkManager = new QNetworkAccessManager(); // check login state int perm = pGlobalAppSettings->loadSetting("permanent").toInt(); - qDebug() << "+-- login state: " << perm; + qDebug() << "+----- login state: " << perm << " -----+"; if(perm == 1){ - // permanent login - // restore login + // permanent login -> restore login this->username = pGlobalAppSettings->loadSetting("username"); this->password = pGlobalAppSettings->loadSetting("password"); @@ -30,52 +29,21 @@ ServerConn::ServerConn(QObject *parent) : QObject(parent) this->checkConnTimer->setSingleShot(true); connect(checkConnTimer, SIGNAL(timeout()), this, SLOT(checkConn())); this->checkConnTimer->start(); - } int 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 network request - QNetworkRequest request; - // call a non-existent file to be fast - request.setUrl( QUrl( "http://www.fanny-leicht.de/static15/http.intern/logintest" ) ); + // add the data to the request + QUrlQuery pdata; + pdata.addQueryItem("username", username); + pdata.addQueryItem("password", password); - // pack the credentials into a string - QString credentialsString = username + ":" + password; - // convert it to a byte array - QByteArray data = credentialsString.toLocal8Bit().toBase64(); - // put it into a string - QString headerData = "Basic " + data; - // and finally write it into the request header - request.setRawHeader( "Authorization", headerData.toLocal8Bit() ); + // send the request + ReturnData_t ret = this->senddata(QUrl("http://www.fanny-leicht.de/j34/templates/g5_helium/intern/events.php"), pdata); - // Send GET request to fanny server - QNetworkReply*reply = networkManager->get( request ); - - // loop to wait until the request has finished before processing the data - QEventLoop loop; - // timer to cancel the request after 3 seconds - QTimer timer; - timer.setSingleShot(true); - - // quit the loop when the request finised - loop.connect(this->networkManager, SIGNAL(finished(QNetworkReply*)), SLOT(quit())); - // or the timer timed out - loop.connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); - // start the timer - timer.start(2000); - // start the loop - loop.exec(); - - // get the status code from the request - int status_code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); - - // 404 is a success because a non existent file was called and not 401 was returned -> user data was correct - if(status_code == 404){ + if(ret.status_code == 200){ + // if not 200 was returned -> user data was correct // store username and password in the class variables this->username = username; this->password = password; @@ -87,15 +55,18 @@ int ServerConn::login(QString username, QString password, bool permanent) pGlobalAppSettings->writeSetting("password", password); } + // set state to loggedIn this->setState("loggedIn"); + qDebug() << "+----- logged in -----+"; + // return success return(200); } else { - // if not 404 was returned -> error -> return the return code + // if not 200 was returned -> error -> return the return code this->setState("notLoggedIn"); - return(status_code); + return(ret.status_code); } } @@ -104,147 +75,69 @@ int ServerConn::logout() // reset the data stored in the class this->username = ""; this->password = ""; + // reset the data stored in the settings pGlobalAppSettings->writeSetting("permanent", "0"); pGlobalAppSettings->writeSetting("username", ""); pGlobalAppSettings->writeSetting("password", ""); this->setState("notLoggedIn"); + + qDebug() << "+----- logout -----+"; + // return success return(200); } int ServerConn::checkConn() { - // Create request - QNetworkRequest request; - request.setUrl( QUrl( "http://www.fanny-leicht.de/static15/http.intern/" ) ); - - // Pack in credentials - // e.g. ZedlerDo:LxyJQB (yes, these do actually work ;) - QString concatenatedCredentials = this->username + ":" + this->password; - QByteArray data = concatenatedCredentials.toLocal8Bit().toBase64(); - QString headerData = "Basic " + data; - request.setRawHeader( "Authorization", headerData.toLocal8Bit() ); + if(this->state == "notLoggedIn"){ + return(903); + } + // add the data to the request 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 ); + pdata.addQueryItem("username", this->username); + pdata.addQueryItem("password", this->password); - QTimer timer; - timer.start(3000); + // send the request + ReturnData_t ret = this->senddata(QUrl("http://www.fanny-leicht.de/j34/templates/g5_helium/intern/events.php"), pdata); - QEventLoop loop; - loop.connect(this->refreshNetworkManager, SIGNAL(finished(QNetworkReply*)), SLOT(quit())); - loop.connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); - loop.exec(); - - int status_code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); - - if(status_code == 401){ + if(ret.status_code == 401){ + // if the stats code is 401 -> userdata is incorrect authErrorCount ++; if(authErrorCount > 3){ + qDebug() << "+----- checkconn: user data is incorrect -----+"; logout(); } } this->checkConnTimer->start(); - return(status_code); + return(ret.status_code); } -void ServerConn::updateProgress(qint64 read, qint64 total) +int ServerConn::getEvents(QString day) { - int read_int = int(read); - int total_int = int(total); - float percent = (float(read_int) / float(total_int)); - this->progress = percent; - percent = int(percent); + if(this->state != "loggedIn"){ + return(401); + } - // qDebug() << read << total << percent << "%"; -} - -float ServerConn::getProgress() -{ - return(this->progress); -} - -int ServerConn::getEvents(QString day){ - - // Create request - QNetworkRequest request; - request.setUrl( QUrl( "http://www.fanny-leicht.de/static15/http.intern/" + day + ".txt" ) ); - - // Pack in credentials - QString concatenatedCredentials = this->username + ":" + this->password; - QByteArray data = concatenatedCredentials.toLocal8Bit().toBase64(); - QString headerData = "Basic " + data; - request.setRawHeader("Authorization", headerData.toLocal8Bit()); + // add the data to the request + QUrlQuery pdata; + pdata.addQueryItem("username", this->username); + pdata.addQueryItem("password", this->password); + pdata.addQueryItem("day", day); // send the request - QNetworkReply*reply = networkManager->get(request); + ReturnData_t ret = this->senddata(QUrl("http://www.fanny-leicht.de/j34/templates/g5_helium/intern/events.php"), pdata); - // loop to wait until the request has finished before processing the data - QEventLoop loop; - // timer to cancel the request after 3 seconds - QTimer timer; - timer.setSingleShot(true); - - // quit the loop when the request finised - loop.connect(this->networkManager, SIGNAL(finished(QNetworkReply*)), SLOT(quit())); - // or the timer timed out - loop.connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); - // start the timer - timer.start(2000); - // start the loop - loop.exec(); - - // get the status code - int status_code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); - - if(status_code != 200){ + if(ret.status_code != 200){ // 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); + return(ret.status_code); } - QString eventString = reply->readAll(); - -// qDebug() << "reading text file"; -// QFile * textFile = new QFile(":/samplehtml/Download File.txt"); -// if (!textFile->open(QIODevice::ReadOnly | QIODevice::Text)) { -// qDebug() << "Load XML File Problem Couldn't open xmlfile.xml to load settings for download"; -// return 900; -// } - -// eventString = textFile->readAll(); - - - // separate all lines into a list - QStringList events = eventString.split("\n"); - - // a line (one element of the list) looks like this: - // class hour replace subject room to text - // 8a 1-2 Ei Ch --- Entfall KEINE KA - // [ ] <-- at least two spaces between two blocks - // 'to' and 'text' can be blank - - for(int i = 0; i < events.length(); i++){ - if(events[i] == ""){ - events.removeAt(i); - } - } - - // all pages of the original Event document have a similar header that gets removed by this command - // (only the first one remains) - events.removeDuplicates(); - - // temporary list to store the events for the given day - QList tmpEvents; - - // temporary list to store the header information - QStringList tmpEventHeader; // get the filers list for later usage QList filtersList = pGlobalAppSettings->readFilters(); @@ -253,158 +146,69 @@ int ServerConn::getEvents(QString day){ for(int i = 0; i < filtersList.length(); i++){ QStringList filterList = filtersList[i]; if( !(pGlobalAppSettings->loadSetting("teacherMode") == "true" ? filterList[2] == "t":filterList[2] == "s") ){ - filtersList.removeAt(i); - i = i-1; + filtersList.removeAt(i); + i = i-1; } } - // go through the list and process every single row - for(int x = 0; x < events.length(); x++){ - // store the event string - QString event = events[x]; + // list to be returned + QList tmpEvents; + QStringList tmpEventHeader; - // value to count spaces between text - int spaceCount = 0; + //qDebug() << jsonString; + QJsonDocument jsonFilters = QJsonDocument::fromJson(ret.text.toUtf8()); + // array with all filters in it + QJsonObject dataArray = jsonFilters.object(); - // temporary list to store the data of one day - QStringList eventList; + // get the version of the json format + QString version = dataArray.value("version").toString(); - // temporary dtring to store the data of one block - QString tmpString; + // get the header data + tmpEventHeader.append(dataArray.value("targetDate").toString()); + tmpEventHeader.append(dataArray.value("stewardingClass").toString()); - // processing works like: - // go through the line char by char - for(int i = 0;i < event.length(); i++){ - // store the char temporarly - QCharRef tmpChar = event[i]; + // expand the length of the header list to seven to prevent list out of range errors + while (tmpEventHeader.length() < 7) { + tmpEventHeader.append(""); + } - // check if the char is a space - if(tmpChar == " "){ - // if so, increase the spaceCount by one - spaceCount ++; - } - else { - // if not -> new block or part of a block started - // could be : 8a 1 - 2 OR 8a 1 - 2 - // here->| OR here->| - // in the first case, the space counter is higer than one - // in the second case, the space counter is exactly one - if(spaceCount == 1){ - // -> append a space to the temp string - tmpString.append(" "); - } + // append the header to the temporyry event list + tmpEvents.append(tmpEventHeader); - // reset the space counter - spaceCount = 0; + // get the event data + QJsonArray eventsArray = dataArray.value("events").toArray(); - // append the current character - tmpString.append(tmpChar); - } + for(int i=0; i break between two blocks - // could be: 8a 1 - 2 - // here ->| + // lst to store the current event + QStringList tmpEventList; - // -> append the current tmpString to the eventList - eventList.append(tmpString); - - // and clear the tmpString - tmpString = ""; - } - - //qDebug() << "char= " << tmpChar << " string= " << tmpString << " list= " << eventList; + // extract values from array + foreach(const QJsonValue & key, eventArray){ + // and append them to the temporyry list + tmpEventList.append(key.toString()); } - // append the remaining tmpString to the eventList - eventList.append(tmpString); - - // fill up the eventList with blanks until it reaches the defined length - while (eventList.length() < 7) { - eventList.append(""); + while (tmpEventList.length() < 7) { + // enshure that the list contains at least seven items (to prevent getting list out of range errors) + tmpEventList.append(""); } - if(x < 6){ - // if the event is in the header - // the header could look like this: - // - // D-70563 FANNY-LEICHT-GYMN. Schuljahr 2018/19 - 1. Halbjahr Untis 2017 - // STUTTGART, F.-LEICHT-STR. 13 gültig ab 10. September 2018 (13.12.2018 9:04) - // - //[Klasse 13.12. / Donnerstag Woche-A] - //{Ordnungsdienst: Klasse 10a} - // - // important data: - // () = date and time the document has been created - // [] = date the document is made for - // {} = class that has to clean up the scool :D - // (brackets are not present in the document) - - // line 0 and 4 don't contain imporant information -> skip - - if (x == 1) { - // the second line contains the creation date - // the creation date is the third block of the line - tmpEventHeader.append(eventList[2]); - } - else if (x == 2) { - // the third line contains the target date of the document - // the target date is the first block of the line - tmpEventHeader.append(eventList[0]); - } - else if (x == 3) { - // the third line contains the cleaning class - // the cleaning class is the first block of the line - tmpEventHeader.append(eventList[0]); - } - else if (x == 4) { - // if the fourth line is reached - // fill the event header - while (tmpEventHeader.length() < 7) { - tmpEventHeader.append(""); - } - - // check if the header is valid - // variable to count filled blocks - int blocksOK = 0; - foreach(QString block, tmpEventHeader){ - if(block != ""){ - blocksOK ++; - } - } - - if(blocksOK != 3) { - // if there are more or less than 3 filled blocks, the data is invalid - this->m_events.clear(); - return(900); - } - - // swap creation and target date - tmpEventHeader.swap(0,1); - - // and append it to the events list - tmpEvents.append(tmpEventHeader); - } - else if (x == 5) { - // the fifth row contains the labels for the different filds - // -> append it to the events list - tmpEvents.append(eventList); - } - - } - else if(filtersList.isEmpty()){ + if(filtersList.isEmpty()){ // if there are no filters append the event immideatly - tmpEvents.append(eventList); + tmpEvents.append(tmpEventList); } else { // if there is at least one filter, check if the event matches it foreach(QStringList filter, filtersList){ // go through all filters and check if one of them matches the event + // always append the first row, as it is the legend - if((eventList[0].contains(filter[0]) && eventList[0].contains(filter[1]))){ + if((tmpEventList[0].contains(filter[0]) && tmpEventList[0].contains(filter[1])) || i == 0){ // append the eventList to the temporary event list - tmpEvents.append(eventList); + tmpEvents.append(tmpEventList); // terminate the loop break; } @@ -412,69 +216,33 @@ int ServerConn::getEvents(QString day){ } } - // store the new events into the class variable - this->m_events = tmpEvents; - qDebug() << tmpEvents; - // check if there is any valid data - if(this->m_events.length() < 3){ - // remove the last (in this case the second) element, as it is unnecessary - m_events.takeLast(); - // return no data - return(901); + if(tmpEvents.length() < 3){ + // remove the last (in this case the second) element, as it is unnecessary (it is the legend -> not needed when there is no data) + tmpEvents.takeLast(); + // set return code to 'no data' (901) + ret.status_code = 901; } - // return success - return(200); + this->m_events = tmpEvents; + return(ret.status_code); } int ServerConn::getFoodPlan() { - // set the progress to 0 - this->progress = 0; + QUrlQuery pdata; + ReturnData_t ret = this->senddata(QUrl("http://www.treffpunkt-fanny.de/fuer-schueler-und-lehrer/speiseplan.html"), pdata); - // 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"); - - // send a GET request to the treffpunkt fanny server - QNetworkReply* reply; - reply = this->networkManager->get(request); - - // update the progress during the request - connect(reply, SIGNAL(downloadProgress(qint64, qint64)), - this, SLOT(updateProgress(qint64, qint64))); - - // loop to wait until the request has finished before processing the data - QEventLoop loop; - // timer to cancel the request after 3 seconds - QTimer timer; - timer.setSingleShot(true); - - // quit the loop when the request finised - loop.connect(this->networkManager, SIGNAL(finished(QNetworkReply*)), SLOT(quit())); - // or the timer timed out - loop.connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); - // start the timer - timer.start(2000); - // start the loop - loop.exec(); - - // get the status code - QVariant status_code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute); - // set the progress to 1 - this->progress = 1; - if(status_code != 200){ + if(ret.status_code != 200){ // if the request didn't result in a success, return the error code // if the request failed but there is still old data available if(!this->m_weekplan.isEmpty()){ // set the status code to 902 (old data) - status_code = 902; + ret.status_code = 902; } - return(status_code.toInt()); + return(ret.status_code); } // initialize the weekplan to store information to it @@ -483,7 +251,7 @@ int ServerConn::getFoodPlan() // 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. // read the whole website - QString returnedData = QString::fromUtf8(reply->readAll()); + QString returnedData = ret.text; // remove unnecessary stuff returnedData.replace("\n",""); @@ -660,13 +428,10 @@ int ServerConn::getFoodPlan() ReturnData_t ServerConn::senddata(QUrl serviceUrl, QUrlQuery pdata) { - ReturnData_t ret; //this is a custom type to store the returned data - // Call the webservice + ReturnData_t ret; //this is a custom type to store the return-data + // Create network request QNetworkRequest request(serviceUrl); - QAuthenticator authenticator; - authenticator.setUser("ZedlerDo"); - authenticator.setPassword("LxyJQB"); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); @@ -676,42 +441,53 @@ ReturnData_t ServerConn::senddata(QUrl serviceUrl, QUrlQuery pdata) reply = this->networkManager->post(request, pdata.toString(QUrl::FullyEncoded).toUtf8()); - //wait until the request has finished + // loop to wait until the request has finished before processing the data QEventLoop loop; + // timer to cancel the request after 3 seconds + QTimer timer; + timer.setSingleShot(true); + + // quit the loop when the request finised loop.connect(this->networkManager, SIGNAL(finished(QNetworkReply*)), SLOT(quit())); + // or the timer timed out + loop.connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); + // start the timer + timer.start(4000); + // start the loop 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()); + if(reply->isOpen()){ + delete reply; + } + //return the data return(ret); } - QString ServerConn::getState() { return(this->state); } void ServerConn::setState(QString state) { - this->state = state; - this->stateChanged(this->state); + + if(state != this->state){ + qDebug() << "+----- serverconn has new state: " + state + " -----+"; + this->state = state; + this->stateChanged(this->state); + } } ServerConn::~ServerConn() { - qDebug("serverconn destruktor"); + qDebug("+----- ServerConn destruktor -----+"); delete this->networkManager; delete this->refreshNetworkManager; - - QString path = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation); - QDir dir(path + "/.fannyapp-tmp"); - dir.removeRecursively(); }