2
* Copyright 2011 Intel Corporation.
3
* Copyright (C) 2012 Jolla Ltd.
5
* This program is licensed under the terms and conditions of the
6
* Apache License, version 2.0. The full text of the Apache License is at
7
* http://www.apache.org/licenses/LICENSE-2.0
10
#ifndef EMAILMESSAGELISTMODEL_H
11
#define EMAILMESSAGELISTMODEL_H
13
#include <QAbstractListModel>
16
#include <qmailmessage.h>
17
#include <qmailmessagelistmodel.h>
18
#include <qmailserviceaction.h>
19
#include <qmailaccount.h>
22
class EmailMessageListModel : public QMailMessageListModel
30
MessageAttachmentCountRole = QMailMessageModelBase::MessageIdRole + 1, // returns number of attachment
31
MessageAttachmentsRole, // returns a list of attachments
32
MessageRecipientsRole, // returns a list of recipients (email address)
33
MessageRecipientsDisplayNameRole, // returns a list of recipients (displayName)
34
MessageReadStatusRole, // returns the read/unread status
35
MessageQuotedBodyRole, // returns the quoted body
36
MessageHtmlBodyRole, // returns the html body
37
MessageUuidRole, // returns a unique string id
38
MessageSenderDisplayNameRole, // returns sender's display name
39
MessageSenderEmailAddressRole, // returns sender's email address
40
MessageToRole, // returns a list of To (email + displayName)
41
MessageCcRole, // returns a list of Cc (email + displayName)
42
MessageBccRole, // returns a list of Bcc (email + displayName)
43
MessageTimeStampRole, // returns timestamp in QDateTime format
44
MessageSelectModeRole, // returns the select mode
45
MessagePreviewRole, // returns message preview if available
46
MessageTimeSectionRole, // returns time section relative to the current time
47
MessagePriorityRole // returns message priority
50
EmailMessageListModel (QObject *parent = 0);
51
~EmailMessageListModel();
52
int rowCount (const QModelIndex & parent = QModelIndex()) const;
53
QVariant data (const QModelIndex & index, int role = Qt::DisplayRole) const;
54
QString bodyHtmlText(const QMailMessage &) const;
55
QString bodyPlainText(const QMailMessage &) const;
57
enum Priority { LowPriority, NormalPriority, HighPriority };
60
void messageDownloadCompleted();
63
Q_INVOKABLE void setFolderKey (QVariant id);
64
Q_INVOKABLE void setAccountKey (QVariant id);
65
Q_INVOKABLE void sortBySender (int key);
66
Q_INVOKABLE void sortBySubject (int key);
67
Q_INVOKABLE void sortByDate (int key);
68
Q_INVOKABLE void sortByAttachment (int key);
69
Q_INVOKABLE void setSearch(const QString search);
70
Q_INVOKABLE void setCombinedInbox(bool unread = false);
72
Q_INVOKABLE QVariant accountIdForMessage(QVariant messageId);
73
Q_INVOKABLE QVariant indexFromMessageId(QString msgId);
74
Q_INVOKABLE QVariant folderIdForMessage(QVariant messageId);
75
Q_INVOKABLE QVariant messageId (int index);
76
Q_INVOKABLE QVariant subject (int index);
77
Q_INVOKABLE QVariant mailSender (int index);
78
Q_INVOKABLE QVariant timeStamp (int index);
79
Q_INVOKABLE QVariant body (int index);
80
Q_INVOKABLE QVariant htmlBody (int index);
81
Q_INVOKABLE QVariant quotedBody (int index);
82
Q_INVOKABLE QVariant attachments (int index);
83
Q_INVOKABLE QVariant numberOfAttachments (int index);
84
Q_INVOKABLE QVariant recipients (int index);
85
Q_INVOKABLE QVariant ccList (int index);
86
Q_INVOKABLE QVariant bccList (int index);
87
Q_INVOKABLE QVariant toList (int index);
88
Q_INVOKABLE QVariant messageRead (int index);
89
Q_INVOKABLE QVariant isCombinedInbox();
90
Q_INVOKABLE int messagesCount ();
91
Q_INVOKABLE void deSelectAllMessages();
92
Q_INVOKABLE void selectMessage( int index );
93
Q_INVOKABLE void deSelectMessage (int index );
94
Q_INVOKABLE void moveSelectedMessageIds(QVariant vFolderId);
95
Q_INVOKABLE void deleteSelectedMessageIds();
97
void foldersAdded(const QMailFolderIdList &folderIds);
100
void downloadActivityChanged(QMailServiceAction::Activity);
104
QProcess m_msgAccount;
105
QMailFolderId m_currentFolderId;
106
QProcess m_messageServerProcess;
107
QMailAccountIdList m_mailAccountIds;
108
QMailRetrievalAction *m_retrievalAction;
110
QMailMessageKey m_key; // key set externally other than search
111
QList<QMailMessageId> m_selectedMsgIds;