diff --git a/CMakeLists.txt b/CMakeLists.txt index a3036cf..f2704b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,96 +1,95 @@ cmake_minimum_required(VERSION 3.5) set(KF5_VERSION "5.67.0") # handled by release scripts set(KF5_DEP_VERSION "5.66.0") # handled by release scripts project (KPeople VERSION ${KF5_VERSION}) include(FeatureSummary) find_package(ECM 5.66.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) set(REQUIRED_QT_VERSION 5.12.0) find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Gui Sql Widgets Qml) if(NOT ANDROID) find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED DBus) endif() find_package(KF5CoreAddons ${KF5_DEP_VERSION} CONFIG REQUIRED) find_package(KF5WidgetsAddons ${KF5_DEP_VERSION} CONFIG REQUIRED) find_package(KF5I18n ${KF5_DEP_VERSION} CONFIG REQUIRED) find_package(KF5ItemViews ${KF5_DEP_VERSION} CONFIG REQUIRED) -find_package(KF5Service ${KF5_DEP_VERSION} CONFIG REQUIRED) include(KDEInstallDirs) include(KDECMakeSettings) include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) include(ECMSetupVersion) include(ECMGenerateHeaders) include(ECMSetupVersion) include(ECMAddTests) include(ECMAddQch) include(CMakePackageConfigHelpers) include(ECMGeneratePriFile) include(GenerateExportHeader) include(ECMQtDeclareLoggingCategory) option(BUILD_QCH "Build API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)" OFF) add_feature_info(QCH ${BUILD_QCH} "API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)") add_definitions(-DTRANSLATION_DOMAIN=\"kpeople5\") set(CMAKECONFIG_INSTALL_DIR "${CMAKECONFIG_INSTALL_PREFIX}/KF5People") ecm_setup_version(PROJECT VARIABLE_PREFIX KPEOPLE VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/kpeople_version.h" PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KF5PeopleConfigVersion.cmake" SOVERSION 5) option(ENABLE_EXAMPLES "Build the examples" "ON") if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/po") ki18n_install(po) endif () add_definitions(-DQT_NO_FOREACH) add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050d00) add_definitions(-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x054200) add_definitions(-DKSERVICE_DISABLE_DEPRECATED_BEFORE_AND_AT=0x04ff00) # TODO: PersonDetailsView(QWidget *) constructor still calls KPluginInfo::fromServices() (deprecated at 5.0) # investigate if needed add_subdirectory (src) if (ENABLE_EXAMPLES) add_subdirectory(examples) endif() if (BUILD_TESTING) add_subdirectory(autotests) endif() if (BUILD_QCH) ecm_install_qch_export( TARGETS KF5People_QCH FILE KF5PeopleQchTargets.cmake DESTINATION "${CMAKECONFIG_INSTALL_DIR}" COMPONENT Devel ) set(PACKAGE_INCLUDE_QCHTARGETS "include(\"\${CMAKE_CURRENT_LIST_DIR}/KF5PeopleQchTargets.cmake\")") endif() configure_package_config_file( "${CMAKE_CURRENT_SOURCE_DIR}/KF5PeopleConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/KF5PeopleConfig.cmake" INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR} ) install(EXPORT KPeopleTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE KPeopleTargets.cmake NAMESPACE KF5::) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/KF5PeopleConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/KF5PeopleConfigVersion.cmake" DESTINATION "${CMAKECONFIG_INSTALL_DIR}" COMPONENT Devel ) install(FILES kpeople.categories DESTINATION ${KDE_INSTALL_LOGGINGCATEGORIESDIR}) feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dfae22b..35f029c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,126 +1,125 @@ include_directories (${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ) add_subdirectory(declarative) add_subdirectory(plugins) add_subdirectory(widgets) add_subdirectory(backends) ecm_qt_declare_logging_category(KF5People_debug_SRCS HEADER kpeople_debug.h IDENTIFIER KPEOPLE_LOG CATEGORY_NAME kf5.kpeople) add_library (KF5People ${KF5People_debug_SRCS} global.cpp metacontact.cpp persondata.cpp matchessolver.cpp match.cpp duplicatesfinder.cpp personsmodel.cpp personpluginmanager.cpp personmanager.cpp personssortfilterproxymodel.cpp resources.qrc ) add_library(KF5::People ALIAS KF5People) target_link_libraries (KF5People PUBLIC Qt5::Gui PRIVATE Qt5::Sql KF5::I18n KF5::CoreAddons KF5::PeopleBackend - KF5::Service ) if(NOT ANDROID) target_link_libraries(KF5People PRIVATE Qt5::DBus) endif() set_target_properties (KF5People PROPERTIES VERSION ${KPEOPLE_VERSION_STRING} SOVERSION ${KPEOPLE_SOVERSION} EXPORT_NAME People) target_include_directories (KF5People PUBLIC "$" INTERFACE "$" ) if (MSVC) set_target_properties (KF5People PROPERTIES OUTPUT_NAME libkpeople ) endif (MSVC) # Install: install (TARGETS KF5People EXPORT KPeopleTargets ${KF5_INSTALL_TARGETS_DEFAULT_ARGS} ) ecm_generate_headers(KPeople_CamelCase_HEADERS HEADER_NAMES PersonData PersonPluginManager PersonsModel Global REQUIRED_HEADERS KPeople_HEADERS PREFIX KPeople ) install (FILES ${KPeople_CamelCase_HEADERS} DESTINATION ${KF5_INCLUDE_INSTALL_DIR}/KPeople/KPeople COMPONENT Devel ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kpeople/kpeople_export.h ${KPeople_HEADERS} DESTINATION ${KF5_INCLUDE_INSTALL_DIR}/KPeople/kpeople COMPONENT Devel ) generate_export_header(KF5People EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/kpeople/kpeople_export.h BASE_NAME KPeople) if(BUILD_QCH) ecm_add_qch( KF5People_QCH NAME KPeople BASE_NAME KF5People VERSION ${KF5_VERSION} ORG_DOMAIN org.kde SOURCES # using only public headers, to cover only public API ${KPeople_HEADERS} ${KPeopleWidgets_QCH_SOURCES} ${KPeopleBackend_QCH_SOURCES} MD_MAINPAGE "${CMAKE_SOURCE_DIR}/README.md" LINK_QCHS Qt5Gui_QCH Qt5Widgets_QCH BLANK_MACROS KPEOPLE_EXPORT KPEOPLE_DEPRECATED KPEOPLE_DEPRECATED_EXPORT KPEOPLEWIDGETS_EXPORT KPEOPLEWIDGETS_DEPRECATED KPEOPLEWIDGETS_DEPRECATED_EXPORT KPEOPLEBACKEND_EXPORT KPEOPLEBACKEND_DEPRECATED KPEOPLEBACKEND_DEPRECATED_EXPORT TAGFILE_INSTALL_DESTINATION ${KDE_INSTALL_QTQCHDIR} QCH_INSTALL_DESTINATION ${KDE_INSTALL_QTQCHDIR} COMPONENT Devel ) endif() install (FILES kpeople_data_source.desktop kpeople_plugin.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR} ) ecm_generate_pri_file(BASE_NAME KPeople LIB_NAME KF5ConfigCore DEPS "gui" FILENAME_VAR PRI_FILENAME INCLUDE_INSTALL_DIR ${KDE_INSTALL_INCLUDEDIR_KF5}/KPeople) install(FILES ${PRI_FILENAME} DESTINATION ${ECM_MKSPECS_INSTALL_DIR}) if (ANDROID) install(FILES KF5People-android-dependencies.xml DESTINATION ${KDE_INSTALL_LIBDIR}) endif() diff --git a/src/personpluginmanager.cpp b/src/personpluginmanager.cpp index cf7c93d..a3e87bd 100644 --- a/src/personpluginmanager.cpp +++ b/src/personpluginmanager.cpp @@ -1,163 +1,148 @@ /* Copyright (C) 2013 David Edmundson This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "personpluginmanager.h" #include "backends/basepersonsdatasource.h" #include #include #include -#include -#include #include #include #include "kpeople_debug.h" using namespace KPeople; class PersonPluginManagerPrivate { public: PersonPluginManagerPrivate(); ~PersonPluginManagerPrivate(); QHash dataSourcePlugins; void loadDataSourcePlugins(); bool m_autoloadDataSourcePlugins; bool m_loadedDataSourcePlugins; QMutex m_mutex; }; Q_GLOBAL_STATIC(PersonPluginManagerPrivate, s_instance) PersonPluginManagerPrivate::PersonPluginManagerPrivate() : m_autoloadDataSourcePlugins(true) , m_loadedDataSourcePlugins(false) { } PersonPluginManagerPrivate::~PersonPluginManagerPrivate() { qDeleteAll(dataSourcePlugins); } void PersonPluginManagerPrivate::loadDataSourcePlugins() { const QVector pluginList = KPluginLoader::findPlugins(QStringLiteral("kpeople/datasource")); for (const KPluginMetaData &service : pluginList) { KPluginLoader loader(service.fileName()); KPluginFactory *factory = loader.factory(); BasePersonsDataSource *dataSource = factory->create(); if (dataSource) { const QString pluginId = dataSource->sourcePluginId(); if (!dataSourcePlugins.contains(pluginId)) { dataSourcePlugins[pluginId] = dataSource; } else { dataSource->deleteLater(); qCDebug(KPEOPLE_LOG) << "Plugin" << pluginId << "was already loaded manually, ignoring..."; } } else { qCWarning(KPEOPLE_LOG) << "Failed to create data source " << service.name() << service.fileName(); } } - //TODO: Remove as soon as KTp sources are released with the new plugin system - const KService::List servicesList = KServiceTypeTrader::self()->query(QStringLiteral("KPeople/DataSource")); - for (const KService::Ptr &service : servicesList) { - BasePersonsDataSource *dataSource = service->createInstance(nullptr); - - - if (dataSource) { - dataSourcePlugins[dataSource->sourcePluginId()] = dataSource; - } else { - qCWarning(KPEOPLE_LOG) << "Failed to create data source " << service->name() << service->entryPath(); - } - } - m_loadedDataSourcePlugins = true; } void PersonPluginManager::setAutoloadDataSourcePlugins(bool autoloadDataSourcePlugins) { s_instance->m_autoloadDataSourcePlugins = autoloadDataSourcePlugins; } void PersonPluginManager::addDataSource(const QString &sourceId, BasePersonsDataSource *source) { QMutexLocker(&s_instance->m_mutex); if (s_instance->dataSourcePlugins.contains(sourceId)) { qCWarning(KPEOPLE_LOG) << "Attempting to load data source that is already loaded, overriding!"; s_instance->dataSourcePlugins[sourceId]->deleteLater(); } s_instance->dataSourcePlugins.insert(sourceId, source); } void PersonPluginManager::setDataSourcePlugins(const QHash &dataSources) { QMutexLocker(&s_instance->m_mutex); qDeleteAll(s_instance->dataSourcePlugins); s_instance->dataSourcePlugins = dataSources; s_instance->m_loadedDataSourcePlugins = true; } QList PersonPluginManager::dataSourcePlugins() { QMutexLocker(&s_instance->m_mutex); if (!s_instance->m_loadedDataSourcePlugins && s_instance->m_autoloadDataSourcePlugins) { s_instance->loadDataSourcePlugins(); } return s_instance->dataSourcePlugins.values(); } BasePersonsDataSource *PersonPluginManager::dataSource(const QString &sourceId) { QMutexLocker(&s_instance->m_mutex); if (!s_instance->m_loadedDataSourcePlugins && s_instance->m_autoloadDataSourcePlugins) { s_instance->loadDataSourcePlugins(); } return s_instance->dataSourcePlugins.value(sourceId); } bool KPeople::PersonPluginManager::addContact(const QVariantMap& properties) { bool ret = false; for (auto p : qAsConst(s_instance->dataSourcePlugins)) { auto v2 = dynamic_cast(p); if (!v2) continue; const bool added = v2->addContact(properties); ret |= added; } return ret; } bool KPeople::PersonPluginManager::deleteContact(const QString &uri) { bool ret = false; for (auto p : qAsConst(s_instance->dataSourcePlugins)) { auto v2 = dynamic_cast(p); if (!v2) continue; const bool deleted = v2->deleteContact(uri); ret |= deleted; } return ret; } diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt index 66b1a5a..deae2cd 100644 --- a/src/widgets/CMakeLists.txt +++ b/src/widgets/CMakeLists.txt @@ -1,80 +1,79 @@ # add_subdirectory(plugins) set (kpeople_widgets_SRCS persondetailsdialog.cpp persondetailsview.cpp persondetailsdialog.cpp plugins/emaildetailswidget.cpp abstractfieldwidgetfactory.cpp actions.cpp mergedialog.cpp mergedelegate.cpp ) ecm_qt_declare_logging_category(kpeople_widgets_SRCS HEADER kpeople_widgets_debug.h IDENTIFIER KPEOPLE_WIDGETS_LOG CATEGORY_NAME kf5.kpeople.widgets) qt5_wrap_ui (kpeople_widgets_SRCS person-details-presentation.ui) add_library (KF5PeopleWidgets SHARED ${kpeople_widgets_SRCS} ) add_library (KF5::PeopleWidgets ALIAS KF5PeopleWidgets) target_link_libraries (KF5PeopleWidgets PUBLIC KF5::People Qt5::Widgets PRIVATE KF5::I18n KF5::ItemViews KF5::WidgetsAddons KF5::PeopleBackend KF5::CoreAddons - KF5::Service ) set_target_properties (KF5PeopleWidgets PROPERTIES VERSION ${KPEOPLE_VERSION_STRING} SOVERSION ${KPEOPLE_SOVERSION} EXPORT_NAME PeopleWidgets) if (MSVC) set_target_properties (KF5PeopleWidgets PROPERTIES OUTPUT_NAME libKPeopleWidgets ) endif (MSVC) # Install: install (TARGETS KF5PeopleWidgets EXPORT KPeopleTargets ${INSTALL_TARGETS_DEFAULT_ARGS} ) ecm_generate_headers(KPeopleWidgets_CamelCase_HEADERS HEADER_NAMES AbstractFieldWidgetFactory PersonDetailsView MergeDialog PersonDetailsDialog Actions REQUIRED_HEADERS KPeopleWidgets_HEADERS PREFIX KPeople/Widgets ) install (FILES ${KPeopleWidgets_CamelCase_HEADERS} DESTINATION ${KF5_INCLUDE_INSTALL_DIR}/KPeople/KPeople/Widgets COMPONENT Devel ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/kpeople/widgets/kpeoplewidgets_export.h ${KPeopleWidgets_HEADERS} DESTINATION ${KF5_INCLUDE_INSTALL_DIR}/KPeople/kpeople/widgets COMPONENT Devel ) generate_export_header(KF5PeopleWidgets EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/kpeople/widgets/kpeoplewidgets_export.h BASE_NAME KPeopleWidgets) install (FILES persondetailsplugin.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR} ) ecm_generate_pri_file(BASE_NAME KPeopleWidgets LIB_NAME KF5ConfigCore DEPS "widgets KPeople" FILENAME_VAR PRI_FILENAME INCLUDE_INSTALL_DIR ${KDE_INSTALL_INCLUDEDIR_KF5}/KPeople) install(FILES ${PRI_FILENAME} DESTINATION ${ECM_MKSPECS_INSTALL_DIR}) # make available to ecm_add_qch in parent folder set(KPeopleWidgets_QCH_SOURCES ${KPeopleWidgets_HEADERS} PARENT_SCOPE) diff --git a/src/widgets/actions.cpp b/src/widgets/actions.cpp index a92d29d..a88caa9 100644 --- a/src/widgets/actions.cpp +++ b/src/widgets/actions.cpp @@ -1,78 +1,65 @@ /* Copyright (C) 2015 Aleix Pol i Gonzalez This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "actions.h" #include #include "kpeople_widgets_debug.h" #include #include #include #include -#include #include "../backends/abstractpersonaction.h" namespace KPeople { static QList actionsPlugins() { QList actionPlugins; const QVector personPluginList = KPluginLoader::findPlugins(QStringLiteral("kpeople/actions")); for (const KPluginMetaData &service : personPluginList) { KPluginLoader loader(service.fileName()); KPluginFactory *factory = loader.factory(); if (!factory) { qCWarning(KPEOPLE_WIDGETS_LOG) << "Couldn't create the factory for" << service.name() << "at" << service.fileName(); continue; } AbstractPersonAction *plugin = factory->create(); if (plugin) { // qCDebug(KPEOPLE_WIDGETS_LOG) << "found plugin" << service->name(); actionPlugins << plugin; } } - //TODO: Remove as soon as KTp sources are released with the new plugin system - const KService::List personServicesList = KServiceTypeTrader::self()->query(QStringLiteral("KPeople/Plugin")); - for (const KService::Ptr &service : personServicesList) { - AbstractPersonAction *plugin = service->createInstance(nullptr); - - - if (plugin) { -// qCDebug(KPEOPLE_WIDGETS_LOG) << "found plugin" << service->name(); - actionPlugins << plugin; - } - } - return actionPlugins; } QList actionsForPerson(const QString &contactUri, QObject *parent) { PersonData person(contactUri); QList actions; const auto lst = actionsPlugins(); for (KPeople::AbstractPersonAction *plugin : lst) { actions << plugin->actionsForPerson(person, parent); } return actions; } } diff --git a/src/widgets/persondetailsview.cpp b/src/widgets/persondetailsview.cpp index 243124b..61455a0 100644 --- a/src/widgets/persondetailsview.cpp +++ b/src/widgets/persondetailsview.cpp @@ -1,220 +1,206 @@ /* Copyright (C) 2011 Martin Klapetek Copyright (C) 2013 David Edmundson This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "persondetailsview.h" #include #include #include #include "kpeople_widgets_debug.h" #include #include #include #include #include -#include -#include #include "abstractfieldwidgetfactory.h" #include "plugins/emaildetailswidget.h" #include "global.h" #include "ui_person-details-presentation.h" namespace KPeople { class PersonDetailsViewPrivate { public: PersonData *m_person; Ui::PersonDetailsPresentation *m_personDetailsPresentation; QWidget *m_mainWidget; QList m_plugins; }; } using namespace KPeople; class CoreFieldsPlugin : public AbstractFieldWidgetFactory { public: CoreFieldsPlugin(const QString &field); ~CoreFieldsPlugin() override; QString label() const override; int sortWeight() const override; QWidget *createDetailsWidget(const PersonData &person, QWidget *parent) const override; private: QString m_field; }; CoreFieldsPlugin::CoreFieldsPlugin(const QString &field): m_field(field) { } CoreFieldsPlugin::~CoreFieldsPlugin() { } QString CoreFieldsPlugin::label() const { #ifdef __GNUC__ #warning fixme, should be made user-visible somehow #endif return m_field; } int CoreFieldsPlugin::sortWeight() const { return 1; } QWidget *CoreFieldsPlugin::createDetailsWidget(const PersonData &person, QWidget *parent) const { // we have a plugin specific for e-mails. if (m_field == QLatin1String("email")) { return nullptr; } QString text = person.contactCustomProperty(m_field).toString(); if (text.isEmpty()) { return nullptr; } return new QLabel(text, parent); } PersonDetailsView::PersonDetailsView(QWidget *parent) : QWidget(parent), d_ptr(new PersonDetailsViewPrivate()) { Q_D(PersonDetailsView); setLayout(new QVBoxLayout(this)); d->m_mainWidget = new QWidget(this); d->m_person = nullptr; QWidget *details = new QWidget(); d->m_personDetailsPresentation = new Ui::PersonDetailsPresentation(); d->m_personDetailsPresentation->setupUi(details); layout()->addWidget(details); layout()->addWidget(d->m_mainWidget); layout()->addItem(new QSpacerItem(1, 1, QSizePolicy::Fixed, QSizePolicy::Expanding)); //create plugins #ifdef __GNUC__ #warning figure out a way to list properties #endif const QStringList fields { QStringLiteral("name"), QStringLiteral("all-email") }; for (const QString &field : fields) { d->m_plugins << new CoreFieldsPlugin(field); } d->m_plugins << new EmailFieldsPlugin(); // load every KPeopleWidgets Plugin const QVector personPluginList = KPluginLoader::findPlugins(QStringLiteral("kpeople/widgets")); for (const KPluginMetaData &service : personPluginList) { KPluginLoader loader(service.fileName()); KPluginFactory *factory = loader.factory(); AbstractFieldWidgetFactory *f = factory->create(); Q_ASSERT(f); if (f) { d->m_plugins << f; } } - //TODO: Remove as soon as KTp sources are released with the new plugin system - KService::List pluginList = KServiceTypeTrader::self()->query(QStringLiteral("KPeopleWidgets/Plugin")); - const QList plugins = KPluginInfo::fromServices(pluginList); - - for (const KPluginInfo &p : plugins) { - QString error; - AbstractFieldWidgetFactory *f = p.service()->createInstance(this, QVariantList(), &error); - if (f) { - d->m_plugins << f; - } - } - //TODO Sort plugins } PersonDetailsView::~PersonDetailsView() { delete d_ptr; } void PersonDetailsView::setPerson(PersonData *person) { Q_D(PersonDetailsView); if (d->m_person) { disconnect(d->m_person, SIGNAL(dataChanged()), this, SLOT(reload())); } d->m_person = person; connect(d->m_person, SIGNAL(dataChanged()), this, SLOT(reload())); reload(); } // void PersonDetailsView::setPersonsModel(PersonsModel *model) // { // Q_D(PersonDetailsView); // Q_FOREACH (AbstractPersonDetailsWidget *detailsWidget, d->m_detailWidgets) { // detailsWidget->setPersonsModel(model); // } // } void PersonDetailsView::reload() { Q_D(PersonDetailsView); //replace the entire main widget int layoutIndex = layout()->indexOf(d->m_mainWidget); layout()->takeAt(layoutIndex); d->m_mainWidget->deleteLater(); d->m_mainWidget = new QWidget(this); dynamic_cast(layout())->insertWidget(layoutIndex, d->m_mainWidget); QFormLayout *layout = new QFormLayout(d->m_mainWidget); layout->setSpacing(4); //update header information //FIXME - possibly split this out into a new class with a nice setPerson method QPixmap avatar = d->m_person->photo(); d->m_personDetailsPresentation->avatarPixmapLabel->setPixmap(avatar.scaled(96, 96, Qt::KeepAspectRatio)); //FIXME d->m_personDetailsPresentation->presencePixmapLabel->setPixmap(QIcon::fromTheme(d->m_person->presenceIconName()).pixmap(32, 32)); //FIXME d->m_personDetailsPresentation->nameLabel->setText(d->m_person->name()); for (AbstractFieldWidgetFactory *widgetFactory : qAsConst(d->m_plugins)) { const QString label = widgetFactory->label() + QLatin1Char(':'); QWidget *widget = widgetFactory->createDetailsWidget(d->m_person->personUri(), this); if (widget) { QFont font = widget->font(); font.setBold(true); widget->setFont(font); QLabel *widgetLabel = new QLabel(label, this); layout->addRow(widgetLabel, widget); } } }