diff --git a/CMakeLists.txt b/CMakeLists.txt index 36a392d..ef195bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,98 +1,98 @@ cmake_minimum_required(VERSION 3.5) set(PIM_VERSION "5.12.40") project(Akonadi-Calendar VERSION ${PIM_VERSION}) # ECM setup set(KF5_MIN_VERSION "5.60.0") find_package(ECM ${KF5_MIN_VERSION} CONFIG REQUIRED) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) set(QT_REQUIRED_VERSION "5.11.0") include(GenerateExportHeader) include(ECMGenerateHeaders) include(ECMGeneratePriFile) include(ECMSetupVersion) include(FeatureSummary) include(KDEInstallDirs) include(KDECMakeSettings) include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) include(ECMQtDeclareLoggingCategory) set(AKONADICALENDAR_LIB_VERSION ${PIM_VERSION}) set(CALENDARCORE_LIB_VERSION "5.12.40") -set(AKONADICONTACT_LIB_VERSION "5.12.43") +set(AKONADICONTACT_LIB_VERSION "5.12.44") set(AKONADI_LIB_VERSION "5.12.40") set(MAILTRANSPORT_LIB_VERSION "5.12.40") set(KCONTACTS_LIB_VERSION "5.12.40") set(CALENDARUTILS_LIB_VERSION "5.12.40") set(IDENTITYMANAGEMENT_LIB_VERSION "5.12.40") ecm_setup_version(PROJECT VARIABLE_PREFIX AKONADICALENDAR VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/akonadi-calendar_version.h" PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KF5AkonadiCalendarConfigVersion.cmake" SOVERSION 5 ) configure_file(akonadi-calendar-version.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/src/akonadi-calendar-version.h @ONLY) if(BUILD_TESTING) add_definitions(-DBUILD_TESTING) endif() ########### Find packages ########### find_package(KF5I18n ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5WidgetsAddons ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5XmlGui ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5KIO ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5Codecs ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5IconThemes ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5DBusAddons ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5MailTransportAkonadi ${MAILTRANSPORT_LIB_VERSION} CONFIG REQUIRED) find_package(KF5IdentityManagement ${IDENTITYMANAGEMENT_LIB_VERSION} CONFIG REQUIRED) find_package(KF5CalendarCore ${CALENDARCORE_LIB_VERSION} CONFIG REQUIRED) find_package(KF5CalendarUtils ${CALENDARUTILS_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Akonadi ${AKONADI_LIB_VERSION} CONFIG REQUIRED) find_package(KF5AkonadiContact ${AKONADICONTACT_LIB_VERSION} CONFIG REQUIRED) ########### Targets ########### add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x060000) add_definitions(-DQT_NO_FOREACH) add_subdirectory(src) add_subdirectory(serializers) if (BUILD_TESTING) add_subdirectory(autotests) endif () ########### CMake Config Files ########### set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF5AkonadiCalendar") configure_package_config_file( "${CMAKE_CURRENT_SOURCE_DIR}/KF5AkonadiCalendarConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/KF5AkonadiCalendarConfig.cmake" INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR} ) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/KF5AkonadiCalendarConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/KF5AkonadiCalendarConfigVersion.cmake" DESTINATION "${CMAKECONFIG_INSTALL_DIR}" COMPONENT Devel ) install(EXPORT KF5AkonadiCalendarTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE KF5AkonadiCalendarTargets.cmake NAMESPACE KF5::) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/akonadi-calendar_version.h DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5} COMPONENT Devel ) install(FILES akonadi-calendar.renamecategories akonadi-calendar.categories DESTINATION ${KDE_INSTALL_LOGGINGCATEGORIESDIR}) feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/src/publishdialog_p.cpp b/src/publishdialog_p.cpp index 2dc8935..5d13d3e 100644 --- a/src/publishdialog_p.cpp +++ b/src/publishdialog_p.cpp @@ -1,146 +1,161 @@ /* Copyright (c) 2001 Cornelius Schumacher Copyright (c) 2009 Allen Winter This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "publishdialog_p.h" #include #include #include #include + #include #include #include #include #include using namespace KCalendarCore; using namespace Akonadi; PublishDialog::Private::Private(PublishDialog *qq) : QObject(), q(qq) { } void PublishDialog::Private::addItem() { mUI.mNameLineEdit->setEnabled(true); mUI.mEmailLineEdit->setEnabled(true); QListWidgetItem *item = mUI.mListWidget->currentItem(); if (item) { if (!item->text().isEmpty()) { item = new QListWidgetItem(mUI.mListWidget); mUI.mListWidget->addItem(item); } } else { item = new QListWidgetItem(mUI.mListWidget); mUI.mListWidget->addItem(item); } item->setSelected(true); mUI.mNameLineEdit->setPlaceholderText(i18n("(EmptyName)")); mUI.mEmailLineEdit->setPlaceholderText(i18n("(EmptyEmail)")); mUI.mListWidget->setCurrentItem(item); mUI.mRemove->setEnabled(true); } void PublishDialog::Private::removeItem() { if (mUI.mListWidget->selectedItems().isEmpty()) { return; } QListWidgetItem *item = mUI.mListWidget->selectedItems().at(0); int row = mUI.mListWidget->row(item); mUI.mListWidget->takeItem(row); if (!mUI.mListWidget->count()) { mUI.mNameLineEdit->setText(QString()); mUI.mNameLineEdit->setEnabled(false); mUI.mEmailLineEdit->setText(QString()); mUI.mEmailLineEdit->setEnabled(false); mUI.mRemove->setEnabled(false); return; } if (row > 0) { row--; } mUI.mListWidget->setCurrentRow(row); } +void PublishDialog::Private::insertAddresses(const KContacts::Addressee::List &list) +{ + for (const KContacts::Addressee &contact : list) { + mUI.mNameLineEdit->setEnabled(true); + mUI.mEmailLineEdit->setEnabled(true); + QListWidgetItem *item = new QListWidgetItem(mUI.mListWidget); + item->setSelected(true); + mUI.mNameLineEdit->setText(contact.name()); + mUI.mEmailLineEdit->setText(contact.preferredEmail()); + mUI.mListWidget->addItem(item); + } +} + + void PublishDialog::Private::openAddressbook() { QPointer dialog; KPluginLoader loader(QStringLiteral("akonadi/emailaddressselectionldapdialogplugin")); KPluginFactory *factory = loader.factory(); if (factory) { dialog = factory->create(q); } else { dialog = new Akonadi::EmailAddressSelectionDialog(q); } dialog->view()->view()->setSelectionMode(QAbstractItemView::MultiSelection); - + connect(dialog.data(), &Akonadi::AbstractEmailAddressSelectionDialog::insertAddresses, this, &PublishDialog::Private::insertAddresses); if (dialog->exec() == QDialog::Accepted) { const Akonadi::EmailAddressSelection::List selections = dialog->selectedAddresses(); if (!selections.isEmpty()) { for (const Akonadi::EmailAddressSelection &selection : selections) { mUI.mNameLineEdit->setEnabled(true); mUI.mEmailLineEdit->setEnabled(true); QListWidgetItem *item = new QListWidgetItem(mUI.mListWidget); item->setSelected(true); mUI.mNameLineEdit->setText(selection.name()); mUI.mEmailLineEdit->setText(selection.email()); mUI.mListWidget->addItem(item); } mUI.mRemove->setEnabled(true); } } delete dialog; } void PublishDialog::Private::updateItem() { if (mUI.mListWidget->selectedItems().isEmpty()) { return; } Person person(mUI.mNameLineEdit->text(), mUI.mEmailLineEdit->text()); QListWidgetItem *item = mUI.mListWidget->selectedItems().at(0); item->setText(person.fullName()); } void PublishDialog::Private::updateInput() { if (mUI.mListWidget->selectedItems().isEmpty()) { return; } mUI.mNameLineEdit->setEnabled(true); mUI.mEmailLineEdit->setEnabled(true); QListWidgetItem *item = mUI.mListWidget->selectedItems().at(0); QString mail, name; KEmailAddress::extractEmailAddressAndName(item->text(), mail, name); mUI.mNameLineEdit->setText(name); mUI.mEmailLineEdit->setText(mail); } diff --git a/src/publishdialog_p.h b/src/publishdialog_p.h index cd181cf..0aabb7e 100644 --- a/src/publishdialog_p.h +++ b/src/publishdialog_p.h @@ -1,48 +1,49 @@ /* Copyright (c) 2001 Cornelius Schumacher This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef AKONADI_PUBLISHDIALOG_P_H #define AKONADI_PUBLISHDIALOG_P_H #include "publishdialog.h" #include "ui_publishdialog_base.h" +#include namespace Akonadi { class Q_DECL_HIDDEN PublishDialog::Private : public QObject { - Q_OBJECT - + Q_OBJECT public: Private(PublishDialog *q); + void insertAddresses(const KContacts::Addressee::List &list); public Q_SLOTS: void addItem(); void removeItem(); void openAddressbook(); void updateItem(); void updateInput(); public: Ui::PublishDialog_base mUI; PublishDialog *q = nullptr; }; } #endif