Commit 57fd315f authored by Laurent Montel's avatar Laurent Montel 😁

Now editor doesn't depend against akonadi

parent 0cebc5cc
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.0)
set(PIM_VERSION "5.5.40") set(PIM_VERSION "5.5.41")
project(Akonadi-Contact VERSION ${PIM_VERSION}) project(Akonadi-Contact VERSION ${PIM_VERSION})
......
...@@ -149,7 +149,8 @@ set(akonadicontact_LIB_SRC ...@@ -149,7 +149,8 @@ set(akonadicontact_LIB_SRC
contactgroupmodel.cpp contactgroupmodel.cpp
contactgroupviewer.cpp contactgroupviewer.cpp
contactgroupviewerdialog.cpp contactgroupviewerdialog.cpp
contactmetadata.cpp contactmetadataakonadi.cpp
contactmetadatabase.cpp
contactparts.cpp contactparts.cpp
contactsfilterproxymodel.cpp contactsfilterproxymodel.cpp
contactstreemodel.cpp contactstreemodel.cpp
......
...@@ -32,7 +32,7 @@ class Addressee; ...@@ -32,7 +32,7 @@ class Addressee;
namespace Akonadi namespace Akonadi
{ {
class ContactMetaData; class ContactMetaDataBase;
class AbstractContactEditorWidget : public QWidget class AbstractContactEditorWidget : public QWidget
{ {
...@@ -42,7 +42,7 @@ public: ...@@ -42,7 +42,7 @@ public:
* *
* @param parent The parent widget. * @param parent The parent widget.
*/ */
AbstractContactEditorWidget(QWidget *parent = 0) explicit AbstractContactEditorWidget(QWidget *parent = nullptr)
: QWidget(parent) : QWidget(parent)
{ {
} }
...@@ -57,12 +57,12 @@ public: ...@@ -57,12 +57,12 @@ public:
/** /**
* @param contact loads the given contact into the editor widget * @param contact loads the given contact into the editor widget
*/ */
virtual void loadContact(const KContacts::Addressee &contact, const Akonadi::ContactMetaData &metaData) = 0; virtual void loadContact(const KContacts::Addressee &contact, const Akonadi::ContactMetaDataBase &metaData) = 0;
/** /**
* @param contact store the given contact into the editor widget * @param contact store the given contact into the editor widget
*/ */
virtual void storeContact(KContacts::Addressee &contact, Akonadi::ContactMetaData &metaData) const = 0; virtual void storeContact(KContacts::Addressee &contact, Akonadi::ContactMetaDataBase &metaData) const = 0;
/** /**
* @param readOnly set read-only mode * @param readOnly set read-only mode
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include "abstractcontacteditorwidget_p.h" #include "abstractcontacteditorwidget_p.h"
#include "autoqpointer_p.h" #include "autoqpointer_p.h"
#include "contactmetadata_p.h" #include "contactmetadataakonadi_p.h"
#include "attributes/contactmetadataattribute_p.h" #include "attributes/contactmetadataattribute_p.h"
#include "editor/contacteditorwidget.h" #include "editor/contacteditorwidget.h"
...@@ -75,14 +75,14 @@ public: ...@@ -75,14 +75,14 @@ public:
void storeDone(KJob *job); void storeDone(KJob *job);
void itemChanged(const Akonadi::Item &item, const QSet<QByteArray> &); void itemChanged(const Akonadi::Item &item, const QSet<QByteArray> &);
void loadContact(const KContacts::Addressee &addr, const ContactMetaData &metaData); void loadContact(const KContacts::Addressee &addr, const ContactMetaDataAkonadi &metaData);
void storeContact(KContacts::Addressee &addr, ContactMetaData &metaData); void storeContact(KContacts::Addressee &addr, ContactMetaDataAkonadi &metaData);
void setupMonitor(); void setupMonitor();
ContactEditor *mParent; ContactEditor *mParent;
ContactEditor::Mode mMode; ContactEditor::Mode mMode;
Akonadi::Item mItem; Akonadi::Item mItem;
Akonadi::ContactMetaData mContactMetaData; Akonadi::ContactMetaDataAkonadi mContactMetaData;
Akonadi::Monitor *mMonitor; Akonadi::Monitor *mMonitor;
Akonadi::Collection mDefaultCollection; Akonadi::Collection mDefaultCollection;
AbstractContactEditorWidget *mEditorWidget; AbstractContactEditorWidget *mEditorWidget;
...@@ -183,12 +183,12 @@ void ContactEditor::Private::itemChanged(const Akonadi::Item &item, const QSet<Q ...@@ -183,12 +183,12 @@ void ContactEditor::Private::itemChanged(const Akonadi::Item &item, const QSet<Q
delete dlg; delete dlg;
} }
void ContactEditor::Private::loadContact(const KContacts::Addressee &addr, const ContactMetaData &metaData) void ContactEditor::Private::loadContact(const KContacts::Addressee &addr, const ContactMetaDataAkonadi &metaData)
{ {
mEditorWidget->loadContact(addr, metaData); mEditorWidget->loadContact(addr, metaData);
} }
void ContactEditor::Private::storeContact(KContacts::Addressee &addr, ContactMetaData &metaData) void ContactEditor::Private::storeContact(KContacts::Addressee &addr, ContactMetaDataAkonadi &metaData)
{ {
mEditorWidget->storeContact(addr, metaData); mEditorWidget->storeContact(addr, metaData);
} }
......
/*
This file is part of Akonadi Contact.
Copyright (c) 2009 Tobias Koenig <tokoe@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 "contactmetadataakonadi_p.h"
#include "attributes/contactmetadataattribute_p.h"
#include <item.h>
using namespace Akonadi;
ContactMetaDataAkonadi::ContactMetaDataAkonadi()
{
}
ContactMetaDataAkonadi::~ContactMetaDataAkonadi()
{
}
void ContactMetaDataAkonadi::load(const Akonadi::Item &contact)
{
if (!contact.hasAttribute("contactmetadata")) {
return;
}
ContactMetaDataAttribute *attribute = contact.attribute<ContactMetaDataAttribute>();
const QVariantMap metaData = attribute->metaData();
loadMetaData(metaData);
}
void ContactMetaDataAkonadi::store(Akonadi::Item &contact)
{
ContactMetaDataAttribute *attribute = contact.attribute<ContactMetaDataAttribute>(Item::AddIfMissing);
attribute->setMetaData(storeMetaData());
}
/*
This file is part of Akonadi Contact.
Copyright (c) 2009 Tobias Koenig <tokoe@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 AKONADI_CONTACTMETADATA_P_H
#define AKONADI_CONTACTMETADATA_P_H
#include <QtCore/QStringList>
#include <QtCore/QVariant>
#include "contactmetadatabase_p.h"
namespace Akonadi
{
class Item;
/**
* @short A helper class for storing contact specific settings.
*/
class ContactMetaDataAkonadi : public ContactMetaDataBase
{
public:
/**
* Creates a contact meta data object.
*/
ContactMetaDataAkonadi();
/**
* Destroys the contact meta data object.
*/
~ContactMetaDataAkonadi();
/**
* Loads the meta data for the given @p contact.
*/
void load(const Akonadi::Item &contact);
/**
* Stores the meta data to the given @p contact.
*/
void store(Akonadi::Item &contact);
};
}
#endif
/* /*
This file is part of Akonadi Contact. This file is part of Akonadi Contact.
Copyright (c) 2009 Tobias Koenig <tokoe@kde.org> Copyright (c) 2017 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or modify it 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 under the terms of the GNU Library General Public License as published by
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
02110-1301, USA. 02110-1301, USA.
*/ */
#include "contactmetadata_p.h" #include "contactmetadatabase_p.h"
#include "attributes/contactmetadataattribute_p.h" #include "attributes/contactmetadataattribute_p.h"
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
using namespace Akonadi; using namespace Akonadi;
class Q_DECL_HIDDEN ContactMetaData::Private class Q_DECL_HIDDEN ContactMetaDataBase::Private
{ {
public: public:
Private() Private()
...@@ -39,34 +39,25 @@ public: ...@@ -39,34 +39,25 @@ public:
QVariantList mCustomFieldDescriptions; QVariantList mCustomFieldDescriptions;
}; };
ContactMetaData::ContactMetaData() ContactMetaDataBase::ContactMetaDataBase()
: d(new Private) : d(new Private)
{ {
} }
ContactMetaData::~ContactMetaData() ContactMetaDataBase::~ContactMetaDataBase()
{ {
delete d; delete d;
} }
void ContactMetaData::load(const Akonadi::Item &contact) void ContactMetaDataBase::loadMetaData(const QVariantMap &metaData)
{ {
if (!contact.hasAttribute("contactmetadata")) {
return;
}
ContactMetaDataAttribute *attribute = contact.attribute<ContactMetaDataAttribute>();
const QVariantMap metaData = attribute->metaData();
d->mDisplayNameMode = metaData.value(QStringLiteral("DisplayNameMode"), -1).toInt(); d->mDisplayNameMode = metaData.value(QStringLiteral("DisplayNameMode"), -1).toInt();
d->mCustomFieldDescriptions = metaData.value(QStringLiteral("CustomFieldDescriptions")).toList(); d->mCustomFieldDescriptions = metaData.value(QStringLiteral("CustomFieldDescriptions")).toList();
} }
void ContactMetaData::store(Akonadi::Item &contact) QVariantMap ContactMetaDataBase::storeMetaData() const
{ {
ContactMetaDataAttribute *attribute = contact.attribute<ContactMetaDataAttribute>(Item::AddIfMissing);
QVariantMap metaData; QVariantMap metaData;
if (d->mDisplayNameMode != -1) { if (d->mDisplayNameMode != -1) {
metaData.insert(QStringLiteral("DisplayNameMode"), QVariant(d->mDisplayNameMode)); metaData.insert(QStringLiteral("DisplayNameMode"), QVariant(d->mDisplayNameMode));
...@@ -75,26 +66,25 @@ void ContactMetaData::store(Akonadi::Item &contact) ...@@ -75,26 +66,25 @@ void ContactMetaData::store(Akonadi::Item &contact)
if (!d->mCustomFieldDescriptions.isEmpty()) { if (!d->mCustomFieldDescriptions.isEmpty()) {
metaData.insert(QStringLiteral("CustomFieldDescriptions"), d->mCustomFieldDescriptions); metaData.insert(QStringLiteral("CustomFieldDescriptions"), d->mCustomFieldDescriptions);
} }
return metaData;
attribute->setMetaData(metaData);
} }
void ContactMetaData::setDisplayNameMode(int mode) void ContactMetaDataBase::setDisplayNameMode(int mode)
{ {
d->mDisplayNameMode = mode; d->mDisplayNameMode = mode;
} }
int ContactMetaData::displayNameMode() const int ContactMetaDataBase::displayNameMode() const
{ {
return d->mDisplayNameMode; return d->mDisplayNameMode;
} }
void ContactMetaData::setCustomFieldDescriptions(const QVariantList &descriptions) void ContactMetaDataBase::setCustomFieldDescriptions(const QVariantList &descriptions)
{ {
d->mCustomFieldDescriptions = descriptions; d->mCustomFieldDescriptions = descriptions;
} }
QVariantList ContactMetaData::customFieldDescriptions() const QVariantList ContactMetaDataBase::customFieldDescriptions() const
{ {
return d->mCustomFieldDescriptions; return d->mCustomFieldDescriptions;
} }
/* /*
This file is part of Akonadi Contact. This file is part of Akonadi Contact.
Copyright (c) 2009 Tobias Koenig <tokoe@kde.org> Copyright (c) 2017 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or modify it 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 under the terms of the GNU Library General Public License as published by
...@@ -19,8 +19,8 @@ ...@@ -19,8 +19,8 @@
02110-1301, USA. 02110-1301, USA.
*/ */
#ifndef AKONADI_CONTACTMETADATA_P_H #ifndef AKONADI_CONTACTMETADATABASE_P_H
#define AKONADI_CONTACTMETADATA_P_H #define AKONADI_CONTACTMETADATABASE_P_H
#include <QtCore/QStringList> #include <QtCore/QStringList>
#include <QtCore/QVariant> #include <QtCore/QVariant>
...@@ -33,28 +33,29 @@ class Item; ...@@ -33,28 +33,29 @@ class Item;
/** /**
* @short A helper class for storing contact specific settings. * @short A helper class for storing contact specific settings.
*/ */
class ContactMetaData class ContactMetaDataBase
{ {
public: public:
/** /**
* Creates a contact meta data object. * Creates a contact meta data object.
*/ */
ContactMetaData(); ContactMetaDataBase();
/** /**
* Destroys the contact meta data object. * Destroys the contact meta data object.
*/ */
~ContactMetaData(); ~ContactMetaDataBase();
/** /**
* Loads the meta data for the given @p contact. * Loads the meta data for the given @p contact.
*/ */
void load(const Akonadi::Item &contact); void loadMetaData(const QVariantMap &metaData);
/** /**
* Stores the meta data to the given @p contact. * Stores the meta data to the given @p contact.
*/ */
void store(Akonadi::Item &contact); QVariantMap storeMetaData() const;
/** /**
* Sets the mode that is used for the display * Sets the mode that is used for the display
...@@ -93,7 +94,7 @@ public: ...@@ -93,7 +94,7 @@ public:
private: private:
//@cond PRIVATE //@cond PRIVATE
Q_DISABLE_COPY(ContactMetaData) Q_DISABLE_COPY(ContactMetaDataBase)
class Private; class Private;
Private *const d; Private *const d;
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#include "contactviewer.h" #include "contactviewer.h"
#include "contactmetadata_p.h" #include "contactmetadataakonadi_p.h"
#include "attributes/contactmetadataattribute_p.h" #include "attributes/contactmetadataattribute_p.h"
#include "customfieldmanager_p.h" #include "customfieldmanager_p.h"
#include "standardcontactformatter.h" #include "standardcontactformatter.h"
...@@ -257,7 +257,7 @@ public: ...@@ -257,7 +257,7 @@ public:
} }
// load the local meta data of the item // load the local meta data of the item
ContactMetaData metaData; ContactMetaDataAkonadi metaData;
metaData.load(mCurrentItem); metaData.load(mCurrentItem);
updateView(metaData.customFieldDescriptions(), addressBookName); updateView(metaData.customFieldDescriptions(), addressBookName);
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include "personaleditor/personaleditorwidget.h" #include "personaleditor/personaleditorwidget.h"
#include "contacteditorpageplugin.h" #include "contacteditorpageplugin.h"
#include "contactmetadata_p.h" #include "contactmetadataakonadi_p.h"
#include <kconfig.h> #include <kconfig.h>
...@@ -208,7 +208,7 @@ ContactEditorWidget::~ContactEditorWidget() ...@@ -208,7 +208,7 @@ ContactEditorWidget::~ContactEditorWidget()
delete d; delete d;
} }
void ContactEditorWidget::loadContact(const KContacts::Addressee &contact, const Akonadi::ContactMetaData &metaData) void ContactEditorWidget::loadContact(const KContacts::Addressee &contact, const Akonadi::ContactMetaDataBase &metaData)
{ {
d->mGeneralInfoWidget->loadContact(contact); d->mGeneralInfoWidget->loadContact(contact);
...@@ -234,7 +234,7 @@ void ContactEditorWidget::loadContact(const KContacts::Addressee &contact, const ...@@ -234,7 +234,7 @@ void ContactEditorWidget::loadContact(const KContacts::Addressee &contact, const
} }
} }
void ContactEditorWidget::storeContact(KContacts::Addressee &contact, Akonadi::ContactMetaData &metaData) const void ContactEditorWidget::storeContact(KContacts::Addressee &contact, Akonadi::ContactMetaDataBase &metaData) const
{ {
d->mGeneralInfoWidget->storeContact(contact); d->mGeneralInfoWidget->storeContact(contact);
......
...@@ -60,13 +60,13 @@ public: ...@@ -60,13 +60,13 @@ public:
* Initializes the fields of the contact editor * Initializes the fields of the contact editor
* with the values from a @p contact. * with the values from a @p contact.
*/ */
void loadContact(const KContacts::Addressee &contact, const Akonadi::ContactMetaData &metaData) Q_DECL_OVERRIDE; void loadContact(const KContacts::Addressee &contact, const Akonadi::ContactMetaDataBase &metaData) Q_DECL_OVERRIDE;
/** /**
* Stores back the fields of the contact editor * Stores back the fields of the contact editor
* into the given @p contact. * into the given @p contact.
*/ */
void storeContact(KContacts::Addressee &contact, Akonadi::ContactMetaData &metaData) const Q_DECL_OVERRIDE; void storeContact(KContacts::Addressee &contact, Akonadi::ContactMetaDataBase &metaData) const Q_DECL_OVERRIDE;
/** /**
* Sets whether the contact in the editor allows * Sets whether the contact in the editor allows
......
...@@ -26,12 +26,13 @@ ...@@ -26,12 +26,13 @@
#include <QWidget> #include <QWidget>
#include <editor/im/imaddress.h> #include <editor/im/imaddress.h>
#include "akonadicontact_private_export.h"
class QToolButton; class QToolButton;
namespace Akonadi namespace Akonadi
{ {
class PreferredLineEditWidget; class PreferredLineEditWidget;
class AkonadiContactComboBox; class AkonadiContactComboBox;
class MessagingWidget : public QWidget class AKONADI_CONTACTS_TESTS_EXPORT MessagingWidget : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
......
...@@ -40,6 +40,5 @@ target_link_libraries(generalinfoeditortest ...@@ -40,6 +40,5 @@ target_link_libraries(generalinfoeditortest
KF5::IconThemes KF5::IconThemes
KF5::WidgetsAddons KF5::WidgetsAddons
KF5::KIOCore KF5::KIOCore
KF5::AkonadiWidgets
) )
...@@ -24,8 +24,9 @@ ...@@ -24,8 +24,9 @@
#include <QVector> #include <QVector>
#include <QString> #include <QString>
#include "akonadicontact_private_export.h"
class IMAddress class AKONADI_CONTACTS_TESTS_EXPORT IMAddress
{ {
public: public:
typedef QVector<IMAddress> List; typedef QVector<IMAddress> List;
......
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