aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2017-04-21 23:18:07 +0200
committerMontel Laurent <[email protected]>2017-04-21 23:18:07 +0200
commit57fd315f491269e42923acc1994717030a475a09 (patch)
treeafd0d46932a068afe72686bb274f2913eaf6c638
parent0cebc5cc3e48a86ceffd5eb6107fc04c90ee99c7 (diff)
Now editor doesn't depend against akonadi
-rw-r--r--CMakeLists.txt2
-rw-r--r--src/CMakeLists.txt3
-rw-r--r--src/abstractcontacteditorwidget_p.h8
-rw-r--r--src/contacteditor.cpp12
-rw-r--r--src/contactmetadataakonadi.cpp53
-rw-r--r--src/contactmetadataakonadi_p.h62
-rw-r--r--src/contactmetadatabase.cpp (renamed from src/contactmetadata.cpp)34
-rw-r--r--src/contactmetadatabase_p.h (renamed from src/contactmetadata_p.h)19
-rw-r--r--src/contactviewer.cpp4
-rw-r--r--src/editor/contacteditorwidget.cpp6
-rw-r--r--src/editor/contacteditorwidget.h4
-rw-r--r--src/editor/generalinfoeditor/messaging/messagingwidget.h3
-rw-r--r--src/editor/generalinfoeditor/tests/CMakeLists.txt1
-rw-r--r--src/editor/im/imaddress.h3
14 files changed, 161 insertions, 53 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4d74296..71e1f4c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.0)
-set(PIM_VERSION "5.5.40")
+set(PIM_VERSION "5.5.41")
project(Akonadi-Contact VERSION ${PIM_VERSION})
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 7f300bc..cfb340e 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -149,7 +149,8 @@ set(akonadicontact_LIB_SRC
contactgroupmodel.cpp
contactgroupviewer.cpp
contactgroupviewerdialog.cpp
- contactmetadata.cpp
+ contactmetadataakonadi.cpp
+ contactmetadatabase.cpp
contactparts.cpp
contactsfilterproxymodel.cpp
contactstreemodel.cpp
diff --git a/src/abstractcontacteditorwidget_p.h b/src/abstractcontacteditorwidget_p.h
index eb0bef3..28df363 100644
--- a/src/abstractcontacteditorwidget_p.h
+++ b/src/abstractcontacteditorwidget_p.h
@@ -32,7 +32,7 @@ class Addressee;
namespace Akonadi
{
-class ContactMetaData;
+class ContactMetaDataBase;
class AbstractContactEditorWidget : public QWidget
{
@@ -42,7 +42,7 @@ public:
*
* @param parent The parent widget.
*/
- AbstractContactEditorWidget(QWidget *parent = 0)
+ explicit AbstractContactEditorWidget(QWidget *parent = nullptr)
: QWidget(parent)
{
}
@@ -57,12 +57,12 @@ public:
/**
* @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
*/
- 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
diff --git a/src/contacteditor.cpp b/src/contacteditor.cpp
index 1d6493a..7e8e9d0 100644
--- a/src/contacteditor.cpp
+++ b/src/contacteditor.cpp
@@ -23,7 +23,7 @@
#include "abstractcontacteditorwidget_p.h"
#include "autoqpointer_p.h"
-#include "contactmetadata_p.h"
+#include "contactmetadataakonadi_p.h"
#include "attributes/contactmetadataattribute_p.h"
#include "editor/contacteditorwidget.h"
@@ -75,14 +75,14 @@ public:
void storeDone(KJob *job);
void itemChanged(const Akonadi::Item &item, const QSet<QByteArray> &);
- void loadContact(const KContacts::Addressee &addr, const ContactMetaData &metaData);
- void storeContact(KContacts::Addressee &addr, ContactMetaData &metaData);
+ void loadContact(const KContacts::Addressee &addr, const ContactMetaDataAkonadi &metaData);
+ void storeContact(KContacts::Addressee &addr, ContactMetaDataAkonadi &metaData);
void setupMonitor();
ContactEditor *mParent;
ContactEditor::Mode mMode;
Akonadi::Item mItem;
- Akonadi::ContactMetaData mContactMetaData;
+ Akonadi::ContactMetaDataAkonadi mContactMetaData;
Akonadi::Monitor *mMonitor;
Akonadi::Collection mDefaultCollection;
AbstractContactEditorWidget *mEditorWidget;
@@ -183,12 +183,12 @@ void ContactEditor::Private::itemChanged(const Akonadi::Item &item, const QSet<Q
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);
}
-void ContactEditor::Private::storeContact(KContacts::Addressee &addr, ContactMetaData &metaData)
+void ContactEditor::Private::storeContact(KContacts::Addressee &addr, ContactMetaDataAkonadi &metaData)
{
mEditorWidget->storeContact(addr, metaData);
}
diff --git a/src/contactmetadataakonadi.cpp b/src/contactmetadataakonadi.cpp
new file mode 100644
index 0000000..902b5b6
--- /dev/null
+++ b/src/contactmetadataakonadi.cpp
@@ -0,0 +1,53 @@
+/*
+ This file is part of Akonadi Contact.
+
+ Copyright (c) 2009 Tobias Koenig <[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 "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());
+}
diff --git a/src/contactmetadataakonadi_p.h b/src/contactmetadataakonadi_p.h
new file mode 100644
index 0000000..465d6f8
--- /dev/null
+++ b/src/contactmetadataakonadi_p.h
@@ -0,0 +1,62 @@
+/*
+ This file is part of Akonadi Contact.
+
+ Copyright (c) 2009 Tobias Koenig <[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 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
diff --git a/src/contactmetadata.cpp b/src/contactmetadatabase.cpp
index 28362c7..c150e3d 100644
--- a/src/contactmetadata.cpp
+++ b/src/contactmetadatabase.cpp
@@ -1,7 +1,7 @@
/*
This file is part of Akonadi Contact.
- Copyright (c) 2009 Tobias Koenig <[email protected]>
+ 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
@@ -19,7 +19,7 @@
02110-1301, USA.
*/
-#include "contactmetadata_p.h"
+#include "contactmetadatabase_p.h"
#include "attributes/contactmetadataattribute_p.h"
@@ -27,7 +27,7 @@
using namespace Akonadi;
-class Q_DECL_HIDDEN ContactMetaData::Private
+class Q_DECL_HIDDEN ContactMetaDataBase::Private
{
public:
Private()
@@ -39,34 +39,25 @@ public:
QVariantList mCustomFieldDescriptions;
};
-ContactMetaData::ContactMetaData()
+ContactMetaDataBase::ContactMetaDataBase()
: d(new Private)
{
}
-ContactMetaData::~ContactMetaData()
+ContactMetaDataBase::~ContactMetaDataBase()
{
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->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;
if (d->mDisplayNameMode != -1) {
metaData.insert(QStringLiteral("DisplayNameMode"), QVariant(d->mDisplayNameMode));
@@ -75,26 +66,25 @@ void ContactMetaData::store(Akonadi::Item &contact)
if (!d->mCustomFieldDescriptions.isEmpty()) {
metaData.insert(QStringLiteral("CustomFieldDescriptions"), d->mCustomFieldDescriptions);
}
-
- attribute->setMetaData(metaData);
+ return metaData;
}
-void ContactMetaData::setDisplayNameMode(int mode)
+void ContactMetaDataBase::setDisplayNameMode(int mode)
{
d->mDisplayNameMode = mode;
}
-int ContactMetaData::displayNameMode() const
+int ContactMetaDataBase::displayNameMode() const
{
return d->mDisplayNameMode;
}
-void ContactMetaData::setCustomFieldDescriptions(const QVariantList &descriptions)
+void ContactMetaDataBase::setCustomFieldDescriptions(const QVariantList &descriptions)
{
d->mCustomFieldDescriptions = descriptions;
}
-QVariantList ContactMetaData::customFieldDescriptions() const
+QVariantList ContactMetaDataBase::customFieldDescriptions() const
{
return d->mCustomFieldDescriptions;
}
diff --git a/src/contactmetadata_p.h b/src/contactmetadatabase_p.h
index 3ff13dc..2a38c84 100644
--- a/src/contactmetadata_p.h
+++ b/src/contactmetadatabase_p.h
@@ -1,7 +1,7 @@
/*
This file is part of Akonadi Contact.
- Copyright (c) 2009 Tobias Koenig <[email protected]>
+ 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
@@ -19,8 +19,8 @@
02110-1301, USA.
*/
-#ifndef AKONADI_CONTACTMETADATA_P_H
-#define AKONADI_CONTACTMETADATA_P_H
+#ifndef AKONADI_CONTACTMETADATABASE_P_H
+#define AKONADI_CONTACTMETADATABASE_P_H
#include <QtCore/QStringList>
#include <QtCore/QVariant>
@@ -33,28 +33,29 @@ class Item;
/**
* @short A helper class for storing contact specific settings.
*/
-class ContactMetaData
+class ContactMetaDataBase
{
public:
/**
* Creates a contact meta data object.
*/
- ContactMetaData();
+ ContactMetaDataBase();
/**
* Destroys the contact meta data object.
*/
- ~ContactMetaData();
+ ~ContactMetaDataBase();
/**
* 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.
*/
- void store(Akonadi::Item &contact);
+ QVariantMap storeMetaData() const;
+
/**
* Sets the mode that is used for the display
@@ -93,7 +94,7 @@ public:
private:
//@cond PRIVATE
- Q_DISABLE_COPY(ContactMetaData)
+ Q_DISABLE_COPY(ContactMetaDataBase)
class Private;
Private *const d;
diff --git a/src/contactviewer.cpp b/src/contactviewer.cpp
index bca5d0a..5636e7d 100644
--- a/src/contactviewer.cpp
+++ b/src/contactviewer.cpp
@@ -21,7 +21,7 @@
#include "contactviewer.h"
-#include "contactmetadata_p.h"
+#include "contactmetadataakonadi_p.h"
#include "attributes/contactmetadataattribute_p.h"
#include "customfieldmanager_p.h"
#include "standardcontactformatter.h"
@@ -257,7 +257,7 @@ public:
}
// load the local meta data of the item
- ContactMetaData metaData;
+ ContactMetaDataAkonadi metaData;
metaData.load(mCurrentItem);
updateView(metaData.customFieldDescriptions(), addressBookName);
diff --git a/src/editor/contacteditorwidget.cpp b/src/editor/contacteditorwidget.cpp
index 2a057f4..4879b87 100644
--- a/src/editor/contacteditorwidget.cpp
+++ b/src/editor/contacteditorwidget.cpp
@@ -24,7 +24,7 @@
#include "personaleditor/personaleditorwidget.h"
#include "contacteditorpageplugin.h"
-#include "contactmetadata_p.h"
+#include "contactmetadataakonadi_p.h"
#include <kconfig.h>
@@ -208,7 +208,7 @@ ContactEditorWidget::~ContactEditorWidget()
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);
@@ -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);
diff --git a/src/editor/contacteditorwidget.h b/src/editor/contacteditorwidget.h
index 8b18569..4bb9b39 100644
--- a/src/editor/contacteditorwidget.h
+++ b/src/editor/contacteditorwidget.h
@@ -60,13 +60,13 @@ public:
* Initializes the fields of the contact editor
* 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
* 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
diff --git a/src/editor/generalinfoeditor/messaging/messagingwidget.h b/src/editor/generalinfoeditor/messaging/messagingwidget.h
index 30fdde6..0327021 100644
--- a/src/editor/generalinfoeditor/messaging/messagingwidget.h
+++ b/src/editor/generalinfoeditor/messaging/messagingwidget.h
@@ -26,12 +26,13 @@
#include <QWidget>
#include <editor/im/imaddress.h>
+#include "akonadicontact_private_export.h"
class QToolButton;
namespace Akonadi
{
class PreferredLineEditWidget;
class AkonadiContactComboBox;
-class MessagingWidget : public QWidget
+class AKONADI_CONTACTS_TESTS_EXPORT MessagingWidget : public QWidget
{
Q_OBJECT
public:
diff --git a/src/editor/generalinfoeditor/tests/CMakeLists.txt b/src/editor/generalinfoeditor/tests/CMakeLists.txt
index f12a850..c64fce9 100644
--- a/src/editor/generalinfoeditor/tests/CMakeLists.txt
+++ b/src/editor/generalinfoeditor/tests/CMakeLists.txt
@@ -40,6 +40,5 @@ target_link_libraries(generalinfoeditortest
KF5::IconThemes
KF5::WidgetsAddons
KF5::KIOCore
- KF5::AkonadiWidgets
)
diff --git a/src/editor/im/imaddress.h b/src/editor/im/imaddress.h
index ea88a89..7f1a64f 100644
--- a/src/editor/im/imaddress.h
+++ b/src/editor/im/imaddress.h
@@ -24,8 +24,9 @@
#include <QVector>
#include <QString>
+#include "akonadicontact_private_export.h"
-class IMAddress
+class AKONADI_CONTACTS_TESTS_EXPORT IMAddress
{
public:
typedef QVector<IMAddress> List;