From f7d5a111d095c3da2445e03393e20e7b68cd3feb Mon Sep 17 00:00:00 2001 From: dorian Date: Wed, 26 Dec 2018 23:44:24 +0100 Subject: [PATCH] added header to the event view, showing: - creation date - target date - cleaning class added one event block underneath the header indicating what the different fields contain --- CHANGELOG.md | 6 +- android-sources/AndroidManifest.xml | 2 +- fannyapp.pro | 3 +- headers/eventmodel.h | 2 + headers/serverconn.h | 1 + qml/Components/EventView.qml | 11 ++- shared/samplehtml/Download File.txt | 29 +++++++ sources/appsettings.cpp | 6 +- sources/eventmodel.cpp | 5 ++ sources/serverconn.cpp | 130 +++++++++++++++++++++------- 10 files changed, 152 insertions(+), 43 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 68ab8e6..f00c7c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). - -## [0.9.0] - ALPHA - 2018-12-25 +## [0.9.0 - 0.9.1] - ALPHA - 2018-12 ### Geändert - Komplett neues Design - der Vertretungsplan wird jetzt innerhalb der App angezeigt @@ -15,6 +14,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Behoben - Viele interne Verbesserungen, die zu besserer performance führen +### Hinzugefügt +- Jetzt kompatibel mit der neusten android API und IOS Geräten + ## [0.04] - 2018-07-19 ### Behoben - Fehler beim Speiseplan, der dafür sorgte, dass der letzte Tag fehlerhaft (zu dünn) angezeigt wurde, wenn nurnoch ein Tag angezeigt wurde diff --git a/android-sources/AndroidManifest.xml b/android-sources/AndroidManifest.xml index 7a4aca8..dad75a1 100644 --- a/android-sources/AndroidManifest.xml +++ b/android-sources/AndroidManifest.xml @@ -1,5 +1,5 @@ - + diff --git a/fannyapp.pro b/fannyapp.pro index af2cac2..1beda11 100644 --- a/fannyapp.pro +++ b/fannyapp.pro @@ -60,5 +60,6 @@ DISTFILES += \ android-sources/res/drawable-hdpi/icon.png \ android-sources/res/drawable-ldpi/icon.png \ android-sources/res/drawable-mdpi/icon.png \ - android-sources/res/xml/provider_paths.xml + android-sources/res/xml/provider_paths.xml \ + CHANGELOG.md diff --git a/headers/eventmodel.h b/headers/eventmodel.h index a12c7a6..d58a799 100644 --- a/headers/eventmodel.h +++ b/headers/eventmodel.h @@ -27,6 +27,8 @@ 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 0580da5..8f121e0 100644 --- a/headers/serverconn.h +++ b/headers/serverconn.h @@ -68,6 +68,7 @@ signals: public: QList> m_weekplan; QList m_events; + QStringList m_eventHeader; }; diff --git a/qml/Components/EventView.qml b/qml/Components/EventView.qml index 1f18445..21a4101 100644 --- a/qml/Components/EventView.qml +++ b/qml/Components/EventView.qml @@ -52,10 +52,10 @@ ListView { width: parent.width - 10 wrapMode: Label.Wrap - text: hour + " | " - + replace + " | " - + subject + " | " - + room + " | " + text: hour + ( replace === "" ? "": ( " | " + + replace + ( subject === "" ? "": ( " | " + + subject + ( room === "" ? "": ( " | " + + room ) ) ) ) ) ) } Label { @@ -68,9 +68,12 @@ ListView { font.pixelSize: gradeLa.font.pixelSize font.bold: true + visible: text !== "" + text: to !== "" && model.text !== "" ? to + " | " + model.text:model.to + model.text } } + } } diff --git a/shared/samplehtml/Download File.txt b/shared/samplehtml/Download File.txt index 191f679..181f713 100644 --- a/shared/samplehtml/Download File.txt +++ b/shared/samplehtml/Download File.txt @@ -51,3 +51,32 @@ Kl. Std. Vertr. Fach Rau nach Vertretungs-Text 12 1-2 Ni bk1 412 Raum! 12 5 Ku D2 --- Entfall 1112 8-9 Fe vma --- Entfall +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 + + +Kl. Std. Vertr. Fach Rau nach Vertretungs-Text +12ac 8-9 Lk SpJ --- Entfall +13c 1-2 Jw Gk 322 Raum! +13c 3 Hf D 220 Hei / Aufgaben +913c 4 Bkn D 220 Hei / Aufgaben +913d 1 Rt Gk --- Do-13.12. / 3 +13d 2 Rt Gk --- Do-13.12. / 4 +92d 3 Rt Gk 218 +91d 4 Rt Gk 218 +92d 5 Ni BK 126 +91d 6 Ni BK 126 +91d 8 Ni BK --- Do-13.12. / 5 +91d 9 Ni BK --- Do-13.12. / 6 +130b 10 - 11 Fe Ph --- Entfall +131 3-4 Ft g4 --- Entfall +131 5 Ei M1 --- Entfall +131 7 Gt sem1 324 geteilte Gruppen Schwimmen / +131 8-9 Ro sem1 ??? +131 10 - 11 Lk sp3 --- Entfall +123 1-2 Ni bk1 412 Raum! +122 5 Ku D2 --- Entfall +11132 8-9 Fe vma --- Entfall diff --git a/sources/appsettings.cpp b/sources/appsettings.cpp index 8fb31b7..dd5b819 100644 --- a/sources/appsettings.cpp +++ b/sources/appsettings.cpp @@ -26,7 +26,7 @@ AppSettings::AppSettings(QObject* parent) //QList filters = {{"5", "d"}, {"6", "c"}, {"11", ""}}; //writeFilters(filters); - qDebug() << readFilters(); + //qDebug() << readFilters(); } QString AppSettings::loadSetting(const QString &key) @@ -55,7 +55,7 @@ QList AppSettings::readFilters() { this->filtersFile->close(); - qDebug() << jsonString; + //qDebug() << jsonString; QJsonDocument jsonFilters = QJsonDocument::fromJson(jsonString.toUtf8()); // array with all filters in it QJsonArray filtersArray = jsonFilters.array(); @@ -88,7 +88,7 @@ void AppSettings::writeFilters(QList list) { } QJsonDocument filtersDoc(filtersArray); - qDebug() << filtersDoc.toJson(); + //qDebug() << filtersDoc.toJson(); this->filtersFile->open(QIODevice::ReadWrite); diff --git a/sources/eventmodel.cpp b/sources/eventmodel.cpp index 600f188..eac2b6f 100644 --- a/sources/eventmodel.cpp +++ b/sources/eventmodel.cpp @@ -55,6 +55,11 @@ 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 a7d87e3..beb2661 100644 --- a/sources/serverconn.cpp +++ b/sources/serverconn.cpp @@ -265,24 +265,24 @@ int ServerConn::getEvents(QString day){ } 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; - } - QString eventString = textFile->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 + // 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++){ @@ -291,16 +291,29 @@ int ServerConn::getEvents(QString day){ } } + // 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(); + // go through the list and process every single row - foreach(QString event, events){ + for(int x = 0; x < events.length(); x++){ + // store the event string + QString event = events[x]; + // value to count spaces between text int spaceCount = 0; // temporary list to store the data of one day - QStringList dayList; + QStringList eventList; // temporary dtring to store the data of one block QString tmpString; @@ -334,42 +347,95 @@ int ServerConn::getEvents(QString day){ tmpString.append(tmpChar); } - // check if the soace count is 2 + // check if the space count is 2 if(spaceCount == 2){ // if so -> break between two blocks - // could be: 8a 1 - 2 OR 8a 1 - 2 - // here ->| + // could be: 8a 1 - 2 + // here ->| - // -> append the current tmpString to the dayList - dayList.append(tmpString); + // -> append the current tmpString to the eventList + eventList.append(tmpString); // and clear the tmpString tmpString = ""; } - //qDebug() << "char= " << tmpChar << " string= " << tmpString << " list= " << dayList; + //qDebug() << "char= " << tmpChar << " string= " << tmpString << " list= " << eventList; } - // append the remaining tmpString to the dayList - dayList.append(tmpString); + // append the remaining tmpString to the eventList + eventList.append(tmpString); - // fill up the dayList with blanks until it reaches the defined length - while (dayList.length() < 7) { - dayList.append(""); + // fill up the eventList with blanks until it reaches the defined length + while (eventList.length() < 7) { + eventList.append(""); } - // if the event matches the filter - QList filtersList = pGlobalAppSettings->readFilters(); - if(filtersList.isEmpty()){ - tmpEvents.append(dayList); + 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(""); + } + + // 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 there are no filters append the event immideatly + tmpEvents.append(eventList); } 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 - if((dayList[0].contains(filter[0]) && dayList[0].contains(filter[1]))){ - // append the dayList to the temporary event list - tmpEvents.append(dayList); + if((eventList[0].contains(filter[0]) && eventList[0].contains(filter[1]))){ + // append the eventList to the temporary event list + tmpEvents.append(eventList); // terminate the loop break; }