From ba774b1654efcd7b27f84c3e0f6fd9d98bc0f0d0 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Fri, 13 Jul 2018 14:56:07 +0200 Subject: Contact removal --- framework/src/domain/contactcontroller.cpp | 14 +++++++++++--- framework/src/domain/contactcontroller.h | 4 ++++ views/people/qml/People.qml | 13 +++++++++++++ 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/framework/src/domain/contactcontroller.cpp b/framework/src/domain/contactcontroller.cpp index e27c4a3b..6bcaac62 100644 --- a/framework/src/domain/contactcontroller.cpp +++ b/framework/src/domain/contactcontroller.cpp @@ -103,9 +103,10 @@ void ContactController::updateSaveAction() saveAction()->setEnabled(!getFirstName().isEmpty()); } -void ContactController::loadContact(const QVariant &contact) +void ContactController::loadContact(const QVariant &variant) { - if (auto c = contact.value()) { + mContact = variant; + if (auto c = variant.value()) { const auto &vcard = c->getVcard(); KContacts::VCardConverter converter; const auto addressee = converter.parseVCard(vcard); @@ -134,7 +135,14 @@ void ContactController::loadContact(const QVariant &contact) } } +void ContactController::remove() +{ + if (auto c = mContact.value()) { + run(Sink::Store::remove(*c)); + } +} + QVariant ContactController::contact() const { - return QVariant{}; + return mContact; } diff --git a/framework/src/domain/contactcontroller.h b/framework/src/domain/contactcontroller.h index 852a003f..61e37de8 100644 --- a/framework/src/domain/contactcontroller.h +++ b/framework/src/domain/contactcontroller.h @@ -54,9 +54,13 @@ public: explicit ContactController(); Q_INVOKABLE void loadContact(const QVariant &contact); + Q_INVOKABLE void remove(); QVariant contact() const; private slots: void updateSaveAction(); + +private: + QVariant mContact; }; diff --git a/views/people/qml/People.qml b/views/people/qml/People.qml index 8b35f5e7..718d3c08 100644 --- a/views/people/qml/People.qml +++ b/views/people/qml/People.qml @@ -228,7 +228,20 @@ FocusScope { } Kube.Button { + anchors { + bottom: parent.bottom + left: parent.left + margins: Kube.Units.largeSpacing + } + text: qsTr("Remove") + onClicked: { + contactController.remove() + stack.pop() + } + } + + Kube.Button { anchors { bottom: parent.bottom right: parent.right -- cgit v1.2.3