diff options
author | Michael Bohlender <michael.bohlender@kdemail.net> | 2015-12-17 20:41:02 +0100 |
---|---|---|
committer | Michael Bohlender <michael.bohlender@kdemail.net> | 2015-12-17 20:41:02 +0100 |
commit | 7b5dd9662ef7c4cb005587a356e471b3767cffce (patch) | |
tree | 5d11c47212f57294f490afe8f212a83cfd89f1b8 /framework/mail/singlemailcontroller.cpp | |
parent | ad1dd41fc444cf598c1dbfec44a8ce348cb2bb73 (diff) | |
download | kube-7b5dd9662ef7c4cb005587a356e471b3767cffce.tar.gz kube-7b5dd9662ef7c4cb005587a356e471b3767cffce.zip |
singlemail controller load mail from akoandi
Diffstat (limited to 'framework/mail/singlemailcontroller.cpp')
-rw-r--r-- | framework/mail/singlemailcontroller.cpp | 73 |
1 files changed, 18 insertions, 55 deletions
diff --git a/framework/mail/singlemailcontroller.cpp b/framework/mail/singlemailcontroller.cpp index 68105839..d8595745 100644 --- a/framework/mail/singlemailcontroller.cpp +++ b/framework/mail/singlemailcontroller.cpp | |||
@@ -1,71 +1,34 @@ | |||
1 | #include "singlemailcontroller.h" | 1 | #include "singlemailcontroller.h" |
2 | 2 | ||
3 | #include <QDebug> | 3 | SingleMailController::SingleMailController(QObject *parent) : QObject(parent), m_model(new MailListModel) |
4 | |||
5 | SingleMailController::SingleMailController(QObject *parent): QObject(parent), m_isImportant(false), m_isUnread(true) | ||
6 | { | 4 | { |
7 | 5 | ||
8 | } | 6 | } |
9 | 7 | ||
10 | QString SingleMailController::akonadiId() const | 8 | SingleMailController::~SingleMailController() |
11 | { | ||
12 | return m_akonadiId; | ||
13 | } | ||
14 | |||
15 | void SingleMailController::setAkonadiId(const QString &id) | ||
16 | { | 9 | { |
17 | if(m_akonadiId != id) { | ||
18 | m_akonadiId = id; | ||
19 | |||
20 | loadMessage(m_akonadiId); | ||
21 | 10 | ||
22 | emit akonadiIdChanged(); | ||
23 | } | ||
24 | } | 11 | } |
25 | 12 | ||
26 | QString SingleMailController::message() const | 13 | MailListModel* SingleMailController::model() const |
27 | { | 14 | { |
28 | return m_message; | 15 | return m_model.data(); |
29 | } | 16 | } |
30 | 17 | ||
31 | bool SingleMailController::isImportant() const | ||
32 | { | ||
33 | return m_isImportant; | ||
34 | } | ||
35 | 18 | ||
36 | bool SingleMailController::isUnread() const | 19 | void SingleMailController::loadMail(const QString &id) |
37 | { | 20 | { |
38 | return m_isUnread; | 21 | Akonadi2::Query query; |
39 | } | 22 | query.syncOnDemand = false; |
40 | 23 | query.processAll = false; | |
41 | void SingleMailController::deleteMail() | 24 | query.liveQuery = false; |
42 | { | 25 | query.requestedProperties << "subject" << "sender" << "senderName" << "date" << "unread" << "important"; |
43 | qDebug() << "UserAction: deleteMail: " << m_akonadiId; | 26 | query.ids << id.toLatin1(); |
44 | } | 27 | m_model->runQuery(query); |
45 | 28 | ||
46 | void SingleMailController::markMailImportant(bool important) | 29 | qDebug() << "***"; |
47 | { | 30 | auto srcIdx = m_model->mapToSource(m_model->index(1, 0)); |
48 | qDebug() << "UserAction: markMailImportant: " << m_akonadiId; | 31 | auto bla = srcIdx.sibling(srcIdx.row(), 3).data(Qt::DisplayRole); |
49 | 32 | qDebug() << bla; | |
50 | if (m_isImportant != important) { | 33 | qDebug() << "***"; |
51 | m_isImportant = important; | 34 | } \ No newline at end of file |
52 | emit isImportantChanged(); | ||
53 | } | ||
54 | } | ||
55 | |||
56 | void SingleMailController::markMailUnread(bool unread) | ||
57 | { | ||
58 | qDebug() << "UserAction: markMailUnread: " << m_akonadiId; | ||
59 | |||
60 | if (m_isUnread != unread) { | ||
61 | m_isUnread = unread; | ||
62 | emit isUnreadChanged(); | ||
63 | } | ||
64 | } | ||
65 | |||
66 | void SingleMailController::loadMessage(const QString &id) | ||
67 | { | ||
68 | //load message from akoandi | ||
69 | m_message = "The message as HTML"; | ||
70 | emit messageChanged(); | ||
71 | } | ||