From 5a27d32ab4a1c4833cda0bce7e8d5bceee41d6cf Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 10 May 2016 15:02:18 +0200 Subject: Use the new getters to fix the mimeMessage loading and look much better. --- framework/domain/maillistmodel.cpp | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) (limited to 'framework') diff --git a/framework/domain/maillistmodel.cpp b/framework/domain/maillistmodel.cpp index 2df3ecbc..eb282533 100644 --- a/framework/domain/maillistmodel.cpp +++ b/framework/domain/maillistmodel.cpp @@ -56,33 +56,26 @@ QHash< int, QByteArray > MailListModel::roleNames() const QVariant MailListModel::data(const QModelIndex &idx, int role) const { auto srcIdx = mapToSource(idx); + auto mail = srcIdx.data(Sink::Store::DomainObjectRole).value(); switch (role) { case Subject: - return srcIdx.sibling(srcIdx.row(), 0).data(Qt::DisplayRole).toString(); + return mail->getSubject(); case Sender: - return srcIdx.sibling(srcIdx.row(), 1).data(Qt::DisplayRole).toString(); + return mail->getSender(); case SenderName: - return srcIdx.sibling(srcIdx.row(), 2).data(Qt::DisplayRole).toString(); + return mail->getSenderName(); case Date: - return srcIdx.sibling(srcIdx.row(), 3).data(Qt::DisplayRole).toString(); + return mail->getDate(); case Unread: - return srcIdx.sibling(srcIdx.row(), 4).data(Qt::DisplayRole).toBool(); + return mail->getUnread(); case Important: - return srcIdx.sibling(srcIdx.row(), 5).data(Qt::DisplayRole).toBool(); + return mail->getImportant(); case Id: - return srcIdx.data(Sink::Store::DomainObjectBaseRole).value()->identifier(); + return mail->identifier(); case DomainObject: - return srcIdx.data(Sink::Store::DomainObjectRole); + return QVariant::fromValue(mail); 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 mail->getMimeMessage(); } } return QSortFilterProxyModel::data(idx, role); -- cgit v1.2.3