From 2b8918e1cf28890b47c0cd2399eccf2087cbfbb4 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 27 Jun 2017 15:19:41 +0200 Subject: No more dummy values in the people view --- framework/qml/People.qml | 50 +++++++++--------------------- framework/src/CMakeLists.txt | 3 +- framework/src/domain/contactcontroller.cpp | 22 ++++++++++--- framework/src/domain/contactcontroller.h | 6 ++++ 4 files changed, 41 insertions(+), 40 deletions(-) (limited to 'framework') diff --git a/framework/qml/People.qml b/framework/qml/People.qml index e60763d9..aa23a78d 100644 --- a/framework/qml/People.qml +++ b/framework/qml/People.qml @@ -272,11 +272,12 @@ Item { leftMargin: Kube.Units.largeSpacing } - text: "CIO" + text: contactController.jobTitle } Rectangle { id: company + visible: contactController.company != "" anchors { bottom: avatar.bottom @@ -306,7 +307,7 @@ Item { leftMargin: Kube.Units.smallSpacing } - text: "Sauerkraut AG" + text: contactController.company } } } @@ -328,19 +329,6 @@ Item { } } - Row { - spacing: Kube.Units.smallSpacing - Kube.Label { text: "(alias)"} - Kube.Label { text: "test.testerson@gmail.com"; color: Kube.Colors.highlightColor } - Item { width: Kube.Units.smallSpacing; height: 1 } - } - - Row { - spacing: Kube.Units.smallSpacing - Kube.Label { text: "(private)"} - Kube.Label { text: "test@gmail.com"; color: Kube.Colors.highlightColor } - Item { width: Kube.Units.smallSpacing; height: 1 } - } } Flow { @@ -349,23 +337,15 @@ Item { width: personPageRoot.width - Kube.Units.largeSpacing spacing: Kube.Units.smallSpacing - Row { - spacing: Kube.Units.smallSpacing - Kube.Label { text: "(inhouse)"} - Kube.Label { text: "+49812324932"; opacity: 0.6 } - Item { width: Kube.Units.smallSpacing; height: 1 } - } - Row { - spacing: Kube.Units.smallSpacing - Kube.Label { text: "(mobile)"} - Kube.Label { text: "+49812324932"; opacity: 0.6 } - Item { width: Kube.Units.smallSpacing; height: 1 } - } - Row { - spacing: Kube.Units.smallSpacing - Kube.Label { text: "(private)"} - Kube.Label { text: "+49812324932"; opacity: 0.6 } - Item { width: Kube.Units.smallSpacing; height: 1 } + Repeater { + model: contactController.phoneNumbers + + Row { + spacing: Kube.Units.smallSpacing + Kube.Label { text: "(main)" } + Kube.Label { text: modelData ; opacity: 0.6 } + Item { width: Kube.Units.smallSpacing; height: 1 } + } } } @@ -374,9 +354,9 @@ Item { width: personPageRoot.width - Kube.Units.largeSpacing - Kube.Label { text: "Albertstrasse 35a"} - Kube.Label { text: "81767 Teststadt"} - Kube.Label { text: "GERMANY" } + Kube.Label { text: contactController.street } + Kube.Label { text: contactController.city } + Kube.Label { text: contactController.country } } // Column { diff --git a/framework/src/CMakeLists.txt b/framework/src/CMakeLists.txt index 0e6af2ce..1b92e8c3 100644 --- a/framework/src/CMakeLists.txt +++ b/framework/src/CMakeLists.txt @@ -6,6 +6,7 @@ find_package(KAsync CONFIG REQUIRED) find_package(QGpgme CONFIG REQUIRED) find_package(KF5Codecs CONFIG REQUIRED) find_package(KF5Package CONFIG REQUIRED) +find_package(KF5Contacts CONFIG REQUIRED) add_definitions("-Wall -std=c++0x -g") @@ -42,7 +43,7 @@ set(SRCS add_library(frameworkplugin SHARED ${SRCS}) qt5_use_modules(frameworkplugin Core Quick Qml WebEngineWidgets Test) -target_link_libraries(frameworkplugin sink kube_otp KF5::Codecs KF5::Package KAsync) +target_link_libraries(frameworkplugin sink kube_otp KF5::Codecs KF5::Package KF5::Contacts KAsync) install(TARGETS frameworkplugin DESTINATION ${FRAMEWORK_INSTALL_DIR}) add_subdirectory(domain/mime/mimetreeparser) diff --git a/framework/src/domain/contactcontroller.cpp b/framework/src/domain/contactcontroller.cpp index 49f78b40..90ef6323 100644 --- a/framework/src/domain/contactcontroller.cpp +++ b/framework/src/domain/contactcontroller.cpp @@ -19,6 +19,7 @@ #include "contactcontroller.h" #include +#include ContactController::ContactController() : Kube::Controller(), @@ -40,11 +41,24 @@ void ContactController::loadContact(const QVariant &contact) { if (auto c = contact.value()) { setName(c->getFn()); - QStringList emails; - for (const auto &e : c->getEmails()) { - emails << e.email; + const auto &vcard = c->getVcard(); + KContacts::VCardConverter converter; + const auto addressee = converter.parseVCard(vcard); + setEmails(addressee.emails()); + QStringList numbers; + for (const auto &n : addressee.phoneNumbers()) { + numbers << n.number(); } - setEmails(emails); + setPhoneNumbers(numbers); + + for(const auto &a :addressee.addresses()) { + setStreet(a.street()); + setCity(a.locality()); + setCountry(a.country()); + break; + } + setCompany(addressee.organization()); + setJobTitle(addressee.role()); } } diff --git a/framework/src/domain/contactcontroller.h b/framework/src/domain/contactcontroller.h index d1973d9c..fea42430 100644 --- a/framework/src/domain/contactcontroller.h +++ b/framework/src/domain/contactcontroller.h @@ -35,6 +35,12 @@ class ContactController : public Kube::Controller //Interface properties KUBE_CONTROLLER_PROPERTY(QString, Name, name) KUBE_CONTROLLER_PROPERTY(QStringList, Emails, emails) + KUBE_CONTROLLER_PROPERTY(QStringList, PhoneNumbers, phoneNumbers) + KUBE_CONTROLLER_PROPERTY(QString, Street, street) + KUBE_CONTROLLER_PROPERTY(QString, City, city) + KUBE_CONTROLLER_PROPERTY(QString, Country, country) + KUBE_CONTROLLER_PROPERTY(QString, Company, company) + KUBE_CONTROLLER_PROPERTY(QString, JobTitle, jobTitle) KUBE_CONTROLLER_ACTION(save) -- cgit v1.2.3