summaryrefslogtreecommitdiffstats
path: root/framework/src/domain/composercontroller.h
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/domain/composercontroller.h')
-rw-r--r--framework/src/domain/composercontroller.h93
1 files changed, 93 insertions, 0 deletions
diff --git a/framework/src/domain/composercontroller.h b/framework/src/domain/composercontroller.h
new file mode 100644
index 00000000..92467d05
--- /dev/null
+++ b/framework/src/domain/composercontroller.h
@@ -0,0 +1,93 @@
1/*
2 Copyright (c) 2016 Michael Bohlender <michael.bohlender@kdemail.net>
3 Copyright (c) 2016 Christian Mollekopf <mollekopf@kolabsys.com>
4
5 This library is free software; you can redistribute it and/or modify it
6 under the terms of the GNU Library General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or (at your
8 option) any later version.
9
10 This library is distributed in the hope that it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 02110-1301, USA.
19*/
20
21#pragma once
22
23#include <QObject>
24#include <QString>
25#include <QStringList>
26#include <QVariant>
27#include <sink/applicationdomaintype.h>
28#include <KMime/Message>
29
30#include "completer.h"
31#include "selector.h"
32#include "controller.h"
33
34inline bool operator !=(const KMime::Types::Mailbox &l, const KMime::Types::Mailbox &r)
35{
36 return !(l.prettyAddress() == r.prettyAddress());
37}
38
39Q_DECLARE_METATYPE(KMime::Types::Mailbox);
40
41namespace KMime {
42class Message;
43}
44
45class ComposerController : public Kube::Controller
46{
47 Q_OBJECT
48
49 //Interface properties
50 KUBE_CONTROLLER_PROPERTY(QString, To, to)
51 KUBE_CONTROLLER_PROPERTY(QString, Cc, cc)
52 KUBE_CONTROLLER_PROPERTY(QString, Bcc, bcc)
53 KUBE_CONTROLLER_PROPERTY(QString, Subject, subject)
54 KUBE_CONTROLLER_PROPERTY(QString, Body, body)
55
56 //Set by identitySelector
57 KUBE_CONTROLLER_PROPERTY(KMime::Types::Mailbox, Identity, identity)
58 KUBE_CONTROLLER_PROPERTY(QByteArray, AccountId, accountId)
59
60 //Set by loadMessage
61 KUBE_CONTROLLER_PROPERTY(KMime::Message::Ptr, ExistingMessage, existingMessage)
62 KUBE_CONTROLLER_PROPERTY(Sink::ApplicationDomain::Mail, ExistingMail, existingMail)
63
64 Q_PROPERTY (Completer* recipientCompleter READ recipientCompleter CONSTANT)
65 Q_PROPERTY (Selector* identitySelector READ identitySelector CONSTANT)
66 //Q_PROPERTY (QValidator* subjectValidator READ subjectValidator CONSTANT)
67
68 KUBE_CONTROLLER_ACTION(send)
69 KUBE_CONTROLLER_ACTION(saveAsDraft)
70
71public:
72 explicit ComposerController();
73
74 Completer *recipientCompleter() const;
75 Selector *identitySelector() const;
76
77 Q_INVOKABLE void loadMessage(const QVariant &draft, bool loadAsDraft);
78
79public slots:
80 virtual void clear() Q_DECL_OVERRIDE;
81
82private slots:
83 void updateSendAction();
84 void updateSaveAsDraftAction();
85
86private:
87 void recordForAutocompletion(const QByteArray &addrSpec, const QByteArray &displayName);
88 void setMessage(const QSharedPointer<KMime::Message> &msg);
89 KMime::Message::Ptr assembleMessage();
90
91 QScopedPointer<Completer> mRecipientCompleter;
92 QScopedPointer<Selector> mIdentitySelector;
93};