diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -9,6 +9,7 @@ ecm_optional_add_subdirectory(maps) endif() -if(QT_QTWEBKIT_FOUND) -#todo ecm_optional_add_subdirectory(web) +find_package(Qt5WebEngineWidgets) +if(Qt5WebEngineWidgets_FOUND) + ecm_optional_add_subdirectory(web) endif() diff --git a/src/plugins/web/CMakeLists.txt b/src/plugins/web/CMakeLists.txt --- a/src/plugins/web/CMakeLists.txt +++ b/src/plugins/web/CMakeLists.txt @@ -11,13 +11,11 @@ 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? + Qt5::WebEngineWidgets # TODO WebEngineWidgets? ) ########### install files ############### diff --git a/src/plugins/web/KReportDesignerItemWeb.h b/src/plugins/web/KReportDesignerItemWeb.h --- a/src/plugins/web/KReportDesignerItemWeb.h +++ b/src/plugins/web/KReportDesignerItemWeb.h @@ -32,8 +32,8 @@ { 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); @@ -46,7 +46,7 @@ virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); private: - void init(QGraphicsScene *, KoReportDesigner *r); + void init(QGraphicsScene *, KReportDesigner *r); private Q_SLOTS: void slotPropertyChanged(KPropertySet &, KProperty &); diff --git a/src/plugins/web/KReportDesignerItemWeb.cpp b/src/plugins/web/KReportDesignerItemWeb.cpp --- a/src/plugins/web/KReportDesignerItemWeb.cpp +++ b/src/plugins/web/KReportDesignerItemWeb.cpp @@ -31,39 +31,39 @@ #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 { kreportpluginDebug(); 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(); @@ -81,7 +81,7 @@ 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); @@ -97,7 +97,7 @@ // 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); } @@ -113,14 +113,14 @@ } } - 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/KReportItemWeb.h b/src/plugins/web/KReportItemWeb.h --- a/src/plugins/web/KReportItemWeb.h +++ b/src/plugins/web/KReportItemWeb.h @@ -28,9 +28,10 @@ #include #include +#include class QUrl; -class QWebPage; +class QWebEngineView; namespace Scripting { @@ -44,7 +45,7 @@ Q_OBJECT public: KReportItemWeb(); - explicit KReportItemWeb(QDomNode *element); + explicit KReportItemWeb(const QDomNode &element); virtual ~KReportItemWeb(); virtual QString typeName() const; @@ -66,7 +67,7 @@ virtual void createProperties(); KProperty *m_controlSource; - QWebPage *m_webPage; + QWebEngineView *m_webView; friend class Scripting::Web; }; diff --git a/src/plugins/web/KReportItemWeb.cpp b/src/plugins/web/KReportItemWeb.cpp --- a/src/plugins/web/KReportItemWeb.cpp +++ b/src/plugins/web/KReportItemWeb.cpp @@ -26,38 +26,39 @@ #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))); + m_webView = new QWebEngineView(); + connect(m_webView, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool))); } void KReportItemWeb::createProperties() @@ -76,21 +77,21 @@ } 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); + m_webView->resize(m_size.toScene().toSize()); + //TODO m_webView->mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff); + //TODO m_webView->mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff); QPainter p(pic->picture()); - m_webPage->mainFrame()->render(&p); + m_webView->render(&p); QPointF pos = m_pos.toScene(); QSizeF size = m_size.toScene(); @@ -125,10 +126,11 @@ QUrl url = QUrl::fromUserInput(data.toString()); if (url.isValid()) { - m_webPage->mainFrame()->load(url); + m_webView->setUrl(url); } else { - m_webPage->mainFrame()->setHtml(data.toString()); + m_webView->setHtml(data.toString()); } + m_webView->show(); return 0; //Item doesn't stretch the section height } diff --git a/src/plugins/web/KReportWebPlugin.h b/src/plugins/web/KReportWebPlugin.h --- a/src/plugins/web/KReportWebPlugin.h +++ b/src/plugins/web/KReportWebPlugin.h @@ -30,9 +30,9 @@ 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); diff --git a/src/plugins/web/KReportWebPlugin.cpp b/src/plugins/web/KReportWebPlugin.cpp --- a/src/plugins/web/KReportWebPlugin.cpp +++ b/src/plugins/web/KReportWebPlugin.cpp @@ -19,52 +19,56 @@ #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"