diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index 4c9fea36..cc69ff28 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -1,14 +1,15 @@ ecm_optional_add_subdirectory(barcode) if(NOT WIN32) #todo ecm_optional_add_subdirectory(chart) endif() find_package(Marble) if(Marble_FOUND) ecm_optional_add_subdirectory(maps) endif() -if(QT_QTWEBKIT_FOUND) -#todo ecm_optional_add_subdirectory(web) +find_package(Qt5WebKitWidgets) +if(Qt5WebKitWidgets_FOUND) + ecm_optional_add_subdirectory(web) endif() diff --git a/src/plugins/web/CMakeLists.txt b/src/plugins/web/CMakeLists.txt index d36878c2..9229b05c 100644 --- a/src/plugins/web/CMakeLists.txt +++ b/src/plugins/web/CMakeLists.txt @@ -1,27 +1,25 @@ ecm_create_qm_loader(kreport_webplugin_QM_LOADER kreport_webplugin_qt) #build a shared library set(kreport_webplugin_LIB_SRCS ${PROJECT_SOURCE_DIR}/src/common/kreportplugin_debug.cpp KReportDesignerItemWeb.cpp KReportItemWeb.cpp KReportWebPlugin.cpp ${kreport_webplugin_QM_LOADER} ) add_library(kreport_webplugin MODULE ${kreport_webplugin_LIB_SRCS}) -set (QT_USE_QTWEBKIT TRUE) - target_link_libraries(kreport_webplugin PUBLIC KReport PRIVATE Qt5::WebKitWidgets # TODO WebEngineWidgets? ) ########### install files ############### install(TARGETS kreport_webplugin DESTINATION ${KREPORT_PLUGIN_INSTALL_DIR}) add_subdirectory(pics) diff --git a/src/plugins/web/KReportDesignerItemWeb.cpp b/src/plugins/web/KReportDesignerItemWeb.cpp index e9a41390..31d3c2d7 100644 --- a/src/plugins/web/KReportDesignerItemWeb.cpp +++ b/src/plugins/web/KReportDesignerItemWeb.cpp @@ -1,125 +1,125 @@ /* This file is part of the KDE project Copyright Shreya Pandit Copyright 2011 Adam Pigg 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 "KReportDesignerItemWeb.h" #include #include #include #include #include #include #include #include #include "kreportplugin_debug.h" -void KReportDesignerItemWeb::init(QGraphicsScene *scene, KoReportDesigner *d) //done,compared,add function if necessary +void KReportDesignerItemWeb::init(QGraphicsScene *scene, KReportDesigner *d) //done,compared,add function if necessary { if (scene) scene->addItem(this); connect(m_set, SIGNAL(propertyChanged(KPropertySet&,KProperty&)), this, SLOT(slotPropertyChanged(KPropertySet&,KProperty&))); - KoReportDesignerItemRectBase::init(&m_pos, &m_size, m_set, d); + KReportDesignerItemRectBase::init(&m_pos, &m_size, m_set, d); setZValue(Z); } -KReportDesignerItemWeb::KReportDesignerItemWeb(KoReportDesigner *rw, QGraphicsScene *scene, +KReportDesignerItemWeb::KReportDesignerItemWeb(KReportDesigner *rw, QGraphicsScene *scene, const QPointF &pos) //done,compared - : KoReportDesignerItemRectBase(rw) + : KReportDesignerItemRectBase(rw) { Q_UNUSED(pos); init(scene, rw); setSceneRect(properRect(*rw, KREPORT_ITEM_RECT_DEFAULT_WIDTH, KREPORT_ITEM_RECT_DEFAULT_WIDTH)); m_name->setValue(m_reportDesigner->suggestEntityName(typeName())); } -KReportDesignerItemWeb::KReportDesignerItemWeb(QDomNode *element, KoReportDesigner *rw, +KReportDesignerItemWeb::KReportDesignerItemWeb(const QDomNode &element, KReportDesigner *rw, QGraphicsScene *scene) //done,compared - : KoReportItemWeb(element), KoReportDesignerItemRectBase(rw) + : KReportItemWeb(element), KReportDesignerItemRectBase(rw) { init(scene, rw); setSceneRect(m_pos.toScene(), m_size.toScene()); } KReportDesignerItemWeb *KReportDesignerItemWeb::clone() //done,compared { QDomDocument d; - QDomElement e = d.createElement("clone"); + QDomElement e = d.createElement(QLatin1String("clone")); QDomNode n; buildXML(&d, &e); n = e.firstChild(); return new KReportDesignerItemWeb(n, designer(), 0); } KReportDesignerItemWeb::~KReportDesignerItemWeb() //done,compared { // do we need to clean anything up? } void KReportDesignerItemWeb::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) { Q_UNUSED(option); Q_UNUSED(widget); painter->drawRect(QGraphicsRectItem::rect()); - painter->drawText(rect(), 0, dataSourceAndObjectTypeName(itemDataSource(), "web-view")); + painter->drawText(rect(), 0, dataSourceAndObjectTypeName(itemDataSource(), QLatin1String("web-view"))); painter->setBackgroundMode(Qt::TransparentMode); drawHandles(painter); } void KReportDesignerItemWeb::buildXML(QDomDocument *doc, QDomElement *parent) { Q_UNUSED(doc); Q_UNUSED(parent); QDomElement entity = doc->createElement(QLatin1String("report:") + typeName()); // properties addPropertyAsAttribute(&entity, m_controlSource); addPropertyAsAttribute(&entity, m_name); - entity.setAttribute("report:z-index", zValue()); + entity.setAttribute(QLatin1String("report:z-index"), zValue()); buildXMLRect(doc, &entity, &m_pos, &m_size); parent->appendChild(entity); } void KReportDesignerItemWeb::slotPropertyChanged(KPropertySet &s, KProperty &p) { if (p.name() == "name") { if (!m_reportDesigner->isEntityNameUnique(p.value().toString(), this)) { p.setValue(m_oldName); } else { m_oldName = p.value().toString(); } } - KoReportDesignerItemRectBase::propertyChanged(s, p); + KReportDesignerItemRectBase::propertyChanged(s, p); if (m_reportDesigner) { m_reportDesigner->setModified(true); } } void KReportDesignerItemWeb::mousePressEvent(QGraphicsSceneMouseEvent *event) { m_controlSource->setListData(m_reportDesigner->fieldKeys(), m_reportDesigner->fieldNames()); - KoReportDesignerItemRectBase::mousePressEvent(event); + KReportDesignerItemRectBase::mousePressEvent(event); } diff --git a/src/plugins/web/KReportDesignerItemWeb.h b/src/plugins/web/KReportDesignerItemWeb.h index 425cded4..7dd1b0cc 100644 --- a/src/plugins/web/KReportDesignerItemWeb.h +++ b/src/plugins/web/KReportDesignerItemWeb.h @@ -1,55 +1,55 @@ /* This file is part of the KDE project Copyright Shreya Pandit Copyright 2011 Adam Pigg 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 KREPORTDESIGNERITEMWEB_H #define KREPORTDESIGNERITEMWEB_H #include #include "KReportItemWeb.h" class QGraphicsScene; /** */ class KReportDesignerItemWeb : public KReportItemWeb, public KReportDesignerItemRectBase { Q_OBJECT public: - KReportDesignerItemWeb(KoReportDesigner *rw, QGraphicsScene *scene, const QPointF &pos); - KReportDesignerItemWeb(QDomNode *element, KoReportDesigner *rw, QGraphicsScene *scene); + KReportDesignerItemWeb(KReportDesigner *rw, QGraphicsScene *scene, const QPointF &pos); + KReportDesignerItemWeb(const QDomNode &element, KReportDesigner *rw, QGraphicsScene *scene); virtual ~KReportDesignerItemWeb(); void init(QGraphicsScene *scene); virtual void buildXML(QDomDocument *doc, QDomElement *parent); virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget); virtual KReportDesignerItemWeb *clone(); protected: virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); private: - void init(QGraphicsScene *, KoReportDesigner *r); + void init(QGraphicsScene *, KReportDesigner *r); private Q_SLOTS: void slotPropertyChanged(KPropertySet &, KProperty &); }; #endif diff --git a/src/plugins/web/KReportItemWeb.cpp b/src/plugins/web/KReportItemWeb.cpp index 12b51f3c..8666373c 100644 --- a/src/plugins/web/KReportItemWeb.cpp +++ b/src/plugins/web/KReportItemWeb.cpp @@ -1,139 +1,143 @@ /* This file is part of the KDE project Copyright Shreya Pandit Copyright 2011 Adam Pigg 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 "KReportItemWeb.h" #include #include #include #include #include #include +#include +#include + #include "kreportplugin_debug.h" KReportItemWeb::KReportItemWeb(): m_rendering(false) { createProperties(); init(); } -KReportItemWeb::KReportItemWeb(QDomNode *element) +KReportItemWeb::KReportItemWeb(const QDomNode &element) { createProperties(); init(); - QDomNodeList nl = element->childNodes(); + QDomNodeList nl = element.childNodes(); QString n; QDomNode node; - QDomElement e = element->toElement(); + QDomElement e = element.toElement(); - m_controlSource->setValue(element->toElement().attribute("report:item-data-source")); - m_name->setValue(element->toElement().attribute("report:name")); - Z = element->toElement().attribute("report:z-index").toDouble(); - parseReportRect(element->toElement(), &m_pos, &m_size); + m_controlSource->setValue(element.toElement().attribute(QLatin1String("report:item-data-source"))); + m_name->setValue(element.toElement().attribute(QLatin1String("report:name"))); + Z = element.toElement().attribute(QLatin1String("report:z-index")).toDouble(); + parseReportRect(element.toElement(), &m_pos, &m_size); for (int i = 0; i < nl.count(); i++) { node = nl.item(i); n = node.nodeName(); } } void KReportItemWeb::init() { m_webPage = new QWebPage(); + connect(m_webPage, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool))); } void KReportItemWeb::createProperties() { m_set = new KPropertySet; m_controlSource = new KProperty("item-data-source", QStringList(), QStringList(), QString(), tr("Data Source")); m_set->addProperty(m_controlSource); addDefaultProperties(); } KReportItemWeb::~KReportItemWeb() { delete m_set; } QString KReportItemWeb::typeName() const { - return "web"; + return QLatin1String("web"); } void KReportItemWeb::loadFinished(bool) { //kreportpluginDebug() << m_rendering; if (m_rendering) { OROPicture * pic = new OROPicture(); m_webPage->setViewportSize(m_size.toScene().toSize()); m_webPage->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); m_webPage->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); QPainter p(pic->picture()); m_webPage->mainFrame()->render(&p); QPointF pos = m_pos.toScene(); QSizeF size = m_size.toScene(); pos += m_targetOffset; pic->setPosition(pos); pic->setSize(size); if (m_targetPage) m_targetPage->addPrimitive(pic, false, true); OROPicture *p2 = dynamic_cast(pic->clone()); p2->setPosition(m_pos.toPoint()); if (m_targetSection) m_targetSection->addPrimitive(p2); m_rendering = false; emit(finishedRendering()); } } int KReportItemWeb::renderSimpleData(OROPage *page, OROSection *section, const QPointF &offset, const QVariant &data, KReportScriptHandler *script) { Q_UNUSED(script); m_rendering = true; //kreportpluginDebug() << data; m_targetPage = page; m_targetSection = section; m_targetOffset = offset; QUrl url = QUrl::fromUserInput(data.toString()); if (url.isValid()) { m_webPage->mainFrame()->load(url); } else { m_webPage->mainFrame()->setHtml(data.toString()); } return 0; //Item doesn't stretch the section height } QString KReportItemWeb::itemDataSource() const { return m_controlSource->value().toString(); } diff --git a/src/plugins/web/KReportItemWeb.h b/src/plugins/web/KReportItemWeb.h index 2e70212b..b51e91d2 100644 --- a/src/plugins/web/KReportItemWeb.h +++ b/src/plugins/web/KReportItemWeb.h @@ -1,74 +1,75 @@ /* This file is part of the KDE project Copyright Shreya Pandit Copyright 2011 Adam Pigg 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 KREPORTITEMWEB_H #define KREPORTITEMWEB_H #include "KReportAsyncItemBase.h" #include "KReportPosition.h" #include "KReportSize.h" #include "KReportData.h" #include #include +#include class QUrl; class QWebPage; namespace Scripting { class Web; } /** */ class KReportItemWeb : public KReportAsyncItemBase { Q_OBJECT public: KReportItemWeb(); - explicit KReportItemWeb(QDomNode *element); + explicit KReportItemWeb(const QDomNode &element); virtual ~KReportItemWeb(); virtual QString typeName() const; virtual int renderSimpleData(OROPage *page, OROSection *section, const QPointF &offset, const QVariant &data, KReportScriptHandler *script); virtual QString itemDataSource() const; private Q_SLOTS: void loadFinished(bool); private: void init(); bool m_rendering; OROPage *m_targetPage; OROSection *m_targetSection; QPointF m_targetOffset; protected: virtual void createProperties(); KProperty *m_controlSource; QWebPage *m_webPage; friend class Scripting::Web; }; #endif diff --git a/src/plugins/web/KReportWebPlugin.cpp b/src/plugins/web/KReportWebPlugin.cpp index dbe6d484..07a4c33c 100644 --- a/src/plugins/web/KReportWebPlugin.cpp +++ b/src/plugins/web/KReportWebPlugin.cpp @@ -1,70 +1,74 @@ /* This file is part of the KDE project Copyright Shreya Pandit 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 "KReportWebPlugin.h" #include "KReportDesignerItemWeb.h" -#include "KReportPluginInfo.h" -#include +#include "KReportPluginMetaData.h" +#include -K_EXPORT_KOREPORT_ITEMPLUGIN(KoReportWebPlugin, webplugin) +KREPORT_PLUGIN_FACTORY(KReportWebPlugin, "kreport_webplugin.json") KReportWebPlugin::KReportWebPlugin(QObject *parent, const QVariantList &args) : KReportPluginInterface(parent) { Q_UNUSED(args) - - KoReportPluginInfo *info = new KoReportPluginInfo(); +#if 0 + KReportPluginMetaData *info = new KReportPluginInfo(); info->setClassName("web"); info->setName(tr("Web browser")); info->setIcon(koIcon("report_web_element")); info->setPriority(40); + setInfo(info); +#endif } KReportWebPlugin::~KReportWebPlugin() { } QObject *KReportWebPlugin::createRendererInstance(const QDomNode &element) { - return new KoReportItemWeb(element); + return new KReportItemWeb(element); } -QObject *KReportWebPlugin::createDesignerInstance(const QDomNode &element, KoReportDesigner *designer, +QObject *KReportWebPlugin::createDesignerInstance(const QDomNode &element, KReportDesigner *designer, QGraphicsScene *scene) { return new KReportDesignerItemWeb(element, designer, scene); } -QObject *KReportWebPlugin::createDesignerInstance(KoReportDesigner *designer, +QObject *KReportWebPlugin::createDesignerInstance(KReportDesigner *designer, QGraphicsScene *scene,const QPointF &pos) { return new KReportDesignerItemWeb(designer, scene, pos); } #ifdef KREPORT_SCRIPTING -QObject *KoReportWebPlugin::createScriptInstance(KReportItemBase *item) +QObject *KReportWebPlugin::createScriptInstance(KReportItemBase *item) { Q_UNUSED(item); // KoReportItemweb *image = dynamic_cast(item); // if (image) { // return new Scripting::Web(image); return 0; } #endif + +#include "KReportWebPlugin.moc" diff --git a/src/plugins/web/KReportWebPlugin.h b/src/plugins/web/KReportWebPlugin.h index 8314f5b7..a619156f 100644 --- a/src/plugins/web/KReportWebPlugin.h +++ b/src/plugins/web/KReportWebPlugin.h @@ -1,42 +1,42 @@ /* This file is part of the KDE project Copyright Shreya Pandit 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 KREPORTWEBPLUGIN_H #define KREPORTWEBPLUGIN_H #include "KReportPluginInterface.h" class KReportWebPlugin : public KReportPluginInterface { Q_OBJECT public: explicit KReportWebPlugin(QObject *parent, const QVariantList &args = QVariantList()); virtual ~KReportWebPlugin(); virtual QObject *createRendererInstance(const QDomNode &element); - virtual QObject *createDesignerInstance(const QDomNode &element, KoReportDesigner *designer, + virtual QObject *createDesignerInstance(const QDomNode &element, KReportDesigner *designer, QGraphicsScene *scene); - virtual QObject *createDesignerInstance(KoReportDesigner *designer, + virtual QObject *createDesignerInstance(KReportDesigner *designer, QGraphicsScene *scene,const QPointF &pos); #ifdef KREPORT_SCRIPTING virtual QObject *createScriptInstance(KReportItemBase *item); #endif }; #endif // KOREPORTWEBPLUGIN_H