diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ include(ECMAddTests) find_package(Qt5 "5.2" REQUIRED COMPONENTS Widgets) -find_package(KF5 "5.8" REQUIRED COMPONENTS CoreAddons People) +find_package(KF5 "5.8" REQUIRED COMPONENTS CoreAddons People I18n) find_package(KF5Contacts REQUIRED) diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt --- a/autotests/CMakeLists.txt +++ b/autotests/CMakeLists.txt @@ -1,3 +1,3 @@ find_package(Qt5Test) -ecm_add_test(kpeoplevcardtest.cpp ../src/kpeoplevcard.cpp TEST_NAME kpeoplevcardtest LINK_LIBRARIES KF5::PeopleBackend KF5::CoreAddons Qt5::Test KF5::Contacts) +ecm_add_test(kpeoplevcardtest.cpp ../src/kpeoplevcard.cpp TEST_NAME kpeoplevcardtest LINK_LIBRARIES KF5::PeopleBackend KF5::CoreAddons Qt5::Test KF5::Contacts KF5::I18n) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,2 +1,2 @@ kcoreaddons_add_plugin(KPeopleVCard SOURCES kpeoplevcard.cpp JSON "kpeoplevcard.json" INSTALL_NAMESPACE "kpeople/datasource") -target_link_libraries(KPeopleVCard KF5::PeopleBackend KF5::CoreAddons KF5::Contacts) +target_link_libraries(KPeopleVCard KF5::PeopleBackend KF5::CoreAddons KF5::Contacts KF5::I18n) diff --git a/src/kpeoplevcard.cpp b/src/kpeoplevcard.cpp --- a/src/kpeoplevcard.cpp +++ b/src/kpeoplevcard.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -48,6 +49,18 @@ if (!name.isEmpty()) { return name; } + + // If both first and last name are set combine them to a full name + if (!m_addressee.givenName().isEmpty() && !m_addressee.familyName().isEmpty()) + return i18nc("given-name family-name", "%1 %2", m_addressee.givenName(), m_addressee.familyName()); + + // If only one of them is set just return what we know + if (!m_addressee.givenName().isEmpty()) + return m_addressee.givenName(); + if (!m_addressee.familyName().isEmpty()) + return m_addressee.familyName(); + + // Fall back to other identifiers if (!m_addressee.preferredEmail().isEmpty()) { return m_addressee.preferredEmail(); }