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/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/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 0000000..52eb71c
Binary files /dev/null and b/icons/mail.png differ
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/message.cpp b/message.cpp
new file mode 100644
index 0000000..dd96c89
--- /dev/null
+++ b/message.cpp
@@ -0,0 +1,36 @@
+#include "message.h"
+#include "ui_message.h"
+
+message::message(QWidget *parent) :
+ QDialog(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()
+{
+ delete ui;
+}
diff --git a/message.h b/message.h
new file mode 100644
index 0000000..e3310da
--- /dev/null
+++ b/message.h
@@ -0,0 +1,30 @@
+#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;
+
+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
new file mode 100644
index 0000000..e04c6f4
--- /dev/null
+++ b/message.ui
@@ -0,0 +1,195 @@
+
+
+ message
+
+
+
+ 0
+ 0
+ 466
+ 612
+
+
+
+
+ 0
+ 0
+
+
+
+
+ 466
+ 612
+
+
+
+
+ 466
+ 612
+
+
+
+ Nachricht
+
+
+
+
+ 360
+ 570
+ 91
+ 32
+
+
+
+ Qt::Horizontal
+
+
+ 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
+
+
+
+
+
+
+
+
+
+
+
+ buttonBox
+ accepted()
+ message
+ accept()
+
+
+ 248
+ 254
+
+
+ 157
+ 274
+
+
+
+
+ buttonBox
+ rejected()
+ message
+ reject()
+
+
+ 316
+ 260
+
+
+ 286
+ 274
+
+
+
+
+
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 @@
-
-
-
+
diff --git a/parser.cpp b/parser.cpp
index 6db60c7..ba3169e 100644
--- a/parser.cpp
+++ b/parser.cpp
@@ -224,8 +224,72 @@ 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;
+ }
+ }
+ else if(responseCategory == 5)
+ {
+ QString body = file["body"].toString();
+ QString title = file["subject"].toString();
+ QString from = file["from"].toString();
+ int time = file["modifiedTimestamp"].toInt();
+ QString dirname = "E-Mails";
+ urlParts.append(dirname);
+
+
+ Structureelement *dir = Utils::getDirectoryItem(currentCourse, urlParts);
+
+ Structureelement* newMessage = new Structureelement(body, title, from, time,
+ currentCourse->data(cidRole).toString(),
+ messageItem);
+ dir->appendRow(newMessage);
+
+
if (!file["attachments"].isNull()) {
QJsonArray attachment = file["attachments"].toArray();
foreach(QJsonValue attachmentElement, attachment)
@@ -252,6 +316,7 @@ void Parser::parseFiles(QNetworkReply *reply, QMapappendRow(newFile);
+
}
}
else {
diff --git a/structureelement.cpp b/structureelement.cpp
index cb8793a..d2334b1 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/mail.png"));
+ }
}
/// Vergleich zwischen zwei Items für Sortierung.
@@ -207,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());
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();
};
diff --git a/utils.cpp b/utils.cpp
index 4c540bc..f187ea7 100644
--- a/utils.cpp
+++ b/utils.cpp
@@ -165,15 +165,31 @@ Structureelement *Utils::getDirectoryItem(Structureelement *courseItem, QStringL
item = "Übungsdokumente";
}
else if (item.contains("EmailAttachments")) {
- item = "E-Mail-Anhänge";
+ item = "E-Mails";
}
else if (item.contains("MediaLibrary")) {
item = "Medienbibliothek";
}
else if (item.contains("AnnouncementDocuments")) {
- item = "Ankündigungs-Anhänge";
+ item = "Ankündigungen";
+ }
+ else if (item.contains("Announcement"))
+ {
+ item = "Ankündigungen";
}
}
+
+ // Bei anderen Sprachen werden Anhänge zu den Nachrichten gepackt.
+ if(QLocale::system().language() != QLocale::German)
+ {
+ if (item.contains("AnnouncementDocuments")) {
+ item = "Announcement";
+ }
+ else if (item.contains("EmailAttachments")) {
+ item = "E-Mails";
+ }
+ }
+
bool correctChildFound = false;
for(int row=0; row < currentItem->rowCount(); ++row)
{