Commit ee8cfabb authored by Carl Schwan's avatar Carl Schwan 🚴 Committed by Claudio Cambra
Browse files

Add data separator in folder list



Signed-off-by: Carl Schwan's avatarCarl Schwan <carl@carlschwan.eu>
parent bf4a8783
......@@ -8,9 +8,11 @@
//#include "messageviewer/viewer.h"
#include <Akonadi/EntityTreeModel>
#include <KMime/Message>
#include <KFormat>
#include <KLocalizedString>
#include <KMime/Message>
#include <QQmlEngine>
#include <kformat.h>
MailModel::MailModel(QObject *parent)
: QIdentityProxyModel(parent)
......@@ -20,14 +22,14 @@ MailModel::MailModel(QObject *parent)
QHash<int, QByteArray> MailModel::roleNames() const
{
return {
{TitleRole, QByteArrayLiteral("title")},
{SenderRole, QByteArrayLiteral("sender")},
{UnreadRole, QByteArrayLiteral("unread")},
{FavoriteRole, QByteArrayLiteral("favorite")},
{TextColorRole, QByteArrayLiteral("textColor")},
{BackgroundColorRole, QByteArrayLiteral("backgroudColor")}
};
return {{TitleRole, QByteArrayLiteral("title")},
{DateRole, QByteArrayLiteral("date")},
{DateTimeRole, QByteArrayLiteral("datetime")},
{SenderRole, QByteArrayLiteral("sender")},
{UnreadRole, QByteArrayLiteral("unread")},
{FavoriteRole, QByteArrayLiteral("favorite")},
{TextColorRole, QByteArrayLiteral("textColor")},
{BackgroundColorRole, QByteArrayLiteral("backgroudColor")}};
}
QVariant MailModel::data(const QModelIndex &index, int role) const
......@@ -102,6 +104,13 @@ QVariant MailModel::data(const QModelIndex &index, int role) const
return QString();
}
case DateRole:
if (mail->date()) {
KFormat format;
return format.formatRelativeDate(mail->date()->dateTime().date(), QLocale::ShortFormat);
} else {
return QString();
}
case DateTimeRole:
if (mail->date()) {
return mail->date()->asUnicodeString();
} else {
......
......@@ -22,14 +22,15 @@ public:
SenderRole,
TextColorRole,
DateRole,
DateTimeRole,
BackgroundColorRole,
UnreadRole,
MailRole,
FavoriteRole,
};
// ViewerHelper *viewerHelper() const;
// void setViewerHelper(ViewerHelper *viewerHelper);
// ViewerHelper *viewerHelper() const;
// void setViewerHelper(ViewerHelper *viewerHelper);
explicit MailModel(QObject *parent = nullptr);
QHash<int, QByteArray> roleNames() const override;
......
......@@ -14,6 +14,11 @@ import org.kde.kitemmodels 1.0 as KItemModels
ListView {
id: mails
model: MailManager.folderModel
section.delegate: Kirigami.ListSectionHeader {
required property string section
label: section
}
section.property: "date"
delegate: Kirigami.BasicListItem {
label: model.title
subtitle: sender
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment