aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2017-06-20 21:13:41 +0200
committerMontel Laurent <[email protected]>2017-06-20 21:13:41 +0200
commit0353684acdaf065fc115d1854ed13f2e1b25e797 (patch)
treef2cc4e28d09b2a2bf362658e89c949c4020fefeb
parentddaf350bd9ad0e539c92e5c4dce516399271532a (diff)
Remove dependency against akonadit
-rw-r--r--CMakeLists.txt2
-rw-r--r--src/akonadi-contacts/CMakeLists.txt2
-rw-r--r--src/contact-editor/CMakeLists.txt14
-rw-r--r--src/contact-editor/editor/generalinfoeditor/categorieseditwidget.cpp26
-rw-r--r--src/contact-editor/editor/generalinfoeditor/categorieseditwidget.h16
-rw-r--r--src/contact-editor/editor/generalinfoeditor/generalinfowidget.cpp11
-rw-r--r--src/contact-editor/editor/generalinfoeditor/generalinfowidget.h4
-rw-r--r--src/contact-editor/editor/widgets/categorieseditabstractwidget.cpp49
-rw-r--r--src/contact-editor/editor/widgets/categorieseditabstractwidget.h48
9 files changed, 130 insertions, 42 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e162574..b178834 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.0)
-set(PIM_VERSION "5.5.42")
+set(PIM_VERSION "5.5.43")
project(Akonadi-Contact VERSION ${PIM_VERSION})
diff --git a/src/akonadi-contacts/CMakeLists.txt b/src/akonadi-contacts/CMakeLists.txt
index f4e4978..fbce189 100644
--- a/src/akonadi-contacts/CMakeLists.txt
+++ b/src/akonadi-contacts/CMakeLists.txt
@@ -222,4 +222,6 @@ if (BUILD_TESTING)
add_subdirectory(tests)
endif()
+add_subdirectory(plugins)
+
install( FILES akonadi-contacts.categories DESTINATION ${KDE_INSTALL_CONFDIR} )
diff --git a/src/contact-editor/CMakeLists.txt b/src/contact-editor/CMakeLists.txt
index f5a2e42..a5fd2f4 100644
--- a/src/contact-editor/CMakeLists.txt
+++ b/src/contact-editor/CMakeLists.txt
@@ -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
diff --git a/src/contact-editor/editor/generalinfoeditor/categorieseditwidget.cpp b/src/contact-editor/editor/generalinfoeditor/categorieseditwidget.cpp
index 4ac6c95..67c7a8b 100644
--- a/src/contact-editor/editor/generalinfoeditor/categorieseditwidget.cpp
+++ b/src/contact-editor/editor/generalinfoeditor/categorieseditwidget.cpp
@@ -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);
}
diff --git a/src/contact-editor/editor/generalinfoeditor/categorieseditwidget.h b/src/contact-editor/editor/generalinfoeditor/categorieseditwidget.h
index ec8fbb6..6f64523 100644
--- a/src/contact-editor/editor/generalinfoeditor/categorieseditwidget.h
+++ b/src/contact-editor/editor/generalinfoeditor/categorieseditwidget.h
@@ -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
diff --git a/src/contact-editor/editor/generalinfoeditor/generalinfowidget.cpp b/src/contact-editor/editor/generalinfoeditor/generalinfowidget.cpp
index 6cf87f2..ddaef1a 100644
--- a/src/contact-editor/editor/generalinfoeditor/generalinfowidget.cpp
+++ b/src/contact-editor/editor/generalinfoeditor/generalinfowidget.cpp
@@ -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);
diff --git a/src/contact-editor/editor/generalinfoeditor/generalinfowidget.h b/src/contact-editor/editor/generalinfoeditor/generalinfowidget.h
index 9d52ea7..8e11998 100644
--- a/src/contact-editor/editor/generalinfoeditor/generalinfowidget.h
+++ b/src/contact-editor/editor/generalinfoeditor/generalinfowidget.h
@@ -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;
};
}
diff --git a/src/contact-editor/editor/widgets/categorieseditabstractwidget.cpp b/src/contact-editor/editor/widgets/categorieseditabstractwidget.cpp
new file mode 100644
index 0000000..794feb6
--- /dev/null
+++ b/src/contact-editor/editor/widgets/categorieseditabstractwidget.cpp
@@ -0,0 +1,49 @@
+/*
+ This file is part of Contact Editor.
+
+ Copyright (c) 2017 Laurent Montel <[email protected]>
+
+ 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);
+}
diff --git a/src/contact-editor/editor/widgets/categorieseditabstractwidget.h b/src/contact-editor/editor/widgets/categorieseditabstractwidget.h
new file mode 100644
index 0000000..731ecfd
--- /dev/null
+++ b/src/contact-editor/editor/widgets/categorieseditabstractwidget.h
@@ -0,0 +1,48 @@
+/*
+ This file is part of Contact Editor.
+
+ Copyright (c) 2017 Laurent Montel <[email protected]>
+
+ 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