summaryrefslogtreecommitdiffstats
path: root/framework/src/domain/contactcontroller.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-04-05 15:04:00 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-04-05 15:04:00 +0200
commit4b1798f0cdf87361869e7cf2b341acacd056c410 (patch)
tree3ff780641acdcb20b81f9b41533afd50a2525d38 /framework/src/domain/contactcontroller.cpp
parent71721aa4f3e85bea1a2fe504e86d99f80a3106a9 (diff)
downloadkube-4b1798f0cdf87361869e7cf2b341acacd056c410.tar.gz
kube-4b1798f0cdf87361869e7cf2b341acacd056c410.zip
Moved cpp code into src directory
Diffstat (limited to 'framework/src/domain/contactcontroller.cpp')
-rw-r--r--framework/src/domain/contactcontroller.cpp68
1 files changed, 68 insertions, 0 deletions
diff --git a/framework/src/domain/contactcontroller.cpp b/framework/src/domain/contactcontroller.cpp
new file mode 100644
index 00000000..49f78b40
--- /dev/null
+++ b/framework/src/domain/contactcontroller.cpp
@@ -0,0 +1,68 @@
1/*
2 * Copyright (C) 2017 Michael Bohlender, <michael.bohlender@kdemail.net>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18
19#include "contactcontroller.h"
20
21#include <sink/applicationdomaintype.h>
22
23ContactController::ContactController()
24 : Kube::Controller(),
25 action_save{new Kube::ControllerAction{this, &ContactController::save}}
26{
27 updateSaveAction();
28}
29
30void ContactController::save() {
31 qWarning() << "Saving is not implemented";
32}
33
34void ContactController::updateSaveAction()
35{
36 saveAction()->setEnabled(!getName().isEmpty());
37}
38
39void ContactController::loadContact(const QVariant &contact)
40{
41 if (auto c = contact.value<Sink::ApplicationDomain::Contact::Ptr>()) {
42 setName(c->getFn());
43 QStringList emails;
44 for (const auto &e : c->getEmails()) {
45 emails << e.email;
46 }
47 setEmails(emails);
48 }
49}
50
51QVariant ContactController::contact() const
52{
53 return QVariant{};
54}
55
56void ContactController::removeEmail(const QString &email)
57{
58 auto emails = getEmails();
59 emails.removeAll(email);
60 setEmails(emails);
61}
62
63void ContactController::addEmail(const QString &email)
64{
65 auto emails = getEmails();
66 emails.append(email);
67 setEmails(emails);
68}