diff options
Diffstat (limited to 'framework/domain/contactcontroller.cpp')
-rw-r--r-- | framework/domain/contactcontroller.cpp | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/framework/domain/contactcontroller.cpp b/framework/domain/contactcontroller.cpp index 0be90e77..a1a805c9 100644 --- a/framework/domain/contactcontroller.cpp +++ b/framework/domain/contactcontroller.cpp | |||
@@ -18,16 +18,17 @@ | |||
18 | 18 | ||
19 | #include "contactcontroller.h" | 19 | #include "contactcontroller.h" |
20 | 20 | ||
21 | #include <sink/applicationdomaintype.h> | ||
22 | |||
21 | ContactController::ContactController() | 23 | ContactController::ContactController() |
22 | : Kube::Controller(), | 24 | : Kube::Controller(), |
23 | action_save{new Kube::ControllerAction{this, &ContactController::save}} | 25 | action_save{new Kube::ControllerAction{this, &ContactController::save}} |
24 | { | 26 | { |
25 | loadContact("test"); | ||
26 | updateSaveAction(); | 27 | updateSaveAction(); |
27 | } | 28 | } |
28 | 29 | ||
29 | void ContactController::save() { | 30 | void ContactController::save() { |
30 | //TODO | 31 | qWarning() << "Saving is not implemented"; |
31 | } | 32 | } |
32 | 33 | ||
33 | void ContactController::updateSaveAction() | 34 | void ContactController::updateSaveAction() |
@@ -37,23 +38,31 @@ void ContactController::updateSaveAction() | |||
37 | 38 | ||
38 | void ContactController::loadContact(const QVariant &contact) | 39 | void ContactController::loadContact(const QVariant &contact) |
39 | { | 40 | { |
40 | setName("Anita Rosenzweig"); | 41 | if (auto c = contact.value<Sink::ApplicationDomain::Contact::Ptr>()) { |
41 | m_emails << "rosenzweig@kolabnow.com" << "wolfi@kolabnow.com"; | 42 | setName(c->getFn()); |
43 | QStringList emails; | ||
44 | for (const auto &e : c->getEmails()) { | ||
45 | emails << e; | ||
46 | } | ||
47 | setEmails(emails); | ||
48 | } | ||
42 | } | 49 | } |
43 | 50 | ||
44 | void ContactController::removeEmail(const QString &email) | 51 | QVariant ContactController::contact() const |
45 | { | 52 | { |
46 | m_emails.removeOne(email); | 53 | return QVariant{}; |
47 | emit emailsChanged(); | ||
48 | } | 54 | } |
49 | 55 | ||
50 | void ContactController::addEmail(const QString &email) | 56 | void ContactController::removeEmail(const QString &email) |
51 | { | 57 | { |
52 | m_emails << email; | 58 | auto emails = getEmails(); |
53 | emit emailsChanged(); | 59 | emails.removeAll(email); |
60 | setEmails(emails); | ||
54 | } | 61 | } |
55 | 62 | ||
56 | QStringList ContactController::emails() const | 63 | void ContactController::addEmail(const QString &email) |
57 | { | 64 | { |
58 | return m_emails; | 65 | auto emails = getEmails(); |
66 | emails.append(email); | ||
67 | setEmails(emails); | ||
59 | } | 68 | } |