diff --git a/src/common/KReportAsyncItemBase.h b/src/common/KReportAsyncItemBase.h --- a/src/common/KReportAsyncItemBase.h +++ b/src/common/KReportAsyncItemBase.h @@ -27,6 +27,7 @@ Q_OBJECT public: int renderSimpleData(OROPage *page, OROSection *section, const QPointF &offset, const QVariant &data, KReportScriptHandler *script) override = 0; + virtual QVariant realItemData(const QVariant& itemData) const; Q_SIGNALS: void finishedRendering(); diff --git a/src/common/KReportAsyncItemBase.cpp b/src/common/KReportAsyncItemBase.cpp --- a/src/common/KReportAsyncItemBase.cpp +++ b/src/common/KReportAsyncItemBase.cpp @@ -18,3 +18,8 @@ #include "KReportAsyncItemBase.h" + +QVariant KReportAsyncItemBase::realItemData(const QVariant& itemData) const +{ + return itemData; +} diff --git a/src/plugins/maps/KReportItemMaps.h b/src/plugins/maps/KReportItemMaps.h --- a/src/plugins/maps/KReportItemMaps.h +++ b/src/plugins/maps/KReportItemMaps.h @@ -52,7 +52,7 @@ int renderSimpleData(OROPage *page, OROSection *section, const QPointF &offset, const QVariant &data, KReportScriptHandler *script) override; QString itemDataSource() const override; - virtual QVariant realItemData(const QVariant &itemData) const; + virtual QVariant realItemData(const QVariant &itemData) const override; void renderFinished(); @@ -72,23 +72,23 @@ void setColumn(const QString&); - qreal m_longtitude; - qreal m_latitude; - int m_zoom; - OROPage *m_pageId; - OROSection *m_sectionId; + qreal m_longtitude = 0.0; + qreal m_latitude = 0.0; + int m_zoom = 1200; + OROPage *m_pageId = nullptr; + OROSection *m_sectionId = nullptr; QPointF m_offset; - OROPicture * m_oroPicture; + OROPicture * m_oroPicture = nullptr; KReportMapRenderer m_mapRenderer; Marble::MapThemeManager m_themeManager; private: void createProperties() override; void deserializeData(const QVariant& serialized); - bool m_longDataSetFromScript; - bool m_latDataSetFromScript; - bool m_zoomDataSetFromScript; + bool m_longDataSetFromScript = false; + bool m_latDataSetFromScript = false; + bool m_zoomDataSetFromScript = false; friend class Scripting::Maps; }; diff --git a/src/plugins/maps/KReportItemMaps.cpp b/src/plugins/maps/KReportItemMaps.cpp --- a/src/plugins/maps/KReportItemMaps.cpp +++ b/src/plugins/maps/KReportItemMaps.cpp @@ -29,15 +29,6 @@ //! @todo replace with ReportItemMaps(const QDomNode &element = QDomNode()) KReportItemMaps::KReportItemMaps() - : m_longtitude(0) - , m_latitude(0) - , m_zoom(1200) - , m_pageId(nullptr) - , m_sectionId(nullptr) - , m_oroPicture(nullptr) - , m_longDataSetFromScript(false) - , m_latDataSetFromScript(false) - , m_zoomDataSetFromScript(false) { createProperties(); } diff --git a/src/plugins/maps/KReportMapsPlugin.cpp b/src/plugins/maps/KReportMapsPlugin.cpp --- a/src/plugins/maps/KReportMapsPlugin.cpp +++ b/src/plugins/maps/KReportMapsPlugin.cpp @@ -56,12 +56,12 @@ } #ifdef KREPORT_SCRIPTING -QObject* KReportMapsPlugin::createScriptInstance(KReportItemBase* /*item*/) +QObject* KReportMapsPlugin::createScriptInstance(KReportItemBase* item) { - /*KoReportItemMaps *image = dynamic_cast(item); - if (image) { - return new Scripting::Maps(image); - }*/ + KReportItemMaps *map = dynamic_cast(item); + if (map) { + return new Scripting::Maps(map); + } return nullptr; } #endif diff --git a/src/renderer/KReportPreRenderer.cpp b/src/renderer/KReportPreRenderer.cpp --- a/src/renderer/KReportPreRenderer.cpp +++ b/src/renderer/KReportPreRenderer.cpp @@ -355,7 +355,7 @@ KReportAsyncItemBase *async_ob = qobject_cast(ob); if (async_ob){ //kreportDebug() << "async object"; - asyncManager->addItem(async_ob, m_page, sec, offset, itemData, m_scriptHandler); + asyncManager->addItem(async_ob, m_page, sec, offset, async_ob->realItemData(itemData), m_scriptHandler); } else { //kreportDebug() << "sync object"; itemHeight = ob->renderSimpleData(m_page, sec, offset, itemData, m_scriptHandler); diff --git a/src/renderer/scripting/KReportScriptReport.h b/src/renderer/scripting/KReportScriptReport.h --- a/src/renderer/scripting/KReportScriptReport.h +++ b/src/renderer/scripting/KReportScriptReport.h @@ -19,6 +19,7 @@ #include #include +#include class KReportDocument; @@ -83,6 +84,7 @@ private: KReportDocument *m_reportData; QJSValue m_scriptObject; + QMap m_scriptObjMap; }; } diff --git a/src/renderer/scripting/KReportScriptReport.cpp b/src/renderer/scripting/KReportScriptReport.cpp --- a/src/renderer/scripting/KReportScriptReport.cpp +++ b/src/renderer/scripting/KReportScriptReport.cpp @@ -57,6 +57,10 @@ QObject* Report::objectByName(const QString &n) { + if (m_scriptObjMap.contains(n)) { + return m_scriptObjMap[n]; + } + QListobs = m_reportData->objects(); foreach(KReportItemBase *o, obs) { if (o->entityName() == n) { @@ -70,6 +74,7 @@ if (plugin) { QObject *obj = plugin->createScriptInstance(o); if (obj) { + m_scriptObjMap[n] = obj; return obj; } }