diff --git a/src/declarative/personactionsmodel.cpp b/src/declarative/personactionsmodel.cpp index 6cd2dce..c150b98 100644 --- a/src/declarative/personactionsmodel.cpp +++ b/src/declarative/personactionsmodel.cpp @@ -1,142 +1,142 @@ /* Copyright (C) 2013 Martin Klapetek 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 "personactionsmodel_p.h" -#include -#include +#include "persondata.h" +#include "widgets/actions.h" #include #include "kpeople_debug.h" #include namespace KPeople { struct PersonActionsPrivate { PersonActionsPrivate() : person(nullptr) {} QList actions; QString id; KPeople::PersonData *person; }; } using namespace KPeople; PersonActionsModel::PersonActionsModel(QObject *parent) : QAbstractListModel(parent), d_ptr(new PersonActionsPrivate) { } PersonActionsModel::~PersonActionsModel() { delete d_ptr; } QHash PersonActionsModel::roleNames() const { QHash roles = QAbstractListModel::roleNames(); roles[IconNameRole] = "iconName"; roles[ActionRole] = "action"; roles[ActionTypeRole] = "actionType"; return roles; } void PersonActionsModel::setPersonUri(const QString &id) { Q_D(PersonActions); if (id == d->id) { return; } delete d->person; d->id = id; if (!id.isEmpty()) { d->person = new PersonData(id, this); connect(d->person, &PersonData::dataChanged, this, &PersonActionsModel::resetActions); resetActions(); } else { d->actions.clear(); } emit personChanged(); } void PersonActionsModel::resetActions() { Q_D(PersonActions); beginResetModel(); d->actions = KPeople::actionsForPerson(d->id, this); endResetModel(); } QString PersonActionsModel::personUri() const { Q_D(const PersonActions); return d->id; } QVariant PersonActionsModel::data(const QModelIndex &index, int role) const { Q_D(const PersonActions); if (!index.isValid()) { return QVariant(); } switch (role) { case Qt::DisplayRole: return d->actions[index.row()]->text(); case Qt::DecorationRole: return d->actions[index.row()]->icon(); case Qt::ToolTip: return d->actions[index.row()]->toolTip(); case IconNameRole: return d->actions[index.row()]->icon().name(); case ActionRole: return QVariant::fromValue(d->actions[index.row()]); case ActionTypeRole: return d->actions[index.row()]->property("actionType"); } return QVariant(); } int PersonActionsModel::rowCount(const QModelIndex &parent) const { Q_D(const PersonActions); return parent.isValid() ? 0 : d->actions.size(); } void PersonActionsModel::triggerAction(int row) const { Q_D(const PersonActions); d->actions[row]->trigger(); } QList< QAction * > PersonActionsModel::actions() const { Q_D(const PersonActions); return d->actions; } diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt index 6cd1a77..66b1a5a 100644 --- a/src/widgets/CMakeLists.txt +++ b/src/widgets/CMakeLists.txt @@ -1,86 +1,80 @@ # 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} ) -install (FILES - - DESTINATION ${INCLUDE_INSTALL_DIR}/kpeople/widgets - COMPONENT Devel -) - ecm_generate_headers(KPeopleWidgets_CamelCase_HEADERS HEADER_NAMES AbstractFieldWidgetFactory PersonDetailsView MergeDialog PersonDetailsDialog Actions REQUIRED_HEADERS KPeopleWidgets_HEADERS - PREFIX KPeople + 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)