Verified Commit cf096a35 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖

Move libkf5kaddressbookimportexport to KAddressBook repo

parent 11e39942
Pipeline #33993 passed with stage
in 17 minutes and 49 seconds
......@@ -67,7 +67,6 @@ set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_subdirectory(kaddressbookgrantlee)
add_subdirectory(kaddressbookimportexport)
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)
ecm_qt_install_logging_categories(
......
ecm_setup_version(PROJECT VARIABLE_PREFIX KADDRESSBOOKIMPORTEXPORT
VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/kaddressbookimportexport_version.h"
PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KF5KaddressbookImportExportConfigVersion.cmake"
SOVERSION 5
)
########### CMake Config Files ###########
set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF5KaddressbookImportExport")
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/KF5KaddressbookImportExportConfig.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/KF5KaddressbookImportExportConfig.cmake"
INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR}
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/KF5KaddressbookImportExportConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/KF5KaddressbookImportExportConfigVersion.cmake"
DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
COMPONENT Devel
)
install(EXPORT KF5KaddressbookImportExportTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE KF5KaddressbookImportExportTargets.cmake NAMESPACE KF5::)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/kaddressbookimportexport_version.h
DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5} COMPONENT Devel
)
add_subdirectory(src)
if (BUILD_TESTING)
add_subdirectory(autotests)
endif()
@PACKAGE_INIT@
include("${CMAKE_CURRENT_LIST_DIR}/KF5KaddressbookImportExportTargets.cmake")
add_executable( contactfieldstest contactfieldstest.cpp)
add_test(NAME contactfieldstest COMMAND contactfieldstest )
ecm_mark_as_test(kaddrebook-contactfieldstest)
target_link_libraries(contactfieldstest KF5::Contacts Qt5::Test Qt5::Gui KF5::I18n KF5::KaddressbookImportExport)
#include "../src/kaddressbookimportexportcontactfields.h"
#include <QTest>
#include <QObject>
class ContactFieldsTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void testFieldCount();
void testSetGet();
private:
KContacts::Addressee mContact;
};
QTEST_MAIN(ContactFieldsTest)
static const QString s_formattedName(QStringLiteral("User, Joe"));
static const QString s_prefix(QStringLiteral("Mr."));
static const QString s_givenName(QStringLiteral("Joe"));
static const QString s_additionalName(QStringLiteral("Doe"));
static const QString s_familyName(QStringLiteral("User"));
static const QString s_suffix(QStringLiteral("Jr."));
static const QString s_nickName(QStringLiteral("joe"));
static const QString s_birthday(QStringLiteral("1966-12-03"));
static const QString s_anniversary(QStringLiteral("1980-10-02"));
static const QString s_homeAddressStreet(QStringLiteral("My Home Street"));
static const QString s_homeAddressPostOfficeBox(QStringLiteral("My Home POB"));
static const QString s_homeAddressLocality(QStringLiteral("My Home Locality"));
static const QString s_homeAddressRegion(QStringLiteral("My Home Address"));
static const QString s_homeAddressPostalCode(QStringLiteral("My Home Postal Code"));
static const QString s_homeAddressCountry(QStringLiteral("My Home Country"));
static const QString s_homeAddressLabel(QStringLiteral("My Home Label"));
static const QString s_businessAddressStreet(QStringLiteral("My Business Street"));
static const QString s_businessAddressPostOfficeBox(QStringLiteral("My Business POB"));
static const QString s_businessAddressLocality(QStringLiteral("My Business Locality"));
static const QString s_businessAddressRegion(QStringLiteral("My Business Region"));
static const QString s_businessAddressPostalCode(QStringLiteral("My Business Postal Code"));
static const QString s_businessAddressCountry(QStringLiteral("My Business Country"));
static const QString s_businessAddressLabel(QStringLiteral("My Business Label"));
static const QString s_homePhone(QStringLiteral("000111222"));
static const QString s_businessPhone(QStringLiteral("333444555"));
static const QString s_mobilePhone(QStringLiteral("666777888"));
static const QString s_homeFax(QStringLiteral("999000111"));
static const QString s_businessFax(QStringLiteral("222333444"));
static const QString s_carPhone(QStringLiteral("555666777"));
static const QString s_isdn(QStringLiteral("888999000"));
static const QString s_pager(QStringLiteral("111222333"));
static const QString s_preferredEmail(QStringLiteral("me@somewhere.org"));
static const QString s_email2(QStringLiteral("you@somewhere.org"));
static const QString s_email3(QStringLiteral("she@somewhere.org"));
static const QString s_email4(QStringLiteral("it@somewhere.org"));
static const QString s_mailer(QStringLiteral("kmail2"));
static const QString s_title(QStringLiteral("Chief"));
static const QString s_role(QStringLiteral("Developer"));
static const QString s_organization(QStringLiteral("KDE"));
static const QString s_note(QStringLiteral("That's a small note"));
static const QString s_homepage(QStringLiteral("http://www.kde.de"));
static const QString s_blogFeed(QStringLiteral("http://planetkde.org"));
static const QString s_profession(QStringLiteral("Developer"));
static const QString s_office(QStringLiteral("Room 2443"));
static const QString s_manager(QStringLiteral("Hans"));
static const QString s_assistant(QStringLiteral("Hins"));
static const QString s_spouse(QStringLiteral("My Darling"));
void ContactFieldsTest::testFieldCount()
{
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::allFields().count(), 48);
}
void ContactFieldsTest::testSetGet()
{
KContacts::Addressee contact;
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::FormattedName, s_formattedName, contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::Prefix, s_prefix, contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::GivenName, s_givenName, contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::AdditionalName, s_additionalName, contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::FamilyName, s_familyName, contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::Suffix, s_suffix, contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::NickName, s_nickName, contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::Birthday, s_birthday, contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::Anniversary, s_anniversary, contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::HomeAddressStreet, s_homeAddressStreet, contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::HomeAddressPostOfficeBox, s_homeAddressPostOfficeBox,
contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::HomeAddressLocality, s_homeAddressLocality, contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::HomeAddressRegion, s_homeAddressRegion, contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::HomeAddressPostalCode, s_homeAddressPostalCode, contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::HomeAddressCountry, s_homeAddressCountry, contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::HomeAddressLabel, s_homeAddressLabel, contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::BusinessAddressStreet, s_businessAddressStreet, contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::BusinessAddressPostOfficeBox,
s_businessAddressPostOfficeBox, contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::BusinessAddressLocality, s_businessAddressLocality,
contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::BusinessAddressRegion, s_businessAddressRegion, contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::BusinessAddressPostalCode, s_businessAddressPostalCode,
contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::BusinessAddressCountry, s_businessAddressCountry,
contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::BusinessAddressLabel, s_businessAddressLabel, contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::HomePhone, s_homePhone, contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::BusinessPhone, s_businessPhone, contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::MobilePhone, s_mobilePhone, contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::HomeFax, s_homeFax, contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::BusinessFax, s_businessFax, contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::CarPhone, s_carPhone, contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::Isdn, s_isdn, contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::Pager, s_pager, contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::PreferredEmail, s_preferredEmail, contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::Email2, s_email2, contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::Email3, s_email3, contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::Email4, s_email4, contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::Mailer, s_mailer, contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::Title, s_title, contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::Role, s_role, contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::Organization, s_organization, contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::Note, s_note, contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::Homepage, s_homepage, contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::BlogFeed, s_blogFeed, contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::Profession, s_profession, contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::Office, s_office, contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::Manager, s_manager, contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::Assistant, s_assistant, contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::Anniversary, s_anniversary, contact);
KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(KAddressBookImportExport::KAddressBookImportExportContactFields::Spouse, s_spouse, contact);
const KContacts::Addressee contactCopy = contact;
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::FormattedName, contactCopy), s_formattedName);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::Prefix, contactCopy), s_prefix);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::GivenName, contactCopy), s_givenName);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::AdditionalName, contactCopy), s_additionalName);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::FamilyName, contactCopy), s_familyName);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::Suffix, contactCopy), s_suffix);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::NickName, contactCopy), s_nickName);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::Birthday, contactCopy), s_birthday);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::Anniversary, contactCopy), s_anniversary);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::HomeAddressStreet,
contactCopy), s_homeAddressStreet);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::HomeAddressPostOfficeBox,
contactCopy), s_homeAddressPostOfficeBox);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::HomeAddressLocality,
contactCopy), s_homeAddressLocality);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::HomeAddressRegion,
contactCopy), s_homeAddressRegion);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::HomeAddressPostalCode,
contactCopy), s_homeAddressPostalCode);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::HomeAddressCountry,
contactCopy), s_homeAddressCountry);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::HomeAddressLabel, contactCopy),
s_homeAddressLabel);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::BusinessAddressStreet,
contactCopy), s_businessAddressStreet);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::BusinessAddressPostOfficeBox,
contactCopy), s_businessAddressPostOfficeBox);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::BusinessAddressLocality,
contactCopy), s_businessAddressLocality);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::BusinessAddressRegion,
contactCopy), s_businessAddressRegion);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::BusinessAddressPostalCode,
contactCopy), s_businessAddressPostalCode);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::BusinessAddressCountry,
contactCopy), s_businessAddressCountry);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::BusinessAddressLabel,
contactCopy), s_businessAddressLabel);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::HomePhone, contactCopy), s_homePhone);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::BusinessPhone, contactCopy), s_businessPhone);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::MobilePhone, contactCopy), s_mobilePhone);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::HomeFax, contactCopy), s_homeFax);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::BusinessFax, contactCopy), s_businessFax);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::CarPhone, contactCopy), s_carPhone);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::Isdn, contactCopy), s_isdn);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::Pager, contactCopy), s_pager);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::PreferredEmail, contactCopy), s_preferredEmail);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::Email2, contactCopy), s_email2);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::Email3, contactCopy), s_email3);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::Email4, contactCopy), s_email4);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::Mailer, contactCopy), s_mailer);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::Title, contactCopy), s_title);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::Role, contactCopy), s_role);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::Organization, contactCopy), s_organization);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::Note, contactCopy), s_note);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::Homepage, contactCopy), s_homepage);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::BlogFeed, contactCopy), s_blogFeed);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::Profession, contactCopy), s_profession);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::Office, contactCopy), s_office);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::Manager, contactCopy), s_manager);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::Assistant, contactCopy), s_assistant);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::Anniversary, contactCopy), s_anniversary);
QCOMPARE(KAddressBookImportExport::KAddressBookImportExportContactFields::value(KAddressBookImportExport::KAddressBookImportExportContactFields::Spouse, contactCopy), s_spouse);
}
#include "contactfieldstest.moc"
add_definitions(-DTRANSLATION_DOMAIN=\"libkaddressbookimportexport\")
set(kaddressbook_importexport_LIB_SRCS
kaddressbookimportexportplugin.cpp
kaddressbookimportexportplugininterface.cpp
kaddressbookimportexportpluginmanager.cpp
kaddressbookimportexportcontactlist.cpp
kaddressbookcontactselectionwidget.cpp
kaddressbookcontactselectiondialog.cpp
kaddressbookexportselectionwidget.cpp
kaddressbookimportexportcontactfields.cpp
)
ecm_qt_declare_logging_category(kaddressbook_importexport_LIB_SRCS HEADER libkaddressbookexportimport_debug.h IDENTIFIER LIBKADDRESSBOOKIMPORTEXPORT_LOG CATEGORY_NAME org.kde.pim.kaddressbookimportexport
DESCRIPTION "kdepim-apps-lib (kaddressbookimportexport)"
EXPORT KDEPIMAPPSLIB
)
add_library(KF5KaddressbookImportExport ${kaddressbook_importexport_LIB_SRCS})
generate_export_header(KF5KaddressbookImportExport BASE_NAME kaddressbook_importexport)
add_library(KF5::KaddressbookImportExport ALIAS KF5KaddressbookImportExport)
target_include_directories(KF5KaddressbookImportExport INTERFACE "$<INSTALL_INTERFACE:${KDE_INSTALL_INCLUDEDIR_KF5}/KAddressBookImportExport/;${KDE_INSTALL_INCLUDEDIR_KF5}/kaddressbookimportexport>")
target_include_directories(KF5KaddressbookImportExport PUBLIC "$<BUILD_INTERFACE:${Grantlee_INCLUDE_DIRS}>")
target_link_libraries(KF5KaddressbookImportExport
PRIVATE
KF5::Contacts
KF5::PimCommon
KF5::I18n
KF5::AkonadiWidgets
)
set_target_properties(KF5KaddressbookImportExport PROPERTIES
VERSION ${KADDRESSBOOKIMPORTEXPORT_VERSION_STRING}
SOVERSION ${KADDRESSBOOKIMPORTEXPORT_SOVERSION}
EXPORT_NAME KaddressbookImportExport
)
install(TARGETS
KF5KaddressbookImportExport
EXPORT KF5KaddressbookImportExportTargets ${KF5_INSTALL_TARGETS_DEFAULT_ARGS}
)
ecm_generate_headers(KaddressbookImportExport_CamelCase_HEADERS
HEADER_NAMES
KAddressBookImportExportPluginInterface
KAddressBookImportExportPlugin
KAddressBookImportExportPluginManager
KAddressBookImportExportContactList
KAddressBookContactSelectionDialog
KAddressBookExportSelectionWidget
KAddressBookContactSelectionWidget
REQUIRED_HEADERS KaddressbookImportExport_HEADERS
PREFIX KAddressBookImportExport
)
ecm_generate_pri_file(BASE_NAME KaddressbookImportExport
LIB_NAME KF5KaddressbookImportExport
DEPS "" FILENAME_VAR PRI_FILENAME INCLUDE_INSTALL_DIR ${KDE_INSTALL_INCLUDEDIR_KF5}/KaddressbookImportExport
)
install(FILES
${KaddressbookImportExport_CamelCase_HEADERS}
DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/KAddressBookImportExport
COMPONENT Devel
)
install(FILES
${KaddressbookImportExport_HEADERS}
${CMAKE_CURRENT_BINARY_DIR}/kaddressbook_importexport_export.h
kaddressbookimportexportcontactfields.h
DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/kaddressbookimportexport
COMPONENT Devel
)
install(FILES
${PRI_FILENAME}
DESTINATION ${ECM_MKSPECS_INSTALL_DIR})
#! /bin/sh
$XGETTEXT `find . -name '*.h' -o -name '*.cpp' | grep -v '/autotests/'` -o $podir/libkaddressbookimportexport.pot
/*
SPDX-FileCopyrightText: 2009 Tobias Koenig <tokoe@kde.org>
SPDX-FileCopyrightText: 2015-2020 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "kaddressbookcontactselectiondialog.h"
#include "kaddressbookcontactselectionwidget.h"
#include <QVBoxLayout>
#include <KLocalizedString>
#include <QDialogButtonBox>
#include <QPushButton>
using namespace KAddressBookImportExport;
KAddressBookContactSelectionDialog::KAddressBookContactSelectionDialog(QItemSelectionModel *selectionModel, bool allowToSelectTypeToExport, QWidget *parent)
: QDialog(parent)
{
setWindowTitle(i18nc("@title:window", "Select Contacts"));
QVBoxLayout *mainLayout = new QVBoxLayout(this);
mSelectionWidget = new KAddressBookContactSelectionWidget(selectionModel, this);
if (allowToSelectTypeToExport) {
mainLayout->addWidget(mSelectionWidget);
mVCardExport = new KAddressBookExportSelectionWidget(this);
mainLayout->addWidget(mVCardExport);
} else {
mainLayout->addWidget(mSelectionWidget);
}
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
okButton->setDefault(true);
okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
connect(buttonBox, &QDialogButtonBox::accepted, this, &KAddressBookContactSelectionDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &KAddressBookContactSelectionDialog::reject);
mainLayout->addWidget(buttonBox);
}
void KAddressBookContactSelectionDialog::setMessageText(const QString &message)
{
mSelectionWidget->setMessageText(message);
}
void KAddressBookContactSelectionDialog::setDefaultAddressBook(const Akonadi::Collection &addressBook)
{
mSelectionWidget->setDefaultAddressBook(addressBook);
}
Akonadi::Item::List KAddressBookContactSelectionDialog::selectedItems() const
{
return mSelectionWidget->selectedItems();
}
KAddressBookImportExport::KAddressBookImportExportContactList KAddressBookContactSelectionDialog::selectedContacts() const
{
return mSelectionWidget->selectedContacts();
}
KAddressBookExportSelectionWidget::ExportFields KAddressBookContactSelectionDialog::exportType() const
{
if (mVCardExport) {
return mVCardExport->exportType();
} else {
return KAddressBookExportSelectionWidget::None;
}
}
void KAddressBookContactSelectionDialog::setAddGroupContact(bool addGroupContact)
{
mSelectionWidget->setAddGroupContact(addGroupContact);
}
/*
SPDX-FileCopyrightText: 2009 Tobias Koenig <tokoe@kde.org>
SPDX-FileCopyrightText: 2015-2020 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#ifndef IMPORTEXPORT_KADDRESSBOOKCONTACTSELECTIONDIALOG_H
#define IMPORTEXPORT_KADDRESSBOOKCONTACTSELECTIONDIALOG_H
#include "kaddressbook_importexport_export.h"
#include <KContacts/Addressee>
#include <QDialog>
#include <KAddressBookImportExport/KAddressBookImportExportContactList>
#include <KAddressBookImportExport/KAddressBookExportSelectionWidget>
#include <AkonadiCore/Item>
class QItemSelectionModel;
class KAddressBookContactSelectionWidget;
namespace Akonadi {
class Collection;
}
namespace KAddressBookImportExport {
class KAddressBookExportSelectionWidget;
class KAddressBookContactSelectionWidget;
/**
* @short A dialog to select a group of contacts.
*
* @author Tobias Koenig <tokoe@kde.org>
*/
class KADDRESSBOOK_IMPORTEXPORT_EXPORT KAddressBookContactSelectionDialog : public QDialog
{
Q_OBJECT
public:
/**
* Creates a new contact selection dialog.
*
* @param selectionModel The model that contains the currently selected contacts.
* @param parent The parent widget.
*/
explicit KAddressBookContactSelectionDialog(QItemSelectionModel *selectionModel, bool allowToSelectTypeToExport, QWidget *parent = nullptr);
/**
* Sets the @p message text.
*/
void setMessageText(const QString &message);
/**
* Sets the default addressbook.
*/
void setDefaultAddressBook(const Akonadi::Collection &addressBook);
/**
* Returns the list of selected contacts.
*/
Q_REQUIRED_RESULT KAddressBookImportExport::KAddressBookImportExportContactList selectedContacts() const;
Q_REQUIRED_RESULT KAddressBookExportSelectionWidget::ExportFields exportType() const;
void setAddGroupContact(bool addGroupContact);
Q_REQUIRED_RESULT Akonadi::Item::List selectedItems() const;
private:
KAddressBookContactSelectionWidget *mSelectionWidget = nullptr;
KAddressBookExportSelectionWidget *mVCardExport = nullptr;
};
}
#endif
/*
SPDX-FileCopyrightText: 2009 Tobias Koenig <tokoe@kde.org>
SPDX-FileCopyrightText: 2016-2020 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "kaddressbookcontactselectionwidget.h"
#include <QDebug>
#include <AkonadiWidgets/CollectionComboBox>
#include <AkonadiCore/EntityTreeModel>
#include <AkonadiCore/ItemFetchJob>
#include <AkonadiCore/ItemFetchScope>
#include <AkonadiCore/RecursiveItemFetchJob>
#include <KLocalizedString>
#include <QButtonGroup>
#include <QCheckBox>
#include <QGridLayout>
#include <QGroupBox>
#include <QItemSelectionModel>
#include <QLabel>
#include <QProgressDialog>
#include <QRadioButton>
#include <QVBoxLayout>
#include <QApplication>
using namespace KAddressBookImportExport;
KAddressBookContactSelectionWidget::KAddressBookContactSelectionWidget(QItemSelectionModel *selectionModel, QWidget *parent)
: QWidget(parent)
, mSelectionModel(selectionModel)
{
initGui();
mSelectedContactsButton->setEnabled(mSelectionModel->hasSelection());
mAddressBookSelection->setEnabled(false);
mAddressBookSelectionRecursive->setEnabled(false);
connect(mAddressBookContactsButton, &QRadioButton::toggled, mAddressBookSelection, &Akonadi::CollectionComboBox::setEnabled);
connect(mAddressBookContactsButton, &QRadioButton::toggled, mAddressBookSelectionRecursive, &QCheckBox::setEnabled);
// apply default configuration
if (mSelectionModel->hasSelection()) {
mSelectedContactsButton->setChecked(true);
} else {
mAllContactsButton->setChecked(true);
}
}
void KAddressBookContactSelectionWidget::setMessageText(const QString &message)
{
if (!message.isEmpty()) {
mMessageLabel->setText(message);
mMessageLabel->show();
}
}
void KAddressBookContactSelectionWidget::setDefaultAddressBook(const Akonadi::Collection &addressBook)
{
mAddressBookSelection->setDefaultCollection(addressBook);
}
Akonadi::Item::List KAddressBookContactSelectionWidget::selectedItems() const
{
if (mAllContactsButton->isChecked()) {
return collectAllItems();
} else if (mSelectedContactsButton->isChecked()) {
return collectSelectedItems();
} else if (mAddressBookContactsButton->isChecked()) {
return collectAddressBookItems();
} else {
qWarning() << " It's a bug here.";
}
return Akonadi::Item::List();
}
KAddressBookImportExport::KAddressBookImportExportContactList KAddressBookContactSelectionWidget::selectedContacts() const
{
if (mAllContactsButton->isChecked()) {
return collectAllContacts();
} else if (mSelectedContactsButton->isChecked()) {
return collectSelectedContacts();
} else if (mAddressBookContactsButton->isChecked()) {
return collectAddressBookContacts();
}
return