Commit 0353684a authored by Laurent Montel's avatar Laurent Montel 😁

Remove dependency against akonadit

parent ddaf350b
cmake_minimum_required(VERSION 3.0)
set(PIM_VERSION "5.5.42")
set(PIM_VERSION "5.5.43")
project(Akonadi-Contact VERSION ${PIM_VERSION})
......
......@@ -222,4 +222,6 @@ if (BUILD_TESTING)
add_subdirectory(tests)
endif()
add_subdirectory(plugins)
install( FILES akonadi-contacts.categories DESTINATION ${KDE_INSTALL_CONFDIR} )
......@@ -125,6 +125,7 @@ set(contacteditor_editor_SRCS
editor/im/improtocols.cpp
editor/widgets/imagewidget.cpp
editor/widgets/preferredlineeditwidget.cpp
editor/widgets/categorieseditabstractwidget.cpp
customfields.cpp
customfieldmanager.cpp
contactmetadatabase.cpp
......@@ -162,8 +163,6 @@ target_link_libraries(KF5ContactEditor
PUBLIC
KF5::Contacts
Qt5::Widgets
KF5::AkonadiCore
KF5::AkonadiWidgets
PRIVATE
KF5::Completion
KF5::ConfigCore
......@@ -213,13 +212,24 @@ ecm_generate_headers(ContactEditor_CamelCase_HEADERS
PREFIX ContactEditor
)
ecm_generate_headers(ContactEditorWidget_CamelCase_HEADERS
HEADER_NAMES
CategoriesEditAbstractWidget
REQUIRED_HEADERS ContactEditorWidget_HEADERS
PREFIX ContactEditor
RELATIVE editor/widgets/
)
install( FILES
${ContactEditor_CamelCase_HEADERS}
${ContactEditorWidget_CamelCase_HEADERS}
DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/ContactEditor COMPONENT Devel
)
install( FILES
${ContactEditor_HEADERS}
${ContactEditorWidget_HEADERS}
${CMAKE_CURRENT_BINARY_DIR}/contacteditor_export.h
editor/im/improtocols.h
DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/contacteditor COMPONENT Devel
......
......@@ -21,20 +21,15 @@
#include "categorieseditwidget.h"
#include <item.h>
#include <tag.h>
#include <tagwidget.h>
#include <kcontacts/addressee.h>
#include <QHBoxLayout>
CategoriesEditWidget::CategoriesEditWidget(QWidget *parent)
: QWidget(parent)
: ContactEditor::CategoriesEditAbstractWidget(parent)
{
QHBoxLayout *layout = new QHBoxLayout(this);
layout->setMargin(0);
mTagWidget = new Akonadi::TagWidget(this);
layout->addWidget(mTagWidget);
}
CategoriesEditWidget::~CategoriesEditWidget()
......@@ -43,31 +38,12 @@ CategoriesEditWidget::~CategoriesEditWidget()
void CategoriesEditWidget::setReadOnly(bool readOnly)
{
mTagWidget->setEnabled(!readOnly);
}
void CategoriesEditWidget::loadContact(const KContacts::Addressee &contact)
{
Akonadi::Tag::List tags;
const QStringList categories = contact.categories();
tags.reserve(categories.count());
for (const QString &category : categories) {
tags.append(Akonadi::Tag::fromUrl(QUrl(category)));
}
mTagWidget->setSelection(tags);
}
void CategoriesEditWidget::storeContact(KContacts::Addressee &contact) const
{
QStringList categories;
const Akonadi::Tag::List tags = mTagWidget->selection();
categories.reserve(tags.count());
for (const Akonadi::Tag &tag : tags) {
categories.append(tag.url().url());
}
contact.setCategories(categories);
}
......@@ -26,15 +26,12 @@
#include <kcontacts/addressee.h>
namespace Akonadi
{
class TagWidget;
}
#include <editor/widgets/categorieseditabstractwidget.h>
/**
* @short A widget for editing the categories of a contact.
*/
class CategoriesEditWidget : public QWidget
class CategoriesEditWidget : public ContactEditor::CategoriesEditAbstractWidget
{
Q_OBJECT
......@@ -42,13 +39,10 @@ public:
explicit CategoriesEditWidget(QWidget *parent = nullptr);
~CategoriesEditWidget();
void loadContact(const KContacts::Addressee &contact);
void storeContact(KContacts::Addressee &contact) const;
void setReadOnly(bool readOnly);
void loadContact(const KContacts::Addressee &contact) override;
void storeContact(KContacts::Addressee &contact) const override;
private:
Akonadi::TagWidget *mTagWidget;
void setReadOnly(bool readOnly) override;
};
#endif
......@@ -34,6 +34,9 @@
#include "categorieseditwidget.h"
#include "../widgets/imagewidget.h"
#include "messageformattingwidget.h"
#include <KPluginLoader>
#include <KPluginFactory>
#include <QDebug>
using namespace ContactEditor;
......@@ -86,7 +89,13 @@ GeneralInfoWidget::GeneralInfoWidget(QWidget *parent)
label->setObjectName(QStringLiteral("categorylabel"));
categoryWidgetLayout->addWidget(label);
mCategoriesWidget = new CategoriesEditWidget(this);
KPluginLoader loader(QStringLiteral("akonadi/contacts/plugins/categorieseditwidgetplugin"));
KPluginFactory *factory = loader.factory();
if (factory) {
mCategoriesWidget = factory->create<ContactEditor::CategoriesEditAbstractWidget>(parent);
} else {
mCategoriesWidget = new CategoriesEditWidget(parent);
}
mCategoriesWidget->setObjectName(QStringLiteral("categories"));
categoryWidgetLayout->addWidget(mCategoriesWidget);
leftLayout->addWidget(categoryWidget);
......
......@@ -26,7 +26,6 @@
#include <QWidget>
#include "displaynameeditwidget.h"
class ImageWidget;
class CategoriesEditWidget;
namespace KContacts
{
class Addressee;
......@@ -34,6 +33,7 @@ class Addressee;
namespace ContactEditor
{
class CategoriesEditAbstractWidget;
class PhoneListWidget;
class WebListWidget;
class MessagingListWidget;
......@@ -63,7 +63,7 @@ private:
ImageWidget *mPhotoWidget;
NameWidget *mNameWidget;
NicknameWidget *mNickNameWidget;
CategoriesEditWidget *mCategoriesWidget;
ContactEditor::CategoriesEditAbstractWidget *mCategoriesWidget;
MessageFormattingWidget *mMessageFormattingWidget;
};
}
......
/*
This file is part of Contact Editor.
Copyright (c) 2017 Laurent Montel <montel@kde.org>
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 "categorieseditabstractwidget.h"
using namespace ContactEditor;
CategoriesEditAbstractWidget::CategoriesEditAbstractWidget(QWidget *parent)
: QWidget(parent)
{
}
CategoriesEditAbstractWidget::~CategoriesEditAbstractWidget()
{
}
void CategoriesEditAbstractWidget::loadContact(const KContacts::Addressee &contact)
{
Q_UNUSED(contact);
}
void CategoriesEditAbstractWidget::storeContact(KContacts::Addressee &contact) const
{
Q_UNUSED(contact);
}
void CategoriesEditAbstractWidget::setReadOnly(bool readOnly)
{
Q_UNUSED(readOnly);
}
/*
This file is part of Contact Editor.
Copyright (c) 2017 Laurent Montel <montel@kde.org>
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 CATEGORIESEDITABSTRACTWIDGET_H
#define CATEGORIESEDITABSTRACTWIDGET_H
#include <QWidget>
#include "contacteditor_export.h"
namespace KContacts
{
class Addressee;
}
namespace ContactEditor
{
class CONTACTEDITOR_EXPORT CategoriesEditAbstractWidget : public QWidget
{
Q_OBJECT
public:
explicit CategoriesEditAbstractWidget(QWidget *parent = nullptr);
~CategoriesEditAbstractWidget();
virtual void loadContact(const KContacts::Addressee &contact);
virtual void storeContact(KContacts::Addressee &contact) const;
virtual void setReadOnly(bool readOnly);
};
}
#endif // CATEGORIESEDITABSTRACTWIDGET_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment