diff options
Diffstat (limited to 'framework/src/domain/contactcontroller.cpp')
-rw-r--r-- | framework/src/domain/contactcontroller.cpp | 68 |
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 | |||
23 | ContactController::ContactController() | ||
24 | : Kube::Controller(), | ||
25 | action_save{new Kube::ControllerAction{this, &ContactController::save}} | ||
26 | { | ||
27 | updateSaveAction(); | ||
28 | } | ||
29 | |||
30 | void ContactController::save() { | ||
31 | qWarning() << "Saving is not implemented"; | ||
32 | } | ||
33 | |||
34 | void ContactController::updateSaveAction() | ||
35 | { | ||
36 | saveAction()->setEnabled(!getName().isEmpty()); | ||
37 | } | ||
38 | |||
39 | void 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 | |||
51 | QVariant ContactController::contact() const | ||
52 | { | ||
53 | return QVariant{}; | ||
54 | } | ||
55 | |||
56 | void ContactController::removeEmail(const QString &email) | ||
57 | { | ||
58 | auto emails = getEmails(); | ||
59 | emails.removeAll(email); | ||
60 | setEmails(emails); | ||
61 | } | ||
62 | |||
63 | void ContactController::addEmail(const QString &email) | ||
64 | { | ||
65 | auto emails = getEmails(); | ||
66 | emails.append(email); | ||
67 | setEmails(emails); | ||
68 | } | ||