From 394d3d9803c101014fb7f521155b0a9ed6809454 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 8 Dec 2015 14:14:15 +0100 Subject: Fixed mapping to result model The result model exposes the different properties as columns --- framework/mail/folderlistmodel.cpp | 7 ++++--- framework/mail/maillistmodel.cpp | 23 ++++++++++++----------- 2 files changed, 16 insertions(+), 14 deletions(-) (limited to 'framework') diff --git a/framework/mail/folderlistmodel.cpp b/framework/mail/folderlistmodel.cpp index 8c513b64..b0969060 100644 --- a/framework/mail/folderlistmodel.cpp +++ b/framework/mail/folderlistmodel.cpp @@ -29,11 +29,12 @@ QHash< int, QByteArray > FolderListModel::roleNames() const QVariant FolderListModel::data(const QModelIndex &idx, int role) const { + auto srcIdx = mapToSource(idx); switch (role) { case Name: - return mapToSource(idx).data(Qt::DisplayRole).toString(); - case Icon: - return mapToSource(idx).data(Qt::DisplayRole).toString(); + return srcIdx.sibling(srcIdx.row(), 0).data(Qt::DisplayRole).toString(); + case Icon: + return srcIdx.sibling(srcIdx.row(), 1).data(Qt::DisplayRole).toString(); } return QIdentityProxyModel::data(idx, role); } diff --git a/framework/mail/maillistmodel.cpp b/framework/mail/maillistmodel.cpp index 06670e09..baa11bc3 100644 --- a/framework/mail/maillistmodel.cpp +++ b/framework/mail/maillistmodel.cpp @@ -35,19 +35,20 @@ QHash< int, QByteArray > MailListModel::roleNames() const QVariant MailListModel::data(const QModelIndex &idx, int role) const { + auto srcIdx = mapToSource(idx); switch (role) { case Subject: - return mapToSource(idx).data(Qt::DisplayRole).toString(); - case Sender: - return mapToSource(idx).data(Qt::DisplayRole).toString(); - case SenderName: - return mapToSource(idx).data(Qt::DisplayRole).toString(); - case Date: - return mapToSource(idx).data(Qt::DisplayRole).toString(); - case Unread: - return mapToSource(idx).data(Qt::DisplayRole).toString(); - case Important: - return mapToSource(idx).data(Qt::DisplayRole).toString(); + return srcIdx.sibling(srcIdx.row(), 0).data(Qt::DisplayRole).toString(); + case Sender: + return srcIdx.sibling(srcIdx.row(), 1).data(Qt::DisplayRole).toString(); + case SenderName: + return srcIdx.sibling(srcIdx.row(), 2).data(Qt::DisplayRole).toString(); + case Date: + return srcIdx.sibling(srcIdx.row(), 3).data(Qt::DisplayRole).toString(); + case Unread: + return srcIdx.sibling(srcIdx.row(), 4).data(Qt::DisplayRole).toString(); + case Important: + return srcIdx.sibling(srcIdx.row(), 5).data(Qt::DisplayRole).toString(); } return QIdentityProxyModel::data(idx, role); } -- cgit v1.2.3