From beb214e7df79abaaf07639057e3290a671c12775 Mon Sep 17 00:00:00 2001 From: Stefan Ahlers Date: Sat, 4 Apr 2015 14:51:06 +0200 Subject: [PATCH 1/7] Graphical interface for e-mails and announcements This commit adds a GUI to show e-mails and announcements --- Sync-my-L2P.pro | 9 ++++--- message.cpp | 14 ++++++++++ message.h | 22 +++++++++++++++ message.ui | 71 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 113 insertions(+), 3 deletions(-) create mode 100644 message.cpp create mode 100644 message.h create mode 100644 message.ui diff --git a/Sync-my-L2P.pro b/Sync-my-L2P.pro index caa14fc..030f123 100644 --- a/Sync-my-L2P.pro +++ b/Sync-my-L2P.pro @@ -32,7 +32,8 @@ SOURCES += main.cpp\ qslog/QsLogDestFile.cpp \ qslog/QsLogDestFunctor.cpp \ logger.cpp \ - info.cpp + info.cpp \ + message.cpp HEADERS += mymainwindow.h \ parser.h \ @@ -54,7 +55,8 @@ HEADERS += mymainwindow.h \ qslog/QsLogDisableForThisFile.h \ qslog/QsLogLevel.h \ logger.h \ - info.h + info.h \ + message.h FORMS += mymainwindow.ui \ mymainwindow.ui \ @@ -64,7 +66,8 @@ FORMS += mymainwindow.ui \ autoclosedialog.ui \ logindialog.ui \ logger.ui \ - info.ui + info.ui \ + message.ui OTHER_FILES += \ Sync-my-L2P.icns \ diff --git a/message.cpp b/message.cpp new file mode 100644 index 0000000..7d1c4dd --- /dev/null +++ b/message.cpp @@ -0,0 +1,14 @@ +#include "message.h" +#include "ui_message.h" + +message::message(QWidget *parent) : + QDialog(parent), + ui(new Ui::message) +{ + ui->setupUi(this); +} + +message::~message() +{ + delete ui; +} diff --git a/message.h b/message.h new file mode 100644 index 0000000..da4eb34 --- /dev/null +++ b/message.h @@ -0,0 +1,22 @@ +#ifndef MESSAGE_H +#define MESSAGE_H + +#include + +namespace Ui { +class message; +} + +class message : public QDialog +{ + Q_OBJECT + +public: + explicit message(QWidget *parent = 0); + ~message(); + +private: + Ui::message *ui; +}; + +#endif // MESSAGE_H diff --git a/message.ui b/message.ui new file mode 100644 index 0000000..ce7d5bd --- /dev/null +++ b/message.ui @@ -0,0 +1,71 @@ + + + + + message + + + + 0 + 0 + 400 + 300 + + + + Dialog + + + + + 30 + 240 + 341 + 32 + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + buttonBox + accepted() + message + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + message + reject() + + + 316 + 260 + + + 286 + 274 + + + + + From 3446ec4fffa0a63af4a0d93465fc5176e9360d2a Mon Sep 17 00:00:00 2001 From: Stefan Ahlers Date: Sat, 4 Apr 2015 14:52:02 +0200 Subject: [PATCH 2/7] Complete message GUI --- message.cpp | 22 ++++++++ message.h | 8 +++ message.ui | 150 +++++++++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 167 insertions(+), 13 deletions(-) diff --git a/message.cpp b/message.cpp index 7d1c4dd..dd96c89 100644 --- a/message.cpp +++ b/message.cpp @@ -6,6 +6,28 @@ message::message(QWidget *parent) : ui(new Ui::message) { ui->setupUi(this); + ui->retranslateUi(this); + setWindowFlags(Qt::Dialog | Qt::WindowTitleHint | Qt::CustomizeWindowHint); +} + +void message::updateAuthor(QString author) +{ + ui->author_label->setText(author); +} + +void message::updateSubject(QString subject) +{ + ui->subject_label->setText(subject); +} + +void message::updateDate(QString date) +{ + ui->dates_label->setText(date); +} + +void message::updateMessage(QString body) +{ + ui->message_body->setText(body); } message::~message() diff --git a/message.h b/message.h index da4eb34..e3310da 100644 --- a/message.h +++ b/message.h @@ -17,6 +17,14 @@ class message : public QDialog private: Ui::message *ui; + +public slots: + void updateSubject(QString subject); + void updateDate(QString date); + void updateMessage(QString body); + void updateAuthor(QString author); + + }; #endif // MESSAGE_H diff --git a/message.ui b/message.ui index ce7d5bd..e04c6f4 100644 --- a/message.ui +++ b/message.ui @@ -1,26 +1,42 @@ + - - - message - + 0 0 - 400 - 300 + 466 + 612 + + + 0 + 0 + + + + + 466 + 612 + + + + + 466 + 612 + + - Dialog + Nachricht - + - 30 - 240 - 341 + 360 + 570 + 91 32 @@ -28,11 +44,119 @@ Qt::Horizontal - QDialogButtonBox::Cancel|QDialogButtonBox::Ok + QDialogButtonBox::Close + + + + + + 10 + 10 + 441 + 551 + + + + + + + + QFormLayout::AllNonFixedFieldsGrow + + + + + + 12 + 75 + true + + + + Von: + + + + + + + Mustermann + + + + + + + + 12 + 75 + true + + + + Datum: + + + + + + + 01.01.2000 + + + + + + + + 12 + 75 + true + + + + Thema: + + + + + + + Musterthema + + + true + + + + + + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Cantarell'; font-size:11pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt;">Musterinhalt</span></p></body></html> + + + + + + true + + + + + + - From 38b75a2d8433cd7e0765b23ea1b6cac3f8259d29 Mon Sep 17 00:00:00 2001 From: Stefan Ahlers Date: Sat, 4 Apr 2015 14:54:41 +0200 Subject: [PATCH 3/7] Implements full support for e-mails and announcement view This commit implements the possibility to show e-mails and announcement. --- browser.cpp | 57 +++++++++++++++++++++++++++++++++++++++- browser.h | 2 ++ info.h | 1 - parser.cpp | 62 +++++++++++++++++++++++++++++++++++++++++++- structureelement.cpp | 35 +++++++++++++++++++++++-- structureelement.h | 21 +++++++++++++-- 6 files changed, 171 insertions(+), 7 deletions(-) diff --git a/browser.cpp b/browser.cpp index 8283008..6d1d7bd 100644 --- a/browser.cpp +++ b/browser.cpp @@ -1,5 +1,6 @@ #include "browser.h" #include "ui_browser.h" +#include "message.h" #include "options.h" @@ -950,6 +951,17 @@ void Browser::on_dataTreeView_doubleClicked(const QModelIndex &index) QDesktopServices::openUrl(QUrl(fileUrl)); } + else if (item->type() == messageItem) + { + // Erzeugt das Popup-Fester mit der anzuzeigenden Nachricht + message messages; + + messages.updateSubject(item->data(topicRole).toString()); + messages.updateMessage(item->data(bodyRole).toString().toUtf8()); + messages.updateAuthor(item->data(authorRole).toString()); + messages.updateDate(item->data(dateRole).toDateTime().toString("ddd dd.MM.yyyy hh:mm")); + messages.exec(); + } } void Browser::on_dataTreeView_customContextMenuRequested(const QPoint &pos) @@ -978,16 +990,33 @@ void Browser::on_dataTreeView_customContextMenuRequested(const QPoint &pos) } // Öffnen des Elements lokal oder im L2P + if (RightClickedItem->type() != messageItem) + { newCustomContextMenu.addAction(tr("Öffnen"), this, SLOT(openFile())); - + } // Kopieren der URL if(RightClickedItem->type() == courseItem || RightClickedItem->type() == fileItem) { newCustomContextMenu.addAction(tr("Link kopieren"), this, SLOT(copyUrlToClipboardSlot())); } + // Öffnen der Nachricht + if(RightClickedItem->type()== messageItem) + { + newCustomContextMenu.addAction(tr("Nachricht anzeigen"), this, SLOT(openMessage())); + + } + + // Öffnen der Nachricht im Quelltext + if(RightClickedItem->type()== messageItem) + { + newCustomContextMenu.addAction(tr("Nachricht im Quelltext anzeigen"), this, SLOT(openSourceMessage())); + + } + // Anzeigen des Menus an der Mausposition newCustomContextMenu.exec(ui->dataTreeView->mapToGlobal(pos)); + } void Browser::openCourse() @@ -996,6 +1025,32 @@ void Browser::openCourse() QDesktopServices::openUrl(lastRightClickItem->data(urlRole).toUrl()); } +void Browser::openMessage() +{ + // Erzeugt das Popup-Fester mit der anzuzeigenden Nachricht + message messages; + + messages.updateSubject(lastRightClickItem->data(topicRole).toString()); + messages.updateMessage(lastRightClickItem->data(bodyRole).toString().toUtf8()); + messages.updateAuthor(lastRightClickItem->data(authorRole).toString()); + messages.updateDate(lastRightClickItem->data(dateRole).toDateTime().toString("ddd dd.MM.yyyy hh:mm")); + + messages.exec(); +} + +void Browser::openSourceMessage() +{ + // Erzeugt das Popup-Fester mit der anzuzeigenden Nachricht + message messages; + + messages.updateSubject(lastRightClickItem->data(topicRole).toString()); + messages.updateMessage(lastRightClickItem->data(bodyRole).toString().toHtmlEscaped()); + messages.updateAuthor(lastRightClickItem->data(authorRole).toString()); + messages.updateDate(lastRightClickItem->data(dateRole).toDateTime().toString("ddd dd.MM.yyyy hh:mm")); + + messages.exec(); +} + void Browser::openFile() { QString baseUrl = "https://www3.elearning.rwth-aachen.de"; diff --git a/browser.h b/browser.h index 03755fc..881fe32 100644 --- a/browser.h +++ b/browser.h @@ -105,6 +105,8 @@ public slots: private slots: void openFile(); + void openMessage(); + void openSourceMessage(); void openCourse(); void coursesRecieved(QNetworkReply*); void filesRecieved(QNetworkReply*); diff --git a/info.h b/info.h index 6194dc8..a6fc5cc 100644 --- a/info.h +++ b/info.h @@ -3,7 +3,6 @@ #include - namespace Ui { class Info; } diff --git a/parser.cpp b/parser.cpp index 6db60c7..1447f0a 100644 --- a/parser.cpp +++ b/parser.cpp @@ -224,8 +224,20 @@ void Parser::parseFiles(QNetworkReply *reply, QMapdata(cidRole).toString(), + messageItem); + dir->appendRow(newMessage); + if (!file["attachments"].isNull()) { QJsonArray attachment = file["attachments"].toArray(); foreach(QJsonValue attachmentElement, attachment) @@ -258,6 +270,54 @@ void Parser::parseFiles(QNetworkReply *reply, QMapdata(cidRole).toString(), + messageItem); + dir->appendRow(newMessage); + + + if (!file["attachments"].isNull()) { + QJsonArray attachment = file["attachments"].toArray(); + foreach(QJsonValue attachmentElement, attachment) + { + QJsonObject fileInformation = attachmentElement.toObject(); + filename = fileInformation["fileName"].toString(); + filesize = fileInformation["fileSize"].toString().toInt(); + timestamp = fileInformation["modifiedTimestamp"].toInt(); + url = fileInformation["downloadUrl"].toString(); + urlParts = url.split('/'); + urlParts.removeFirst(); + urlParts.removeFirst(); + urlParts.removeFirst(); + urlParts.removeFirst(); + urlParts.removeLast(); + urlParts.removeLast(); + + Structureelement *dir = Utils::getDirectoryItem(currentCourse, urlParts); + + Structureelement* newFile = new Structureelement(filename, QUrl(url), timestamp, filesize, + currentCourse->data(cidRole).toString(), + fileItem); + + // Element hinzufügen + dir->appendRow(newFile); + + + } + } + else { + continue; + } + } // Wegen der inneren foreach-Schleife in den Kategorien 2,4 und 5 ist diese Übergabe nur noch für die Kategorie 0, 1 und 3 if(responseCategory == 0 ||responseCategory == 1 || responseCategory == 3){ diff --git a/structureelement.cpp b/structureelement.cpp index cb8793a..99c4840 100644 --- a/structureelement.cpp +++ b/structureelement.cpp @@ -35,6 +35,21 @@ Structureelement::Structureelement(QString name, QUrl url, int time, qint32 size chooseIcon(); } +// Überladener Konstruktor für Nachrichtenelemente, welche nicht heruntergeladen werden können. +Structureelement::Structureelement(QString body, QString topic, QString author, int time, QString cid, MyItemType typeEX) + :QStandardItem(topic), + included(true), + body(body), + topic(topic), + author(author), + time(QDateTime::fromMSecsSinceEpoch(qint64(1000) * time)), + typeEX(typeEX), + cid(cid) +{ + synchronised = NOT_SYNCHRONISED; + chooseIcon(); +} + QVariant Structureelement::data(int role) const { switch(role) @@ -47,6 +62,12 @@ QVariant Structureelement::data(int role) const return size; case dateRole: return time; + case bodyRole: + return body; + case topicRole: + return topic; + case authorRole: + return author; case synchronisedRole: return synchronised; case cidRole: @@ -62,20 +83,26 @@ QVariant Structureelement::data(int role) const else statustip.append(QString::number(size/1024.0,'f',2) % " KB"); - statustip.append(" - " % time.toString("ddd dd.MM.yy hh:mm")); + statustip.append(" - " % time.toString("ddd dd.MM.yyyy hh:mm")); statustip.append(" - "); switch(synchronised) { case NOW_SYNCHRONISED: case SYNCHRONISED: - statustip.append("synchronisert"); + statustip.append("synchronisiert"); break; case NOT_SYNCHRONISED: default: statustip.append("nicht synchronisiert"); } } + else if (typeEX == messageItem) + { + statustip.append(text() % " - "); + statustip.append(author); + statustip.append(" - " % time.toString("ddd dd.MM.yyyy hh:mm")); + } return statustip; } case Qt::ForegroundRole: @@ -192,6 +219,10 @@ void Structureelement::chooseIcon() { setIcon(QIcon(":/icons/semester.png")); } + else if(typeEX == messageItem) + { + setIcon(QIcon(":/icons/otherFile.png")); + } } /// Vergleich zwischen zwei Items für Sortierung. diff --git a/structureelement.h b/structureelement.h index 3f8c19c..e1d9170 100644 --- a/structureelement.h +++ b/structureelement.h @@ -26,7 +26,8 @@ enum MyItemType semesterItem = 1000, courseItem = 1001, directoryItem = 1002, - fileItem = 1003 + fileItem = 1003, + messageItem = 1004 }; enum MyItemDataRole @@ -36,7 +37,10 @@ enum MyItemDataRole dateRole = 34, includeRole = 35, synchronisedRole = 36, - cidRole = 37 + cidRole = 37, + bodyRole = 38, + topicRole = 39, + authorRole = 40, }; enum synchroniseStatus @@ -52,6 +56,8 @@ class Structureelement : public QStandardItem public: Structureelement(QString name, QUrl url = QUrl(), int time = 0, qint32 size = 0, QString cid = "", MyItemType typeEX = fileItem); + Structureelement(QString body, QString topic, QString author, int time = 0, QString cid = "", MyItemType typeEX = messageItem); + int type() const { return typeEX; } bool operator< (const QStandardItem& other) const; @@ -78,9 +84,20 @@ class Structureelement : public QStandardItem /// Type des Elements MyItemType typeEX; + /// Inhalt der Nachricht + QString body; + + /// Thema der Nachricht + QString topic; + + /// Autor der Nachricht + QString author; + /// Status der Synchronisation enum synchroniseStatus synchronised; + // Neuer Bereich für die Nachrichten + private: void chooseIcon(); }; From dce9395ea5ba90ecd99fd84a44e06919857e4c01 Mon Sep 17 00:00:00 2001 From: Stefan Ahlers Date: Sat, 4 Apr 2015 15:25:53 +0200 Subject: [PATCH 4/7] Add icon for mails/announcements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Source: modified version of mail-message-new.png of the adwaita-icon-theme (GNOME Project) License: LGPL3+ – modifying is allowed --- icons/icons.qrc | 1 + icons/mail.png | Bin 0 -> 2152 bytes structureelement.cpp | 2 +- 3 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 icons/mail.png diff --git a/icons/icons.qrc b/icons/icons.qrc index 483ad8c..93aa7db 100644 --- a/icons/icons.qrc +++ b/icons/icons.qrc @@ -21,5 +21,6 @@ audio.png picture.png archive.png + mail.png diff --git a/icons/mail.png b/icons/mail.png new file mode 100644 index 0000000000000000000000000000000000000000..52eb71c4292f786f60654fd5df5a153db74f168f GIT binary patch literal 2152 zcmV-u2$%PXP)rS7m#>jS&5fO5E4*?U_tN~qJ2S% zEJc2?@=X3hl%QOBAku0=|FkMWHpN z?&+@XKHoWCedkm)@a^{P_W!-H(|E}2>}>ZrlC!?CfmkzXHJg{4c*JOzZ7OF8<&<=gyurOQjOG?IQB|0&+$Up7hY` zbiP> zRnR`ZLDxE7H0iJx>G< zz~r1W#u$ib^p^(xwblf{WehrYo%1as{QT;ZPygn`9J}$}J3Ef!kkB;Gc;Vi~`|1V+f-d#9OH+8>hT9_Q4>PH4(Y;Jz;@~}K%9An-5`egTBmkxmH($B- zTE#TY0|waO*f(mJ(a9FgCD~)gr2vy&N1c{!QH!p0auDGefmloI)T0a|M)rH-Emlu|HF3y$MJO4-i? zQ5`?J_p_s5Sp`gvPl1TwI1WtH8fyHZ0E7?_T);B(aGV~rRsa~rtK*Tun$Ez3s3ap0 zwsb}gBjOuOaGV}2GY=6+^|2#hnkH)1I`;S5;G734v<^2i22Lvirj_q!V#je%tJV>h z@nZnsjH6hz!5G8NP78*SL%mXul?zGrNuG-;PdWn8^4aIUlpZRT8f?38@>(bypv9sM zO&VMG@1wQbg6sA&^#2$!h(^H7qgJk=K0c0O(LSAGE?U==%VlV#;JQ83%C$rU(&{sy zmhbf}&5uUFb$h5*t0UV|pW>dFdi+m2mdySs|b%}wm??m$Wpo|KSM z!Y~Zv3N+%mWXgR<8wx9XovhA&kbv1hmq)bLTb+1shVj zSop^R>h*Cv`sgK;OBLkv7EIHEVHl87!gU?=dJcB?cJT2hALGk^eu+yzyadBA(d~9{ z=FD0DxupH*oz{FH4ZxShW^)QkDSY`FjFHx5B zgg~4a01LdsAUzKY3m@UBD_7x37p~{@y$y;ePGB&i`X2%!!1Ww>(#2C(u3}-~BS_B! zg7>8BtP=wWriYracxw@lKlTKqR`5J8R*+HDXiyv&DAm{VJV>qZ_+w9C@zx?pQ)+^A z;)Sh{yF`TL<dR&zOBrQPwHVEX+Bd0kevKy1%<-0JmcE(7t0XBXaOh&hI>I% z0LX|8<{W@LfQh9~m)`sn{&1bKqbC>e*0n7jh7phdy`jim>te_bH z3S(nqV>1uV6p4t@QJ0Jd+asYK1YYX^*aOf7AP)n>7$e3Qt$ww--)^_tk$aq=Dfp#X z-%~s=o@b1Q;{qrrysr|ChA!j9d9MQy;c?6`mK?;V@EzG0V$>*fq6`Yss0N-C02|RT eoI=0<&Fx=DqgNt@{8PjL0000 Date: Sat, 4 Apr 2015 16:23:34 +0200 Subject: [PATCH 5/7] Sorting e-mails and announcements by date --- structureelement.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/structureelement.cpp b/structureelement.cpp index 8f0c3f8..c2698ec 100644 --- a/structureelement.cpp +++ b/structureelement.cpp @@ -238,6 +238,10 @@ bool Structureelement::operator< (const QStandardItem& other) const { return false; } + else if ((typeEX == messageItem)) + { + return (data(dateRole) < other.data(dateRole)); + } else { return (text().toLower() < other.text().toLower()); From 8507aec550c1d4dd6c21c4c11253d7f7328f02fa Mon Sep 17 00:00:00 2001 From: Stefan Ahlers Date: Sat, 4 Apr 2015 17:00:08 +0200 Subject: [PATCH 6/7] Add directories for emails and announcements --- parser.cpp | 5 +++++ structureelement.cpp | 2 +- utils.cpp | 20 ++++++++++++++++++-- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/parser.cpp b/parser.cpp index 1447f0a..ba3169e 100644 --- a/parser.cpp +++ b/parser.cpp @@ -230,6 +230,8 @@ void Parser::parseFiles(QNetworkReply *reply, QMaprowCount(); ++row) { From 2d1bc56d8997bf6542b95de9ed39d7958d966fa4 Mon Sep 17 00:00:00 2001 From: Stefan Ahlers Date: Sat, 4 Apr 2015 17:02:54 +0200 Subject: [PATCH 7/7] =?UTF-8?q?Change=20options=20to=20"E-Mails"=20and=20"?= =?UTF-8?q?Ank=C3=BCndigungen"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit changes Ankündigungs-Anhänge to Ankündigungen and E-Mail-Anhänge to E-Mails because of full email and announcement support! --- options.ui | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/options.ui b/options.ui index dc4829c..ef99271 100644 --- a/options.ui +++ b/options.ui @@ -71,7 +71,7 @@ Einloggen - + :/icons/login.png:/icons/login.png @@ -106,7 +106,7 @@ Durchsuchen - + :/icons/downloadDirectory.png:/icons/downloadDirectory.png @@ -163,14 +163,14 @@ - E-Mail-Anhänge + E-Mails - Ankündigungs-Anhänge + Ankündigungen @@ -300,8 +300,6 @@ - - - +