diff options
Diffstat (limited to 'framework/mail')
-rw-r--r-- | framework/mail/maillistmodel.cpp | 14 | ||||
-rw-r--r-- | framework/mail/maillistmodel.h | 3 | ||||
-rw-r--r-- | framework/mail/singlemailcontroller.cpp | 2 |
3 files changed, 17 insertions, 2 deletions
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 @@ | |||
1 | #include "maillistmodel.h" | 1 | #include "maillistmodel.h" |
2 | 2 | ||
3 | #include <QFile> | ||
4 | |||
3 | MailListModel::MailListModel(QObject *parent) | 5 | MailListModel::MailListModel(QObject *parent) |
4 | : QIdentityProxyModel() | 6 | : QIdentityProxyModel() |
5 | { | 7 | { |
@@ -22,6 +24,7 @@ QHash< int, QByteArray > MailListModel::roleNames() const | |||
22 | roles[Unread] = "unread"; | 24 | roles[Unread] = "unread"; |
23 | roles[Important] = "important"; | 25 | roles[Important] = "important"; |
24 | roles[Id] = "id"; | 26 | roles[Id] = "id"; |
27 | roles[MimeMessage] = "mimeMessage"; | ||
25 | 28 | ||
26 | return roles; | 29 | return roles; |
27 | } | 30 | } |
@@ -44,6 +47,17 @@ QVariant MailListModel::data(const QModelIndex &idx, int role) const | |||
44 | return srcIdx.sibling(srcIdx.row(), 5).data(Qt::DisplayRole).toString(); | 47 | return srcIdx.sibling(srcIdx.row(), 5).data(Qt::DisplayRole).toString(); |
45 | case Id: | 48 | case Id: |
46 | return srcIdx.data(Akonadi2::Store::DomainObjectBaseRole).value<Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr>()->identifier(); | 49 | return srcIdx.data(Akonadi2::Store::DomainObjectBaseRole).value<Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr>()->identifier(); |
50 | case MimeMessage: { | ||
51 | auto filename = srcIdx.sibling(srcIdx.row(), 6).data(Qt::DisplayRole).toString(); | ||
52 | QFile file(filename); | ||
53 | if (file.open(QFile::ReadOnly)) { | ||
54 | auto content = file.readAll(); | ||
55 | return content; | ||
56 | } else { | ||
57 | qWarning() << "Failed to open the file"; | ||
58 | } | ||
59 | return "Failed to read mail."; | ||
60 | } | ||
47 | } | 61 | } |
48 | return QIdentityProxyModel::data(idx, role); | 62 | return QIdentityProxyModel::data(idx, role); |
49 | } | 63 | } |
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: | |||
23 | Date, | 23 | Date, |
24 | Unread, | 24 | Unread, |
25 | Important, | 25 | Important, |
26 | Id | 26 | Id, |
27 | MimeMessage | ||
27 | }; | 28 | }; |
28 | 29 | ||
29 | QHash<int, QByteArray> roleNames() const; | 30 | QHash<int, QByteArray> 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) | |||
22 | query.syncOnDemand = false; | 22 | query.syncOnDemand = false; |
23 | query.processAll = false; | 23 | query.processAll = false; |
24 | query.liveQuery = false; | 24 | query.liveQuery = false; |
25 | query.requestedProperties << "subject" << "sender" << "senderName" << "date" << "unread" << "important"; | 25 | query.requestedProperties << "subject" << "sender" << "senderName" << "date" << "unread" << "important" << "mimeMessage"; |
26 | query.ids << id.toLatin1(); | 26 | query.ids << id.toLatin1(); |
27 | m_model->runQuery(query); | 27 | m_model->runQuery(query); |
28 | } \ No newline at end of file | 28 | } \ No newline at end of file |