From 3af80d6bce96009a66cebb0650f1f20cf4ef1be7 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Fri, 18 Dec 2015 13:08:59 +0100 Subject: Load the full mime message in the viewer as well. --- framework/mail/maillistmodel.cpp | 14 ++++++++++++++ framework/mail/maillistmodel.h | 3 ++- framework/mail/singlemailcontroller.cpp | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) (limited to 'framework/mail') diff --git a/framework/mail/maillistmodel.cpp b/framework/mail/maillistmodel.cpp index 2b2d2aeb..d1ad99db 100644 --- a/framework/mail/maillistmodel.cpp +++ b/framework/mail/maillistmodel.cpp @@ -1,5 +1,7 @@ #include "maillistmodel.h" +#include + MailListModel::MailListModel(QObject *parent) : QIdentityProxyModel() { @@ -22,6 +24,7 @@ QHash< int, QByteArray > MailListModel::roleNames() const roles[Unread] = "unread"; roles[Important] = "important"; roles[Id] = "id"; + roles[MimeMessage] = "mimeMessage"; return roles; } @@ -44,6 +47,17 @@ QVariant MailListModel::data(const QModelIndex &idx, int role) const return srcIdx.sibling(srcIdx.row(), 5).data(Qt::DisplayRole).toString(); case Id: return srcIdx.data(Akonadi2::Store::DomainObjectBaseRole).value()->identifier(); + case MimeMessage: { + auto filename = srcIdx.sibling(srcIdx.row(), 6).data(Qt::DisplayRole).toString(); + QFile file(filename); + if (file.open(QFile::ReadOnly)) { + auto content = file.readAll(); + return content; + } else { + qWarning() << "Failed to open the file"; + } + return "Failed to read mail."; + } } return QIdentityProxyModel::data(idx, role); } diff --git a/framework/mail/maillistmodel.h b/framework/mail/maillistmodel.h index 69b986a2..f925e005 100644 --- a/framework/mail/maillistmodel.h +++ b/framework/mail/maillistmodel.h @@ -23,7 +23,8 @@ public: Date, Unread, Important, - Id + Id, + MimeMessage }; QHash roleNames() const; diff --git a/framework/mail/singlemailcontroller.cpp b/framework/mail/singlemailcontroller.cpp index d7335a0b..fecf2fbc 100644 --- a/framework/mail/singlemailcontroller.cpp +++ b/framework/mail/singlemailcontroller.cpp @@ -22,7 +22,7 @@ void SingleMailController::loadMail(const QString &id) query.syncOnDemand = false; query.processAll = false; query.liveQuery = false; - query.requestedProperties << "subject" << "sender" << "senderName" << "date" << "unread" << "important"; + query.requestedProperties << "subject" << "sender" << "senderName" << "date" << "unread" << "important" << "mimeMessage"; query.ids << id.toLatin1(); m_model->runQuery(query); } \ No newline at end of file -- cgit v1.2.3