Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 32c9536a authored by Laurent Montel's avatar Laurent Montel 😁

Remove qtwebengine dep

parent 7ddb5cc3
cmake_minimum_required(VERSION 3.0)
set(PIM_VERSION "5.6.40")
set(PIM_VERSION "5.6.41")
project(Akonadi-Contact VERSION ${PIM_VERSION})
......@@ -31,7 +31,7 @@ set(KMIMELIB_VERSION "5.6.40")
set(AKONADI_VERSION "5.6.40")
set(QT_REQUIRED_VERSION "5.8.0")
find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED Widgets Test WebEngine WebEngineWidgets)
find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED Widgets Test)
########### Find packages ###########
find_package(KF5KIO ${KF5_VERSION} CONFIG REQUIRED)
find_package(KF5I18n ${KF5_VERSION} CONFIG REQUIRED)
......@@ -40,7 +40,7 @@ find_package(KF5Codecs ${KF5_VERSION} CONFIG REQUIRED)
find_package(KF5IconThemes ${KF5_VERSION} CONFIG REQUIRED)
find_package(KF5DBusAddons ${KF5_VERSION} CONFIG REQUIRED)
find_package(KF5TextWidgets ${KF5_VERSION} CONFIG REQUIRED)
find_package(Grantlee5 "5.1" CONFIG REQUIRED)
#find_package(Grantlee5 "5.1" CONFIG REQUIRED)
find_package(KF5Contacts ${KCONTACTS_VERSION} CONFIG REQUIRED)
find_package(KF5Mime ${KMIMELIB_VERSION} CONFIG REQUIRED)
......
......@@ -30,6 +30,10 @@ configure_file(config-contact-editor.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-
add_subdirectory(editor/im)
set(contacteditor_abstractaddresslocation_SRCS
editor/addresseditor/abstractaddresslocationwidget.cpp)
set(contacteditor_customfieldseditor_SRCS
editor/customfieldeditor/customfieldswidget.cpp
editor/customfieldeditor/customfieldeditorwidget.cpp
......@@ -86,22 +90,11 @@ set(contacteditor_editor_generalinfo_SRCS
${contacteditor_editor_generalinfo_phone_SRCS}
${contacteditor_editor_generalinfo_web_SRCS}
${contacteditor_editor_generalinfo_mail_SRCS}
)
set(contacteditor_addresslocation_web_editor_SRCS
editor/addresseditor/webengine/addresseslocationengineviewer.cpp
editor/addresseditor/webengine/addresseslocationenginepage.cpp
${contacteditor_abstractaddresslocation_SRCS}
)
set(contacteditor_addresslocation_editor_SRCS
${contacteditor_addresslocation_web_editor_SRCS}
editor/addresseditor/addresslocationwidget.cpp
editor/addresseditor/addresseslocationgrantleeformater.cpp
editor/addresseditor/addressgrantleeobject.cpp
editor/addresseditor/iconnamecache.cpp
editor/addresseditor/addresseslocationwidget.cpp
editor/addresseditor/selectaddresstypecombobox.cpp
editor/addresseditor/addresstypedialog.cpp
)
set(contacteditor_personal_editor_SRCS
......@@ -174,9 +167,6 @@ target_link_libraries(KF5ContactEditor
KF5::Service
KF5::TextWidgets
KF5::WidgetsAddons
Grantlee5::Templates
Qt5::WebEngine
Qt5::WebEngineWidgets
)
set_target_properties(KF5ContactEditor PROPERTIES
......@@ -212,16 +202,25 @@ ecm_generate_headers(ContactEditorWidget_CamelCase_HEADERS
RELATIVE editor/widgets/
)
ecm_generate_headers(ContactEditorAddressLocationWidget_CamelCase_HEADERS
HEADER_NAMES
AbstractAddressLocationWidget
REQUIRED_HEADERS ContactEditorAddressLocationWidget_HEADERS
PREFIX ContactEditor
RELATIVE editor/addresseditor/
)
install( FILES
${ContactEditor_CamelCase_HEADERS}
${ContactEditorWidget_CamelCase_HEADERS}
${ContactEditorAddressLocationWidget_CamelCase_HEADERS}
DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/ContactEditor COMPONENT Devel
)
install( FILES
${ContactEditor_HEADERS}
${ContactEditorWidget_HEADERS}
${ContactEditorAddressLocationWidget_HEADERS}
${CMAKE_CURRENT_BINARY_DIR}/contacteditor_export.h
editor/im/improtocols.h
DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/contacteditor COMPONENT Devel
......@@ -230,8 +229,6 @@ install( FILES
if (BUILD_TESTING)
add_subdirectory(editor/addresseditor/autotests/)
add_subdirectory(editor/addresseditor/tests)
add_subdirectory(editor/generalinfoeditor/autotests/)
add_subdirectory(editor/generalinfoeditor/tests)
add_subdirectory(editor/customfieldeditor/autotests/)
......@@ -242,6 +239,4 @@ endif()
install(FILES editor/pics/world.jpg DESTINATION ${KDE_INSTALL_DATADIR_KF5}/akonadi/contact/pics)
install(FILES editor/data/zone.tab DESTINATION ${KDE_INSTALL_DATADIR_KF5}/akonadi/contact/data)
add_subdirectory(editor/addresseditor/html)
install( FILES contact-editor.categories DESTINATION ${KDE_INSTALL_CONFDIR} )
......@@ -27,3 +27,23 @@ AbstractAddressLocationWidget::AbstractAddressLocationWidget(QWidget *parent)
{
}
AbstractAddressLocationWidget::~AbstractAddressLocationWidget()
{
}
void AbstractAddressLocationWidget::loadContact(const KContacts::Addressee &contact)
{
Q_UNUSED(contact);
}
void AbstractAddressLocationWidget::storeContact(KContacts::Addressee &contact) const
{
Q_UNUSED(contact);
}
void AbstractAddressLocationWidget::setReadOnly(bool readOnly)
{
Q_UNUSED(readOnly);
}
......@@ -24,14 +24,23 @@
#define ABSTRACTADDRESSLOCATIONWIDGET_H
#include <QWidget>
#include <KContacts/Addressee>
#include "contacteditor_export.h"
namespace ContactEditor
{
class AbstractAddressLocationWidget : public QWidget
class CONTACTEDITOR_EXPORT AbstractAddressLocationWidget : public QWidget
{
Q_OBJECT
public:
explicit AbstractAddressLocationWidget(QWidget *parent = nullptr);
~AbstractAddressLocationWidget();
virtual void loadContact(const KContacts::Addressee &contact);
virtual void storeContact(KContacts::Addressee &contact) const;
virtual void setReadOnly(bool readOnly);
};
}
#endif // ABSTRACTADDRESSLOCATIONWIDGET_H
/*
This file is part of Contact Editor.
Copyright (C) 2016 eyeOS S.L.U., a Telefonica company, sales@eyeos.com
Copyright (C) 2016-2017 Laurent Montel <laurent.montel@kdab.com>
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 "addresseslocationgrantleeformater.h"
#include "addressgrantleeobject.h"
#include <grantlee/engine.h>
#include <QVariantList>
#include <QStandardPaths>
using namespace ContactEditor;
AddressesLocationGrantleeFormater::AddressesLocationGrantleeFormater(QObject *parent)
: QObject(parent)
, mEngine(new Grantlee::Engine)
, mReadOnly(false)
{
mTemplateLoader = QSharedPointer<Grantlee::FileSystemTemplateLoader>(new Grantlee::FileSystemTemplateLoader);
mGrantleeThemePath = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
QStringLiteral("contacteditor/grantleetheme/default/"),
QStandardPaths::LocateDirectory);
changeGrantleePath(mGrantleeThemePath);
}
AddressesLocationGrantleeFormater::~AddressesLocationGrantleeFormater()
{
delete mEngine;
mTemplateLoader.clear();
}
QString AddressesLocationGrantleeFormater::formatAddresses(const KContacts::Address::List &addresses)
{
QVariantList addressList;
const int nbAddress(addresses.count());
addressList.reserve(nbAddress);
QList<AddressGrantleeObject *> lstAddress;
lstAddress.reserve(nbAddress);
for (int i = 0; i < nbAddress; ++i) {
AddressGrantleeObject *addressObj = new AddressGrantleeObject(addresses.at(i), i);
addressList << QVariant::fromValue(static_cast<QObject *>(addressObj));
lstAddress.append(addressObj);
}
QVariantHash addressHash;
addressHash.insert(QStringLiteral("addresses"), addressList);
addressHash.insert(QStringLiteral("absoluteThemePath"), mGrantleeThemePath);
addressHash.insert(QStringLiteral("readOnly"), mReadOnly);
Grantlee::Context context(addressHash);
const QString contentHtml = mSelfcontainedTemplate->render(&context);
qDeleteAll(lstAddress);
return contentHtml;
}
void AddressesLocationGrantleeFormater::setReadOnly(bool readOnly)
{
mReadOnly = readOnly;
}
void AddressesLocationGrantleeFormater::changeGrantleePath(const QString &path)
{
if (!mTemplateLoader) {
mTemplateLoader = QSharedPointer<Grantlee::FileSystemTemplateLoader>(new Grantlee::FileSystemTemplateLoader);
}
mTemplateLoader->setTemplateDirs(QStringList() << path);
mEngine->addTemplateLoader(mTemplateLoader);
mSelfcontainedTemplate = mEngine->loadByName(QStringLiteral("addresseslocation.html"));
if (mSelfcontainedTemplate->error()) {
mErrorMessage += mSelfcontainedTemplate->errorString() + QLatin1String("<br>");
}
}
/*
This file is part of Contact Editor.
Copyright (C) 2016 eyeOS S.L.U., a Telefonica company, sales@eyeos.com
Copyright (C) 2016-2017 Laurent Montel <laurent.montel@kdab.com>
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 ADDRESSESLOCATIONGRANTLEEFORMATER_H
#define ADDRESSESLOCATIONGRANTLEEFORMATER_H
#include <QObject>
#include <KContacts/Address>
#include <QSharedPointer>
#include <grantlee/templateloader.h>
namespace Grantlee {
class Engine;
}
namespace ContactEditor {
class AddressesLocationGrantleeFormater : public QObject
{
Q_OBJECT
public:
explicit AddressesLocationGrantleeFormater(QObject *parent = nullptr);
~AddressesLocationGrantleeFormater();
QString formatAddresses(const KContacts::Address::List &addresses);
void setReadOnly(bool readOnly);
private:
void changeGrantleePath(const QString &path);
Grantlee::Engine *mEngine = nullptr;
QString mErrorMessage;
QString mGrantleeThemePath;
QSharedPointer<Grantlee::FileSystemTemplateLoader> mTemplateLoader;
Grantlee::Template mSelfcontainedTemplate;
bool mReadOnly;
};
}
#endif // ADDRESSESLOCATIONGRANTLEEFORMATER_H
......@@ -21,25 +21,11 @@
*/
#include "addresseslocationwidget.h"
#include "webengine/addresseslocationengineviewer.h"
#include "addresslocationwidget.h"
using namespace ContactEditor;
AddressesLocationWidget::AddressesLocationWidget(QWidget *parent)
: QSplitter(parent)
: QWidget(parent)
{
setChildrenCollapsible(false);
mAddressLocationWidget = new AddressLocationWidget(this);
mAddressLocationWidget->setObjectName(QStringLiteral("addresslocationwidget"));
addWidget(mAddressLocationWidget);
mAddressesLocationViewer = new AddressesLocationEngineViewer(this);
mAddressesLocationViewer->setObjectName(QStringLiteral("addresseslocationviewer"));
addWidget(mAddressesLocationViewer);
connect(mAddressesLocationViewer, &AddressesLocationEngineViewer::modifyAddress, mAddressLocationWidget, &AddressLocationWidget::slotModifyAddress);
connect(mAddressLocationWidget, &AddressLocationWidget::addNewAddress, mAddressesLocationViewer, &AddressesLocationEngineViewer::addAddress);
connect(mAddressLocationWidget, &AddressLocationWidget::updateAddressCanceled, mAddressesLocationViewer, &AddressesLocationEngineViewer::updateAddressCanceled);
connect(mAddressLocationWidget, &AddressLocationWidget::updateAddress, mAddressesLocationViewer, &AddressesLocationEngineViewer::replaceAddress);
setSizes(QList<int>() << 400 << 300);
}
AddressesLocationWidget::~AddressesLocationWidget()
......@@ -48,31 +34,15 @@ AddressesLocationWidget::~AddressesLocationWidget()
void AddressesLocationWidget::loadContact(const KContacts::Addressee &contact)
{
mAddressesLocationViewer->setAddresses(contact.addresses());
//TODO
}
void AddressesLocationWidget::storeContact(KContacts::Addressee &contact) const
{
// delete all previous addresses
const KContacts::Address::List oldAddresses = contact.addresses();
const int numberOfOldAddresses(oldAddresses.count());
for (int i = 0; i < numberOfOldAddresses; ++i) {
contact.removeAddress(oldAddresses.at(i));
}
const KContacts::Address::List addressList = mAddressesLocationViewer->addresses();
// insert the new ones
const int numberOfAddress(addressList.count());
for (int i = 0; i < numberOfAddress; ++i) {
const KContacts::Address address(addressList.at(i));
if (!address.isEmpty()) {
contact.insertAddress(address);
}
}
//TODO
}
void AddressesLocationWidget::setReadOnly(bool readOnly)
{
mAddressesLocationViewer->setReadOnly(readOnly);
mAddressLocationWidget->setReadOnly(readOnly);
//TODO
}
......@@ -26,9 +26,7 @@
#include <QSplitter>
#include <KContacts/Addressee>
namespace ContactEditor {
class AddressLocationWidget;
class AddressesLocationEngineViewer;
class AddressesLocationWidget : public QSplitter
class AddressesLocationWidget : public QWidget
{
Q_OBJECT
public:
......@@ -39,9 +37,6 @@ public:
void storeContact(KContacts::Addressee &contact) const;
void setReadOnly(bool readOnly);
private:
AddressesLocationEngineViewer *mAddressesLocationViewer = nullptr;
AddressLocationWidget *mAddressLocationWidget = nullptr;
};
}
#endif // ADDRESSESLOCATIONWIDGET_H
/*
This file is part of Contact Editor.
Copyright (C) 2016 eyeOS S.L.U., a Telefonica company, sales@eyeos.com
Copyright (C) 2016-2017 Laurent Montel <laurent.montel@kdab.com>
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 "addressgrantleeobject.h"
#include "iconnamecache_p.h"
#include <KIconLoader>
#include <KLocalizedString>
#include <QUrlQuery>
using namespace ContactEditor;
AddressGrantleeObject::AddressGrantleeObject(const KContacts::Address &address, int addressIndex, QObject *parent)
: QObject(parent)
, mAddress(address)
, mAddressIndex(addressIndex)
{
mIconSize = KIconLoader::global()->currentSize(KIconLoader::Small);
}
AddressGrantleeObject::~AddressGrantleeObject()
{
}
QString AddressGrantleeObject::formattedAddress() const
{
QString str;
if (mAddress.label().isEmpty()) {
str = mAddress.formattedAddress().trimmed().toHtmlEscaped();
} else {
str = mAddress.label().toHtmlEscaped();
}
return str;
}
QString AddressGrantleeObject::createActionUrl(const QString &actionName) const
{
QUrl url;
url.setScheme(QStringLiteral("addresslocationaction"));
url.setPath(actionName);
QUrlQuery query;
query.addQueryItem(QStringLiteral("id"), QString::number(mAddressIndex));
url.setQuery(query);
return url.toDisplayString();
}
QString AddressGrantleeObject::preferredAddressAction() const
{
QString text;
if (preferredAddress()) {
const QString iconPath = QUrl::fromLocalFile(IconNameCache::instance()->iconPath(QStringLiteral("bookmarks"), KIconLoader::Small)).url();
text = QStringLiteral("<img class=\"headimage\" height=\"%3\" width=\"%3\" title=\"%1\" src=\"%2\"></a>\n")
.arg(i18n("Remove Address"), iconPath, QString::number(mIconSize));
}
return text;
}
QString AddressGrantleeObject::postOfficeBox() const
{
return mAddress.postOfficeBox();
}
QString AddressGrantleeObject::street() const
{
return mAddress.street();
}
QString AddressGrantleeObject::locality() const
{
return mAddress.locality();
}
QString AddressGrantleeObject::region() const
{
return mAddress.region();
}
QString AddressGrantleeObject::postalCode() const
{
return mAddress.postalCode();
}
QString AddressGrantleeObject::country() const
{
return mAddress.country();
}
QString AddressGrantleeObject::removeAddressAction() const
{
const QString iconPath = QUrl::fromLocalFile(IconNameCache::instance()->iconPath(QStringLiteral("edit-delete"), KIconLoader::Small)).url();
const QString text = QStringLiteral("<a href=\"%1\"><img class=\"headimage\" height=\"%4\" width=\"%4\" title=\"%3\" src=\"%2\"></a>\n")
.arg(createActionUrl(QStringLiteral("removeaddress")), iconPath, i18n("Remove Address"), QString::number(mIconSize));
return text;
}
QString AddressGrantleeObject::modifyAddressAction() const
{
const QString iconPath = QUrl::fromLocalFile(IconNameCache::instance()->iconPath(QStringLiteral("document-edit"), KIconLoader::Small)).url();
const QString text = QStringLiteral("<a href=\"%1\"><img class=\"headimage\" height=\"%4\" width=\"%4\" title=\"%3\" src=\"%2\"></a>\n")
.arg(createActionUrl(QStringLiteral("editaddress")), iconPath, i18n("Edit Address"), QString::number(mIconSize));
return text;
}
QString AddressGrantleeObject::addressType() const
{
return KContacts::Address::typeLabel(mAddress.type());
}
bool AddressGrantleeObject::preferredAddress() const
{
return mAddress.type() & KContacts::Address::Pref;
}
/*
This file is part of Contact Editor.
Copyright (C) 2016 eyeOS S.L.U., a Telefonica company, sales@eyeos.com
Copyright (C) 2016-2017 Laurent Montel <laurent.montel@kdab.com>
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 ADDRESSGRANTLEEOBJECT_H
#define ADDRESSGRANTLEEOBJECT_H
#include <QObject>
#include <KContacts/Address>
namespace ContactEditor {
class AddressGrantleeObject : public QObject
{
Q_OBJECT
Q_PROPERTY(QString removeAddressAction READ removeAddressAction)
Q_PROPERTY(QString modifyAddressAction READ modifyAddressAction)
Q_PROPERTY(QString formattedAddress READ formattedAddress)
Q_PROPERTY(QString preferredAddressAction READ preferredAddressAction)
Q_PROPERTY(QString addressType READ addressType)
Q_PROPERTY(QString postOfficeBox READ postOfficeBox)
Q_PROPERTY(QString street READ street)
Q_PROPERTY(QString locality READ locality)
Q_PROPERTY(QString region READ region)
Q_PROPERTY(QString postalCode READ postalCode)
Q_PROPERTY(QString country READ country)
Q_PROPERTY(bool preferredAddress READ preferredAddress)
public:
explicit AddressGrantleeObject(const KContacts::Address &address, int addressIndex, QObject *parent = nullptr);
~AddressGrantleeObject();
QString removeAddressAction() const;
QString modifyAddressAction() const;
QString formattedAddress() const;
QString addressType() const;
bool preferredAddress() const;
QString preferredAddressAction() const;
QString postOfficeBox() const;
QString street() const;
QString locality() const;
QString region() const;
QString postalCode() const;
QString country() const;
private:
QString createActionUrl(const QString &actionName) const;
KContacts::Address mAddress;
int mAddressIndex;
int mIconSize;
};
}
#endif // ADDRESSGRANTLEEOBJECT_H
/*
This file is part of Contact Editor.
Copyright (C) 2016 eyeOS S.L.U., a Telefonica company, sales@eyeos.com
Copyright (C) 2016-2017 Laurent Montel <laurent.montel@kdab.com>
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 ADDRESSLOCATIONWIDGET_H
#define ADDRESSLOCATIONWIDGET_H
#include <QWidget>
#include <KContacts/Address>
class QStackedWidget;
class QCheckBox;
class KLineEdit;
class KComboBox;
class QPushButton;
namespace ContactEditor {
class SelectAddressTypeComboBox;
class AddressLocationWidget : public QWidget
{
Q_OBJECT
public:
enum Mode {
CreateAddress = 0,
ModifyAddress
};
explicit AddressLocationWidget(QWidget *parent = nullptr);
~AddressLocationWidget();
void setAddress(const KContacts::Address &address);
KContacts::Address address() const;
void slotModifyAddress(const KContacts::Address &address, int currentIndex);
void clear();
void setReadOnly(bool readOnly);
Q_SIGNALS:
void addNewAddress(const KContacts::Address &address);
void updateAddress(const KContacts::Address &address, int index);
void updateAddressCanceled();